|
| 1 | +*** Settings *** |
| 2 | +Resource ../resources/common.resource |
| 3 | +Library Cumulocity |
| 4 | +Library ThinEdgeIO |
| 5 | + |
| 6 | +Suite Setup Custom Setup |
| 7 | +Test Teardown Test Teardown |
| 8 | + |
| 9 | +Test Tags theme:cli theme:http theme:childdevices |
| 10 | + |
| 11 | + |
| 12 | +*** Test Cases *** |
| 13 | +Sanity check: No HTTP service on a child device |
| 14 | + Execute Command curl http://localhost:8000/tedge/entity-store/v1/entities exp_exit_code=7 |
| 15 | + |
| 16 | +Listing entities from a child device |
| 17 | + ${entities}= Execute Command tedge http get /tedge/entity-store/v1/entities |
| 18 | + Should Contain ${entities} device/main// |
| 19 | + Should Contain ${entities} device/${CHILD_SN}// |
| 20 | + |
| 21 | +Updating entities from a child device |
| 22 | + Execute Command |
| 23 | + ... tedge http post /tedge/entity-store/v1/entities '{"@topic-id": "device/${CHILD_SN}/service/watchdog", "@type": "service", "@parent": "device/${CHILD_SN}//"}' |
| 24 | + ${entity}= Execute Command tedge http get /tedge/entity-store/v1/entities/device/${CHILD_SN}/service/watchdog |
| 25 | + Should Contain ${entity} "@topic-id":"device/${CHILD_SN}/service/watchdog" |
| 26 | + Should Contain ${entity} "@parent":"device/${CHILD_SN}//" |
| 27 | + Should Contain ${entity} "@type":"service" |
| 28 | + Execute Command tedge http delete /tedge/entity-store/v1/entities/device/${CHILD_SN}/service/watchdog |
| 29 | + Execute Command |
| 30 | + ... tedge http get /tedge/entity-store/v1/entities/device/${CHILD_SN}/service/watchdog |
| 31 | + ... exp_exit_code=1 |
| 32 | + |
| 33 | +Accessing c8y from a child device |
| 34 | + ${external_id}= Execute Command |
| 35 | + ... tedge http get /c8y/identity/externalIds/c8y_Serial/${PARENT_SN} | jq .externalId |
| 36 | + Should Be Equal ${external_id} "${PARENT_SN}"\n |
| 37 | + |
| 38 | +Accessing file-transfer from a child device |
| 39 | + Execute Command printf "source file content" >/tmp/source-file.txt |
| 40 | + Execute Command tedge http put /tedge/file-transfer/target --file /tmp/source-file.txt --content-type text/plain |
| 41 | + ${content}= Execute Command tedge http get /tedge/file-transfer/target |
| 42 | + Should Be Equal ${content} source file content |
| 43 | + Execute Command tedge http delete /tedge/file-transfer/target |
| 44 | + Execute Command tedge http get /tedge/file-transfer/target exp_exit_code=1 |
| 45 | + |
| 46 | + |
| 47 | +*** Keywords *** |
| 48 | +Setup Child Device |
| 49 | + ThinEdgeIO.Set Device Context ${CHILD_SN} |
| 50 | + Execute Command sudo dpkg -i packages/tedge_*.deb |
| 51 | + |
| 52 | + Execute Command sudo tedge config set http.client.host ${PARENT_IP} |
| 53 | + Execute Command sudo tedge config set http.client.port 8000 |
| 54 | + Execute Command sudo tedge config set c8y.proxy.client.host ${PARENT_IP} |
| 55 | + Execute Command sudo tedge config set c8y.proxy.client.port 8001 |
| 56 | + Execute Command sudo tedge config set mqtt.client.host ${PARENT_IP} |
| 57 | + Execute Command sudo tedge config set mqtt.client.port 1883 |
| 58 | + Execute Command sudo tedge config set mqtt.topic_root te |
| 59 | + Execute Command sudo tedge config set mqtt.device_topic_id "device/${CHILD_SN}//" |
| 60 | + |
| 61 | + # Install plugin after the default settings have been updated to prevent it from starting up as the main plugin |
| 62 | + Execute Command sudo dpkg -i packages/tedge-agent*.deb |
| 63 | + Execute Command sudo systemctl enable tedge-agent |
| 64 | + Execute Command sudo systemctl start tedge-agent |
| 65 | + |
| 66 | +Custom Setup |
| 67 | + # Parent |
| 68 | + ${parent_sn}= Setup skip_bootstrap=${True} |
| 69 | + Set Suite Variable $PARENT_SN ${parent_sn} |
| 70 | + Execute Command test -f ./bootstrap.sh && ./bootstrap.sh --no-connect || true |
| 71 | + |
| 72 | + ${parent_ip}= Get IP Address |
| 73 | + Set Suite Variable $PARENT_IP ${parent_ip} |
| 74 | + Execute Command sudo tedge config set mqtt.external.bind.address ${PARENT_IP} |
| 75 | + Execute Command sudo tedge config set mqtt.external.bind.port 1883 |
| 76 | + Execute Command sudo tedge config set http.bind.address ${PARENT_IP} |
| 77 | + Execute Command sudo tedge config set http.bind.port 8000 |
| 78 | + Execute Command sudo tedge config set c8y.proxy.bind.address ${PARENT_IP} |
| 79 | + Execute Command sudo tedge config set c8y.proxy.bind.port 8001 |
| 80 | + |
| 81 | + ThinEdgeIO.Connect Mapper c8y |
| 82 | + ThinEdgeIO.Service Health Status Should Be Up tedge-mapper-c8y |
| 83 | + |
| 84 | + # Child |
| 85 | + ${CHILD_SN}= Setup skip_bootstrap=${True} |
| 86 | + Set Suite Variable $CHILD_SN |
| 87 | + Set Suite Variable $CHILD_XID ${PARENT_SN}:device:${CHILD_SN} |
| 88 | + Setup Child Device |
| 89 | + Cumulocity.Device Should Exist ${CHILD_XID} |
| 90 | + |
| 91 | +Test Teardown |
| 92 | + Get Logs name=${PARENT_SN} |
| 93 | + Get Logs name=${CHILD_SN} |
0 commit comments