-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_limits.py
More file actions
49 lines (44 loc) · 1.55 KB
/
test_limits.py
File metadata and controls
49 lines (44 loc) · 1.55 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
Unit tests for the Drycc scheduler module.
Run the tests with './manage.py test scheduler'
"""
from scheduler.tests import TestCase
from scheduler import KubeHTTPException
class LimitRangesTest(TestCase):
def test_create_quota(self):
namespace_name = self.create_namespace()
spec = {
"limits": [
{
"type": "Container",
"max": {
"cpu": "32",
"memory": "128Gi"
},
"min": {
"cpu": "100m",
"memory": "128Mi"
}
},
{
"type": "PersistentVolumeClaim",
"max": {
"storage": "100Gi"
},
"min": {
"storage": "100Mi"
}
}
]
}
self.scheduler.limits.create(namespace_name, 'test-1', spec=spec)
response = self.scheduler.limits.get(namespace_name, 'test-1')
data = response.json()
self.assertEqual(data.get('spec', {}), spec)
self.assertEqual(data['metadata']['namespace'], namespace_name)
def test_create_with_nonexistent_namespace(self):
with self.assertRaises(
KubeHTTPException,
msg='failed to create LimitRanges test-1 for namespace ghost-namespace: 404 Not Found'
):
self.scheduler.quota.create('ghost-namespace', 'test-1', data={})