Skip to content

Commit

Permalink
Add reconnection end to end test
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Orru <simone.orru@secomind.com>
  • Loading branch information
sorru94 committed Sep 26, 2023
1 parent ae648c9 commit 8019e1d
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ jobs:
echo "E2E_DEVICE_2_ID=$DEVICE_2_ID" >> $GITHUB_ENV
CREDENTIALS_SECRET_2=$(astartectl pairing agent register --compact-output -- "$DEVICE_2_ID")
echo "E2E_CREDENTIALS_SECRET_2=$CREDENTIALS_SECRET_2" >> $GITHUB_ENV
- name: Setup env variables for device 3
run: |
DEVICE_3_ID=$(astartectl utils device-id generate-random)
echo "E2E_DEVICE_3_ID=$DEVICE_3_ID" >> $GITHUB_ENV
CREDENTIALS_SECRET_3=$(astartectl pairing agent register --compact-output -- "$DEVICE_3_ID")
echo "E2E_CREDENTIALS_SECRET_3=$CREDENTIALS_SECRET_3" >> $GITHUB_ENV
- name: Install the astarte device Python module
run: |
python3 -m pip install -e .[e2e]
Expand All @@ -81,3 +87,11 @@ jobs:
command: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 e2etest/persistency/main.py
- name: Run test for reconnection
uses: nick-fields/retry@v2
with:
timeout_seconds: 30
max_attempts: 2
command: |
export REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
python3 e2etest/reconnection/main.py
4 changes: 4 additions & 0 deletions e2etest/base/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):

time.sleep(1)

if not device.is_connected():
print("Connection failed.", flush=True)
sys.exit(1)

test_datastream_from_device_to_server(device, test_cfg)

time.sleep(1)
Expand Down
5 changes: 5 additions & 0 deletions e2etest/persistency/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ def main(cb_loop: asyncio.AbstractEventLoop, test_cfg: TestCfg):
device.on_data_received = on_data_received_cbk
device.on_disconnected = on_disconnected_cbk
device.connect()

time.sleep(1)

if not device.is_connected():
print("Connection failed.", flush=True)
sys.exit(1)

assert peek_database(persistency_dir, test_cfg.device_id) == list()
assert peek_astarte(test_cfg) == {
test_cfg.interface_device_prop: {},
Expand Down
Loading

0 comments on commit 8019e1d

Please sign in to comment.