Skip to content

Commit

Permalink
fix some var names
Browse files Browse the repository at this point in the history
  • Loading branch information
gargnitingoogle committed Nov 4, 2024
1 parent 6ced261 commit 4d16cb5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
8 changes: 4 additions & 4 deletions perfmetrics/scripts/testing_on_gke/examples/run-gke-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ function installDependencies() {
sudo apt install docker-ce -y
fi
# Ensure that gcloud monitoring tools are installed.
# pip install --upgrade google-cloud-storage
# pip install --ignore-installed --upgrade google-api-python-client
# pip install --ignore-installed --upgrade google-cloud
pip install --upgrade google-cloud-monitoring
pip install --upgrade google-cloud-storage 1>/dev/null
pip install --ignore-installed --upgrade google-api-python-client 1>/dev/null
pip install --ignore-installed --upgrade google-cloud 1>/dev/null
pip install --upgrade google-cloud-monitoring 1>/dev/null
# Ensure that jq is installed.
which jq || sudo apt-get install -y jq
# Ensure sudoless docker is installed.
Expand Down
33 changes: 19 additions & 14 deletions perfmetrics/scripts/testing_on_gke/examples/utils/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,31 @@ def setUpClass(self):
self.start = '2024-09-25 06:32:22 UTC'
self.end = '2024-09-25 07:06:22 UTC'

def test_get_memory(self):
low1, high1 = get_memory_from_monitoring_api(
def test_get_memory_from_monitoring_api(self):
low, high = get_memory_from_monitoring_api(
project_id=self.project_id,
cluster_name=self.cluster_name,
pod_name=self.pod_name,
namespace_name=self.namespace_name,
start_epoch=self.start_epoch,
end_epoch=self.end_epoch,
)
self.assertLessEqual(low1, high1)
self.assertGreater(high1, 0)

def test_get_cpu(self):
low1, high1 = get_cpu_from_monitoring_api(
self.assertLessEqual(low, high)
self.assertGreater(high, 0)

def test_get_cpu_from_monitoring_api(self):
low, high = get_cpu_from_monitoring_api(
project_id=self.project_id,
cluster_name=self.cluster_name,
pod_name=self.pod_name,
namespace_name=self.namespace_name,
start_epoch=self.start_epoch,
end_epoch=self.end_epoch,
)
self.assertLessEqual(low1, high1)
self.assertGreater(high1, 0)

self.assertLessEqual(low, high)
self.assertGreater(high, 0)

def test_timestamp_to_epoch(self):
self.assertEqual(timestamp_to_epoch('2024-08-21T19:20:25'), 1724268025)
Expand All @@ -66,7 +68,7 @@ def test_timestamp_to_epoch_with_nznano(self):
timestamp_to_epoch('2024-08-21T19:20:25.547456'), 1724268025
)

def test_resource_limit(self):
def test_resource_limits(self):
inputs = [
{
'nodeType': 'n2-standard-32',
Expand Down Expand Up @@ -96,17 +98,20 @@ def test_resource_limit(self):
{'nodeType': 'n2-standard-1', 'expected_error': True},
{'nodeType': 'unknown-machine-type', 'expected_error': True},
]

for input in inputs:
self.assertEqual(dict, type(input))
try:

if input['expected_error']:

with self.assertRaises(utils.UnknownMachineTypeError):
resource_limits = utils.resource_limits(input['nodeType'])
else:
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__':
Expand Down

0 comments on commit 4d16cb5

Please sign in to comment.