From 5e596b392ae46643ce0bf8df8820abd75295d354 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 23 Jan 2024 13:35:05 +0100 Subject: [PATCH] wait for verifications --- .github/workflows/e2e.yml | 4 ++-- tasks.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f5f04b7..79ddb37 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,8 +61,8 @@ jobs: - name: 🔁 E2E Test Start run: poetry run invoke test start - - name: ⏳ Wait - run: sleep 1500 + - name: ⏳ Wait for verifications + run: poetry run invoke test wait - name: 🧪 E2E Test Run Checks run: | diff --git a/tasks.py b/tasks.py index 05a3fd6..842407d 100644 --- a/tasks.py +++ b/tasks.py @@ -68,6 +68,8 @@ def test(ctx, action): check_env_vars() network(ctx, "start") start_coordinator(ctx) + elif action == "wait": + wait_for_verifications(ctx) elif action == "stop": network(ctx, "stop") stop_coordinator(ctx) @@ -488,6 +490,42 @@ def postgres_get_data(): return postgres_submitters, postgres_verified_subs +import time +from datetime import datetime, timedelta + + +@task(pre=[load_env]) +def wait_for_verifications(ctx): + timeout = 60 * 60 # 60 minutes in seconds + start_time = datetime.now() + keyspace_subs = keyspace_get_submissions() + keyspace_verified_subs = [sub for sub in keyspace_subs if sub["verified"]] + + while len(keyspace_verified_subs) != len(keyspace_subs): + current_time = datetime.now() + elapsed_time = (current_time - start_time).total_seconds() + + # Check if timeout has been reached + if elapsed_time > timeout: + print( + f"Timeout reached: Verified submissions: {len(keyspace_verified_subs)} / {len(keyspace_subs)}" + ) + exit(1) + + ctx.run("sleep 15", echo=True) + + print( + f"Waiting for verifications. Verified submissions: {len(keyspace_verified_subs)} / {len(keyspace_subs)}" + ) + + keyspace_subs = keyspace_get_submissions() + keyspace_verified_subs = [sub for sub in keyspace_subs if sub["verified"]] + + print( + f"All submissions have been verified. {len(keyspace_verified_subs)} / {len(keyspace_subs)}" + ) + + @task(pre=[load_env]) def assert_data(ctx): # Get data from Keyspaces