Skip to content

Commit

Permalink
add utils unit tests for resource limits
Browse files Browse the repository at this point in the history
  • Loading branch information
gargnitingoogle committed Sep 18, 2024
1 parent 0adc614 commit c93fde8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions perfmetrics/scripts/testing_on_gke/examples/utils/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,49 @@ def test_timestamp_to_epoch(self):
self.assertEqual(timestamp_to_epoch(timestamp), expected_epoch)
pass

def test_resource_limit(self):
inputs = [
{
'nodeType': 'n2-standard-32',
'expected_limits_cpu': 32,
'expected_error': False,
},
{
'nodeType': 'n2-standard-96',
'expected_limits_cpu': 96,
'expected_error': False,
},
{
'nodeType': 'n2-standard-96',
'expected_limits_cpu': 96,
'expected_error': False,
},
{
'nodeType': 'c3-standard-176',
'expected_limits_cpu': 176,
'expected_error': False,
},
{
'nodeType': 'c3-standard-176-lssd',
'expected_limits_cpu': 176,
'expected_error': False,
},
{'nodeType': 'n2-standard-1', 'expected_error': True},
{'nodeType': 'unknown-machine-type', 'expected_error': True},
]
for input in inputs:
self.assertEqual(dict, type(input))
try:
resource_limits = utils.resource_limits(input['nodeType'])
self.assertEqual(
input['expected_limits_cpu'],
resource_limits[0]['cpu'],
)
self.assertFalse(input['expected_error'])
except utils.UnknownMachineTypeError:
self.assertTrue(input['expected_error'])
pass


if __name__ == '__main__':
unittest.main()

0 comments on commit c93fde8

Please sign in to comment.