Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
cli: adds support for parsing -ms parameters as int (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsimam authored Sep 16, 2022
1 parent bcb4444 commit 7721b50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions cli/integration/tests/waiter/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def test_implicit_create_args(self):
self.assertNotIn('--max-queue-length', cli.stdout(cp))
self.assertNotIn('--expired-instance-restart-rate', cli.stdout(cp))
self.assertNotIn('--jitter-threshold', cli.stdout(cp))
self.assertNotIn('--queue-timeout-ms', cli.stdout(cp))
token_name = self.token_name()
cp = cli.create(self.waiter_url, token_name, create_flags=('--https-redirect true '
'--cpus 0.1 '
Expand All @@ -174,7 +175,8 @@ def test_implicit_create_args(self):
'--health-check-max-consecutive-failures 10 '
'--max-queue-length 1000000 '
'--expired-instance-restart-rate 0.1 '
'--jitter-threshold 0.1 '))
'--jitter-threshold 0.1 '
'--queue-timeout-ms 60000 '))
self.assertEqual(0, cp.returncode, cp.stderr)
try:
token = util.load_token(self.waiter_url, token_name)
Expand All @@ -189,6 +191,7 @@ def test_implicit_create_args(self):
self.assertEqual(1000000, token['max-queue-length'])
self.assertEqual(0.1, token['expired-instance-restart-rate'])
self.assertEqual(0.1, token['jitter-threshold'])
self.assertEqual(60000, token['queue-timeout-ms'])
cp = cli.create(self.waiter_url, token_name, create_flags=('--https-redirect false '
'--cpus 0.1 '
'--fallback-period-secs 20 '
Expand All @@ -200,7 +203,8 @@ def test_implicit_create_args(self):
'--health-check-max-consecutive-failures 2 '
'--max-queue-length 2000000 '
'--expired-instance-restart-rate 0.2 '
'--jitter-threshold 0.2 '))
'--jitter-threshold 0.2 '
'--queue-timeout-ms 80000 '))
self.assertEqual(0, cp.returncode, cp.stderr)
token = util.load_token(self.waiter_url, token_name)
self.assertFalse(token['https-redirect'])
Expand All @@ -214,6 +218,7 @@ def test_implicit_create_args(self):
self.assertEqual(2000000, token['max-queue-length'])
self.assertEqual(0.2, token['expired-instance-restart-rate'])
self.assertEqual(0.2, token['jitter-threshold'])
self.assertEqual(80000, token['queue-timeout-ms'])
finally:
util.delete_token(self.waiter_url, token_name)

Expand Down Expand Up @@ -254,13 +259,15 @@ def test_implicit_update_args(self):
self.assertNotIn('--idle-timeout-mins', cli.stdout(cp))
self.assertNotIn('--max-instances', cli.stdout(cp))
self.assertNotIn('--restart-backoff-factor', cli.stdout(cp))
self.assertNotIn('--queue-timeout-ms', cli.stdout(cp))
token_name = self.token_name()
cp = cli.update(self.waiter_url, token_name, update_flags='--https-redirect true '
'--cpus 0.1 '
'--fallback-period-secs 10 '
'--idle-timeout-mins 1 '
'--max-instances 100 '
'--restart-backoff-factor 1.1')
'--restart-backoff-factor 1.1 '
'--queue-timeout-ms 60000 ')
self.assertEqual(0, cp.returncode, cp.stderr)
try:
token = util.load_token(self.waiter_url, token_name)
Expand All @@ -269,19 +276,22 @@ def test_implicit_update_args(self):
self.assertEqual(1, token['idle-timeout-mins'])
self.assertEqual(100, token['max-instances'])
self.assertEqual(1.1, token['restart-backoff-factor'])
self.assertEqual(60000, token['queue-timeout-ms'])
cp = cli.update(self.waiter_url, token_name, update_flags='--https-redirect false '
'--cpus 0.1 '
'--fallback-period-secs 20 '
'--idle-timeout-mins 2 '
'--max-instances 200 '
'--restart-backoff-factor 2.2')
'--restart-backoff-factor 2.2 '
'--queue-timeout-ms 80000 ')
self.assertEqual(0, cp.returncode, cp.stderr)
token = util.load_token(self.waiter_url, token_name)
self.assertFalse(token['https-redirect'])
self.assertEqual(20, token['fallback-period-secs'])
self.assertEqual(2, token['idle-timeout-mins'])
self.assertEqual(200, token['max-instances'])
self.assertEqual(2.2, token['restart-backoff-factor'])
self.assertEqual(80000, token['queue-timeout-ms'])
finally:
util.delete_token(self.waiter_url, token_name)

Expand Down
2 changes: 1 addition & 1 deletion cli/waiter/token_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
guard_no_cluster, str2bool, update_in

BOOL_STRINGS = TRUE_STRINGS + FALSE_STRINGS
INT_PARAM_SUFFIXES = ['-failures', '-index', '-instances', '-length', '-level', '-mins', '-secs']
INT_PARAM_SUFFIXES = ['-failures', '-index', '-instances', '-length', '-level', '-mins', '-ms', '-secs']
FLOAT_PARAM_SUFFIXES = ['-factor', '-rate', '-threshold']
STRING_PARAM_PREFIXES = ['env', 'metadata']

Expand Down

0 comments on commit 7721b50

Please sign in to comment.