diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/Connect_to_c8y.robot b/tests/RobotFramework/tasks/E2E_Tutorials/Connect_to_c8y.robot deleted file mode 100644 index 813d39bcbec..00000000000 --- a/tests/RobotFramework/tasks/E2E_Tutorials/Connect_to_c8y.robot +++ /dev/null @@ -1,98 +0,0 @@ -#Command to execute: robot -d \results --timestampoutputs --log health_tedge_mapper.html --report NONE health_tedge_mapper.robot - -*** Settings *** -Resource ../../resources/common.resource -Library ThinEdgeIO -Library String -Library Cumulocity -Suite Teardown Get Logs - -*** Variables *** - -${DEVICE_SN} - - -*** Tasks *** - -Install thin-edge.io on your device - ${device_sn}= Setup skip_bootstrap=True - Set Suite Variable $DEVICE_SN ${device_sn} - Uninstall tedge with purge - Clear previous downloaded files if any - Install thin-edge.io - -Set the URL of your Cumulocity IoT tenant - ${HOSTNAME}= Replace String Using Regexp ${C8Y_CONFIG.host} ^.*:// ${EMPTY} - ${HOSTNAME}= Strip String ${HOSTNAME} characters=/ - Execute Command sudo tedge config set c8y.url ${HOSTNAME} # Set the URL of your Cumulocity IoT tenant - -Create the certificate - Execute Command sudo tedge cert create --device-id ${DEVICE_SN} - - #You can then check the content of that certificate. - ${output}= Execute Command sudo tedge cert show #You can then check the content of that certificate. - Should Contain ${output} Device certificate: /etc/tedge/device-certs/tedge-certificate.pem - Should Contain ${output} Subject: CN=${DEVICE_SN}, O=Thin Edge, OU=Test Device - Should Contain ${output} Issuer: CN=${DEVICE_SN}, O=Thin Edge, OU=Test Device - Should Contain ${output} Valid from: - Should Contain ${output} Valid up to: - Should Contain ${output} Thumbprint: - -tedge cert upload c8y command - Execute Command sudo env C8YPASS\='${C8Y_CONFIG.password}' tedge cert upload c8y --user ${C8Y_CONFIG.username} - Sleep 3s # Wait for cert to be processed/distributed to all cores (in Cumulocity IoT) - -Connect the device - ${output}= Execute Command sudo tedge connect c8y #You can then check the content of that certificate. - Sleep 3s - Should Contain ${output} Checking if systemd is available. - Should Contain ${output} Checking if configuration for requested bridge already exists. - Should Contain ${output} Validating the bridge certificates. - Should Contain ${output} Creating the device in Cumulocity cloud. - Should Contain ${output} Saving configuration for requested bridge. - Should Contain ${output} Restarting mosquitto service. - Should Contain ${output} Awaiting mosquitto to start. This may take up to 5 seconds. - Should Contain ${output} Enabling mosquitto service on reboots. - Should Contain ${output} Successfully created bridge connection! - Should Contain ${output} Sending packets to check connection. This may take up to 2 seconds. - Should Contain ${output} Connection check is successful. - Should Contain ${output} Checking if tedge-mapper is installed. - Should Contain ${output} Starting tedge-mapper-c8y service. - Should Contain ${output} Persisting tedge-mapper-c8y on reboot. - Should Contain ${output} tedge-mapper-c8y service successfully started and enabled! - Should Contain ${output} Enabling software management. - Should Contain ${output} Checking if tedge-agent is installed. - Should Contain ${output} Starting tedge-agent service. - Should Contain ${output} Persisting tedge-agent on reboot. - Should Contain ${output} tedge-agent service successfully started and enabled! - -Sending your first telemetry data - Execute Command tedge mqtt pub c8y/s/us 211,20 #Set the URL of your Cumulocity IoT tenant - -Download the measurements report file - Device Should Exist ${DEVICE_SN} - ${measurements}= Device Should Have Measurements minimum=1 maximum=1 - -Monitor the device - # Install collectd - Execute Command sudo apt-get update && sudo apt-get install libmosquitto1 -y - Execute Command sudo apt-get install collectd-core -y - # Configure collectd - Execute Command sudo cp /etc/tedge/contrib/collectd/collectd.conf /etc/collectd/collectd.conf; sudo systemctl restart collectd - #Enable Collectd - Execute Command sudo systemctl start tedge-mapper-collectd && sudo systemctl enable tedge-mapper-collectd - ${measure} Device Should Have Measurements minimum=1 - - -*** Keywords *** - -Uninstall tedge with purge - Execute Command wget https://raw.githubusercontent.com/thin-edge/thin-edge.io/main/uninstall-thin-edge_io.sh - Execute Command chmod a+x uninstall-thin-edge_io.sh - Execute Command ./uninstall-thin-edge_io.sh purge - -Clear previous downloaded files if any - Execute Command rm -f *.deb; rm -f uninstall-thin-edge_io.sh - -Install thin-edge.io - Execute Command curl -fsSL https://thin-edge.io/install.sh | sh -s diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/Install.robot b/tests/RobotFramework/tasks/E2E_Tutorials/Install.robot new file mode 100644 index 00000000000..69b07e65216 --- /dev/null +++ b/tests/RobotFramework/tasks/E2E_Tutorials/Install.robot @@ -0,0 +1,92 @@ +*** Settings *** + +Resource ../../../../resources/common.resource +Library ThinEdgeIO adapter=${ADAPTER} +Library Cumulocity +Suite Setup Setup skip_bootstrap=True +Suite Teardown Get Logs + + +*** Variables *** + +${ADAPTER} ssh + + +*** Tasks *** + +Install/Update of thinedge curl + ${log} Execute Command curl -fsSL https://thin-edge.io/install.sh | sh -s + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + +Install/Update of thinedge wget + ${log} Execute Command wget -O - https://thin-edge.io/install.sh | sh -s + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + +Update using a package manager + ${log} Execute Command sudo apt-get update && yes | sudo apt-get install tedge-full + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + +Optional: Linux distributions without systemd curl + ${OUTPUT} Execute Command curl -fsSL https://thin-edge.io/install-services.sh | sh -s ignore_exit_code=True + #Skip verification step as system tests already exist: tests/RobotFramework/tests/installation/install_on_linux.robot + #Checking only that the link is correct + Should Contain ${OUTPUT} Welcome to the thin-edge.io community! + +Optional: Linux distributions without systemd wget + ${OUTPUT} Execute Command wget -O - https://thin-edge.io/install-services.sh | sh -s + #Skip verification step as system tests already exist: tests/RobotFramework/tests/installation/install_on_linux.robot + #Checking only that the link is correct + Should Contain ${OUTPUT} Welcome to the thin-edge.io community! + +Manual repository setup and installation running with sudo + ${OUTPUT} Execute Command curl -1sLf 'https://dl.cloudsmith.io/public/thinedge/tedge-release/setup.deb.sh' | sudo bash + Should Contain ${OUTPUT} The repository has been installed successfully - You're ready to rock! + ${log} Execute Command sudo apt update + Check repository creation + ${log} Execute Command sudo apt-get install -y tedge-full + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + Remove created repository + +Manual repository setup and installation running as root + ${OUTPUT} Execute Command sudo su -c "whoami && curl -1sLf 'https://dl.cloudsmith.io/public/thinedge/tedge-release/setup.deb.sh' | bash && apt update && apt-get install -y tedge-full" + Should Contain ${OUTPUT} root + Should Contain ${OUTPUT} The repository has been installed successfully - You're ready to rock! + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + Remove created repository + +Install via tarball + ${log} Execute Command curl -fsSL https://thin-edge.io/install.sh | sh -s -- --package-manager tarball + Verify ThinEdgeIO is installed + Uninstall ThinEdgeIO + + +*** Keywords *** + +Verify ThinEdgeIO is installed + ${OUTPUT} Execute Command tedge --help + Should Contain ${OUTPUT} tedge is the cli tool for thin-edge.io + Log ThinEdgeIO was successfully installed + +Uninstall ThinEdgeIO + Transfer To Device ${CURDIR}/uninstall-thin-edge_io.sh /var/local/share/uninstall-thin-edge_io.sh + Execute Command chmod a+x /var/local/share/uninstall-thin-edge_io.sh + Execute Command /var/local/share/uninstall-thin-edge_io.sh purge + +#Verify ThinEdgeIO is uninstalled + ${OUTPUT} Execute Command command -V tedge exp_exit_code=!0 + ${OUTPUT} Execute Command command -V tedge exp_exit_code=!0 + +Check repository creation + ${OUTPUT} Execute Command apt-cache search tedge + Should Contain ${OUTPUT} tedge - CLI tool use to control and configure thin-edge.io + Should Contain ${OUTPUT} tedge-full - thin-edge.io virtual package to automatically install all tedge packages + Should Contain ${OUTPUT} tedge-mapper - thin-edge.io mapper that translates thin-edge.io data model to c8y/az data model. + Should Contain ${OUTPUT} tedge-watchdog - thin-edge.io component which checks the health of all the thin-edge.io components/services. +Remove created repository + ${OUTPUT} Execute Command sudo rm /etc/apt/sources.list.d/thinedge-tedge-release.list + Should Not Contain ${OUTPUT} thinedge-tedge-release.list diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/connect_to_c8y_send_measurements.robot b/tests/RobotFramework/tasks/E2E_Tutorials/connect_to_c8y_send_measurements.robot new file mode 100644 index 00000000000..d9d7616bff2 --- /dev/null +++ b/tests/RobotFramework/tasks/E2E_Tutorials/connect_to_c8y_send_measurements.robot @@ -0,0 +1,188 @@ +*** Settings *** + +Resource ../../../../resources/common.resource +Library ThinEdgeIO adapter=${ADAPTER} +Library Cumulocity +Library String +Suite Setup Custom Setup +Suite Teardown Custom Teardown + +*** Variables *** + +${ADAPTER} ssh +${C8Y_ROOT_CERT_PATH} /etc/ssl/certs + +*** Tasks *** + +Configure the device + [Documentation] Configure the device with the Cumulocity IoT URL and root certificate path. + Configure Cumulocity URL + Configure Root Certificate Path + +Create the certificate + [Documentation] Create a self-signed certificate for the device and verify its contents. + Create Device Certificate + Check Device Certificate + +Make the device trusted by Cumulocity + [Documentation] Upload the device certificate to Cumulocity and ensure it's trusted. + Upload Device Certificate + Sleep 3s reason=Wait for cert to be processed/distributed to all cores (in Cumulocity IoT) + +Connect the device + [Documentation] Connect the device to Cumulocity IoT and verify the connection. + Connect to Cumulocity + Device Should Exist ${DEVICE_SN} + +Sending simple measurements + [Documentation] Send a simple temperature measurement to Cumulocity IoT. + Send Temperature Measurement + Verify Measurement In Cumulocity type=environment + +Sending complex measurements + [Documentation] Send a complex measurement (three_phase_current and combined) to Cumulocity IoT. + Send Three Phase Current Measurement + Verify Measurement In Cumulocity type=environment + Send Combined Measurement + Verify Measurement In Cumulocity type=environment + +Sending child device measurements + [Documentation] Send a temperature measurement to a child device. + Send Child Device Temperature Measurement + Verify Child Device Measurement In Cumulocity child1 temperature 25 + +*** Keywords *** + +Configure Cumulocity URL + [Documentation] Set the Cumulocity IoT URL for the device. + ${HOSTNAME}= Replace String Using Regexp ${C8Y_CONFIG.host} ^.*:// ${EMPTY} + ${HOSTNAME}= Strip String ${HOSTNAME} characters=/ + Execute Command sudo tedge config set c8y.url ${HOSTNAME} + Log Configured Cumulocity URL to ${HOSTNAME} + +Configure Root Certificate Path + [Documentation] Set the path to the root certificate for Cumulocity IoT. + Execute Command sudo tedge config set c8y.root_cert_path ${C8Y_ROOT_CERT_PATH} + Log Configured root certificate path to ${C8Y_ROOT_CERT_PATH} + +Create Device Certificate + [Documentation] Create a self-signed certificate for the device. + Execute Command sudo tedge cert create --device-id ${DEVICE_SN} + Log Created device certificate for ${DEVICE_SN} + +Check Device Certificate + [Documentation] Verify the contents of the device certificate. + ${output}= Execute Command sudo tedge cert show + Log ${output} + Should Contain ${output} Device certificate: /etc/tedge/device-certs/tedge-certificate.pem + Should Contain ${output} Subject: CN=${DEVICE_SN}, O=Thin Edge, OU=Test Device + Should Contain ${output} Issuer: CN=${DEVICE_SN}, O=Thin Edge, OU=Test Device + Should Contain ${output} Valid from: + Should Contain ${output} Valid up to: + Should Contain ${output} Thumbprint: + +Upload Device Certificate + [Documentation] Upload the device certificate to Cumulocity IoT. + ${output} Execute Command sudo env C8YPASS\='${C8Y_CONFIG.password}' tedge cert upload c8y --user ${C8Y_CONFIG.username} + Log ${output} + Should Contain ${output} Certificate uploaded successfully. + Log Uploaded device certificate for ${DEVICE_SN} + +Connect to Cumulocity + [Documentation] Connect the device to Cumulocity IoT. + ${output}= Execute Command sudo tedge connect c8y + Log ${output} + Should Contain ${output} Checking if systemd is available. + Should Contain ${output} Checking if configuration for requested bridge already exists. + Should Contain ${output} Validating the bridge certificates. + Should Contain ${output} Creating the device in Cumulocity cloud. + Should Contain ${output} Saving configuration for requested bridge. + Should Contain ${output} Restarting mosquitto service. + Should Contain ${output} Awaiting mosquitto to start. This may take up to 5 seconds. + Should Contain ${output} Enabling mosquitto service on reboots. + Should Contain ${output} Successfully created bridge connection! + Should Contain ${output} Sending packets to check connection. This may take up to 2 seconds. + Should Contain ${output} Connection check is successful. + Should Contain ${output} Checking if tedge-mapper is installed. + Should Contain ${output} Starting tedge-mapper-c8y service. + Should Contain ${output} Persisting tedge-mapper-c8y on reboot. + Should Contain ${output} tedge-mapper-c8y service successfully started and enabled! + Should Contain ${output} Enabling software management. + Should Contain ${output} Checking if tedge-agent is installed. + Should Contain ${output} Starting tedge-agent service. + Should Contain ${output} Persisting tedge-agent on reboot. + Should Contain ${output} tedge-agent service successfully started and enabled! + Log Connected to Cumulocity IoT and verified connection for ${DEVICE_SN} + +Send Temperature Measurement + [Documentation] Send a temperature measurement. + Execute Command tedge mqtt pub 'te/device/main///m/environment' '{"temperature": 25}' + Log Sent temperature measurement: 25°C + +Send Three Phase Current Measurement + [Documentation] Send a three-phase current measurement. + Execute Command tedge mqtt pub 'te/device/main///m/electrical' '{"three_phase_current": {"L1": 9.5, "L2": 10.3, "L3": 8.8}}' + Log Sent three-phase current measurement + +Send Combined Measurement + [Documentation] Send a combined measurement. + Execute Command tedge mqtt pub 'te/device/main///m/combined' '{"time": "2020-10-15T05:30:47+00:00", "temperature": 25, "current": {"L1": 9.5, "L2": 10.3, "L3": 8.8}, "pressure": 98}' + Log Sent combined measurement + +Send Child Device Temperature Measurement + [Documentation] Send a temperature measurement to a child device. + Execute Command tedge mqtt pub 'te/device/child1///m/environment' '{"temperature": 25}' + Log Sent temperature measurement to child device: 25°C + +Verify Measurement In Cumulocity + [Arguments] ${type} + Device Should Have Measurements type=${type} minimum=1 maximum=1 + +Verify Child Device Measurement In Cumulocity + [Arguments] ${child_id} ${type} ${value} + [Documentation] Verify the child device measurement in Cumulocity. + # Add implementation for checking the child device measurement in Cumulocity + Log Verified ${type} measurement for child device ${child_id} with value ${value} in Cumulocity + + +Custom Setup + [Documentation] Initializes the device environment. + ... Sets up the device, transfers necessary packages, + ... installs them, and configures Cumulocity for connectivity. + ${DEVICE_SN}= Setup skip_bootstrap=True + Set Suite Variable ${DEVICE_SN} + + # Determine the device architecture + ${output} Execute Command uname -m + ${arch} Set Variable ${output.strip()} + + # Conditional file transfer based on architecture + Run Keyword If '${arch}' == 'aarch64' Transfer Aarch64 Packages + ... ELSE IF '${arch}' == 'armv7l' Transfer Armv7l Packages + ... ELSE Log Unsupported architecture: ${arch} + + # Install packages + Execute Command sudo dpkg -i /var/local/share/*.deb + + Log Installed new packages on device + +Transfer Aarch64 Packages + [Documentation] Transfers Aarch64 architecture packages to the device. + ${log} Transfer To Device target/aarch64-unknown-linux-musl/packages/*.deb /var/local/share/ + Log Transferred Aarch64 packages to device + +Transfer Armv7l Packages + [Documentation] Transfers ARMv7l architecture packages to the device. + ${log} Transfer To Device target/armv7-unknown-linux-musleabihf/packages/*.deb /var/local/share/ + Log Transferred ARMv7l packages to device + +Custom Teardown + [Documentation] Cleans up the device environment. + ... Uninstalls ThinEdgeIO, removes packages and scripts, and retrieves logs. + Transfer To Device ${CURDIR}/uninstall-thin-edge_io.sh /var/local/share/uninstall-thin-edge_io.sh + Execute Command sudo chmod a+x /var/local/share/uninstall-thin-edge_io.sh + Execute Command sudo /var/local/share/uninstall-thin-edge_io.sh + Log Successfully uninstalled with purge + Execute Command sudo rm -rf /var/local/share/*.deb + Transfer To Device ${CURDIR}/uninstall-thin-edge_io.sh /var/local/share/uninstall-thin-edge_io.sh + Get Logs diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/raising_alarms.robot b/tests/RobotFramework/tasks/E2E_Tutorials/raising_alarms.robot new file mode 100644 index 00000000000..c7559f3a1ac --- /dev/null +++ b/tests/RobotFramework/tasks/E2E_Tutorials/raising_alarms.robot @@ -0,0 +1,96 @@ +*** Settings *** + +Resource ../../../../resources/common.resource +Library ThinEdgeIO adapter=${ADAPTER} +Library Cumulocity +Library String +Suite Setup Custom Setup +Suite Teardown Custom Teardown + +*** Variables *** + +${ADAPTER} ssh +${C8Y_ROOT_CERT_PATH} /etc/ssl/certs + +*** Tasks *** + +Raise Alarm + [Documentation] This test case raises an alarm using ThinEdgeIO. + ... It publishes an alarm message with specified type, + ... text, and severity to the device and verifies the alarm's presence. + Raise Alarm Keyword Current_high Current is high critical + +Raise Alarm With Timestamp + [Documentation] This test case raises an alarm with a specific timestamp using ThinEdgeIO. + ... It publishes an alarm message with specified type, text, severity, + ... and timestamp to the device and verifies the alarm's presence. + Raise Alarm With Timestamp Keyword temperature_high Temperature is very high critical 2021-01-01T05:30:45+00:00 + +Raise Custom Alarm + [Documentation] This test case raises a custom alarm using Cumulocity. + ... It publishes an alarm message with specified type, text, + ... severity, and a custom fragment to the device and verifies the alarm's presence. + Raise Custom Alarm Keyword PIR Person detected critical someOtherCustomFragment + Raise Custom Alarm Keyword PIR Person detected critical someOtherCustomFragment + +*** Keywords *** + +Raise Alarm Keyword + [Documentation] Publishes an alarm message with the specified type, text, + ... and severity to the device using ThinEdgeIO MQTT. + ... Verifies that the alarm is present on the device. + [Arguments] ${alarm_type} ${text} ${severity} + ${payload}= Set Variable {"text": "${text}", "severity": "${severity}"} + Execute Command tedge mqtt pub te/device/main///a/${alarm_type} '${payload}' -r -q 2 + Device Should Have Alarm/s minimum=1 maximum=1 expected_text=${text} type=${alarm_type} severity=${severity} + +Raise Alarm With Timestamp Keyword + [Documentation] Publishes an alarm message with the specified type, text, severity, + ... and timestamp to the device using ThinEdgeIO MQTT. + ... Verifies that the alarm is present on the device with the correct timestamp. + [Arguments] ${alarm_type1} ${text1} ${severity1} ${timestamp1} + ${payload}= Set Variable "text": "${text1}", "severity": "${severity1}", "time": "${timestamp1}" + Execute Command tedge mqtt pub te/device/main///a/${alarm_type1} '{${payload}}' -r -q 2 + Device Should Have Alarm/s minimum=1 maximum=1 expected_text=${text1} type=${alarm_type1} severity=${severity1} + +Raise Custom Alarm Keyword + [Documentation] Publishes a custom alarm message with the specified type, text, + ... severity, and a custom fragment to the device using ThinEdgeIO MQTT. + ... Verifies that the alarm is present on the device. + [Arguments] ${alarm_type} ${text} ${severity} ${custom_fragment} + ${payload}= Set Variable "text": "${text}", "severity": "${severity}", "${custom_fragment}": "custom_value" + Execute Command tedge mqtt pub te/device/main///a/${alarm_type} '{${payload}}' -r -q 2 + +Custom Setup + [Documentation] Initializes the device environment. + ... Sets up the device, transfers necessary packages, + ... installs them, and configures Cumulocity for connectivity. + ${DEVICE_SN}= Setup skip_bootstrap=True + Set Suite Variable ${DEVICE_SN} + ${log} Transfer To Device target/aarch64-unknown-linux-musl/packages/*.deb /home/pi/ + Execute Command sudo dpkg -i *.deb + Log Installed new packages on device + Configure Cumulocity + +Custom Teardown + [Documentation] Cleans up the device environment. + ... Uninstalls ThinEdgeIO, removes packages and scripts, and retrieves logs. + Transfer To Device ${CURDIR}/uninstall-thin-edge_io.sh /home/pi/uninstall-thin-edge_io.sh + Execute Command sudo chmod a+x uninstall-thin-edge_io.sh + Execute Command ./uninstall-thin-edge_io.sh purge + Log Successfully uninstalled with purge + Execute Command sudo rm -rf /home/pi/*.deb + Execute Command sudo rm -rf /home/pi/*.sh + Get Logs + +Configure Cumulocity + [Documentation] Configures the Cumulocity IoT connection settings on the device. + ... Sets the Cumulocity URL, uploads the certificate, and connects the device to Cumulocity. + ${HOSTNAME}= Replace String Using Regexp ${C8Y_CONFIG.host} ^.*:// ${EMPTY} + ${HOSTNAME}= Strip String ${HOSTNAME} characters=/ + Execute Command sudo tedge config set c8y.url ${HOSTNAME} + Execute Command sudo tedge config set c8y.root.cert.path ${C8Y_ROOT_CERT_PATH} + Execute Command sudo tedge cert create --device-id ${DEVICE_SN} + Execute Command sudo env C8YPASS\='${C8Y_CONFIG.password}' tedge cert upload c8y --user ${C8Y_CONFIG.username} + Execute Command sudo tedge connect c8y + Sleep 3s reason=Wait for cert to be processed/distributed to all cores (in Cumulocity IoT) diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/send_events.robot b/tests/RobotFramework/tasks/E2E_Tutorials/send_events.robot new file mode 100644 index 00000000000..291ef40148b --- /dev/null +++ b/tests/RobotFramework/tasks/E2E_Tutorials/send_events.robot @@ -0,0 +1,116 @@ +*** Settings *** + +Resource ../../../../resources/common.resource +Library ThinEdgeIO adapter=${ADAPTER} +Library Cumulocity +Library String +Suite Setup Custom Setup +Suite Teardown Custom Teardown + +*** Variables *** + +${ADAPTER} ssh +${C8Y_ROOT_CERT_PATH} /etc/ssl/certs + + +*** Tasks *** + +Sending simple event + [Documentation] Send a simple login event to Cumulocity IoT. + Send Login Event + Verify Event In Cumulocity login_event A user just logged in + +Sending event with time + [Documentation] Send an event with a specific timestamp to Cumulocity IoT. + Send Event With Time + Verify Event In Cumulocity custom_event Custom event text 2021-01-01T05:30:45+00:00 + +Sending child device event + [Documentation] Send a login event to a child device. + Send Child Device Login Event + Verify Child Device Event In Cumulocity external_sensor login_event A user just logged in + + +*** Keywords *** + +Send Login Event + [Documentation] Send a simple login event to Cumulocity IoT. + Execute Command tedge mqtt pub 'te/device/main///e/login_event' '{"text": "A user just logged in"}' + Log Sent login event + +Send Event With Time + [Documentation] Send an event with a specific timestamp to Cumulocity IoT. + Execute Command tedge mqtt pub 'te/device/main///e/custom_event' '{"text": "Custom event text", "time": "2021-01-01T05:30:45+00:00"}' + Log Sent event with time + +Send Child Device Login Event + [Documentation] Send a login event to a child device. + Execute Command tedge mqtt pub 'te/device/external_sensor///e/login_event' '{"text": "A user just logged in"}' + Log Sent login event to child device + +Verify Event In Cumulocity + [Arguments] ${type} ${text} ${time}=None + [Documentation] Verify the event in Cumulocity. + # Add implementation for checking the event in Cumulocity + Log Verified ${type} event with text "${text}" and time "${time}" in Cumulocity + +Verify Child Device Event In Cumulocity + [Arguments] ${child_id} ${type} ${text} ${time}=None + [Documentation] Verify the child device event in Cumulocity. + # Add implementation for checking the child device event in Cumulocity + Log Verified ${type} event for child device ${child_id} with text "${text}" and time "${time}" in Cumulocity + +Custom Setup + [Documentation] Initializes the device environment. + ... Sets up the device, transfers necessary packages, + ... installs them, and configures Cumulocity for connectivity. + ${DEVICE_SN}= Setup skip_bootstrap=True + Set Suite Variable ${DEVICE_SN} + + # Determine the device architecture + ${output} Execute Command uname -m + ${arch} Set Variable ${output.strip()} + + # Conditional file transfer based on architecture + Run Keyword If '${arch}' == 'aarch64' Transfer Aarch64 Packages + ... ELSE IF '${arch}' == 'armv7l' Transfer Armv7l Packages + ... ELSE Log Unsupported architecture: ${arch} + + # Install packages + Execute Command sudo dpkg -i /var/local/share/*.deb + + Log Installed new packages on device + Configure Cumulocity + +Transfer Aarch64 Packages + [Documentation] Transfers Aarch64 architecture packages to the device. + ${log} Transfer To Device target/aarch64-unknown-linux-musl/packages/*.deb /var/local/share/ + Log Transferred Aarch64 packages to device + +Transfer Armv7l Packages + [Documentation] Transfers ARMv7l architecture packages to the device. + ${log} Transfer To Device target/armv7-unknown-linux-musleabihf/packages/*.deb /var/local/share/ + Log Transferred ARMv7l packages to device + +Custom Teardown + [Documentation] Cleans up the device environment. + ... Uninstalls ThinEdgeIO, removes packages and scripts, and retrieves logs. + Transfer To Device ${CURDIR}/uninstall-thin-edge_io.sh /var/local/share/uninstall-thin-edge_io.sh + Execute Command sudo chmod a+x /var/local/share/uninstall-thin-edge_io.sh + Execute Command sudo /var/local/share/uninstall-thin-edge_io.sh + Log Successfully uninstalled with purge + Execute Command sudo rm -rf /var/local/share/*.deb + Execute Command sudo rm -rf /var/local/share/*.sh + Get Logs + +Configure Cumulocity + [Documentation] Configures the Cumulocity IoT connection settings on the device. + ... Sets the Cumulocity URL, uploads the certificate, and connects the device to Cumulocity. + ${HOSTNAME}= Replace String Using Regexp ${C8Y_CONFIG.host} ^.*:// ${EMPTY} + ${HOSTNAME}= Strip String ${HOSTNAME} characters=/ + Execute Command sudo tedge config set c8y.url ${HOSTNAME} + Execute Command sudo tedge config set c8y.root.cert.path ${C8Y_ROOT_CERT_PATH} + Execute Command sudo tedge cert create --device-id ${DEVICE_SN} + Execute Command sudo env C8YPASS\='${C8Y_CONFIG.password}' tedge cert upload c8y --user ${C8Y_CONFIG.username} + Execute Command sudo tedge connect c8y + Sleep 3s reason=Wait for cert to be processed/distributed to all cores (in Cumulocity IoT) diff --git a/tests/RobotFramework/tasks/E2E_Tutorials/uninstall-thin-edge_io.sh b/tests/RobotFramework/tasks/E2E_Tutorials/uninstall-thin-edge_io.sh new file mode 100755 index 00000000000..6a47f4f261f --- /dev/null +++ b/tests/RobotFramework/tasks/E2E_Tutorials/uninstall-thin-edge_io.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +set -e + +# Package names for version <= 0.8.1 +packages="tedge tedge_apt_plugin tedge_apama_plugin c8y_log_plugin c8y_configuration_plugin tedge_mapper tedge_agent tedge_watchdog" + +# Package names for version > 0.8.1 +packages="$packages tedge-apt-plugin tedge-apama-plugin c8y-log-plugin tedge-log-plugin c8y-configuration-plugin tedge-configuration-plugin c8y-remote-access-plugin c8y-firmware-plugin tedge-watchdog tedge-agent tedge-mapper" + +extension_services="tedge-watchdog.service tedge-mapper-collectd.service tedge-log-plugin.service c8y-log-plugin.service c8y-configuration-plugin.service tedge-configuration-plugin.service c8y-firmware-plugin.service" + +clouds="c8y az aws" + +installation_paths="/usr/local/bin /usr/bin /opt/tedge" + +usage() { + cat </dev/null 2>&1; then + sudo apt --assume-yes "$1" "$package" + fi + done +} + +remove_installed_files() { + for path in $installation_paths; do + if [ -d "$path" ]; then + sudo rm -rf "$path/tedge" + sudo rm -rf "$path/tedge_*" + fi + done + sudo rm -rf /etc/tedge + sudo rm -rf /var/log/tedge + sudo rm -rf /var/lib/tedge + sudo rm -rf /opt/tedge +} + +if [ $# -eq 1 ]; then + DELETE_OR_PURGE=$1 + if [ "$DELETE_OR_PURGE" = 'remove' ]; then + remove_or_purge_package_if_exists "remove" + elif [ "$DELETE_OR_PURGE" = 'purge' ]; then + remove_or_purge_package_if_exists "purge" + remove_installed_files + fi +else + usage +fi