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 Oct 3, 2024
1 parent ec2b794 commit d4a44f3
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 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 @@ -88,6 +88,48 @@ def test_timestamp_to_epoch_with_nznano(self):
timestamp_to_epoch('2024-08-21T19:20:25.547456'), 1724268025
)

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'])


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

0 comments on commit d4a44f3

Please sign in to comment.