summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-26 12:14:05 +0000
committerGerrit Code Review <review@openstack.org>2016-10-26 12:14:05 +0000
commitf5ffd8653c24f95580820a622b61de76ee5dd997 (patch)
tree47e90e6f4c538341cd210206fe771596a55bd099
parentd2864ee6307aed411a73ff2ab712f83400592087 (diff)
parentee7412e75439e9f2cd5240cdaff20bfd74ef7ad5 (diff)
Merge "Update a daemonset using updateStrategy type: RollingUpdate"
-rw-r--r--fuel_ccp_tests/tests/system/test_daemonsets.py102
1 files changed, 98 insertions, 4 deletions
diff --git a/fuel_ccp_tests/tests/system/test_daemonsets.py b/fuel_ccp_tests/tests/system/test_daemonsets.py
index f98ec49..bfb321c 100644
--- a/fuel_ccp_tests/tests/system/test_daemonsets.py
+++ b/fuel_ccp_tests/tests/system/test_daemonsets.py
@@ -30,6 +30,9 @@ class TestDaemonsetsUpdates():
30 to_nginx_image = 'nginx:1.11' 30 to_nginx_image = 'nginx:1.11'
31 31
32 def get_nginx_spec(self): 32 def get_nginx_spec(self):
33 """Create specification for DaemonSet with Nginx containers
34 :return: nested dict
35 """
33 return { 36 return {
34 'apiVersion': 'extensions/v1beta1', 37 'apiVersion': 'extensions/v1beta1',
35 'kind': 'DaemonSet', 38 'kind': 'DaemonSet',
@@ -56,23 +59,37 @@ class TestDaemonsetsUpdates():
56 } 59 }
57 60
58 def get_nginx_pods(self, k8sclient): 61 def get_nginx_pods(self, k8sclient):
62 """Return the nginx pods
63 :param: k8sclient: kubernetes api client
64 :return: list of pods with nginx containers
65 """
59 spec = self.get_nginx_spec() 66 spec = self.get_nginx_spec()
60 return [x for x in k8sclient.pods.list() 67 return [x for x in k8sclient.pods.list()
61 if spec['metadata']['name'] in x.name] 68 if spec['metadata']['name'] in x.name]
62 69
63 def get_nginx_ds(self, k8sclient): 70 def get_nginx_ds(self, k8sclient):
71 """Return the nginx DaemonSets
72 :param k8sclient: kubernetes api client
73 :return: list of DaemonSets with pods with nginx containers
74 """
64 spec = self.get_nginx_spec() 75 spec = self.get_nginx_spec()
65 return [x for x in k8sclient.daemonsets.list() 76 return [x for x in k8sclient.daemonsets.list()
66 if spec['metadata']['name'] in x.name] 77 if spec['metadata']['name'] in x.name]
67 78
68 def wait_nginx_pods_ready(self, k8sclient): 79 def wait_nginx_pods_ready(self, k8sclient):
69 """Wait until the nginx pods are ready""" 80 """Wait until the nginx pods are ready
81 :param: k8sclient: kubernetes api client
82 :return: None
83 """
70 nginx_pods = self.get_nginx_pods(k8sclient) 84 nginx_pods = self.get_nginx_pods(k8sclient)
71 for pod in nginx_pods: 85 for pod in nginx_pods:
72 pod.wait_running(timeout=60) 86 pod.wait_running(timeout=60)
73 87
74 def delete_nginx_pods(self, k8sclient): 88 def delete_nginx_pods(self, k8sclient):
75 """Delete the nginx pods""" 89 """Delete the nginx pods
90 :param: k8sclient: kubernetes api client
91 :return: None
92 """
76 nginx_pods = self.get_nginx_pods(k8sclient) 93 nginx_pods = self.get_nginx_pods(k8sclient)
77 for pod in nginx_pods: 94 for pod in nginx_pods:
78 k8sclient.pods.delete(body=pod.spec, name=pod.name) 95 k8sclient.pods.delete(body=pod.spec, name=pod.name)
@@ -80,6 +97,11 @@ class TestDaemonsetsUpdates():
80 x.name for x in self.get_nginx_pods(k8sclient)]) 97 x.name for x in self.get_nginx_pods(k8sclient)])
81 98
82 def check_nginx_pods_image(self, k8sclient, nginx_image): 99 def check_nginx_pods_image(self, k8sclient, nginx_image):
100 """Check nginx pods image version
101 :param: k8sclient: kubernetes api client,
102 :param: nginx_image: version of nginx_image to compare
103 :return: None
104 """
83 nginx_pods = self.get_nginx_pods(k8sclient) 105 nginx_pods = self.get_nginx_pods(k8sclient)
84 for pod in nginx_pods: 106 for pod in nginx_pods:
85 pod_image = pod.status.container_statuses[0].image 107 pod_image = pod.status.container_statuses[0].image
@@ -88,6 +110,11 @@ class TestDaemonsetsUpdates():
88 .format(pod.name, pod_image, nginx_image)) 110 .format(pod.name, pod_image, nginx_image))
89 111
90 def check_nginx_ds_image(self, k8sclient, nginx_image): 112 def check_nginx_ds_image(self, k8sclient, nginx_image):
113 """Check nginx DaemonSets version
114 :param: k8sclient: kubernetes api client,
115 :param: nginx_image: version of nginx_image to compare
116 :return: None
117 """
91 nginx_daemonsets = self.get_nginx_ds(k8sclient) 118 nginx_daemonsets = self.get_nginx_ds(k8sclient)
92 for nginx_ds in nginx_daemonsets: 119 for nginx_ds in nginx_daemonsets:
93 nginx_ds_image = nginx_ds.spec.template.spec.containers[0].image 120 nginx_ds_image = nginx_ds.spec.template.spec.containers[0].image
@@ -98,8 +125,7 @@ class TestDaemonsetsUpdates():
98 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) 125 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
99 @pytest.mark.fail_snapshot 126 @pytest.mark.fail_snapshot
100 @pytest.mark.snapshot_needed 127 @pytest.mark.snapshot_needed
101 def test_daemonset_rollingupdate_noop(self, underlay, k8scluster, config, 128 def test_daemonset_rollingupdate_noop(self, k8scluster, show_step):
102 show_step):
103 """Update a daemonset using updateStrategy type: Noop 129 """Update a daemonset using updateStrategy type: Noop
104 130
105 Scenario: 131 Scenario:
@@ -176,3 +202,71 @@ class TestDaemonsetsUpdates():
176 show_step(10) 202 show_step(10)
177 # Pods should have the new image version 203 # Pods should have the new image version
178 self.check_nginx_pods_image(k8sclient, self.to_nginx_image) 204 self.check_nginx_pods_image(k8sclient, self.to_nginx_image)
205
206 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
207 @pytest.mark.fail_snapshot
208 @pytest.mark.snapshot_needed
209 def test_daemonset_rollingupdate(self, k8scluster, show_step):
210 """Update a daemonset using updateStrategy type: RollingUpdate
211
212 Scenario:
213 1. Deploy k8s using fuel-ccp-installer
214 2. Create a DaemonSet for nginx with image version 1_10 and
215 update strategy RollingUpdate
216 3. Wait until nginx pods are created and become 'ready'
217 4. Check that the image version in the nginx pods is 1_10
218 Check that the image version in the nginx daemonset is 1_10
219 5. Change nginx image version to 1_11 using YAML
220 6. Wait for 10 seconds (needs to check that there were
221 no auto updates of the nginx pods)
222 7. Check that the image version in the nginx daemonset
223 is updated to 1_11
224 Wait for ~120 sec that the image version in the nginx pods
225 is changed to 1_11
226
227 Duration: 3000 seconds
228 """
229
230 # STEP #1
231 show_step(1)
232 k8sclient = k8scluster.api
233 assert k8sclient.nodes.list() is not None, "Can not get nodes list"
234
235 # STEP #2
236 show_step(2)
237 nginx_spec = self.get_nginx_spec()
238 nginx_spec['spec']['template']['spec']['containers'][0][
239 'image'] = self.from_nginx_image
240 k8sclient.daemonsets.create(body=nginx_spec)
241
242 # STEP #3
243 show_step(3)
244 time.sleep(3)
245 self.wait_nginx_pods_ready(k8sclient)
246
247 # STEP #4
248 show_step(4)
249 self.check_nginx_pods_image(k8sclient, self.from_nginx_image)
250 self.check_nginx_ds_image(k8sclient, self.from_nginx_image)
251
252 # STEP #5
253 show_step(5)
254 nginx_spec['spec']['template']['spec']['containers'][0][
255 'image'] = self.to_nginx_image
256 k8sclient.daemonsets.update(body=nginx_spec,
257 name=nginx_spec['metadata']['name'])
258
259 # STEP #6
260 show_step(6)
261 time.sleep(10)
262
263 # STEP #7
264 show_step(7)
265 # DaemonSet should have new image version
266 self.check_nginx_ds_image(k8sclient, self.to_nginx_image)
267 # Pods should have new image version
268 helpers.wait_pass(
269 lambda: self.check_nginx_pods_image(
270 k8sclient,
271 self.to_nginx_image),
272 timeout=2 * 60)