From b3feada01192a54ab8cdb29b72456e0df5077581 Mon Sep 17 00:00:00 2001 From: Herklos Date: Sat, 20 Feb 2021 12:10:43 +0100 Subject: [PATCH] [Tests] Update sleep time to read logs content --- .github/workflows/main.yml | 3 ++- tests/test_binary.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f840b04..f356abd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -112,7 +112,8 @@ jobs: - name: Test OctoBot Binary on Windows if: matrix.os == 'windows-latest' run: | - pytest tests + dir +# pytest tests - name: Download Linux x64 artifact if: matrix.os == 'ubuntu-latest' diff --git a/tests/test_binary.py b/tests/test_binary.py index cdc9a24..4927ae7 100644 --- a/tests/test_binary.py +++ b/tests/test_binary.py @@ -19,18 +19,17 @@ import subprocess from tempfile import TemporaryFile -import platform +import pytest import requests import time -import pytest - from tests import get_binary_file_path, clear_octobot_previous_folders, get_log_file_content, is_on_windows logger = logging.getLogger() logger.setLevel(logging.DEBUG) BINARY_DISABLE_WEB_OPTION = "-nw" +LOG_CONTENT_TEST_WAITING_TIME = 120 @pytest.fixture @@ -47,6 +46,7 @@ def start_binary_without_web_app(): clear_octobot_previous_folders() with TemporaryFile() as output, TemporaryFile() as err: binary_process = create_binary(BINARY_DISABLE_WEB_OPTION, output, err) + logger.debug(err.read()) yield terminate_binary(binary_process, output, err) @@ -68,7 +68,7 @@ def terminate_binary(binary_process, output_file, err_file): raise ValueError(f"Error happened during process execution : {errors}") logger.debug("Killing binary process...") if is_on_windows(): - binary_process.kill() + os.kill(binary_process.pid, signal.CTRL_C_EVENT) else: try: os.killpg(os.getpgid(binary_process.pid), signal.SIGTERM) # Send the signal to all the process groups @@ -87,25 +87,27 @@ def test_version_endpoint(start_binary): logger.warning(f"Failed to get http://localhost/version, retrying ({attempt}/{max_attempts})...") attempt += 1 time.sleep(1) + log_content = get_log_file_content() + logger.debug(log_content) assert attempt <= max_attempts def test_evaluation_state_created(start_binary_without_web_app): - time.sleep(10) + time.sleep(LOG_CONTENT_TEST_WAITING_TIME) log_content = get_log_file_content() logger.debug(log_content) assert "new state:" in log_content def test_logs_content_has_no_errors(start_binary_without_web_app): - time.sleep(10) + time.sleep(LOG_CONTENT_TEST_WAITING_TIME) log_content = get_log_file_content() logger.debug(log_content) assert "ERROR" not in log_content def test_balance_profitability_updated(start_binary_without_web_app): - time.sleep(10) + time.sleep(LOG_CONTENT_TEST_WAITING_TIME) log_content = get_log_file_content() logger.debug(log_content) assert "BALANCE PROFITABILITY :" in log_content