-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_daemonsets.py
More file actions
72 lines (66 loc) · 2.35 KB
/
test_daemonsets.py
File metadata and controls
72 lines (66 loc) · 2.35 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""
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 DaemonsetsTest(TestCase):
"""Tests scheduler daemonset calls"""
def test_get_daemonsets(self):
response = self.scheduler.daemonset.get('drycc')
data = response.json()
self.assertEqual(response.status_code, 200, data)
self.assertIn('items', data)
self.assertEqual(1, len(data['items']))
# simple verify of data
self.assertEqual(data['items'][0]['metadata']['name'], 'drycc')
def test_get_daemonset(self):
with self.assertRaises(
KubeHTTPException,
msg='failed to get Daemonset doesnotexist in Namespace drycc: 404 Not Found' # noqa
):
self.scheduler.daemonset.get('drycc', 'doesnotexist')
namespace = 'drycc'
name = 'drycc'
response = self.scheduler.daemonset.get(namespace, name)
data = response.json()
self.assertEqual(response.status_code, 200, data)
self.assertEqual(data['apiVersion'], 'apps/v1')
self.assertEqual(data['kind'], 'DaemonSet')
self.assertEqual(data['metadata']['name'], name)
def test_patch_daemonset(self):
namespace = 'drycc'
name = 'drycc'
manifest_affinity = {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [{
"matchExpressions": [{
"key": "kubernetes.io/hostname",
"operator": "In",
"values": [
"nohostname"
]
}]
}]
}
}
}
response = self.scheduler.daemonset.patch(
namespace,
name,
manifest={
"spec": {
"template": {
"spec": {
"affinity": manifest_affinity
}
}
}
},
)
affinity = response.json()["spec"]["template"]['spec']['affinity']
self.assertEqual(
affinity,
manifest_affinity
)