-
Notifications
You must be signed in to change notification settings - Fork 55
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
Create tasks that will follow the Documentation instructions #2878
base: main
Are you sure you want to change the base?
Changes from 16 commits
288b37e
8b4b54d
cfc3ad7
352de23
30eea5e
8ac3cd0
b08fee4
1f665ab
153ae2f
1b762da
1023435
a9955bc
b030341
b5e9894
2ad3f3f
397ab9a
8f5c79f
744ec70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -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 | ||||||
#Not verifiing this test step because the test running in container already exists: 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 | ||||||
#Not verifiing this test step because the test running in container already exists: tests/RobotFramework/tests/installation/install_on_linux.robot | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
#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 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,201 @@ | ||||||
*** 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 | ||||||
|
||||||
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 | ||||||
Send Combined Measurement | ||||||
Verify Combined Measurement In Cumulocity | ||||||
|
||||||
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! | ||||||
reubenmiller marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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 | ||||||
Device Should Have Measurements type=environment minimum=1 maximum=1 | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would make more sense to make this a Keyword (function) that takes an argument for the type, then you can reuse it for the other measurements.
Then the usage is just:
|
||||||
Verify Combined Measurement In Cumulocity | ||||||
[Documentation] Verify the combined measurement in Cumulocity. | ||||||
# Add implementation for checking the combined measurement in Cumulocity | ||||||
Log Verified combined measurement in Cumulocity | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now you can use the same |
||||||
|
||||||
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 *.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 /home/pi/ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't be using
Suggested change
|
||||||
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 /home/pi/ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't be using
Suggested change
|
||||||
Log Transferred ARMv7l packages to device | ||||||
|
||||||
# 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 | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be deleted |
||||||
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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though there are other places which also use the |
||||||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.