-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_pod_resources.py
More file actions
26 lines (23 loc) · 1.07 KB
/
test_pod_resources.py
File metadata and controls
26 lines (23 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
from scheduler.resources.pod import Pod
class TestSchedulerPodResources(unittest.TestCase):
def test_manifest_limits(self):
resources_cases = [
{"app_type": "web", "expected": {"limits": {"cpu": 1}}},
{"app_type": "web", "expected": {"limits": {"memory": "1G"}}},
{"app_type": "web", "expected": {"limits": {"cpu": 1, "memory": "1G"}}},
]
for caze in resources_cases:
manifest = Pod("").manifest("",
"",
"",
app_type=caze["app_type"],
resources=caze["expected"])
self._assert_resources(caze, manifest)
def _assert_resources(self, caze, manifest):
resources_parent = manifest["spec"]["containers"][0]
expected = caze["expected"]
if expected:
self.assertEqual(resources_parent["resources"], expected, caze)
else:
self.assertTrue(resources_parent["resources"] == {}, caze)