From 4ea16984c2dcc925edff802c0494658db62bb6f1 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Sat, 10 Feb 2024 18:45:23 +0100 Subject: [PATCH 1/8] feat: add Mqtt Notification Test --- README.md | 3 + .../mqtt/058_01.robot | 90 ++++++++++++++++++ .../mqtt/058_02.robot | 94 ++++++++++++++++++ .../mqtt/058_03.robot | 94 ++++++++++++++++++ .../mqtt/058_04.robot | 95 +++++++++++++++++++ libraries/evaluateJson.py | 5 + requirements.txt | 2 + resources/mqttUtils/MqttUtils.resource | 30 ++++++ resources/mqttUtils/mosquitto/mosquitto.conf | 3 + resources/mqttUtils/mosquitto/mosquitto_pwd | 1 + .../mosquitto/mosquitto_with_user.conf | 5 + 11 files changed, 422 insertions(+) create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot create mode 100644 TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot create mode 100644 libraries/evaluateJson.py create mode 100644 resources/mqttUtils/MqttUtils.resource create mode 100644 resources/mqttUtils/mosquitto/mosquitto.conf create mode 100644 resources/mqttUtils/mosquitto/mosquitto_pwd create mode 100644 resources/mqttUtils/mosquitto/mosquitto_with_user.conf diff --git a/README.md b/README.md index e14b5ae8..61558a28 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,9 @@ to maintain and run the selected Test Cases from the pickle file. The list of co tsm collections off [collections] +### Specific test requirements + - Mqtt tests (058) launch a mosquitto container with docker, thus it requires docker to be installed and running + ## Contribute to the Test Suite In order to contribute to the ETSI NGSI-LD Test Suite, it is recommended to install an IDE with the corresponding diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot new file mode 100644 index 00000000..3fb555b7 --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot @@ -0,0 +1,90 @@ +*** Settings *** +Documentation Check Mqtt Notification + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource +Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Library ${EXECDIR}/libraries/evaluateJson.py + +Test Teardown After Test +Test Template Check receive mqtt notification + + +*** Variables *** +${subscription_id_prefix} urn:ngsi-ld:Subscription: +${subscription_payload_file_path} subscriptions/subscription-building-entities-default.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +${topic} ngsild-test-suite/topic + + +*** Test Cases *** +058_01_01 Without_user_and_port + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} +058_01_02 With_non_default_port + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1:2883/${topic} port=2883 +058_01_03 With_user + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://user@127.0.0.1/${topic} +058_01_04 With_user_password + [Tags] mqtt 1.3.1 + mosquitto_with_user.conf mqtt://user_with_password:password@127.0.0.1/${topic} username=user_with_password password=password +058_01_05 With_user_password_and_non_default_port + [Tags] mqtt 1.3.1 + mosquitto_with_user.conf mqtt://user_with_password:password@127.0.0.1:2883/${topic} username=user_with_password password=password port=2883 + + +*** Keywords *** +Check receive mqtt notification + [Documentation] Check that the broker use the authentication information from the endpoint url + [Arguments] ${config_filename} ${endpoint_uri} ${port}=1883 ${username}=${None} ${password}=${None} + + Launch Mqtt Server ${config_filename} ${port} + Setup Mqtt Subscription ${endpoint_uri} + + Set Username And Password ${username} ${password} + Connect 127.0.0.1 ${port} + Subscribe topic=${topic} qos=1 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + ${listenMessages}= Listen ${topic} + ${firstmessage}= Set Variable ${listenMessages}[0] + Length Should Be ${listenMessages} 1 + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Kill Mqtt Server + Disconnect + +Setup Mqtt Subscription + [Arguments] ${endpoint_uri} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${endpoint_uri} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + + Set Suite Variable ${subscription_id} + Set Suite Variable ${entity_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot new file mode 100644 index 00000000..02360fae --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot @@ -0,0 +1,94 @@ +*** Settings *** +Documentation Check Mqtt Notification + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource +Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Library ${EXECDIR}/libraries/evaluateJson.py + +Test Teardown After Test +Test Template Check qos on mqtt notification + + +*** Variables *** +${subscription_id_prefix} urn:ngsi-ld:Subscription: +${subscription_payload_file_path} subscriptions/subscription-building-entities-default.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +${topic} ngsild-test-suite/topic + + +*** Test Cases *** +058_02_01 With_default_qos + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} +058_02_02 With_non_default_qos_1 + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} qos=1 +058_02_03 With_non_default_qos_2 + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} qos=2 +# we could test more if we find a broker that does not support some qos + + +*** Keywords *** +Check qos on mqtt notification + [Documentation] Check that the broker support different quality of service (qos) + [Arguments] ${config_filename} ${endpoint_uri} ${qos}=${None} + + Launch Mqtt Server ${config_filename} 1883 + Setup Mqtt Subscription ${endpoint_uri} qos=${qos} + + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${listenMessages}= Listen ${topic} + Length Should Be ${listenMessages} 1 + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Kill Mqtt Server + Disconnect + +Setup Mqtt Subscription + [Arguments] ${endpoint_uri} ${qos}=${None} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${endpoint_uri} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + IF ${qos} != ${None} + ${notifierInfo}= Create Dictionary + Set To Dictionary ${notifierInfo} key MQTT-QoS + Set To Dictionary ${notifierInfo} value ${qos} + ${notifierInfo}= Create List ${notifierInfo} + ${subscription_payload}= Add Object To Json + ... ${subscription_payload} + ... $.notification.endpoint.notifierInfo + ... ${notifierInfo} + END + + Set Suite Variable ${subscription_id} + Set Suite Variable ${entity_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot new file mode 100644 index 00000000..05148ced --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot @@ -0,0 +1,94 @@ +*** Settings *** +Documentation Check Mqtt Notification + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource +Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Library ${EXECDIR}/libraries/evaluateJson.py + +Test Teardown After Test +Test Template Check Mqtt Protocol Version on mqtt notification + + +*** Variables *** +${subscription_id_prefix} urn:ngsi-ld:Subscription: +${subscription_payload_file_path} subscriptions/subscription-building-entities-default.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +${topic} ngsild-test-suite/topic + + +*** Test Cases *** +058_03_01 With_default_protocol + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} +058_03_02 With_mqtt3.1.1_protocol + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt3.1.1 +058_03_03 With_mqtt5.0_protocol + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt5.0 +# could test that the subscription actually use the indicated version +# if we find a docker image with a mqtt broker that does not support a version + + +*** Keywords *** +Check Mqtt Protocol Version on mqtt notification + [Documentation] Check that the broker support different mqtt version + [Arguments] ${config_filename} ${endpoint_uri} ${version}=${None} + + Launch Mqtt Server ${config_filename} 1883 + Setup Mqtt Subscription ${endpoint_uri} version=${version} + + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + + ${listenMessages}= Listen ${topic} + Length Should Be ${listenMessages} 1 + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Kill Mqtt Server + Disconnect + +Setup Mqtt Subscription + [Arguments] ${endpoint_uri} ${version}=${None} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${endpoint_uri} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + ${notifierInfo}= Create Dictionary + IF $version != $None + Set To Dictionary ${notifierInfo} key MQTT-Version + Set To Dictionary ${notifierInfo} value ${version} + ${notifierInfo}= Create List ${notifierInfo} + ${subscription_payload}= Add Object To Json + ... ${subscription_payload} + ... $.notification.endpoint.notifierInfo + ... ${notifierInfo} + END + Set Suite Variable ${subscription_id} + Set Suite Variable ${entity_id} + + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot new file mode 100644 index 00000000..2793d9ee --- /dev/null +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot @@ -0,0 +1,95 @@ +*** Settings *** +Documentation Check Mqtt Notification + +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource +Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource +Resource ${EXECDIR}/resources/AssertionUtils.resource +Resource ${EXECDIR}/resources/JsonUtils.resource +Resource ${EXECDIR}/resources/NotificationUtils.resource +Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Library ${EXECDIR}/libraries/evaluateJson.py + +Test Teardown After Test +Test Template Check receive well formed data + + +*** Variables *** +${subscription_id_prefix} urn:ngsi-ld:Subscription: +${subscription_payload_file_path} subscriptions/subscription-building-entities-default.jsonld +${building_id_prefix} urn:ngsi-ld:Building: +${entity_building_filepath} building-simple-attributes-sample.jsonld +${fragment_filename} airQualityLevel-fragment.jsonld +${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" +${topic} ngsild-test-suite/topic + + +*** Test Cases *** +058_01_01 basic_subscription + [Tags] mqtt 1.3.1 + mosquitto.conf mqtt://127.0.0.1/${topic} + + +*** Keywords *** +Check receive well formed data + [Documentation] Check that the broker send well formed data + [Arguments] ${config_filename} ${endpoint_uri} + + Launch Mqtt Server ${config_filename} 1883 + Setup Mqtt Subscription ${endpoint_uri} + + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 + + ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} + ${listenMessages}= Listen ${topic} + ${firstmessage}= Set Variable ${listenMessages}[0] + ${message}= Evaluate Json ${firstmessage} + + Dictionary Should Contain Key ${message} metadata + Dictionary Should Contain Key ${message} body + Dictionary Should Contain Key ${message}[metadata] Content-Type + Dictionary Should Contain Key ${message}[metadata] Link + Should Be Equal As Strings ${message}[metadata][test-receiver-key] test-receiver-info + Should Be Equal As Strings ${message}[body][type] Notification + Dictionary Should Contain Key ${message}[body] data + Dictionary Should Contain Key ${message}[body][data][0] id + Dictionary Should Contain Key ${message}[body][data][0] type + +After Test + Delete Initial Subscriptions + Delete Initial Entity + Kill Mqtt Server + Disconnect + +Setup Mqtt Subscription + [Arguments] ${endpoint_uri} + ${subscription_id}= Generate Random Entity Id ${subscription_id_prefix} + ${entity_id}= Generate Random Entity Id ${building_id_prefix} + + ${subscription_payload}= Load Subscription Sample With Reachable Endpoint + ... ${subscription_payload_file_path} + ... ${subscription_id} + ... ${endpoint_uri} + ${subscription_payload}= Set Entity Id In Subscription ${subscription_payload} ${entity_id} + + Set Suite Variable ${subscription_id} + + Set Suite Variable ${entity_id} + ${receiverInfo}= Create Dictionary + Set To Dictionary ${receiverInfo} key test-receiver-key + Set To Dictionary ${receiverInfo} value test-receiver-info + ${receiverInfo}= Create List ${receiverInfo} + ${subscription_payload}= Add Object To Json + ... ${subscription_payload} + ... $.notification.endpoint.receiverInfo + ... ${receiverInfo} + Create Entity ${entity_building_filepath} ${entity_id} + Sleep 1s + Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Sleep 1s + +Delete Initial Subscriptions + Delete Subscription ${subscription_id} + +Delete Initial Entity + Delete Entity by Id ${entity_id} diff --git a/libraries/evaluateJson.py b/libraries/evaluateJson.py new file mode 100644 index 00000000..d1f9e264 --- /dev/null +++ b/libraries/evaluateJson.py @@ -0,0 +1,5 @@ +import json + + +def evaluate_json(payload): # force to implement this because robot framework can't read {a: true} or {a: false} + return json.loads(payload) diff --git a/requirements.txt b/requirements.txt index 5104bc18..e26df1ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,5 @@ deepdiff==6.7.1 prettydiff==0.1.0 robotframework-httpctrl==0.3.1 robotframework-tidy==4.11.0 +paho-mqtt==1.6.1 +robotframework-mqttlibrary==0.7.1.post3 diff --git a/resources/mqttUtils/MqttUtils.resource b/resources/mqttUtils/MqttUtils.resource new file mode 100644 index 00000000..16235378 --- /dev/null +++ b/resources/mqttUtils/MqttUtils.resource @@ -0,0 +1,30 @@ +*** Settings *** +Documentation manage a mqtt server + +Library Process +Library MQTTLibrary + + +*** Variables *** +${container_name}= ngsi-ld-test-suite-mosquitto-container + + +*** Keywords *** +Launch Mqtt Server + [Arguments] ${conf_file_name} ${port} + ${request} = Set Variable + ... docker run -d -p ${port}:1883 -v "${CURDIR}/mosquitto/${conf_file_name}:/mosquitto/config/mosquitto.conf" -v "${CURDIR}/mosquitto/mosquitto_pwd:/mosquitto/config/mosquitto_pwd" --name "${container_name}" eclipse-mosquitto:2.0.18-openssl + + ${result} = Run Process ${request} shell=yes + IF ${result.rc} > 0 + Log The launching of mosquitto encounter an error + Log check that docker is installed + Log that the port ${port} is free + Log and that no other container named ${container_name} is running + Log ${result.stdout} + Log ${result.stderr} + END + +Kill Mqtt Server + ${request} = Set Variable docker container rm -f "${container_name}" + Run Process ${request} shell=yes diff --git a/resources/mqttUtils/mosquitto/mosquitto.conf b/resources/mqttUtils/mosquitto/mosquitto.conf new file mode 100644 index 00000000..5c56c8ed --- /dev/null +++ b/resources/mqttUtils/mosquitto/mosquitto.conf @@ -0,0 +1,3 @@ +# see possible config : https://mosquitto.org/man/mosquitto-conf-5.html +allow_anonymous true +listener 1883 \ No newline at end of file diff --git a/resources/mqttUtils/mosquitto/mosquitto_pwd b/resources/mqttUtils/mosquitto/mosquitto_pwd new file mode 100644 index 00000000..b0f87528 --- /dev/null +++ b/resources/mqttUtils/mosquitto/mosquitto_pwd @@ -0,0 +1 @@ +user_with_password:$7$101$DJEdWpis1ub7wd3W$2wJOFueA24YFV/q35IJT3MI6cOXkHX75PZXGcxMPeuMuc//YqFDyk6Nz5MKcrJtvkKXXmJItkorF7qZEoCb/9g== \ No newline at end of file diff --git a/resources/mqttUtils/mosquitto/mosquitto_with_user.conf b/resources/mqttUtils/mosquitto/mosquitto_with_user.conf new file mode 100644 index 00000000..bf300cb8 --- /dev/null +++ b/resources/mqttUtils/mosquitto/mosquitto_with_user.conf @@ -0,0 +1,5 @@ +# see possible config : https://mosquitto.org/man/mosquitto-conf-5.html +allow_anonymous false +listener 1883 +# file with username user:user_with_password and password:password +password_file /mosquitto/config/mosquitto_pwd \ No newline at end of file -- GitLab From c698b98524fd37c6a460031d3a929b525db62b95 Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Thu, 11 Jul 2024 08:18:58 +0200 Subject: [PATCH 2/8] chore: wording and tags --- .../mqtt/058_01.robot | 26 +++++++++---------- .../mqtt/058_02.robot | 19 +++++++------- .../mqtt/058_03.robot | 18 ++++++------- .../mqtt/058_04.robot | 8 +++--- 4 files changed, 34 insertions(+), 37 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot index 3fb555b7..18611efe 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot @@ -10,7 +10,7 @@ Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test -Test Template Check receive mqtt notification +Test Template Check Receive MQTT Notification *** Variables *** @@ -24,26 +24,26 @@ ${topic} ngsild-test-suite/topic *** Test Cases *** -058_01_01 Without_user_and_port - [Tags] mqtt 1.3.1 +058_01_01 Without User And Port + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} -058_01_02 With_non_default_port - [Tags] mqtt 1.3.1 +058_01_02 With Non Default Port + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1:2883/${topic} port=2883 -058_01_03 With_user - [Tags] mqtt 1.3.1 +058_01_03 With User + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://user@127.0.0.1/${topic} -058_01_04 With_user_password - [Tags] mqtt 1.3.1 +058_01_04 With User And Password + [Tags] sub-mqtt-notification 5_8_6 mosquitto_with_user.conf mqtt://user_with_password:password@127.0.0.1/${topic} username=user_with_password password=password -058_01_05 With_user_password_and_non_default_port - [Tags] mqtt 1.3.1 +058_01_05 With User Password And Non Default Port + [Tags] sub-mqtt-notification 5_8_6 mosquitto_with_user.conf mqtt://user_with_password:password@127.0.0.1:2883/${topic} username=user_with_password password=password port=2883 *** Keywords *** -Check receive mqtt notification - [Documentation] Check that the broker use the authentication information from the endpoint url +Check Receive MQTT Notification + [Documentation] Check that the broker uses the authentication information from the endpoint url [Arguments] ${config_filename} ${endpoint_uri} ${port}=1883 ${username}=${None} ${password}=${None} Launch Mqtt Server ${config_filename} ${port} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot index 02360fae..c2651821 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot @@ -10,7 +10,7 @@ Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test -Test Template Check qos on mqtt notification +Test Template Check QoS On MQTT Notification *** Variables *** @@ -24,21 +24,20 @@ ${topic} ngsild-test-suite/topic *** Test Cases *** -058_02_01 With_default_qos - [Tags] mqtt 1.3.1 +058_02_01 With Default QoS + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} -058_02_02 With_non_default_qos_1 - [Tags] mqtt 1.3.1 +058_02_02 With QoS 1 + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} qos=1 -058_02_03 With_non_default_qos_2 - [Tags] mqtt 1.3.1 +058_02_03 With QoS 2 + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} qos=2 -# we could test more if we find a broker that does not support some qos *** Keywords *** -Check qos on mqtt notification - [Documentation] Check that the broker support different quality of service (qos) +Check QoS On MQTT Notification + [Documentation] Check that the broker supports different quality of service (qos) [Arguments] ${config_filename} ${endpoint_uri} ${qos}=${None} Launch Mqtt Server ${config_filename} 1883 diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot index 05148ced..10eaa43f 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot @@ -10,7 +10,7 @@ Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test -Test Template Check Mqtt Protocol Version on mqtt notification +Test Template Check MQTT Protocol Version on MQTT notification *** Variables *** @@ -24,21 +24,19 @@ ${topic} ngsild-test-suite/topic *** Test Cases *** -058_03_01 With_default_protocol - [Tags] mqtt 1.3.1 +058_03_01 With Default Protocol + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} -058_03_02 With_mqtt3.1.1_protocol - [Tags] mqtt 1.3.1 +058_03_02 With MQTT 3.1.1 Protocol + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt3.1.1 -058_03_03 With_mqtt5.0_protocol - [Tags] mqtt 1.3.1 +058_03_03 With MQTT 5.0 Protocol + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt5.0 -# could test that the subscription actually use the indicated version -# if we find a docker image with a mqtt broker that does not support a version *** Keywords *** -Check Mqtt Protocol Version on mqtt notification +Check MQTT Protocol Version on MQTT notification [Documentation] Check that the broker support different mqtt version [Arguments] ${config_filename} ${endpoint_uri} ${version}=${None} diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot index 2793d9ee..5d01bd2b 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot @@ -10,7 +10,7 @@ Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test -Test Template Check receive well formed data +Test Template Check Receive Well Formed Data *** Variables *** @@ -24,13 +24,13 @@ ${topic} ngsild-test-suite/topic *** Test Cases *** -058_01_01 basic_subscription - [Tags] mqtt 1.3.1 +058_04_01 Basic Subscription + [Tags] sub-mqtt-notification 5_8_6 mosquitto.conf mqtt://127.0.0.1/${topic} *** Keywords *** -Check receive well formed data +Check Receive Well Formed Data [Documentation] Check that the broker send well formed data [Arguments] ${config_filename} ${endpoint_uri} -- GitLab From d43b2bb82028609de6001c451400985a474d55b6 Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Fri, 12 Jul 2024 09:38:07 +0200 Subject: [PATCH 3/8] fix: MR comments --- README.md | 6 +++--- .../mqtt/058_01.robot | 14 +++++++------- .../mqtt/058_02.robot | 15 +++++++++------ .../mqtt/058_03.robot | 14 ++++++++------ .../mqtt/058_04.robot | 15 +++++++++------ libraries/evaluateJson.py | 5 ----- resources/mqttUtils/MqttUtils.resource | 10 +++++----- 7 files changed, 41 insertions(+), 38 deletions(-) delete mode 100644 libraries/evaluateJson.py diff --git a/README.md b/README.md index 61558a28..833ca398 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,9 @@ test launch command followed by the file name. > > .venv\scripts\deactivate.bat > ``` +### Specific test requirements +- Mqtt tests (058) launch a mosquitto container with docker, thus it requires docker to be installed and running + ## Test Suite Management (tsm) The `tsm` script is designed to facilitate the selection and execution of the Test Suite, especially if not all the @@ -246,9 +249,6 @@ to maintain and run the selected Test Cases from the pickle file. The list of co tsm collections off [collections] -### Specific test requirements - - Mqtt tests (058) launch a mosquitto container with docker, thus it requires docker to be installed and running - ## Contribute to the Test Suite In order to contribute to the ETSI NGSI-LD Test Suite, it is recommended to install an IDE with the corresponding diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot index 18611efe..e7eddc49 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check Mqtt Notification +Documentation Check that we receive the Mqtt Notification with different userInfo and port Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -7,7 +7,6 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource -Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test Test Template Check Receive MQTT Notification @@ -46,7 +45,7 @@ Check Receive MQTT Notification [Documentation] Check that the broker uses the authentication information from the endpoint url [Arguments] ${config_filename} ${endpoint_uri} ${port}=1883 ${username}=${None} ${password}=${None} - Launch Mqtt Server ${config_filename} ${port} + Start Mqtt Server ${config_filename} ${port} Setup Mqtt Subscription ${endpoint_uri} Set Username And Password ${username} ${password} @@ -55,13 +54,12 @@ Check Receive MQTT Notification ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} - ${firstmessage}= Set Variable ${listenMessages}[0] Length Should Be ${listenMessages} 1 After Test Delete Initial Subscriptions Delete Initial Entity - Kill Mqtt Server + Stop Mqtt Server Disconnect Setup Mqtt Subscription @@ -78,9 +76,11 @@ Setup Mqtt Subscription Set Suite Variable ${subscription_id} Set Suite Variable ${entity_id} - Create Entity ${entity_building_filepath} ${entity_id} + ${response}= Create Entity ${entity_building_filepath} ${entity_id} + Check Response Status Code 201 ${response.status_code} Sleep 1s - Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + ${response}= Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response.status_code} Sleep 1s Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot index c2651821..e8dce4ec 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check Mqtt Notification +Documentation Check that we receive mqtt notification with different qos Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -7,7 +7,6 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource -Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test Test Template Check QoS On MQTT Notification @@ -40,7 +39,7 @@ Check QoS On MQTT Notification [Documentation] Check that the broker supports different quality of service (qos) [Arguments] ${config_filename} ${endpoint_uri} ${qos}=${None} - Launch Mqtt Server ${config_filename} 1883 + Start Mqtt Server ${config_filename} 1883 Setup Mqtt Subscription ${endpoint_uri} qos=${qos} Connect 127.0.0.1 1883 @@ -54,7 +53,7 @@ Check QoS On MQTT Notification After Test Delete Initial Subscriptions Delete Initial Entity - Kill Mqtt Server + Stop Mqtt Server Disconnect Setup Mqtt Subscription @@ -81,9 +80,13 @@ Setup Mqtt Subscription Set Suite Variable ${subscription_id} Set Suite Variable ${entity_id} - Create Entity ${entity_building_filepath} ${entity_id} + ${response}= Create Entity ${entity_building_filepath} ${entity_id} + Check Response Status Code 201 ${response.status_code} + Sleep 1s - Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + ${response}= Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response.status_code} + Sleep 1s Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot index 10eaa43f..be4cdfe9 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check Mqtt Notification +Documentation Check that we receive mqtt notification with different mqtt version Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -7,7 +7,6 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource -Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test Test Template Check MQTT Protocol Version on MQTT notification @@ -40,7 +39,7 @@ Check MQTT Protocol Version on MQTT notification [Documentation] Check that the broker support different mqtt version [Arguments] ${config_filename} ${endpoint_uri} ${version}=${None} - Launch Mqtt Server ${config_filename} 1883 + Start Mqtt Server ${config_filename} 1883 Setup Mqtt Subscription ${endpoint_uri} version=${version} Connect 127.0.0.1 1883 @@ -54,7 +53,7 @@ Check MQTT Protocol Version on MQTT notification After Test Delete Initial Subscriptions Delete Initial Entity - Kill Mqtt Server + Stop Mqtt Server Disconnect Setup Mqtt Subscription @@ -80,9 +79,12 @@ Setup Mqtt Subscription Set Suite Variable ${subscription_id} Set Suite Variable ${entity_id} - Create Entity ${entity_building_filepath} ${entity_id} + ${response}= Create Entity ${entity_building_filepath} ${entity_id} + Check Response Status Code 201 ${response.status_code} Sleep 1s - Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + + ${response}= Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response.status_code} Sleep 1s Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot index 5d01bd2b..1382bbe4 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check Mqtt Notification +Documentation Check that the mqtt notification payload is well formed Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource @@ -7,7 +7,6 @@ Resource ${EXECDIR}/resources/AssertionUtils.resource Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource -Library ${EXECDIR}/libraries/evaluateJson.py Test Teardown After Test Test Template Check Receive Well Formed Data @@ -34,7 +33,7 @@ Check Receive Well Formed Data [Documentation] Check that the broker send well formed data [Arguments] ${config_filename} ${endpoint_uri} - Launch Mqtt Server ${config_filename} 1883 + Start Mqtt Server ${config_filename} 1883 Setup Mqtt Subscription ${endpoint_uri} Connect 127.0.0.1 1883 @@ -43,7 +42,7 @@ Check Receive Well Formed Data ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} ${firstmessage}= Set Variable ${listenMessages}[0] - ${message}= Evaluate Json ${firstmessage} + ${message}= Convert String To Json ${firstmessage} Dictionary Should Contain Key ${message} metadata Dictionary Should Contain Key ${message} body @@ -58,7 +57,7 @@ Check Receive Well Formed Data After Test Delete Initial Subscriptions Delete Initial Entity - Kill Mqtt Server + Stop Mqtt Server Disconnect Setup Mqtt Subscription @@ -83,9 +82,13 @@ Setup Mqtt Subscription ... ${subscription_payload} ... $.notification.endpoint.receiverInfo ... ${receiverInfo} + Create Entity ${entity_building_filepath} ${entity_id} + ${response}= Check Response Status Code 201 ${response.status_code} Sleep 1s - Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + + ${response}= Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} + Check Response Status Code 201 ${response.status_code} Sleep 1s Delete Initial Subscriptions diff --git a/libraries/evaluateJson.py b/libraries/evaluateJson.py deleted file mode 100644 index d1f9e264..00000000 --- a/libraries/evaluateJson.py +++ /dev/null @@ -1,5 +0,0 @@ -import json - - -def evaluate_json(payload): # force to implement this because robot framework can't read {a: true} or {a: false} - return json.loads(payload) diff --git a/resources/mqttUtils/MqttUtils.resource b/resources/mqttUtils/MqttUtils.resource index 16235378..8ee17e86 100644 --- a/resources/mqttUtils/MqttUtils.resource +++ b/resources/mqttUtils/MqttUtils.resource @@ -10,21 +10,21 @@ ${container_name}= ngsi-ld-test-suite-mosquitto-container *** Keywords *** -Launch Mqtt Server +Start Mqtt Server [Arguments] ${conf_file_name} ${port} ${request} = Set Variable ... docker run -d -p ${port}:1883 -v "${CURDIR}/mosquitto/${conf_file_name}:/mosquitto/config/mosquitto.conf" -v "${CURDIR}/mosquitto/mosquitto_pwd:/mosquitto/config/mosquitto_pwd" --name "${container_name}" eclipse-mosquitto:2.0.18-openssl ${result} = Run Process ${request} shell=yes IF ${result.rc} > 0 - Log The launching of mosquitto encounter an error - Log check that docker is installed - Log that the port ${port} is free + Log The launch of mosquitto encount an error + Log Check that docker is installed + Log that the port ${port} is available Log and that no other container named ${container_name} is running Log ${result.stdout} Log ${result.stderr} END -Kill Mqtt Server +Stop Mqtt Server ${request} = Set Variable docker container rm -f "${container_name}" Run Process ${request} shell=yes -- GitLab From afd09bb7dc8017e9de5cc7888e550e3f3d0bb271 Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Fri, 12 Jul 2024 11:01:05 +0200 Subject: [PATCH 4/8] fix: remove we --- .../SubscriptionNotificationBehaviour/mqtt/058_01.robot | 2 +- .../SubscriptionNotificationBehaviour/mqtt/058_02.robot | 2 +- .../SubscriptionNotificationBehaviour/mqtt/058_03.robot | 2 +- .../SubscriptionNotificationBehaviour/mqtt/058_04.robot | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot index e7eddc49..0f27ab2b 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that we receive the Mqtt Notification with different userInfo and port +Documentation Check that the Mqtt Notification is received with different userInfo and port Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot index e8dce4ec..563dbd7e 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that we receive mqtt notification with different qos +Documentation Check that the mqtt notification is received with different qos Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot index be4cdfe9..11c85b73 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation Check that we receive mqtt notification with different mqtt version +Documentation Check that mqtt notification is received with different mqtt version Resource ${EXECDIR}/resources/ApiUtils/ContextInformationSubscription.resource Resource ${EXECDIR}/resources/ApiUtils/ContextInformationProvision.resource diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot index 1382bbe4..dd1deff0 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot @@ -83,8 +83,8 @@ Setup Mqtt Subscription ... $.notification.endpoint.receiverInfo ... ${receiverInfo} - Create Entity ${entity_building_filepath} ${entity_id} - ${response}= Check Response Status Code 201 ${response.status_code} + ${response}= Create Entity ${entity_building_filepath} ${entity_id} + Check Response Status Code 201 ${response.status_code} Sleep 1s ${response}= Create Subscription From Subscription Payload ${subscription_payload} ${CONTENT_TYPE_LD_JSON} -- GitLab From 7ffea239d795d29c30132b0a96326c437ee43e49 Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Mon, 15 Jul 2024 14:45:31 +0200 Subject: [PATCH 5/8] fix: documentation --- README.md | 2 +- .../{mqtt => MQTT}/058_01.robot | 7 +- .../{mqtt => MQTT}/058_02.robot | 30 ++--- .../{mqtt => MQTT}/058_03.robot | 28 +++-- .../{mqtt => MQTT}/058_04.robot | 35 +++--- doc/analysis/checks.py | 30 ++++- doc/analysis/generaterobotdata.py | 1 + doc/analysis/initial_setup.py | 12 ++ .../Subscription/058_01.json | 105 ++++++++++++++++++ .../Subscription/058_02.json | 74 ++++++++++++ .../Subscription/058_03.json | 74 ++++++++++++ .../Subscription/058_04.json | 42 +++++++ .../test_ContextInformation_Subscription.py | 29 +++++ resources/AssertionUtils.resource | 18 ++- 14 files changed, 434 insertions(+), 53 deletions(-) rename TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/{mqtt => MQTT}/058_01.robot (93%) rename TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/{mqtt => MQTT}/058_02.robot (85%) rename TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/{mqtt => MQTT}/058_03.robot (83%) rename TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/{mqtt => MQTT}/058_04.robot (76%) create mode 100644 doc/files/ContextInformation/Subscription/058_01.json create mode 100644 doc/files/ContextInformation/Subscription/058_02.json create mode 100644 doc/files/ContextInformation/Subscription/058_03.json create mode 100644 doc/files/ContextInformation/Subscription/058_04.json diff --git a/README.md b/README.md index 833ca398..e471a856 100644 --- a/README.md +++ b/README.md @@ -355,7 +355,7 @@ In these cases, it is needed to provide the corresponding information in the Pyt in `self.description` to reference the method that pretty print the operation, and add the method that pretty prints the operation) - When a new permutation is added in an existing Test Case, run the documentation generation script - (`python doc/generateDocumentationData.py {tc_id}`) for the Test Case and copy the generated JSON file in the + (`python doc/analysis/generateDocumentationData.py {tc_id}`) for the Test Case and copy the generated JSON file in the folder containing all files for the given group and subgroup (`cp doc/results/{tc_id}.json doc/files/{group}/{subgroup}`) - When a new directory containing Test Cases is created, it has to be declared in `doc/generaterobotdata.py` along with its acronym diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01.robot similarity index 93% rename from TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot rename to TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01.robot index 0f27ab2b..93b3d182 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_01.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01.robot @@ -9,7 +9,7 @@ Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource Test Teardown After Test -Test Template Check Receive MQTT Notification +Test Template Receive MQTT Notification *** Variables *** @@ -18,7 +18,6 @@ ${subscription_payload_file_path} subscriptions/subscription-building-enti ${building_id_prefix} urn:ngsi-ld:Building: ${entity_building_filepath} building-simple-attributes-sample.jsonld ${fragment_filename} airQualityLevel-fragment.jsonld -${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" ${topic} ngsild-test-suite/topic @@ -41,7 +40,7 @@ ${topic} ngsild-test-suite/topic *** Keywords *** -Check Receive MQTT Notification +Receive MQTT Notification [Documentation] Check that the broker uses the authentication information from the endpoint url [Arguments] ${config_filename} ${endpoint_uri} ${port}=1883 ${username}=${None} ${password}=${None} @@ -54,7 +53,7 @@ Check Receive MQTT Notification ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} - Length Should Be ${listenMessages} 1 + Check Messages Contain One Instance ${listenMessages} After Test Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02.robot similarity index 85% rename from TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot rename to TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02.robot index 563dbd7e..3f985a69 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_02.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02.robot @@ -8,8 +8,9 @@ Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Test Setup Start Mqtt Server And Connect Test Teardown After Test -Test Template Check QoS On MQTT Notification +Test Template Receive MQTT Notification *** Variables *** @@ -18,37 +19,38 @@ ${subscription_payload_file_path} subscriptions/subscription-building-enti ${building_id_prefix} urn:ngsi-ld:Building: ${entity_building_filepath} building-simple-attributes-sample.jsonld ${fragment_filename} airQualityLevel-fragment.jsonld -${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" ${topic} ngsild-test-suite/topic +${endpoint} mqtt://127.0.0.1/${topic} +${config_filename} mosquitto.conf *** Test Cases *** 058_02_01 With Default QoS [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} + qos=${None} 058_02_02 With QoS 1 [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} qos=1 + qos=1 058_02_03 With QoS 2 [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} qos=2 + qos=2 *** Keywords *** -Check QoS On MQTT Notification +Receive MQTT Notification [Documentation] Check that the broker supports different quality of service (qos) - [Arguments] ${config_filename} ${endpoint_uri} ${qos}=${None} - - Start Mqtt Server ${config_filename} 1883 - Setup Mqtt Subscription ${endpoint_uri} qos=${qos} - - Connect 127.0.0.1 1883 - Subscribe topic=${topic} qos=1 + [Arguments] ${qos} + Setup Mqtt Subscription ${endpoint} qos=${qos} ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} - Length Should Be ${listenMessages} 1 + Check Messages Contain One Instance ${listenMessages} + +Start Mqtt Server And Connect + Start Mqtt Server ${config_filename} 1883 + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 After Test Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03.robot similarity index 83% rename from TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot rename to TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03.robot index 11c85b73..863e9534 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_03.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03.robot @@ -8,8 +8,9 @@ Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Test Setup Start Mqtt Server And Connect Test Teardown After Test -Test Template Check MQTT Protocol Version on MQTT notification +Test Template Receive Mqtt Notification *** Variables *** @@ -18,37 +19,40 @@ ${subscription_payload_file_path} subscriptions/subscription-building-enti ${building_id_prefix} urn:ngsi-ld:Building: ${entity_building_filepath} building-simple-attributes-sample.jsonld ${fragment_filename} airQualityLevel-fragment.jsonld -${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" ${topic} ngsild-test-suite/topic +${endpoint} mqtt://127.0.0.1/${topic} +${config_filename} mosquitto.conf *** Test Cases *** 058_03_01 With Default Protocol [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} + version=${None} 058_03_02 With MQTT 3.1.1 Protocol [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt3.1.1 + version=mqtt3.1.1 058_03_03 With MQTT 5.0 Protocol [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} version=mqtt5.0 + version=mqtt5.0 *** Keywords *** -Check MQTT Protocol Version on MQTT notification +Receive Mqtt Notification [Documentation] Check that the broker support different mqtt version - [Arguments] ${config_filename} ${endpoint_uri} ${version}=${None} + [Arguments] ${version} - Start Mqtt Server ${config_filename} 1883 - Setup Mqtt Subscription ${endpoint_uri} version=${version} - - Connect 127.0.0.1 1883 + Setup Mqtt Subscription ${endpoint} ${version} Subscribe topic=${topic} qos=1 ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} - Length Should Be ${listenMessages} 1 + Check Messages Contain One Instance ${listenMessages} + +Start Mqtt Server And Connect + Start Mqtt Server ${config_filename} 1883 + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 After Test Delete Initial Subscriptions diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot similarity index 76% rename from TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot rename to TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot index dd1deff0..8906ecd7 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/mqtt/058_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot @@ -8,8 +8,9 @@ Resource ${EXECDIR}/resources/JsonUtils.resource Resource ${EXECDIR}/resources/NotificationUtils.resource Resource ${EXECDIR}/resources/mqttUtils/MqttUtils.resource +Test Setup Start Mqtt Server And Connect Test Teardown After Test -Test Template Check Receive Well Formed Data +Test Template Receive Mqtt Notification *** Variables *** @@ -18,41 +19,35 @@ ${subscription_payload_file_path} subscriptions/subscription-building-enti ${building_id_prefix} urn:ngsi-ld:Building: ${entity_building_filepath} building-simple-attributes-sample.jsonld ${fragment_filename} airQualityLevel-fragment.jsonld -${expected_header_links} <${ngsild_test_suite_context}>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json" ${topic} ngsild-test-suite/topic +${endpoint} mqtt://127.0.0.1/${topic} +${config_filename} mosquitto.conf *** Test Cases *** 058_04_01 Basic Subscription [Tags] sub-mqtt-notification 5_8_6 - mosquitto.conf mqtt://127.0.0.1/${topic} + ${EMPTY} *** Keywords *** -Check Receive Well Formed Data +Receive Mqtt Notification [Documentation] Check that the broker send well formed data - [Arguments] ${config_filename} ${endpoint_uri} - - Start Mqtt Server ${config_filename} 1883 - Setup Mqtt Subscription ${endpoint_uri} - - Connect 127.0.0.1 1883 - Subscribe topic=${topic} qos=1 + [Arguments] ${arg} ${response}= Update Entity Attributes ${entity_id} ${fragment_filename} ${CONTENT_TYPE_LD_JSON} ${listenMessages}= Listen ${topic} ${firstmessage}= Set Variable ${listenMessages}[0] ${message}= Convert String To Json ${firstmessage} - Dictionary Should Contain Key ${message} metadata - Dictionary Should Contain Key ${message} body - Dictionary Should Contain Key ${message}[metadata] Content-Type - Dictionary Should Contain Key ${message}[metadata] Link - Should Be Equal As Strings ${message}[metadata][test-receiver-key] test-receiver-info - Should Be Equal As Strings ${message}[body][type] Notification - Dictionary Should Contain Key ${message}[body] data - Dictionary Should Contain Key ${message}[body][data][0] id - Dictionary Should Contain Key ${message}[body][data][0] type + Check Mqtt Message Is Well Formed ${message} + +Start Mqtt Server And Connect + Start Mqtt Server ${config_filename} 1883 + Setup Mqtt Subscription ${endpoint} + + Connect 127.0.0.1 1883 + Subscribe topic=${topic} qos=1 After Test Delete Initial Subscriptions diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index ec9a873d..4a39c488 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -138,7 +138,11 @@ class Checks: Checks.check_response_headers_link_set_to, 'Check Response Headers Containing NGSILD-Results-Count Equals To' : Checks.check_response_header_contains_ngsild_results_count_equals_to, - } + 'Check Messages Contain One Instance' : + Checks.check_messages_contain_one_instance, + 'Check Mqtt Message Is Well Formed': + Checks.check_mqtt_message_is_well_formed + } self.args = { 'Check Response Status Code': { @@ -399,6 +403,14 @@ class Checks: 'Check Response Headers Containing NGSILD-Results-Count Equals To': { 'params': ['expected_result_count' , 'response_headers'], 'position': [0, 1] + }, + 'Check Messages Contain One Instance': { + 'params': ['messages'], + 'position': [0] + }, + 'Check Mqtt Message Is Well Formed': { + 'params': ['message'], + 'position': [0] } } @@ -1106,6 +1118,22 @@ class Checks: else: raise Exception(f"ERROR, Expected 'expected_result_count' but received: '{kwargs}'") + @staticmethod + def check_messages_contain_one_instance(kwargs: list) -> str: + if 'messages' in kwargs: + messages = kwargs['messages'] + return f'Received messages {messages}' + else: + raise Exception(f"ERROR, Expected 1 message but received: '{kwargs}'") + + @staticmethod + def check_mqtt_message_is_well_formed(kwargs: list) -> str: + if 'message' in kwargs: + message = kwargs['message'] + return f'Received message {message}' + else: + raise Exception(f"ERROR, Expected a well formed mqtt message but received: '{kwargs}'") + def get_checks(self, **kwargs) -> str: checking = None diff --git a/doc/analysis/generaterobotdata.py b/doc/analysis/generaterobotdata.py index 0c6c7b39..9b2b7a91 100644 --- a/doc/analysis/generaterobotdata.py +++ b/doc/analysis/generaterobotdata.py @@ -68,6 +68,7 @@ class GenerateRobotData: 'Subscription/RetrieveSubscription': 'SUB', 'Subscription/UpdateSubscription': 'SUB', 'Subscription/SubscriptionNotificationBehaviour': 'SUB', + 'Subscription/SubscriptionNotificationBehaviour/MQTT': 'SUBMQTT', 'Registration/CreateContextSourceRegistration': 'REG', 'Registration/CreateCSRegistration': 'REG', 'Registration/UpdateCSRegistration': 'REG', diff --git a/doc/analysis/initial_setup.py b/doc/analysis/initial_setup.py index 3dd79db0..d249a4fd 100644 --- a/doc/analysis/initial_setup.py +++ b/doc/analysis/initial_setup.py @@ -21,6 +21,7 @@ class InitialSetup: 'Create Id': InitialSetup.init_temporal_entity2(), 'Create Initial Subscription': InitialSetup.init_subscription(), 'Setup Initial Subscriptions': InitialSetup.init_subscription(), + 'Start Mqtt Server And Connect': InitialSetup.init_mqtt_subscription(), 'Setup Initial Entities': InitialSetup.init_entities(), 'Setup Initial Temporal Entities': InitialSetup.init_temporal_entities(), 'Create Initial Context Source Registration and Context Source Registration Subscription': @@ -108,6 +109,17 @@ class InitialSetup: }''' return data + @staticmethod + def init_mqtt_subscription() -> str: + data = '''with + the SUT being in the "initial state" and + the SUT containing an initial Subscription ${subscription} + with an id set to ${subscription_id} + and an notification endpoint set to a mqtt broker +}''' + return data + + @staticmethod def init_entities() -> str: data = '''with { diff --git a/doc/files/ContextInformation/Subscription/058_01.json b/doc/files/ContextInformation/Subscription/058_01.json new file mode 100644 index 00000000..4ed02e97 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/058_01.json @@ -0,0 +1,105 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01", + "test_objective": "Check that the Mqtt Notification is received with different userInfo and port", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Receive MQTT Notification", + "After Test", + "Setup Mqtt Subscription", + "Delete Initial Subscriptions", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with {\n the SUT containing an initial state\n}", + "test_cases": [ + { + "name": "058_01_01 Without User And Port", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_01", + "doc": "Check that the broker uses the authentication information from the endpoint url", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": null, + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_01_02 With Non Default Port", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_02", + "doc": "Check that the broker uses the authentication information from the endpoint url", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": null, + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_01_03 With User", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_03", + "doc": "Check that the broker uses the authentication information from the endpoint url", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": null, + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_01_04 With User And Password", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_04", + "doc": "Check that the broker uses the authentication information from the endpoint url", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": null, + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_01_05 With User Password And Non Default Port", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_05", + "doc": "Check that the broker uses the authentication information from the endpoint url", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": null, + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + } + ], + "permutations": [], + "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotfile": "058_01" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_02.json b/doc/files/ContextInformation/Subscription/058_02.json new file mode 100644 index 00000000..45620457 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/058_02.json @@ -0,0 +1,74 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02", + "test_objective": "Check that the mqtt notification is received with different qos", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Receive MQTT Notification", + "Start Mqtt Server And Connect", + "After Test", + "Setup Mqtt Subscription", + "Delete Initial Subscriptions", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with \n the SUT being in the \"initial state\" and\n the SUT containing an initial Subscription ${subscription} \n with an id set to ${subscription_id}\n and an notification endpoint set to a mqtt broker\n}", + "test_cases": [ + { + "name": "058_02_01 With Default QoS", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_01", + "doc": "Check that the broker supports different quality of service (qos)", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_02_02 With QoS 1", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_02", + "doc": "Check that the broker supports different quality of service (qos)", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_02_03 With QoS 2", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_03", + "doc": "Check that the broker supports different quality of service (qos)", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive MQTT Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + } + ], + "permutations": [], + "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotfile": "058_02" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_03.json b/doc/files/ContextInformation/Subscription/058_03.json new file mode 100644 index 00000000..0a3e701d --- /dev/null +++ b/doc/files/ContextInformation/Subscription/058_03.json @@ -0,0 +1,74 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03", + "test_objective": "Check that mqtt notification is received with different mqtt version", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Receive Mqtt Notification", + "Start Mqtt Server And Connect", + "After Test", + "Setup Mqtt Subscription", + "Delete Initial Subscriptions", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with \n the SUT being in the \"initial state\" and\n the SUT containing an initial Subscription ${subscription} \n with an id set to ${subscription_id}\n and an notification endpoint set to a mqtt broker\n}", + "test_cases": [ + { + "name": "058_03_01 With Default Protocol", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_01", + "doc": "Check that the broker support different mqtt version", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive Mqtt Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_03_02 With MQTT 3.1.1 Protocol", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_02", + "doc": "Check that the broker support different mqtt version", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive Mqtt Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + }, + { + "name": "058_03_03 With MQTT 5.0 Protocol", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_03", + "doc": "Check that the broker support different mqtt version", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive Mqtt Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received messages ${listenMessages}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + } + ], + "permutations": [], + "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotfile": "058_03" +} \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_04.json b/doc/files/ContextInformation/Subscription/058_04.json new file mode 100644 index 00000000..d165b185 --- /dev/null +++ b/doc/files/ContextInformation/Subscription/058_04.json @@ -0,0 +1,42 @@ +{ + "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04", + "test_objective": "Check that the mqtt notification payload is well formed", + "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", + "config_id": "", + "parent_release": "v1.3.1", + "clauses": [ + "5.8.6" + ], + "pics_selection": "", + "keywords": [ + "Receive Mqtt Notification", + "Start Mqtt Server And Connect", + "After Test", + "Setup Mqtt Subscription", + "Delete Initial Subscriptions", + "Delete Initial Entity" + ], + "teardown": "None", + "initial_condition": "with \n the SUT being in the \"initial state\" and\n the SUT containing an initial Subscription ${subscription} \n with an id set to ${subscription_id}\n and an notification endpoint set to a mqtt broker\n}", + "test_cases": [ + { + "name": "058_04_01 Basic Subscription", + "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04_01", + "doc": "Check that the broker send well formed data", + "tags": [ + "5_8_6", + "sub-mqtt-notification" + ], + "setup": "Start Mqtt Server And Connect", + "teardown": "After Test", + "template": "Receive Mqtt Notification", + "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received message ${message}\n}", + "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", + "http_verb": "PATCH", + "endpoint": "entities/{entityId}/attrs/{attributeId}" + } + ], + "permutations": [], + "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotfile": "058_04" +} \ No newline at end of file diff --git a/doc/tests/test_ContextInformation_Subscription.py b/doc/tests/test_ContextInformation_Subscription.py index 265e10d4..33b2b1b8 100644 --- a/doc/tests/test_ContextInformation_Subscription.py +++ b/doc/tests/test_ContextInformation_Subscription.py @@ -328,3 +328,32 @@ class TestCISubscription(TestCase): difference_file = f'{self.folder_test_suites}/doc/results/out_029_11.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_058_01(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/058_01.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/058_01.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_058_01.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_058_02(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/058_02.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/058_02.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_058_02.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_058_03(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/058_03.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/058_03.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_029_11.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + + def test_058_04(self): + robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/058_04.robot' + expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/058_04.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_058_04.json' + + self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) + diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index 432e6ce7..a29dfa97 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -43,7 +43,7 @@ Check Response Body Containing Entities URIS set to Append To List ${response_entities_ids} ${entity['id']} END - Lists Should Be Equal ${expected_entities_ids} ${response_entities_ids} ignore_order=True + Lists Should Be Equal ${expected_entities_ids} ${response_entities_ids} ignore_order=True Check Response Body Content [Arguments] ${expectation_filename} ${response_body} ${additional_ignored_path}=${EMPTY} @@ -759,3 +759,19 @@ Check Context Response Body Containing a JSONObject with details of a Implicitly # Check that there is no other keys Check Context Detailed Information Keys ${response}[0] + +Check Messages Contain One Instance + [Arguments] ${messages} + Length Should Be ${messages} 1 + +Check Mqtt Message Is Well Formed + [Arguments] ${message} + Dictionary Should Contain Key ${message} metadata + Dictionary Should Contain Key ${message} body + Dictionary Should Contain Key ${message}[metadata] Content-Type + Dictionary Should Contain Key ${message}[metadata] Link + Should Be Equal As Strings ${message}[metadata][test-receiver-key] test-receiver-info + Should Be Equal As Strings ${message}[body][type] Notification + Dictionary Should Contain Key ${message}[body] data + Dictionary Should Contain Key ${message}[body][data][0] id + Dictionary Should Contain Key ${message}[body][data][0] type -- GitLab From ac27202fe020403b302641a9b7d1b023eab92e5e Mon Sep 17 00:00:00 2001 From: Benoit Orihuela Date: Mon, 15 Jul 2024 15:31:31 +0000 Subject: [PATCH 6/8] fix: typo in contextInformation --- doc/tests/test_ContextInformation_Subscription.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/tests/test_ContextInformation_Subscription.py b/doc/tests/test_ContextInformation_Subscription.py index 33b2b1b8..8a550fbd 100644 --- a/doc/tests/test_ContextInformation_Subscription.py +++ b/doc/tests/test_ContextInformation_Subscription.py @@ -346,7 +346,7 @@ class TestCISubscription(TestCase): def test_058_03(self): robot_file = f'{self.folder_test_suites}/TP/NGSI-LD/ContextInformation/Subscription/UpdateSubscription/058_03.robot' expected_value = f'{self.folder_test_suites}/doc/files/ContextInformation/Subscription/058_03.json' - difference_file = f'{self.folder_test_suites}/doc/results/out_029_11.json' + difference_file = f'{self.folder_test_suites}/doc/results/out_058_03.json' self.common_function(robot_file=robot_file, expected_value=expected_value, difference_file=difference_file) -- GitLab From af499f653379ec45bdebcaf22eb6b863882006df Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Tue, 16 Jul 2024 12:10:40 +0200 Subject: [PATCH 7/8] refacto: check for 058_04 --- .../MQTT/058_04.robot | 10 +++++- doc/analysis/checks.py | 34 ++++++++++++++----- .../Subscription/058_04.json | 2 +- resources/AssertionUtils.resource | 18 ++++------ 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot index 8906ecd7..e45aca73 100644 --- a/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot +++ b/TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04.robot @@ -40,7 +40,15 @@ Receive Mqtt Notification ${firstmessage}= Set Variable ${listenMessages}[0] ${message}= Convert String To Json ${firstmessage} - Check Mqtt Message Is Well Formed ${message} + Check Message Contain Key ${message} metadata + Check Message Contain Key ${message} body + Check Message Contain Key ${message}[metadata] Content-Type + Check Message Contain Key ${message}[metadata] Link + Check Message Field Equal ${message}[metadata][test-receiver-key] test-receiver-info + Check Message Field Equal ${message}[body][type] Notification + Check Message Contain Key ${message}[body] data + Check Message Contain Key ${message}[body][data][0] id + Check Message Contain Key ${message}[body][data][0] type Start Mqtt Server And Connect Start Mqtt Server ${config_filename} 1883 diff --git a/doc/analysis/checks.py b/doc/analysis/checks.py index 4a39c488..d0b4f7ce 100644 --- a/doc/analysis/checks.py +++ b/doc/analysis/checks.py @@ -140,8 +140,10 @@ class Checks: Checks.check_response_header_contains_ngsild_results_count_equals_to, 'Check Messages Contain One Instance' : Checks.check_messages_contain_one_instance, - 'Check Mqtt Message Is Well Formed': - Checks.check_mqtt_message_is_well_formed + 'Check Message Contain Key': + Checks.check_message_contain_key, + 'Check Message Field Equal': + Checks.check_message_field_equal } self.args = { @@ -408,9 +410,13 @@ class Checks: 'params': ['messages'], 'position': [0] }, - 'Check Mqtt Message Is Well Formed': { - 'params': ['message'], - 'position': [0] + 'Check Message Contain Key': { + 'params': ['message', 'key'], + 'position': [0,1] + }, + 'Check Message Field Equal': { + 'params': ['expected_field', 'field'], + 'position': [0,1] } } @@ -1127,12 +1133,22 @@ class Checks: raise Exception(f"ERROR, Expected 1 message but received: '{kwargs}'") @staticmethod - def check_mqtt_message_is_well_formed(kwargs: list) -> str: - if 'message' in kwargs: + def check_message_contain_key(kwargs: list) -> str: + if 'message' in kwargs and 'key' in kwargs: message = kwargs['message'] - return f'Received message {message}' + key = kwargs['key'] + return f'Received message {message} with key {key}' + else: + raise Exception(f"ERROR, Expected a message containing the key but received: '{kwargs}'") + + @staticmethod + def check_message_field_equal(kwargs: list) -> str: + if 'expected_field' in kwargs and 'field' in kwargs: + field = kwargs['field'] + expected_field = kwargs['expected_field'] + return f'expected field {expected_field} equals field {field}' else: - raise Exception(f"ERROR, Expected a well formed mqtt message but received: '{kwargs}'") + raise Exception(f"ERROR, Expected the field to be equal 'expected_field' but received: '{kwargs}'") def get_checks(self, **kwargs) -> str: checking = None diff --git a/doc/files/ContextInformation/Subscription/058_04.json b/doc/files/ContextInformation/Subscription/058_04.json index d165b185..01ba55f3 100644 --- a/doc/files/ContextInformation/Subscription/058_04.json +++ b/doc/files/ContextInformation/Subscription/058_04.json @@ -30,7 +30,7 @@ "setup": "Start Mqtt Server And Connect", "teardown": "After Test", "template": "Receive Mqtt Notification", - "then": "then {\n the SUT sends a valid Response for the operation:\n Notification with Received message ${message}\n}", + "then": "then {\n the SUT sends a valid Response for the operations:\n Notification with Received message ${message} with key metadata and\n Notification with Received message ${message} with key body and\n Notification with Received message ${message}[metadata] with key Content-Type and\n Notification with Received message ${message}[metadata] with key Link and\n Notification with expected field ${message}[metadata][test-receiver-key] equals field test-receiver-info and\n Notification with expected field ${message}[body][type] equals field Notification and\n Notification with Received message ${message}[body] with key data and\n Notification with Received message ${message}[body][data][0] with key id and\n Notification with Received message ${message}[body][data][0] with key type\n}", "when": "when {\n the SUT receives a Request from the client containing:\n URL set to '/ngsi-ld/v1/entities/{entityId}/attrs/{attributeId}'\n method set to 'PATCH'\n Update Entity Attributes and\n Query Parameter: id set to '${entity_id}' and\n Query Parameter: fragment_filename set to '${fragment_filename}' and\n Query Parameter: content_type set to 'application/ld+json'\n}", "http_verb": "PATCH", "endpoint": "entities/{entityId}/attrs/{attributeId}" diff --git a/resources/AssertionUtils.resource b/resources/AssertionUtils.resource index a29dfa97..63181b6d 100755 --- a/resources/AssertionUtils.resource +++ b/resources/AssertionUtils.resource @@ -764,14 +764,10 @@ Check Messages Contain One Instance [Arguments] ${messages} Length Should Be ${messages} 1 -Check Mqtt Message Is Well Formed - [Arguments] ${message} - Dictionary Should Contain Key ${message} metadata - Dictionary Should Contain Key ${message} body - Dictionary Should Contain Key ${message}[metadata] Content-Type - Dictionary Should Contain Key ${message}[metadata] Link - Should Be Equal As Strings ${message}[metadata][test-receiver-key] test-receiver-info - Should Be Equal As Strings ${message}[body][type] Notification - Dictionary Should Contain Key ${message}[body] data - Dictionary Should Contain Key ${message}[body][data][0] id - Dictionary Should Contain Key ${message}[body][data][0] type +Check Message Contain Key + [Arguments] ${message} ${key} + Dictionary Should Contain Key ${message} ${key} + +Check Message Field Equal + [Arguments] ${expected_field} ${field} + Should Be Equal As Strings ${expected_field} ${field} -- GitLab From 33e4708ae8b9b593c619a8eeea0ff847ff487eea Mon Sep 17 00:00:00 2001 From: Thomas BOUSSELIN Date: Tue, 23 Jul 2024 14:05:23 +0200 Subject: [PATCH 8/8] fix: documentation generation --- .../ContextInformation/Subscription/058_01.json | 14 +++++++------- .../ContextInformation/Subscription/058_02.json | 10 +++++----- .../ContextInformation/Subscription/058_03.json | 10 +++++----- .../ContextInformation/Subscription/058_04.json | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/doc/files/ContextInformation/Subscription/058_01.json b/doc/files/ContextInformation/Subscription/058_01.json index 4ed02e97..2eee9463 100644 --- a/doc/files/ContextInformation/Subscription/058_01.json +++ b/doc/files/ContextInformation/Subscription/058_01.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01", + "tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01", "test_objective": "Check that the Mqtt Notification is received with different userInfo and port", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", "config_id": "", @@ -20,7 +20,7 @@ "test_cases": [ { "name": "058_01_01 Without User And Port", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_01", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01_01", "doc": "Check that the broker uses the authentication information from the endpoint url", "tags": [ "5_8_6", @@ -36,7 +36,7 @@ }, { "name": "058_01_02 With Non Default Port", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_02", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01_02", "doc": "Check that the broker uses the authentication information from the endpoint url", "tags": [ "5_8_6", @@ -52,7 +52,7 @@ }, { "name": "058_01_03 With User", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_03", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01_03", "doc": "Check that the broker uses the authentication information from the endpoint url", "tags": [ "5_8_6", @@ -68,7 +68,7 @@ }, { "name": "058_01_04 With User And Password", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_04", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01_04", "doc": "Check that the broker uses the authentication information from the endpoint url", "tags": [ "5_8_6", @@ -84,7 +84,7 @@ }, { "name": "058_01_05 With User Password And Non Default Port", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_01_05", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_01_05", "doc": "Check that the broker uses the authentication information from the endpoint url", "tags": [ "5_8_6", @@ -100,6 +100,6 @@ } ], "permutations": [], - "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", "robotfile": "058_01" } \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_02.json b/doc/files/ContextInformation/Subscription/058_02.json index 45620457..87e91aa1 100644 --- a/doc/files/ContextInformation/Subscription/058_02.json +++ b/doc/files/ContextInformation/Subscription/058_02.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02", + "tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_02", "test_objective": "Check that the mqtt notification is received with different qos", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", "config_id": "", @@ -21,7 +21,7 @@ "test_cases": [ { "name": "058_02_01 With Default QoS", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_01", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_02_01", "doc": "Check that the broker supports different quality of service (qos)", "tags": [ "5_8_6", @@ -37,7 +37,7 @@ }, { "name": "058_02_02 With QoS 1", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_02", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_02_02", "doc": "Check that the broker supports different quality of service (qos)", "tags": [ "5_8_6", @@ -53,7 +53,7 @@ }, { "name": "058_02_03 With QoS 2", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_02_03", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_02_03", "doc": "Check that the broker supports different quality of service (qos)", "tags": [ "5_8_6", @@ -69,6 +69,6 @@ } ], "permutations": [], - "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", "robotfile": "058_02" } \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_03.json b/doc/files/ContextInformation/Subscription/058_03.json index 0a3e701d..64a223fa 100644 --- a/doc/files/ContextInformation/Subscription/058_03.json +++ b/doc/files/ContextInformation/Subscription/058_03.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03", + "tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_03", "test_objective": "Check that mqtt notification is received with different mqtt version", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", "config_id": "", @@ -21,7 +21,7 @@ "test_cases": [ { "name": "058_03_01 With Default Protocol", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_01", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_03_01", "doc": "Check that the broker support different mqtt version", "tags": [ "5_8_6", @@ -37,7 +37,7 @@ }, { "name": "058_03_02 With MQTT 3.1.1 Protocol", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_02", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_03_02", "doc": "Check that the broker support different mqtt version", "tags": [ "5_8_6", @@ -53,7 +53,7 @@ }, { "name": "058_03_03 With MQTT 5.0 Protocol", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_03_03", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_03_03", "doc": "Check that the broker support different mqtt version", "tags": [ "5_8_6", @@ -69,6 +69,6 @@ } ], "permutations": [], - "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", "robotfile": "058_03" } \ No newline at end of file diff --git a/doc/files/ContextInformation/Subscription/058_04.json b/doc/files/ContextInformation/Subscription/058_04.json index 01ba55f3..c55aa3cc 100644 --- a/doc/files/ContextInformation/Subscription/058_04.json +++ b/doc/files/ContextInformation/Subscription/058_04.json @@ -1,5 +1,5 @@ { - "tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04", + "tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_04", "test_objective": "Check that the mqtt notification payload is well formed", "reference": "ETSI GS CIM 009 V1.3.1 [], clause 5.8.6", "config_id": "", @@ -21,7 +21,7 @@ "test_cases": [ { "name": "058_04_01 Basic Subscription", - "permutation_tp_id": "TP/NGSI-LD/CI/Subscription/SubscriptionNotificationBehaviour/MQTT/058_04_01", + "permutation_tp_id": "TP/NGSI-LD/CI/SUB/MQTT/058_04_01", "doc": "Check that the broker send well formed data", "tags": [ "5_8_6", @@ -37,6 +37,6 @@ } ], "permutations": [], - "robotpath": "TP/NGSI-LD/ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", + "robotpath": "ContextInformation/Subscription/SubscriptionNotificationBehaviour/MQTT", "robotfile": "058_04" } \ No newline at end of file -- GitLab