1919import subprocess
2020from tempfile import TemporaryFile
2121
22- import platform
22+ import pytest
2323import requests
2424import time
2525
26- import pytest
27-
2826from tests import get_binary_file_path , clear_octobot_previous_folders , get_log_file_content , is_on_windows
2927
3028logger = logging .getLogger ()
3129logger .setLevel (logging .DEBUG )
3230
3331BINARY_DISABLE_WEB_OPTION = "-nw"
32+ LOG_CONTENT_TEST_WAITING_TIME = 60
3433
3534
3635@pytest .fixture
@@ -47,6 +46,7 @@ def start_binary_without_web_app():
4746 clear_octobot_previous_folders ()
4847 with TemporaryFile () as output , TemporaryFile () as err :
4948 binary_process = create_binary (BINARY_DISABLE_WEB_OPTION , output , err )
49+ logger .debug (err .read ())
5050 yield
5151 terminate_binary (binary_process , output , err )
5252
@@ -68,7 +68,7 @@ def terminate_binary(binary_process, output_file, err_file):
6868 raise ValueError (f"Error happened during process execution : { errors } " )
6969 logger .debug ("Killing binary process..." )
7070 if is_on_windows ():
71- binary_process .kill ()
71+ os .kill (binary_process . pid , signal . CTRL_C_EVENT )
7272 else :
7373 try :
7474 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):
8787 logger .warning (f"Failed to get http://localhost/version, retrying ({ attempt } /{ max_attempts } )..." )
8888 attempt += 1
8989 time .sleep (1 )
90+ log_content = get_log_file_content ()
91+ logger .debug (log_content )
9092 assert attempt <= max_attempts
9193
9294
9395def test_evaluation_state_created (start_binary_without_web_app ):
94- time .sleep (10 )
96+ time .sleep (LOG_CONTENT_TEST_WAITING_TIME )
9597 log_content = get_log_file_content ()
9698 logger .debug (log_content )
9799 assert "new state:" in log_content
98100
99101
100102def test_logs_content_has_no_errors (start_binary_without_web_app ):
101- time .sleep (10 )
103+ time .sleep (LOG_CONTENT_TEST_WAITING_TIME )
102104 log_content = get_log_file_content ()
103105 logger .debug (log_content )
104106 assert "ERROR" not in log_content
105107
106108
107109def test_balance_profitability_updated (start_binary_without_web_app ):
108- time .sleep (10 )
110+ time .sleep (LOG_CONTENT_TEST_WAITING_TIME )
109111 log_content = get_log_file_content ()
110112 logger .debug (log_content )
111113 assert "BALANCE PROFITABILITY :" in log_content
0 commit comments