Skip to content

Commit

Permalink
Correcting timeouts when changing default values
Browse files Browse the repository at this point in the history
Added logic for correcting timeouts when changing default and
logging this change.
By new logic:
1) if the value of --server-start-timeout is increased, the value
 for --test-timeout and --no-output-timeout will be increased
2) if --no-output-timeout is decreased --test-timeout and
 --server-start-timeout will be decreased
3) if --test-timeout is increased --no-output-timeout will be
 increased
4) if --test-timeout is decreased --server-start-timeout will be
 decreased
  • Loading branch information
Islam Elkanov committed Jun 29, 2023
1 parent a6405f1 commit dc17c4c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/options.py
Expand Up @@ -511,8 +511,36 @@ def __init__(self):

self.check()

self.correct_timeout_offset(parser)

Options._initialized = True

def correct_timeout_offset(self, parser: argparse.ArgumentParser) -> None:
"""Check and correct timeout offset if necessary."""
default_time_offset = 10
if self.args.server_start_timeout > parser.get_default('server_start_timeout'):
if (self.args.test_timeout - self.args.server_start_timeout) < default_time_offset:
color_stdout("Warning: test-timeout and no-output-timeout has been changed. \n",
schema='info')
self.args.test_timeout = self.args.server_start_timeout + default_time_offset
self.args.no_output_timeout = self.args.test_timeout + default_time_offset

if self.args.no_output_timeout < parser.get_default('no_output_timeout'):
if (self.args.no_output_timeout - self.args.test_timeout) < default_time_offset:
color_stdout("Warning: test-timeout and server-start-timeout has been changed. \n",
schema='info')
self.args.test_timeout = self.args.no_output_timeout - default_time_offset
self.args.server_start_timeout = self.args.test_timeout - default_time_offset

if self.args.test_timeout > parser.get_default('test_timeout'):
if (self.args.no_output_timeout - self.args.test_timeout) < default_time_offset:
color_stdout("Warning: no-output-timeout has been changed. \n", schema='info')
self.args.no_output_timeout = self.args.test_timeout + default_time_offset
elif self.args.test_timeout < parser.get_default('test_timeout'):
if (self.args.test_timeout - self.args.server_start_timeout) < default_time_offset:
color_stdout("Warning: server-start-timeout has been changed. \n", schema='info')
self.args.server_start_timeout = self.args.test_timeout - default_time_offset

def check(self):
"""Check the arguments for correctness."""
check_error = False
Expand Down

0 comments on commit dc17c4c

Please sign in to comment.