From 8ccac6dda4a0c72160f29547652898af980c45e7 Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 21 Jan 2022 20:22:47 +0800 Subject: [PATCH 01/10] harden e2e test by adding healthCheck Signed-off-by: tison --- .github/workflows/e2e.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a581102..3d57cbe 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,4 +22,7 @@ jobs: pip3 install --upgrade pip pip3 install setuptools pip3 install -r requirements.txt + until curl http://127.0.0.1:8081/healthCheck; do + sleep 1 + done python3 tests/e2e/run_e2e.py --expected_file=tests/e2e/data/expected_context.yaml --max_retry_times=3 --target_path=/ping From 461edc4af4edec3a80708a89ec41ba7a7921bc74 Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 21 Jan 2022 20:32:00 +0800 Subject: [PATCH 02/10] retrigger Signed-off-by: tison From 2dd8b0b927dc517a8e4e5423a1ffcbf48f35c4d9 Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 21 Jan 2022 20:44:19 +0800 Subject: [PATCH 03/10] retrigger Signed-off-by: tison From 5156e940708852b1344236be5ce409832d37ab0e Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 21 Jan 2022 20:52:40 +0800 Subject: [PATCH 04/10] retrigger Signed-off-by: tison From c923822a18d20dd24c9533ff64fb073318c216be Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 13:30:06 +0800 Subject: [PATCH 05/10] move probe to the e2e script Signed-off-by: tison --- .github/workflows/e2e.yml | 3 --- tests/e2e/run_e2e.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3d57cbe..a581102 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,7 +22,4 @@ jobs: pip3 install --upgrade pip pip3 install setuptools pip3 install -r requirements.txt - until curl http://127.0.0.1:8081/healthCheck; do - sleep 1 - done python3 tests/e2e/run_e2e.py --expected_file=tests/e2e/data/expected_context.yaml --max_retry_times=3 --target_path=/ping diff --git a/tests/e2e/run_e2e.py b/tests/e2e/run_e2e.py index cd2e1c9..03803b9 100644 --- a/tests/e2e/run_e2e.py +++ b/tests/e2e/run_e2e.py @@ -43,6 +43,22 @@ def validate(expected_file_name): args = parser.parse_args() + health_check_times = 0 + while True: + if health_check_times > 30: + raise RuntimeError("Producer health check times exceeded") + + try: + requests.get('http://0.0.0.0:8081/healthCheck', timeout=5) + except Exception as e: + print(e) + health_check_times += 1 + time.sleep(2) + continue + + # health check passed + break + retry_times = 0 while True: if retry_times > args.max_retry_times: From fa1a02932ca3b6f9cb90153870ece16995a65ba8 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 13:30:50 +0800 Subject: [PATCH 06/10] trigger ci Signed-off-by: tison From 7b573af5ce86d3c416e828b3acb18e39ba6bd150 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 14:51:30 +0800 Subject: [PATCH 07/10] trigger ci Signed-off-by: tison From 662f499c791205d73f08f9e3cb465b03a5a59288 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 18:53:05 +0800 Subject: [PATCH 08/10] make use of retry lib Signed-off-by: tison --- requirements.txt | 1 + tests/e2e/run_e2e.py | 52 ++++++++++++++------------------------------ 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/requirements.txt b/requirements.txt index a8774cb..313885f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ PyYAML==5.4 apache-skywalking==0.5.0 +retry==0.9.2 diff --git a/tests/e2e/run_e2e.py b/tests/e2e/run_e2e.py index 03803b9..a4f99a9 100644 --- a/tests/e2e/run_e2e.py +++ b/tests/e2e/run_e2e.py @@ -1,21 +1,19 @@ import os import sys -import time from difflib import Differ -from os.path import dirname +from retry.api import retry_call import argparse import yaml import requests -import time try: from yaml import CSafeLoader as Loader except ImportError: from yaml import SafeLoader as Loader -def validate(expected_file_name): - with open(expected_file_name) as expected_data_file: +def validate(excepted_file): + with open(excepted_file) as expected_data_file: expected_data = os.linesep.join(expected_data_file.readlines()) response = requests.post(url='http://0.0.0.0:12800/dataValidate', data=expected_data) @@ -35,6 +33,13 @@ def validate(expected_file_name): return response +def health_check(): + requests.get('http://0.0.0.0:8081/healthCheck', timeout=5) + +def call_target_path(target_path): + requests.get('http://0.0.0.0:8081{0}'.format(target_path), timeout=5) + + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--expected_file', help='File name which includes expected reported value') @@ -43,35 +48,10 @@ def validate(expected_file_name): args = parser.parse_args() - health_check_times = 0 - while True: - if health_check_times > 30: - raise RuntimeError("Producer health check times exceeded") - - try: - requests.get('http://0.0.0.0:8081/healthCheck', timeout=5) - except Exception as e: - print(e) - health_check_times += 1 - time.sleep(2) - continue - - # health check passed - break - - retry_times = 0 - while True: - if retry_times > args.max_retry_times: - raise RuntimeError("Max retry times exceeded") - - try: - requests.get('http://0.0.0.0:8081{0}'.format(args.target_path), timeout=5) - except Exception as e: - print(e) - retry_times += 1 - time.sleep(2) - continue + import logging + logging.basicConfig() + retry_call(health_check, tries=30, delay=2) + retry_call(call_target_path, fargs=[args.target_path], tries=args.max_retry_times, delay=2) - res = validate(args.expected_file) - assert res.status_code == 200 - break + res = validate(args.expected_file) + assert res.status_code == 200 From ddf85f0bfb6bf5e10551fb8841110da3728f2b74 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 18:59:42 +0800 Subject: [PATCH 09/10] trigger ci Signed-off-by: tison From a64713609ee6b51c4540e1d906c04bd913196518 Mon Sep 17 00:00:00 2001 From: tison Date: Sat, 22 Jan 2022 19:16:09 +0800 Subject: [PATCH 10/10] trigger ci Signed-off-by: tison