From 4d9741de6d59d498e1300521407ccd3d1098b970 Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Thu, 17 Oct 2024 08:37:20 +0200 Subject: [PATCH 1/2] add system test to check offline publishing of telemetry data Signed-off-by: Reuben Miller --- .../tests/mqtt/offline_publishing.robot | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/RobotFramework/tests/mqtt/offline_publishing.robot diff --git a/tests/RobotFramework/tests/mqtt/offline_publishing.robot b/tests/RobotFramework/tests/mqtt/offline_publishing.robot new file mode 100644 index 0000000000..abfc80f3c7 --- /dev/null +++ b/tests/RobotFramework/tests/mqtt/offline_publishing.robot @@ -0,0 +1,24 @@ +*** Settings *** +Resource ../../resources/common.resource +Library ThinEdgeIO +Library Cumulocity + +Test Setup Setup Test +Test Teardown Get Logs + + +*** Test Cases *** +Publish event whilst mapper is down + [Documentation] The mapper should publish the event to the cloud when it comes back online + ${event_type}= Get Random Name + Stop Service tedge-mapper-c8y + Execute Command tedge mqtt pub -q 1 te/device/main///e/${event_type} '{"text":"test message"}' + Start Service tedge-mapper-c8y + Cumulocity.Device Should Have Event/s type=${event_type} expected_text=test message + + +*** Keywords *** +Setup Test + ${DEVICE_SN}= Setup + Set Suite Variable $DEVICE_SN + Device Should Exist ${DEVICE_SN} From cbb889f4722e3c59b4bf87634cb54aad48a817ad Mon Sep 17 00:00:00 2001 From: Reuben Miller Date: Thu, 17 Oct 2024 11:50:07 +0200 Subject: [PATCH 2/2] use mosquitto 2.0.11 in system tests Reverting back to mosquitto 2.0.11 due to a persistent session bug which affects thin-edge.io's ability to process any messages which are published locally whilst the mapper is down Signed-off-by: Reuben Miller --- .../debian-systemd/debian-systemd.dockerfile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/images/debian-systemd/debian-systemd.dockerfile b/tests/images/debian-systemd/debian-systemd.dockerfile index 7ce25a7d4c..4010a0cec5 100644 --- a/tests/images/debian-systemd/debian-systemd.dockerfile +++ b/tests/images/debian-systemd/debian-systemd.dockerfile @@ -20,17 +20,24 @@ RUN apt-get -y update \ net-tools \ # json tools (for tests) jq \ - jo + jo \ + # mosquitto (default version used by Debian, see below for more details) + mosquitto \ + mosquitto-clients +# Note: Avoid using mosquitto 2.0.18 due to a session persistence bug when using `per_listener_settings true +# Only comment out the custom install logic to make it easier to re-enable once the bug is resolved +# See https://github.com/thin-edge/thin-edge.io/issues/3185 for more details # Install more recent version of mosquitto >= 2.0.18 from debian backports to avoid mosquitto following bugs: # The mosquitto repo can't be used as it does not included builds for arm64/aarch64 (only amd64 and armhf) # * https://github.com/eclipse/mosquitto/issues/2604 (2.0.11) # * https://github.com/eclipse/mosquitto/issues/2634 (2.0.15) -RUN sh -c "echo 'deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian bookworm-backports main' > /etc/apt/sources.list.d/debian-bookworm-backports.list" \ - && apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install -t bookworm-backports \ - mosquitto \ - mosquitto-clients +# * https://github.com/eclipse/mosquitto/issues/2618 (2.0.18) +#RUN sh -c "echo 'deb [signed-by=/usr/share/keyrings/debian-archive-keyring.gpg] http://deb.debian.org/debian bookworm-backports main' > /etc/apt/sources.list.d/debian-bookworm-backports.list" \ +# && apt-get update \ +# && DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install -t bookworm-backports \ +# mosquitto \ +# mosquitto-clients # Remove unnecessary systemd services RUN rm -f /lib/systemd/system/multi-user.target.wants/* \