Skip to content

Commit

Permalink
Merge pull request #2774 from gligorisaev/deregister
Browse files Browse the repository at this point in the history
Add deregister test steps to register testcase
  • Loading branch information
reubenmiller authored Mar 20, 2024
2 parents 01f1cea + aed95ef commit 90fbf7f
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Resource ../../../resources/common.resource
Library Cumulocity
Library ThinEdgeIO

Test Tags theme:c8y theme:registration
Test Tags theme:c8y theme:registration theme:deregistration
Suite Setup Custom Setup
Test Setup Test Setup
Test Teardown Get Logs ${DEVICE_SN}
Expand All @@ -30,6 +30,18 @@ Child device registration
Cumulocity.Set Device ${DEVICE_SN}
Cumulocity.Should Be A Child Device Of Device ${CHILD_SN}

# Deregister Child device
Execute Command mosquitto_sub --remove-retained -W 3 -t "te/device/${CHILD_SN}/+/+/#" exp_exit_code=27

# Check if deregistration was successful
Sleep 1s reason=Allowing components to process messages
Should Have Retained Message Count te/device/${CHILD_SN}/+/+/# 0

# Checking if child device will be recreated after mapper restart
Restart Service tedge-mapper-c8y
Sleep 5s reason=Allowing startup to complete
Should Have Retained Message Count te/device/${CHILD_SN}/+/+/# 0

Register child device with defaults via MQTT
Execute Command tedge mqtt pub --retain 'te/device/${CHILD_SN}//' '{"@type":"child-device"}'
Check Child Device parent_sn=${DEVICE_SN} child_sn=${CHILD_XID} child_name=${CHILD_XID} child_type=thin-edge.io-child
Expand Down Expand Up @@ -73,6 +85,12 @@ Register service on a child device via MQTT
# Check service registration
Check Service child_sn=${CHILD_XID} service_sn=${CHILD_XID}:service:custom-app service_name=custom-app service_type=custom-type service_status=up

# Deregister service on a child device
Execute Command mosquitto_sub --remove-retained -W 3 -t 'te/device/${CHILD_SN}/service/custom-app/#' exp_exit_code=27

# Check if deregistration was successful
Sleep 1s reason=Allowing components to process messages
Should Have Retained Message Count te/device/${CHILD_SN}/service/custom-app/# 0

Register devices using custom MQTT schema
[Documentation] Complex example showing how to use custom MQTT topics to register devices/services using
Expand Down Expand Up @@ -234,6 +252,11 @@ Entities send to cloud on restart

*** Keywords ***

Should Have Retained Message Count
[Arguments] ${topic} ${exp_count}
${output}= Execute Command mosquitto_sub --retained-only -W 3 -t "${topic}" -v exp_exit_code=27 return_stdout=True
Length Should Be ${output.splitlines()} ${exp_count}

Re-enable auto-registration and collect logs
[Teardown] Get Logs ${DEVICE_SN}
Execute Command sudo tedge config unset c8y.entity_store.auto_register
Expand All @@ -251,7 +274,7 @@ Check Child Device
${child_mo}= Device Should Exist ${child_sn}

${child_mo}= Cumulocity.Device Should Have Fragment Values name\=${child_name}
Should Be Equal ${child_mo["owner"]} device_${DEVICE_SN} # The parent is the owner of the child
Should Be Equal ${child_mo["owner"]} device_${DEVICE_SN}
Should Be Equal ${child_mo["name"]} ${child_name}
Should Be Equal ${child_mo["type"]} ${child_type}

Expand Down

0 comments on commit 90fbf7f

Please sign in to comment.