summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Grechanichenko <agrechanichenko@mirantis.com>2016-10-26 13:16:11 +0300
committerArtem Grechanichenko <agrechanichenko@mirantis.com>2016-10-26 16:33:29 +0000
commitde0f5deced1841520437859c519989b68be6bc4d (patch)
tree7374240f7b166642fc52e52bd1730e82c6947bf5
parenta1f1304fba7e1c053c6d919d29c69c96fee198fd (diff)
Test rollout skipping
Notes
Notes (review): Verified+1: Mirantis CCP CI <mirantis-fuel-ccp-ci@mirantis.com> Code-Review+1: tatyana-leontovich <tleontovich@mirantis.com> Code-Review+2: Dennis Dmitriev <ddmitriev@mirantis.com> Workflow+1: Dennis Dmitriev <ddmitriev@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 17 Nov 2016 18:21:05 +0000 Reviewed-on: https://review.openstack.org/390813 Project: openstack/fuel-ccp-tests Branch: refs/heads/master
-rw-r--r--fuel_ccp_tests/tests/system/test_daemonsets.py136
1 files changed, 136 insertions, 0 deletions
diff --git a/fuel_ccp_tests/tests/system/test_daemonsets.py b/fuel_ccp_tests/tests/system/test_daemonsets.py
index 3a0c062..021a933 100644
--- a/fuel_ccp_tests/tests/system/test_daemonsets.py
+++ b/fuel_ccp_tests/tests/system/test_daemonsets.py
@@ -136,6 +136,43 @@ class TestDaemonsetsUpdates():
136 "revision {0} has image {1} while expected {2}".format( 136 "revision {0} has image {1} while expected {2}".format(
137 revision, nginx_revision_image, nginx_image)) 137 revision, nginx_revision_image, nginx_image))
138 138
139 def get_nginx_pod_start_time(self, k8sclient):
140 start_time = {}
141 for pod in self.get_nginx_pods(k8sclient):
142 start_time[pod.name] = pod.status._container_statuses[
143 0].state.running.started_at
144 return start_time
145
146 def check_rollout_skipping(self, k8sclient,
147 config, underlay, revision=None):
148
149 # collect pods start time
150 start_time = self.get_nginx_pod_start_time(k8sclient)
151
152 # try to rollout
153 if revision:
154 cmd = "kubectl rollout undo daemonset/nginx --to-revision=0"
155 else:
156 cmd = "kubectl rollout undo daemonset/nginx"
157 stdout = underlay.check_call(cmd, host=config)['stdout_str']
158 warning_message = 'daemonset "nginx" skipped rollback ' \
159 '(DaemonRollbackRevisionNotFound: ' \
160 'Unable to find last revision.)'
161 assert stdout == warning_message, (
162 "wrong warning message: \n{}. Expected: \n{}".format(
163 stdout, warning_message))
164
165 # check that pods start time don't changed
166 # collect pods start time
167 start_time_after_rollout = self.get_nginx_pod_start_time(k8sclient)
168
169 assert start_time == start_time_after_rollout, (
170 "pod's restarted. pods start time before rollout: \n{} "
171 "pods start time after rollout: \n{}".format(
172 start_time,
173 start_time_after_rollout)
174 )
175
139 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) 176 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
140 @pytest.mark.fail_snapshot 177 @pytest.mark.fail_snapshot
141 @pytest.mark.snapshot_needed 178 @pytest.mark.snapshot_needed
@@ -734,3 +771,102 @@ class TestDaemonsetsUpdates():
734 self.from_nginx_image), 771 self.from_nginx_image),
735 timeout=2 * 60 772 timeout=2 * 60
736 ) 773 )
774
775 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
776 @pytest.mark.fail_snapshot
777 @pytest.mark.snapshot_needed
778 def test_daemonset_skip_rollout(self, underlay, k8scluster,
779 config, show_step):
780 """Testing of skipping rollout for a daemonset
781 using updateStrategy type: RollingUpdate if no updates after initial
782 daemonset creacting
783
784 Scenario:
785 1. Deploy k8s using fuel-ccp-installer
786 2. Create a DaemonSet for nginx with image version 1_10 and
787 update strategy RollingUpdate
788 3. Wait until nginx pods are created and become 'ready'
789 4. Check that the image version in the nginx pods is 1_10
790 Check that the image version in the nginx daemonset is 1_10
791 5. Rollback the nginx daemonset:
792 kubectl rollout undo daemonset/nginx
793 6. Check that rollout was skipped and pods were not restarted
794 Duration: 3000 seconds
795 """
796
797 # STEP #1
798 show_step(1)
799 k8sclient = k8scluster.api
800 assert k8sclient.nodes.list() is not None, "Can not get nodes list"
801
802 # STEP #2
803 show_step(2)
804 nginx_spec = self.get_nginx_spec()
805 nginx_spec['spec']['template']['spec']['containers'][0][
806 'image'] = self.from_nginx_image
807 k8sclient.daemonsets.create(body=nginx_spec)
808
809 # STEP #3
810 show_step(3)
811 time.sleep(3)
812 self.wait_nginx_pods_ready(k8sclient)
813
814 # STEP #4
815 show_step(4)
816 self.check_nginx_pods_image(k8sclient, self.from_nginx_image)
817 self.check_nginx_ds_image(k8sclient, self.from_nginx_image)
818
819 # STEP #5,6
820 show_step(5)
821 show_step(6)
822 self.check_rollout_skipping(k8sclient, config.k8s.kube_host, underlay)
823
824 @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
825 @pytest.mark.fail_snapshot
826 @pytest.mark.snapshot_needed
827 def test_daemonset_skip_rollout_revision(self, underlay, k8scluster,
828 config, show_step):
829 """Testing of skipping rollout for a daemonset
830 using updateStrategy type: RollingUpdate if no updates after initial
831 daemonset creacting
832
833 Scenario:
834 1. Deploy k8s using fuel-ccp-installer
835 2. Create a DaemonSet for nginx with image version 1_10 and
836 update strategy RollingUpdate
837 3. Wait until nginx pods are created and become 'ready'
838 4. Check that the image version in the nginx pods is 1_10
839 Check that the image version in the nginx daemonset is 1_10
840 5. Rollback the nginx daemonset:
841 kubectl rollout undo daemonset/nginx --to-revision
842 6. Check that rollout was skipped and pods were not restarted
843 Duration: 3000 seconds
844 """
845
846 # STEP #1
847 show_step(1)
848 k8sclient = k8scluster.api
849 assert k8sclient.nodes.list() is not None, "Can not get nodes list"
850
851 # STEP #2
852 show_step(2)
853 nginx_spec = self.get_nginx_spec()
854 nginx_spec['spec']['template']['spec']['containers'][0][
855 'image'] = self.from_nginx_image
856 k8sclient.daemonsets.create(body=nginx_spec)
857
858 # STEP #3
859 show_step(3)
860 time.sleep(3)
861 self.wait_nginx_pods_ready(k8sclient)
862
863 # STEP #4
864 show_step(4)
865 self.check_nginx_pods_image(k8sclient, self.from_nginx_image)
866 self.check_nginx_ds_image(k8sclient, self.from_nginx_image)
867
868 # STEP #5,6
869 show_step(5)
870 show_step(6)
871 self.check_rollout_skipping(k8sclient, config.k8s.kube_host,
872 underlay, revision=True)