Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX 3001_mqtt_alarms removing dependency on external MQTT broker #4638

Merged
merged 6 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ jobs:
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: functional - ${{ matrix.payload.name }}

strategy:
Expand All @@ -58,6 +46,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 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
23 changes: 11 additions & 12 deletions .github/workflows/valgrind-nocache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
23 changes: 11 additions & 12 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
2 changes: 1 addition & 1 deletion scripts/check_files_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down
2 changes: 1 addition & 1 deletion test/functionalTest/cases/3001_mqtt/mqtt_notification.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ 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. 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
Expand Down Expand Up @@ -67,8 +66,8 @@ payload='{
},
"notification": {
"mqtt": {
"url": "mqtt://mqtt.flespi.io:1883",
"user": "user",
"url": "mqtt://localhost:1883",
"user": "user_noexist",
"passwd": "xxxx",
"topic": "sub1"
}
Expand Down Expand Up @@ -118,8 +117,8 @@ echo "========================================"
payload='{
"notification": {
"mqtt": {
"url": "mqtt://mqtt.flespi.io:1883",
"user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ",
"url": "mqtt://localhost:1883",
"user": "user1",
"passwd": "xxxx",
"topic": "sub1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ 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. 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
Expand All @@ -59,8 +56,8 @@ payload='{
},
"notification": {
"mqtt": {
"url": "mqtt://mqtt.flespi.io:1883",
"user": "user",
"url": "mqtt://localhost:1883",
"user": "user_noexist",
"passwd": "xxxx",
"topic": "sub1"
}
Expand Down Expand Up @@ -91,7 +88,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
Expand All @@ -114,7 +110,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
Expand All @@ -125,8 +120,8 @@ echo "========================================"
payload='{
"notification": {
"mqtt": {
"url": "mqtt://mqtt.flespi.io:1883",
"user": "SeY7oD5XPa1UENBiOLPHqWXmj4r4OZHu4tsgWn1AmTkQuMW6lCDCmqMvi1oURVfJ",
"url": "mqtt://localhost:1883",
"user": "user1",
"passwd": "xxxx",
"topic": "sub1"
}
Expand Down Expand Up @@ -154,7 +149,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
Expand Down Expand Up @@ -193,7 +187,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

[
{
Expand All @@ -210,8 +204,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
Expand Down Expand Up @@ -248,7 +242,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

[
{
Expand All @@ -265,8 +259,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
Expand Down Expand Up @@ -311,7 +305,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

[
{
Expand All @@ -328,8 +322,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
Expand All @@ -354,16 +348,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

Expand Down
Loading
Loading