diff options
author | Michael Abel <75477722+abelikt@users.noreply.github.com> | 2022-05-23 14:48:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 14:48:27 +0200 |
commit | eaa32c5ebd64704cfa94dca5ea7ce7db06cc1585 (patch) | |
tree | 4ab557bd48c8b678a7722df7f2fea6e5efee9384 | |
parent | df336d050fd0fcc25519b61cf9de984069f2702a (diff) | |
parent | 355f7c5fab690a67eecbe44ad9eaed5df590caf5 (diff) |
Merge pull request #1146 from abelikt/bugs/retry_getting_c8y_id
Retry when retrieving the C8Y ID fails
-rwxr-xr-x | ci/ci_smoke_test_c8y.sh | 2 | ||||
-rwxr-xr-x | ci/configure_bridge.sh | 2 | ||||
-rwxr-xr-x | ci/find_device_id.py | 8 | ||||
-rw-r--r-- | tests/requirements.txt | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/ci/ci_smoke_test_c8y.sh b/ci/ci_smoke_test_c8y.sh index dc48bc8e..f77d23f0 100755 --- a/ci/ci_smoke_test_c8y.sh +++ b/ci/ci_smoke_test_c8y.sh @@ -76,7 +76,7 @@ PATH=$PATH:/usr/sbin python3 -m venv ~/env-c8y-api source ~/env-c8y-api/bin/activate -pip3 install c8y-api +pip3 install c8y-api retry-decorator export C8YDEVICEID=$(python3 ./ci/find_device_id.py --tenant $C8YTENANT --user $C8YUSERNAME --device $C8YDEVICE --url $C8YURL) # after calling the script, the ID should be a numeric value diff --git a/ci/configure_bridge.sh b/ci/configure_bridge.sh index 1c476d6f..4099efd9 100755 --- a/ci/configure_bridge.sh +++ b/ci/configure_bridge.sh @@ -37,7 +37,7 @@ cat /etc/mosquitto/mosquitto.conf python3 -m venv ~/env-c8y-api source ~/env-c8y-api/bin/activate -pip3 install c8y-api +pip3 install c8y-api retry-decorator # Delete the device (ignore error) set +e diff --git a/ci/find_device_id.py b/ci/find_device_id.py index 816274e4..721824b6 100755 --- a/ci/find_device_id.py +++ b/ci/find_device_id.py @@ -8,21 +8,27 @@ For example: python3 ci/find_device_id.py --tenant t493319102 --user octocat --device devraspberrypi --url thin-edge-io.eu-latest.cumulocity.com +Hint: Make sure to use the local interpreter with python3 and avoid +the dot-slash notation when using a Python environment. + +Also export the C8Y password into variable C8YPASS """ import argparse import os import sys from c8y_api import CumulocityApi +from retry_decorator import retry +@retry(Exception, tries=5, timeout_secs=2) def get_device_id(c8y, name): """retrive the current device ID""" devices = c8y.device_inventory.get_all(name=name) if len(devices) == 1: return devices[0].id - return None + raise SystemError("Failed to retrive ID") def main(): diff --git a/tests/requirements.txt b/tests/requirements.txt index 54edea56..f9d43d38 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,4 +6,4 @@ junitparser == 2.2.0 junit2html == 30.0.6 psutil == 5.9.0 c8y-api == 1.1.1 - +retry-decorator == 1.1.1 |