From: Gwenael Lambrouin Date: Mon, 19 Jul 2021 08:45:15 +0000 (+0200) Subject: behave_tests: log nfvbench API test X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?p=nfvbench.git;a=commitdiff_plain;h=6e15b62fa75d1d000317beb0ab5244924a3f6ca7 behave_tests: log nfvbench API test Change-Id: I67bfba22393f2f324b3c052b443b24c520231172 Signed-off-by: Gwenael Lambrouin --- diff --git a/behave_tests/features/steps/steps.py b/behave_tests/features/steps/steps.py index 7be8241..76ed12d 100644 --- a/behave_tests/features/steps/steps.py +++ b/behave_tests/features/steps/steps.py @@ -143,10 +143,11 @@ def start_server(context, host_ip: Optional[str]=None, port: Optional[int]=None) if port is not None: context.port = port + nfvbench_test_url = "http://{ip}:{port}/status".format(ip=context.host_ip, port=context.port) + try: # check if API is already available - requests.get( - "http://{host_ip}:{port}/status".format(host_ip=context.host_ip, port=context.port)) + requests.get(nfvbench_test_url) except RequestException: cmd = ["nfvbench", "-c", context.data['config'], "--server"] if context.host_ip != "127.0.0.1": @@ -158,7 +159,8 @@ def start_server(context, host_ip: Optional[str]=None, port: Optional[int]=None) subprocess.Popen(cmd, stdout=DEVNULL, stderr=subprocess.STDOUT) - test_nfvbench_api(context) + context.logger.info("start_server: test nfvbench API: " + nfvbench_test_url) + test_nfvbench_api(nfvbench_test_url) """Then steps.""" @@ -330,9 +332,9 @@ def push_result_database(context): @retry(AssertionError, tries=24, delay=5.0, logger=None) -def test_nfvbench_api(context): +def test_nfvbench_api(nfvbench_test_url: str): try: - r = requests.get("http://{ip}:{port}/status".format(ip=context.host_ip, port=context.port)) + r = requests.get(nfvbench_test_url) assert r.status_code == 200 assert json.loads(r.text)["error_message"] == "no pending NFVbench run" except RequestException as exc: