-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): mqtt logger reads mqtt host via tedge
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
- Loading branch information
1 parent
ff0152e
commit 37e29bb
Showing
3 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
*** Settings *** | ||
Resource ../../resources/common.resource | ||
Library ThinEdgeIO | ||
Library Cumulocity | ||
|
||
Test Tags theme:mqtt theme:c8y adapter:docker | ||
Suite Setup Custom Setup | ||
Suite Teardown Get Logs name=${CONTAINER_1} | ||
|
||
*** Variables *** | ||
${CONTAINER_1} | ||
${CONTAINER_2} | ||
|
||
*** Test Cases *** | ||
Check remote mqtt broker #1773 | ||
[Documentation] The test relies on two containers functioning as one logical device. 1 container (CONTAINER_1) | ||
... runs the mqtt broker and the mapper, and the other container (CONTAINER_2) runs the other tedge components. | ||
... Together the two containers should function similar to installing everything in one container (more or less). | ||
... This is the building blocks for enabling a single-process container setup where each thin-edge.io component | ||
... is running in its own container. | ||
[Tags] \#1773 | ||
ThinEdgeIO.Set Device Context ${CONTAINER_1} | ||
ThinEdgeIO.Service Should Be Running mosquitto | ||
ThinEdgeIO.Service Should Be Running tedge-mapper-c8y | ||
ThinEdgeIO.Service Should Be Stopped tedge-agent | ||
ThinEdgeIO.Service Should Be Stopped c8y-configuration-plugin | ||
ThinEdgeIO.Service Should Be Stopped c8y-firmware-plugin | ||
ThinEdgeIO.Service Should Be Stopped c8y-log-plugin | ||
|
||
ThinEdgeIO.Set Device Context ${CONTAINER_2} | ||
ThinEdgeIO.Service Should Be Stopped mosquitto | ||
ThinEdgeIO.Service Should Be Stopped tedge-mapper-c8y | ||
ThinEdgeIO.Service Should Be Running tedge-agent | ||
ThinEdgeIO.Service Should Be Running c8y-configuration-plugin | ||
ThinEdgeIO.Service Should Be Running c8y-firmware-plugin | ||
ThinEdgeIO.Service Should Be Running c8y-log-plugin | ||
|
||
# Validate the device exists in the cloud | ||
Cumulocity.Device Should Exist ${CONTAINER_1} | ||
|
||
# Cumulocity sanity check | ||
ThinEdgeIO.Set Device Context ${CONTAINER_2} | ||
ThinEdgeIO.Execute Command tedge mqtt pub tedge/measurements '{"temperature": 29.8}' | ||
${measurements}= Cumulocity.Device Should Have Measurements value=temperature series=temperature | ||
Should Be Equal As Numbers ${measurements[0]["temperature"]["temperature"]["value"]} ${29.8} | ||
|
||
Cumulocity.Should Have Services name=tedge-mapper-c8y status=up | ||
Cumulocity.Should Have Services name=tedge-agent status=up | ||
Cumulocity.Should Have Services name=c8y-configuration-plugin status=up | ||
Cumulocity.Should Have Services name=c8y-firmware-plugin status=up | ||
Cumulocity.Should Have Services name=c8y-log-plugin status=up | ||
|
||
*** Keywords *** | ||
|
||
Custom Setup | ||
# Container 1 running mqtt host and mapper | ||
${CONTAINER_1}= Setup skip_bootstrap=${True} | ||
Execute Command ./bootstrap.sh --no-connect --bootstrap | ||
Set Suite Variable $CONTAINER_1 | ||
${CONTAINER_1_IP}= Get IP Address | ||
Disconnect Mapper c8y | ||
Execute Command sudo tedge config set mqtt.client.host ${CONTAINER_1_IP} | ||
Execute Command sudo tedge config set mqtt.client.port 1883 | ||
Execute Command sudo tedge config set mqtt.bind_address ${CONTAINER_1_IP} | ||
Connect Mapper c8y | ||
Restart Service mqtt-logger | ||
|
||
Stop Service tedge-agent | ||
Stop Service c8y-configuration-plugin | ||
Stop Service c8y-log-plugin | ||
Stop Service c8y-firmware-plugin | ||
|
||
# Copy files form one device to another | ||
${tedge_toml}= Execute Command cat /etc/tedge/tedge.toml | ||
${pem}= Execute Command cat "$(tedge config get device.cert.path)" | ||
|
||
# container 2 running all other services | ||
${CONTAINER_2}= Setup skip_bootstrap=${True} | ||
Execute Command ./bootstrap.sh --no-connect --no-bootstrap | ||
Set Suite Variable $CONTAINER_2 | ||
|
||
# Stop services that don't need to be running on the second device | ||
Stop Service mosquitto | ||
Stop Service tedge-mapper-c8y | ||
|
||
Execute Command echo "${tedge_toml}" | sudo tee /etc/tedge/tedge.toml | ||
Execute Command sudo tedge config set mqtt.client.host ${CONTAINER_1_IP} | ||
Execute Command sudo tedge config set mqtt.client.port 1883 | ||
Execute Command echo "${pem}" | sudo tee "$(tedge config get device.cert.path)" | ||
Restart Service c8y-firmware-plugin | ||
Restart Service c8y-log-plugin | ||
Restart Service c8y-configuration-plugin | ||
Restart Service tedge-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters