Commit 92a3c844 authored by Ken Zangelin's avatar Ken Zangelin
Browse files

swbroker_known_bad: tag 4 more DistOps tests for Robot int-vs-string



D007_01_exc/red, D012_01_red, D013_01_inc all hit the same Robot
type-strict bug already documented for the other D015/D016 variants:
  Should Be Equal    ${stub_count}    1
treats the literal '1' as a string while ${stub_count} comes back
as an integer, so the assertion fails 1 (integer) != 1 (string).
The expected idiom is `${1}` or `Should Be Equal As Integers`.

Also adds resources/prerun_v16_drift.py + resources/v16-drift-excludes.txt
— a Robot prerunmodifier that tags v1.6 vs v1.9 spec-drift cases with
'v16_drift' at runtime, so spec-drift excludes (currently 9 § 6.3.10
cap-default tests) can be skipped via --skip v16_drift without
touching upstream .robot files.

Co-Authored-By: default avatarClaude Opus 4.7 (1M context) <noreply@anthropic.com>
parent e90417ff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi
*** Test Cases ***
D012_01_red Batch Create Entities With Redirect Registration
    [Documentation]    Check that if one requests the Context Broker to create a batch of entities that match a redirect registration, these are created on the Context Source
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_7
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_7    swbroker_known_bad

    ${first_entity}=    Load Entity    ${entity_payload_filename}    ${first_entity_id}
    ${second_entity}=    Load Entity    ${entity_payload_filename}    ${second_entity_id}
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ ${context_regex_expr} root\\[.*\\]\\['@context'\\]\\[1\\]
*** Test Cases ***
D013_01_inc Batch Upsert Entities With Inclusive Registration Without Update Flag
    [Documentation]    Check that if one requests the Context Broker to replace a batch of entities that match an inclusive registration, these are replaced on the Context Source too
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_8
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    additive-inclusive    4_3_6_2    5_6_8    swbroker_known_bad

    ${response}=    Retrieve Entity    ${first_entity_id}    context=${ngsild_test_suite_context}
    ${old_brandname}=    Get Value From Json    ${response.json()}    $.brandName
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi
*** Test Cases ***
D007_01_exc Replace Entity
    [Documentation]    Check that if one requests the Context Broker to replace an entity that matches an exclusive registration, the entity is replaced on the Context Source too
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_18
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-exclusive    4_3_6_3    5_6_18    swbroker_known_bad

    Set Stub Reply    PUT    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    ${response}=    Replace Entity
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ ${registration_payload_file_path} csourceRegistrations/context-source-regi
*** Test Cases ***
D007_01_red Replace Entity
    [Documentation]    Check that if one requests the Context Broker to replace an entity that matches redirect registrations, the entity is replaced on the Context Sources
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_18
    [Tags]    since_v1.6.1    dist-ops    4_3_3    cf_06    proxy-redirect    4_3_6_3    5_6_18    swbroker_known_bad

    Set Stub Reply    PUT    /broker1/ngsi-ld/v1/entities/${entity_id}    204
    Set Stub Reply    PUT    /broker2/ngsi-ld/v1/entities/${entity_id}    204
+56 −0
Original line number Diff line number Diff line
"""
Robot Framework prerunmodifier for v1.6 vs v1.9 spec-drift excludes.

Reads v16-drift-excludes.txt alongside this script and tags matching
test cases with `v16_drift`. Combined with Robot's `--skip v16_drift`,
this keeps the spec-drift excludes outside the ETSI test source tree,
so the upstream .robot files stay untouched.

Usage:
    robot --prerunmodifier resources/prerun_v16_drift.py \\
          --skip v16_drift \\
          --skip swbroker_known_bad \\
          ./TP/NGSI-LD

The exclude list lives in this directory under v16-drift-excludes.txt
— one test name per line, glob (*) supported, '#' comments OK.
"""

import fnmatch
import pathlib
from robot.api import SuiteVisitor

EXCLUDE_TAG = "v16_drift"
EXCLUDE_FILE = pathlib.Path(__file__).parent / "v16-drift-excludes.txt"


def _load_patterns():
    if not EXCLUDE_FILE.exists():
        return []
    patterns = []
    for raw in EXCLUDE_FILE.read_text().splitlines():
        line = raw.strip()
        if not line or line.startswith("#"):
            continue
        patterns.append(line)
    return patterns


class prerun_v16_drift(SuiteVisitor):
    def __init__(self):
        self._patterns = _load_patterns()
        self._tagged = 0

    def start_test(self, test):
        for pat in self._patterns:
            if fnmatch.fnmatchcase(test.name, pat):
                test.tags.add(EXCLUDE_TAG)
                self._tagged += 1
                break

    def end_suite(self, suite):
        if suite.parent is None and self._tagged:
            print(
                f"[prerun_v16_drift] tagged {self._tagged} test(s) "
                f"with '{EXCLUDE_TAG}' from {EXCLUDE_FILE.name}"
            )
Loading