Skip to content

Commit

Permalink
[Tests] Update sleep time to read logs content
Browse files Browse the repository at this point in the history
  • Loading branch information
Herklos committed Feb 20, 2021
1 parent 39cbf84 commit b3feada
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 9 additions & 7 deletions tests/test_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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

0 comments on commit b3feada

Please sign in to comment.