Commit e09bb0f1 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

Add IOP Viewer scripts

parent ee8eac6d
Loading
Loading
Loading
Loading
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,3 +9,4 @@ results
.claude/archives/
results*/
*.out
/tools/interoperability_visualizer/output/
+11 −0
Changes for doc/analysis/generaterobotdata.py: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ class GenerateRobotData:

        self.test_suite = {
            'tp_id': tp_id,
            'name': self.generate_iop_test_name(),
            'test_objective': self.suite.doc,
            'reference': reference,
            'config_id': str(),
@@ -670,6 +671,16 @@ class GenerateRobotData:
                test_name=self.robot.test_case_names[0]
            )

    def generate_iop_test_name(self) -> str:
        test_names = self.robot.test_case_names
        if len(test_names) == 1:
            return test_names[0]

        _, separator, name = test_names[0].partition(' ')
        name = name.replace(' With Default Context', '')
        name = name.replace(' With User Context', '')
        return f'{self.robot.test_suite}{separator}{name}'

    def _get_iop_setup(self, test_name: str):
        test = next((item for item in self.suite.tests if item.name == test_name), None)
        if test is None:
+32 −4
Changes for doc/tests/test_iop_preconditions.py: 32 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -11,7 +11,13 @@ from analysis.generaterobotdata import GenerateRobotData


class IopPreconditionsTest(unittest.TestCase):
    def generate(self, variables: str, setup: str, test_body: str = '    No Operation'):
    def generate(
        self,
        variables: str,
        setup: str,
        test_body: str = '    No Operation',
        test_name: str = 'IOP_999_01 Generated Preconditions',
    ):
        robot = f'''*** Settings ***
Documentation       Objective
Test Setup          Prepare Preconditions
@@ -22,7 +28,7 @@ Test Setup Prepare Preconditions


*** Test Cases ***
IOP_999_01 Generated Preconditions
{test_name}
    [Documentation]    Pre-conditions: documentation must be ignored.
    [Tags]
    ...    since_v1.6.1
@@ -87,6 +93,20 @@ Prepare Preconditions
            )
        )

    def test_preserves_context_in_single_test_case_name(self):
        name = 'IOP_999_01 Scenario With Default Context'
        self.generate(
            variables='${b1_url}    ${EMPTY}',
            setup='    No Operation',
            test_name=name,
        )

        self.assertEqual(self.generated_info['name'], name)
        self.assertEqual(
            self.generated_info['test_cases'][0]['name'],
            name
        )

    def test_generates_mixed_context_and_data_objects(self):
        result = self.generate(
            variables='''${first_payload}     fixtures/first-entity.jsonld
@@ -198,12 +218,12 @@ ${b1_url} ${EMPTY}


*** Test Cases ***
IOP_999_01_01 Default Context
IOP_999_01_01 Scenario With Default Context
    [Tags]    since_v1.6.1    iop    core_4_3_3    default-context
    [Setup]    Prepare Preconditions    ${core_context}
    ${core_context}

IOP_999_01_02 User Context
IOP_999_01_02 Scenario With User Context
    [Tags]    since_v1.6.1    iop    core_4_3_3    user-context
    [Setup]    Prepare Preconditions    context=${ngsild_test_suite_context}
    ${ngsild_test_suite_context}
@@ -227,6 +247,14 @@ Prepare Preconditions
        user_conditions = self.generated_info['test_cases'][1]['initial_conditions']

        self.assertNotIn('initial_conditions', self.generated_info)
        self.assertEqual(self.generated_info['name'], 'IOP_999_01 Scenario')
        self.assertEqual(
            [test_case['name'] for test_case in self.generated_info['test_cases']],
            [
                'IOP_999_01_01 Scenario With Default Context',
                'IOP_999_01_02 Scenario With User Context',
            ]
        )
        self.assertEqual(
            default_conditions['pre_conditions'][0],
            {
+89 −0
Changes for tools/interoperability_visualizer/README.md: 89 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Interoperability Architecture Visualizer

Generates an offline interactive architecture view of the Robot Framework tests in
`IOP_TP/NGSI-LD/Interoperability`.

## Setup

The tool requires Python 3 and Robot Framework. Run the commands below from the repository root, using either
`venv` or Conda.

Using `venv`:

```console
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install robotframework
```

Using Conda:

```console
conda create -n ngsi-ld-tests python=3
conda activate ngsi-ld-tests
pip install robotframework
```

If you already have an environment with Robot Framework installed, you can reuse it.

## Run

With the environment activated, from the repository root:

```console
python tools/interoperability_visualizer/generate.py
```

The generated page is written to:

```text
tools/interoperability_visualizer/output/interoperability-architecture.html
```

Select a different Robot file or directory with `--source`:

```console
python tools/interoperability_visualizer/generate.py \
  --source IOP_TP/NGSI-LD/Interoperability/Provision/CreateEntity
```

Select another filename inside the dedicated output directory with `--output-name`:

```console
python tools/interoperability_visualizer/generate.py --output-name provision.html
```

Output paths and non-HTML output names are rejected. The complete `output/` directory is ignored by Git.

## Viewer

- Select any concrete interoperability test permutation.
- Switch between the full-size **Preview** graph and **Expected output** workspace.
- Brokers use a left-to-right hierarchy rooted at `b1`; each registration hop advances one level.
- Hover over a broker to inspect every entity created in that broker during setup.
- Hover over a registration arc to inspect its effective creation payload.
- Browse assertion-derived expected responses by broker or in execution order.
- Timeline view treats each consecutive inline comment block as one numbered Robot step and nests every correlated
  Robot keyword operation and expected HTTP response below it.
- Every numbered comment step has its own assertion panel, including `Client sends` and `Agent checks` steps.
- Expand a response step to see its prominent HTTP status, request, assertions, and expected JSON inline.
- Click a broker or registration to pin it; press Escape or use the close button to unpin it.
- Drag brokers to rearrange the architecture.
- Drag empty graph space to pan, use the mouse wheel to zoom, and use **Reset view** to restore the hierarchy and viewport.

Registration arrows start at the broker where the registration is created and point to the broker referenced by its
endpoint. Effective payloads resolve entity IDs and contexts while keeping runtime broker URLs and generated
registration IDs symbolic.

Expected responses are derived statically from the Robot request and assertion calls. HTTP 201 and 404 steps remain
status-only, and unsupported future assertion patterns are displayed as unresolved instead of inventing a body.

## Test

With the environment from [Setup](#setup) activated:

```console
python -m unittest discover \
  -s tools/interoperability_visualizer/tests \
  -p 'test_*.py'
```
+554 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading