Log diff when cds-resource-resolution fails 09/143309/2
authorFiete Ostkamp <fiete.ostkamp@telekom.de>
Fri, 13 Feb 2026 13:44:36 +0000 (14:44 +0100)
committerFiete Ostkamp <fiete.ostkamp@telekom.de>
Fri, 13 Feb 2026 13:50:35 +0000 (14:50 +0100)
Issue-ID: INT-2351
Change-Id: Idc77f403cf2d80eb3972ccf2c0f38b66ab93ebbf
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
README.md
src/onaptests/steps/onboard/cds.py

index 35f4836..faceca0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,7 +26,8 @@ and create zip file for heat template `templates/heat_files`.
 - Create a virtual environment and clone the python-onapsdk
 
   ```shell
-  virtualenv my_test
+  virtualenv my_test # use `python3.11 -m virtualenv .venv` if 3.11 is
+  # not your systems default
   source my_test/bin/activate
   git clone git@gitlab.com:Orange-OpenSource/lfn/onap/python-onapsdk.
   git -b develop
index e91eb4a..794b0a1 100644 (file)
@@ -27,6 +27,7 @@ class CDSBaseStep(BaseStep, ABC):
 
 class ExposeCDSBlueprintprocessorNodePortStep(CDSBaseStep, ExposeServiceNodePortStep):
     """Expose CDS blueprintsprocessor port."""
+
     def __init__(self) -> None:
         """Initialize step."""
         super().__init__(component="CDS",
@@ -185,4 +186,42 @@ class CbaProcessStep(CDSBaseStep):
         workflow: Workflow = blueprint.get_workflow_by_name(settings.CDS_WORKFLOW_NAME)
         output: Dict[str, Any] = workflow.execute(settings.CDS_WORKFLOW_INPUT)
         if not output == settings.CDS_WORKFLOW_EXPECTED_OUTPUT:
-            raise OnapTestException("Response is not equal to the expected one")
+            error_msg = format_error_message(output)
+            self._logger.error(error_msg)
+            raise OnapTestException(error_msg)
+
+
+def format_error_message(output):
+    """Format error message with diff between expected and actual output.
+
+    Args:
+        output: The actual output from the workflow execution.
+
+    Returns:
+        str: Formatted error message with expected vs actual comparison and diff.
+
+    """
+    import json
+    import difflib
+
+    # Pretty print both outputs for comparison
+    expected_str = json.dumps(settings.CDS_WORKFLOW_EXPECTED_OUTPUT, indent=2, sort_keys=True)
+    actual_str = json.dumps(output, indent=2, sort_keys=True)
+
+    # Generate a unified diff
+    diff = difflib.unified_diff(
+        expected_str.splitlines(keepends=True),
+        actual_str.splitlines(keepends=True),
+        fromfile='expected_output',
+        tofile='actual_output',
+        lineterm=''
+    )
+    diff_text = ''.join(diff)
+
+    error_msg = (
+        f"CDS workflow response does not match expected output.\n\n"
+        f"Expected output:\n{expected_str}\n\n"
+        f"Actual output:\n{actual_str}\n\n"
+        f"Diff:\n{diff_text}"
+    )
+    return error_msg