From 0aa6c36c47d3e7192fca9a6040fdbab4e7c13905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 13 Jan 2025 16:47:55 +0100 Subject: [PATCH 1/6] FIX 3001_mqtt_alarms removing dependency on external MQTT broker --- .github/workflows/functional.yml | 3 ++ .../mqtt_alarms_log_summary.test | 16 ++++--- .../mqtt_alarms_raise_and_release.test | 46 +++++++++--------- .../mqtt_alarms_raise_repeat_and_release.test | 48 ++++++++++--------- .../mosquitto_conf_for_tests.conf | 2 + test/functionalTest/mosquitto_passwd | 1 + 6 files changed, 65 insertions(+), 51 deletions(-) create mode 100644 test/functionalTest/mosquitto_conf_for_tests.conf create mode 100644 test/functionalTest/mosquitto_passwd diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index b8b4bcb597..a08bd0f2e2 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -32,6 +32,9 @@ jobs: image: eclipse-mosquitto:1.6.15 ports: - 1883:1883 + volumes: + - ./test/functionalTest/mosquitto_conf_for_tests.conf:/mosquitto/config/mosquitto.conf + - ./test/functionalTest/mosquitto_passwd:/mosquitto/config/passwd mosquitto-extra: # Needed by MQTT notification tests (multi broker) diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test index 8f85a26087..45b8d25f08 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test @@ -32,8 +32,12 @@ brokerStart CB 0 IPv4 -logSummary 5 --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) +# This test requires a MQTT broker with authentication enabled. This may help: +# +# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 +# sudo chmod 640 /etc/mosquitto/passwd +# sudo chown root:mosquitto /etc/mosquitto/passwd # # 01. Sleep 6 and see 0-0 raised and 0-0 released # 02. Create MQTT sub with wrong user/pass @@ -67,8 +71,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -118,8 +122,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test index f531b4247f..886dc1f1f8 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test @@ -30,10 +30,12 @@ brokerStart CB 0 IPV4 --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) -# Given the MQTT broker is a remote system in the Internet, we have to wait at some points -# so subscription status and logs get consolidated before checking it +# This test requires a MQTT broker with authentication enabled. This may help: +# +# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 +# sudo chmod 640 /etc/mosquitto/passwd +# sudo chown root:mosquitto /etc/mosquitto/passwd # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm @@ -59,8 +61,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -125,8 +127,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } @@ -193,7 +195,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -210,8 +212,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 1 @@ -248,7 +250,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -265,8 +267,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 2 @@ -311,7 +313,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 566 +Content-Length: 502 [ { @@ -328,8 +330,8 @@ Content-Length: 566 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ" + "url": "mqtt://localhost:1883", + "user": "user1" }, "onlyChangedAttrs": false, "timesSent": 3 @@ -354,16 +356,16 @@ Content-Length: 566 09. Check logs and see 1 raised alarm and 1 released alarm ========================================================== #SORT_START -Request received: POST /v2/subscriptions, request payload (181 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "user", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 +Request received: POST /v2/subscriptions, request payload (184 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Raising alarm MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. +Raising alarm MqttConnectionError localhost:1883: Connection Refused: not authorised. Request received: GET /v2/subscriptions, response code: 200 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 Request received: GET /v2/subscriptions, response code: 200 -Request received: PATCH /v2/subscriptions/SUB_ID, request payload (182 bytes): { "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 +Request received: PATCH /v2/subscriptions/SUB_ID, request payload (118 bytes): { "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user1", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Releasing alarm MqttConnectionError mqtt.flespi.io:1883 -MQTT Notif delivered (subId: SUB_ID): broker: mqtt.flespi.io:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} +Releasing alarm MqttConnectionError localhost:1883 +MQTT Notif delivered (subId: SUB_ID): broker: localhost:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} Request received: GET /v2/subscriptions, response code: 200 #SORT_END diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test index c60bf280d5..763dea67d7 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test @@ -30,10 +30,12 @@ brokerStart CB 0 IPV4 -relogAlarms --SHELL-- # -# FIXME: this test relies on an external service (mqtt.flespi.io) which we don't control -# It would be better to use a MQTT broker running by us (docker?) -# Given the MQTT broker is a remote system in the Internet, we have to wait at some points -# so subscription status and logs get consolidated before checking it +# This test requires a MQTT broker with authentication enabled. This may help: +# +# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 +# sudo chmod 640 /etc/mosquitto/passwd +# sudo chown root:mosquitto /etc/mosquitto/passwd # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm @@ -59,8 +61,8 @@ payload='{ }, "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user", + "url": "mqtt://localhost:1883", + "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } @@ -125,8 +127,8 @@ echo "========================================" payload='{ "notification": { "mqtt": { - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", + "url": "mqtt://localhost:1883", + "user": "user1", "passwd": "xxxx", "topic": "sub1" } @@ -193,7 +195,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -210,8 +212,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 1 @@ -248,7 +250,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 482 +Content-Length: 485 [ { @@ -265,8 +267,8 @@ Content-Length: 482 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "user" + "url": "mqtt://localhost:1883", + "user": "user_noexist" }, "onlyChangedAttrs": false, "timesSent": 2 @@ -311,7 +313,7 @@ HTTP/1.1 200 OK Date: REGEX(.*) Fiware-Correlator: REGEX([0-9a-f\-]{36}) Content-Type: application/json -Content-Length: 566 +Content-Length: 502 [ { @@ -328,8 +330,8 @@ Content-Length: 566 "qos": 0, "retain": false, "topic": "sub1", - "url": "mqtt://mqtt.flespi.io:1883", - "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ" + "url": "mqtt://localhost:1883", + "user": "user1" }, "onlyChangedAttrs": false, "timesSent": 3 @@ -354,17 +356,17 @@ Content-Length: 566 09. Check logs and see 1 raised alarm, 1 repeat alarm and 1 released alarm ========================================================================== #SORT_START -Request received: POST /v2/subscriptions, request payload (181 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "user", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 +Request received: POST /v2/subscriptions, request payload (184 bytes): { "subject": { "entities": [ { "id": "E", "type": "T" } ] }, "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user_noexist", "passwd": "xxxx", "topic": "sub1" } } }, response code: 201 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Raising alarm MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. +Raising alarm MqttConnectionError localhost:1883: Connection Refused: not authorised. Request received: GET /v2/subscriptions, response code: 200 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 Request received: GET /v2/subscriptions, response code: 200 -Repeated MqttConnectionError mqtt.flespi.io:1883: Connection Refused: bad user name or password. -Request received: PATCH /v2/subscriptions/SUB_ID, request payload (182 bytes): { "notification": { "mqtt": { "url": "mqtt://mqtt.flespi.io:1883", "user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 +Repeated MqttConnectionError localhost:1883: Connection Refused: not authorised. +Request received: PATCH /v2/subscriptions/SUB_ID, request payload (118 bytes): { "notification": { "mqtt": { "url": "mqtt://localhost:1883", "user": "user1", "passwd": "xxxx", "topic": "sub1" } } }, response code: 204 Request received: POST /v2/entities?options=forcedUpdate,upsert, request payload (64 bytes): { "id": "E", "type": "T", "A": { "value": 1, "type": "Float" } }, response code: 204 -Releasing alarm MqttConnectionError mqtt.flespi.io:1883 -MQTT Notif delivered (subId: SUB_ID): broker: mqtt.flespi.io:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} +Releasing alarm MqttConnectionError localhost:1883 +MQTT Notif delivered (subId: SUB_ID): broker: localhost:1883, topic: sub1, payload (121 bytes): {"subscriptionId":"SUB_ID","data":[{"id":"E","type":"T","A":{"type":"Float","value":1,"metadata":{}}}]} Request received: GET /v2/subscriptions, response code: 200 #SORT_END diff --git a/test/functionalTest/mosquitto_conf_for_tests.conf b/test/functionalTest/mosquitto_conf_for_tests.conf new file mode 100644 index 0000000000..430b996c59 --- /dev/null +++ b/test/functionalTest/mosquitto_conf_for_tests.conf @@ -0,0 +1,2 @@ +password_file /etc/mosquitto/passwd +allow_anonymous true diff --git a/test/functionalTest/mosquitto_passwd b/test/functionalTest/mosquitto_passwd new file mode 100644 index 0000000000..eb65166dae --- /dev/null +++ b/test/functionalTest/mosquitto_passwd @@ -0,0 +1 @@ +user1:$7$101$eqgU7wUvh4Y3VQAm$ovEPI43qOwAskK5M+OFmNJAoXtLRx5GI2tBjTX4AOf3ZTB79IRv1CMgbHrPnKY+/K/RKMm2i/XFp9syteeOCvg== From 25ed111783e8c99e0c738404daaa84fe84918b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Mon, 13 Jan 2025 16:58:43 +0100 Subject: [PATCH 2/6] FIX GitAction fixes --- .github/workflows/codeql.yml | 4 ++-- .github/workflows/functional.yml | 15 +++++------- scripts/check_files_compliance.py | 2 +- .../mqtt_alarms_log_summary.test | 2 +- .../mqtt_alarms_raise_and_release.test | 5 +--- .../mqtt_alarms_raise_repeat_and_release.test | 5 +--- .../mosquittoConf/mosquitto.conf | 24 +++++++++++++++++++ .../{ => mosquittoConf}/mosquitto_passwd | 0 .../mosquitto_conf_for_tests.conf | 2 -- 9 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 test/functionalTest/mosquittoConf/mosquitto.conf rename test/functionalTest/{ => mosquittoConf}/mosquitto_passwd (100%) delete mode 100644 test/functionalTest/mosquitto_conf_for_tests.conf diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a0a1f80e32..b1b93e849f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,9 +14,9 @@ name: "CodeQL Advanced" on: push: branches: [ "master" ] - pull_request: + pull_request: branches: [ "master" ] - schedule: + schedule: - cron: '33 5 * * 1' jobs: diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index a08bd0f2e2..6c269ff167 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -27,17 +27,9 @@ jobs: ports: - 27017:27017 - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - volumes: - - ./test/functionalTest/mosquitto_conf_for_tests.conf:/mosquitto/config/mosquitto.conf - - ./test/functionalTest/mosquitto_passwd:/mosquitto/config/passwd - mosquitto-extra: # Needed by MQTT notification tests (multi broker) + #image: eclipse-mosquitto:2.0.11 image: eclipse-mosquitto:1.6.15 ports: - 1884:1883 @@ -61,6 +53,11 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config eclipse-mosquitto:2.0.11 + - name: Run functional test run: | docker run --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts functional diff --git a/scripts/check_files_compliance.py b/scripts/check_files_compliance.py index d14574cb39..0ccc974e21 100755 --- a/scripts/check_files_compliance.py +++ b/scripts/check_files_compliance.py @@ -138,7 +138,7 @@ def ignore(root, file): 'ContributionPolicy.txt', 'CHANGES_NEXT_RELEASE', 'Changelog', 'compileInfo.h', 'unittests_that_fail_sporadically.txt', 'Vagrantfile', 'contextBroker.ubuntu', 'mkdocs.yml', 'fiware-ngsiv2-reference.errata', 'ServiceRoutines.txt', '.readthedocs.yml', 'uncrustify.cfg', - 'requirements.txt'] + 'requirements.txt', 'mosquitto_passwd' ] if file in files_names: return True if 'scripts' in root and (file == 'cpplint.py' or file == 'pdi-pep8.py' or file == 'uncrustify.cfg' \ diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test index 45b8d25f08..b3880c7903 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test @@ -34,7 +34,7 @@ brokerStart CB 0 IPv4 -logSummary 5 # # This test requires a MQTT broker with authentication enabled. This may help: # -# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf # sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 # sudo chmod 640 /etc/mosquitto/passwd # sudo chown root:mosquitto /etc/mosquitto/passwd diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test index 886dc1f1f8..b1df0bf261 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test @@ -32,7 +32,7 @@ brokerStart CB 0 IPV4 # # This test requires a MQTT broker with authentication enabled. This may help: # -# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf # sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 # sudo chmod 640 /etc/mosquitto/passwd # sudo chown root:mosquitto /etc/mosquitto/passwd @@ -93,7 +93,6 @@ echo echo "03. Get sub and see timesSent:1, failsCounter:1 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -116,7 +115,6 @@ echo echo "05. Get sub and see timesSent:1, failsCounter:2 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -156,7 +154,6 @@ echo echo "08. Get sub and see timesSent:3, lastFailure (old) and lastSuccess but not failsCounter" echo "=======================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test index 763dea67d7..d2ee5a82f7 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test @@ -32,7 +32,7 @@ brokerStart CB 0 IPV4 -relogAlarms # # This test requires a MQTT broker with authentication enabled. This may help: # -# sudo cp /path/to/test/functionalTest/mosquitto_conf_for_tests.conf /etc/mosquitto/conf.d/local.conf +# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf # sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 # sudo chmod 640 /etc/mosquitto/passwd # sudo chown root:mosquitto /etc/mosquitto/passwd @@ -93,7 +93,6 @@ echo echo "03. Get sub and see timesSent:1, failsCounter:1 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -116,7 +115,6 @@ echo echo "05. Get sub and see timesSent:1, failsCounter:2 and lastFailure (but no lastSuccess)" echo "====================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo @@ -156,7 +154,6 @@ echo echo "08. Get sub and see timesSent:3, lastFailure (old) and lastSuccess but not failsCounter" echo "=======================================================================================" -sleep 1s orionCurl --url /v2/subscriptions echo echo diff --git a/test/functionalTest/mosquittoConf/mosquitto.conf b/test/functionalTest/mosquittoConf/mosquitto.conf new file mode 100644 index 0000000000..8fa29fb5c7 --- /dev/null +++ b/test/functionalTest/mosquittoConf/mosquitto.conf @@ -0,0 +1,24 @@ +# Copyright 2025 Telefonica Investigacion y Desarrollo, S.A.U +# +# This file is part of Orion Context Broker. +# +# Orion Context Broker is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Orion Context Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Orion Context Broker. If not, see http://www.gnu.org/licenses/. +# +# For those usages not covered by this license please contact with +# iot_support at tid dot es + + +password_file /mosquitto/config/mosquitto_passwd +allow_anonymous true +listener 1883 0.0.0.0 diff --git a/test/functionalTest/mosquitto_passwd b/test/functionalTest/mosquittoConf/mosquitto_passwd similarity index 100% rename from test/functionalTest/mosquitto_passwd rename to test/functionalTest/mosquittoConf/mosquitto_passwd diff --git a/test/functionalTest/mosquitto_conf_for_tests.conf b/test/functionalTest/mosquitto_conf_for_tests.conf deleted file mode 100644 index 430b996c59..0000000000 --- a/test/functionalTest/mosquitto_conf_for_tests.conf +++ /dev/null @@ -1,2 +0,0 @@ -password_file /etc/mosquitto/passwd -allow_anonymous true From cc39b31744935416febea0f093a42b87ccd3927a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 16 Jan 2025 20:47:11 +0100 Subject: [PATCH 3/6] FIX use extra MQTT broker as step instead action --- .github/workflows/functional.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 6c269ff167..d0c67da26a 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -27,12 +27,12 @@ jobs: ports: - 27017:27017 - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - #image: eclipse-mosquitto:2.0.11 - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 + #mosquitto-extra: + # # Needed by MQTT notification tests (multi broker) + # #image: eclipse-mosquitto:2.0.11 + # image: eclipse-mosquitto:1.6.15 + # ports: + # - 1884:1883 name: functional - ${{ matrix.payload.name }} @@ -56,7 +56,13 @@ jobs: - name: Run Mosquitto container with authenticated user # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) - run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config eclipse-mosquitto:2.0.11 + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 - name: Run functional test run: | From ddf53d5f914c367181fe43a08cfbfb59727083a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 16 Jan 2025 21:01:19 +0100 Subject: [PATCH 4/6] FIX mosquitto-extra docker in GitAction --- .github/workflows/codeql.yml | 4 ++-- .github/workflows/functional.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b1b93e849f..a0a1f80e32 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,9 +14,9 @@ name: "CodeQL Advanced" on: push: branches: [ "master" ] - pull_request: + pull_request: branches: [ "master" ] - schedule: + schedule: - cron: '33 5 * * 1' jobs: diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index d0c67da26a..f46576dbe8 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -62,7 +62,7 @@ jobs: # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) - run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 - name: Run functional test run: | From 817fb8b6260de667e7238e3a21a3457d191d9753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 16 Jan 2025 22:25:30 +0100 Subject: [PATCH 5/6] FIX valgrind GitActions --- .github/workflows/valgrind-nocache.yml | 23 +++++++++++------------ .github/workflows/valgrind.yml | 23 +++++++++++------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/valgrind-nocache.yml b/.github/workflows/valgrind-nocache.yml index e8ff06e31b..e7c7e4eb9c 100644 --- a/.github/workflows/valgrind-nocache.yml +++ b/.github/workflows/valgrind-nocache.yml @@ -29,18 +29,6 @@ jobs: image: mongo:6.0 ports: - 27017:27017 - - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 name: valgrind - ${{ matrix.payload.name }} @@ -56,6 +44,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + - name: Run valgrind test run: | docker run --privileged --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts valgrind diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 33010b755d..483a9d0c34 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -26,18 +26,6 @@ jobs: image: mongo:6.0 ports: - 27017:27017 - - mosquitto: - # Needed by MQTT notification tests - image: eclipse-mosquitto:1.6.15 - ports: - - 1883:1883 - - mosquitto-extra: - # Needed by MQTT notification tests (multi broker) - image: eclipse-mosquitto:1.6.15 - ports: - - 1884:1883 name: valgrind - ${{ matrix.payload.name }} @@ -53,6 +41,17 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Run Mosquitto container with authenticated user + # Why don't to use a service for this (as moquitto-extra above)? It would be the desirable solution, but I haven't able to + # configure volumes properly for it (the mosquitto container as service has problems to get the configuration files). Feedback welcome! :) + run: docker run -d --name mosquitto -p 1883:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + + - name: Run Extra Mosquitto container used in multibroker tests + # Note we are reusing the same volume (although the extra broker does not require authenticated user). We use a service in the past + # to implement this (using eclipse-mosquitto:1.6.15) but in eclipse-mosquitto:2.0.11 it seems something in the internal configuration + # has changed and it doesn't work if we don't provide the configuration files in the volume. Again, feedback is welcome! :) + run: docker run -d --name mosquitto-extra -p 1884:1883 -v $(pwd)/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 + - name: Run valgrind test run: | docker run --privileged --network host -t --rm -e REPO_ACCESS_TOKEN=${{ secrets.REPO_ACCESS_TOKEN }} ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts valgrind From 4cd89de8c90bdfd39be4de53f01c226e29a8fdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferm=C3=ADn=20Gal=C3=A1n=20M=C3=A1rquez?= Date: Thu, 16 Jan 2025 22:26:11 +0100 Subject: [PATCH 6/6] FIX cleanup --- .github/workflows/functional.yml | 7 ------- .../cases/3001_mqtt/mqtt_notification.test | 2 +- .../3001_mqtt/mqtt_notification_custom.test | 2 +- .../3001_mqtt/mqtt_notification_qos.test | 2 +- .../mqtt_subscription_multibroker.test | 4 ++-- .../cases/3001_mqtt/subscribe_and_update.test | 2 +- .../mqtt_alarms_log_summary.test | 7 +------ .../3001_mqtt_alarms/mqtt_alarms_none.test | 2 +- .../mqtt_alarms_raise_and_release.test | 7 +------ .../mqtt_alarms_raise_repeat_and_release.test | 7 +------ test/functionalTest/mosquittoConf/README.md | 21 +++++++++++++++++++ .../mosquittoConf/mosquitto.conf | 1 - 12 files changed, 31 insertions(+), 33 deletions(-) create mode 100644 test/functionalTest/mosquittoConf/README.md diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index f46576dbe8..390188b167 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -27,13 +27,6 @@ jobs: ports: - 27017:27017 - #mosquitto-extra: - # # Needed by MQTT notification tests (multi broker) - # #image: eclipse-mosquitto:2.0.11 - # image: eclipse-mosquitto:1.6.15 - # ports: - # - 1884:1883 - name: functional - ${{ matrix.payload.name }} strategy: diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification.test index 8e60fee1e6..52377cd61e 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub for entity E with topic sub1 # 02. Create MQTT sub for entity E with topic sub2 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test index ecc29badba..844c37c5be 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification_custom.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT custom sub for entity E with topic sub/{$id} payload A:{$A} # 02. Create entity E1 with A=1 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test b/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test index a0adbcf1f6..4316fc7cc8 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_notification_qos.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub for entity E with topic sub0 and qos=0 # 02. Create MQTT sub for entity E with topic sub1 and qos=1 diff --git a/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test b/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test index a63f157e54..f8ca62e270 100644 --- a/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test +++ b/test/functionalTest/cases/3001_mqtt/mqtt_subscription_multibroker.test @@ -35,8 +35,8 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT brokers needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 -# docker run -d -p 1884:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 +# docker run -d -p 1884:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub1 at localhost:1883 (1) # 02. Create MQTT sub2 at localhost:1883 (2) diff --git a/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test b/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test index 979feb7bdf..72f4863cf0 100644 --- a/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test +++ b/test/functionalTest/cases/3001_mqtt/subscribe_and_update.test @@ -35,7 +35,7 @@ accumulatorStart --pretty-print --mqttHost ${MQTT_HOST} --mqttPort ${MQTT_PORT} # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. POST /v2/entities, creating E1/T1 # 02. Subscribe to E1 on condition A2 diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test index b3880c7903..d172a45782 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_log_summary.test @@ -32,12 +32,7 @@ brokerStart CB 0 IPv4 -logSummary 5 --SHELL-- # -# This test requires a MQTT broker with authentication enabled. This may help: -# -# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf -# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 -# sudo chmod 640 /etc/mosquitto/passwd -# sudo chown root:mosquitto /etc/mosquitto/passwd +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Sleep 6 and see 0-0 raised and 0-0 released # 02. Create MQTT sub with wrong user/pass diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test index 35ee20c7c3..6d25daaf1a 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_none.test @@ -32,7 +32,7 @@ brokerStart CB 0 IPV4 # # Hint: use this to run the MQTT broker needed for this .test: # -# docker run -d -p 1883:1883 eclipse-mosquitto:1.6.7 +# docker run -d -p 1883:1883 -v /path/to/repo/test/functionalTest/mosquittoConf:/mosquitto/config:ro eclipse-mosquitto:2.0.11 # # 01. Create MQTT sub with right enpdoint (localhost:1883) # 02. Upsert three times to trigger three MQTT notifications diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test index b1df0bf261..8108b226cc 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_and_release.test @@ -30,12 +30,7 @@ brokerStart CB 0 IPV4 --SHELL-- # -# This test requires a MQTT broker with authentication enabled. This may help: -# -# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf -# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 -# sudo chmod 640 /etc/mosquitto/passwd -# sudo chown root:mosquitto /etc/mosquitto/passwd +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm diff --git a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test index d2ee5a82f7..8e077ed571 100644 --- a/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test +++ b/test/functionalTest/cases/3001_mqtt_alarms/mqtt_alarms_raise_repeat_and_release.test @@ -30,12 +30,7 @@ brokerStart CB 0 IPV4 -relogAlarms --SHELL-- # -# This test requires a MQTT broker with authentication enabled. This may help: -# -# sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf -# sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 -# sudo chmod 640 /etc/mosquitto/passwd -# sudo chown root:mosquitto /etc/mosquitto/passwd +# This test requires a MQTT broker with authentication enabled. See test/functionalTest/mosquittoConf/README.md # # 01. Create MQTT sub with wrong user/pass # 02. Upsert to trigger first MQTT notification, which fails and raises alarm diff --git a/test/functionalTest/mosquittoConf/README.md b/test/functionalTest/mosquittoConf/README.md new file mode 100644 index 0000000000..9b4c01410c --- /dev/null +++ b/test/functionalTest/mosquittoConf/README.md @@ -0,0 +1,21 @@ +This directory contains some configuration files, to be used (mounting a volume) by mosquitto docker containers. See functional.yml (and some other GitActions) for an example on how they are used. + +The `mosquitto_passwd` file containts a harmless credential: `user1` with password `xxxx`, used in `cases/3001_mqtt_alarms` tests. The password file works for mosquitto 2.0 version but other versions (specifically, 1.6) could not recognize its format. + +This files can be also being used in a local mosquitto instance. For instance + +``` +$ sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto.conf /etc/mosquitto/conf.d/local.conf +$ # edit the /etc/mosquitto/conf.d/local.conf file to change the password_file location to /etc/mosquitto/passwd +$ sudo cp /path/to/repo/test/functionalTest/mosquittoConf/mosquitto_passwd /etc/mosquitto/passwd +$ sudo chmod 640 /etc/mosquitto/passwd +$ sudo chown root:mosquitto /etc/mosquitto/passwd +``` + +Alternativelly you can add users to password file using a command like this one: + +``` +$ sudo mosquitto_passwd -c /etc/mosquitto/passwd user1 +``` + + diff --git a/test/functionalTest/mosquittoConf/mosquitto.conf b/test/functionalTest/mosquittoConf/mosquitto.conf index 8fa29fb5c7..9d5d46d789 100644 --- a/test/functionalTest/mosquittoConf/mosquitto.conf +++ b/test/functionalTest/mosquittoConf/mosquitto.conf @@ -18,7 +18,6 @@ # For those usages not covered by this license please contact with # iot_support at tid dot es - password_file /mosquitto/config/mosquitto_passwd allow_anonymous true listener 1883 0.0.0.0