diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-11-17 18:23:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-11-17 18:23:19 +0000 |
commit | cc292bdd50b0b39ffcdfbe36b7309b02c07f0eb1 (patch) | |
tree | b97cdad2c080db9b8bd41ed9402082547661cdde | |
parent | 5652af648585817a5b4242c826d7be3b8af340f8 (diff) | |
parent | 9704b23fa89a27e2cf73e8433edca7e3a7ff8a16 (diff) |
Merge "Add negative tests for checking --to-revision arg for kubectl unroll undo daemonset/<name>"
-rw-r--r-- | fuel_ccp_tests/tests/system/test_daemonsets.py | 240 |
1 files changed, 239 insertions, 1 deletions
diff --git a/fuel_ccp_tests/tests/system/test_daemonsets.py b/fuel_ccp_tests/tests/system/test_daemonsets.py index 021a933..612d4ce 100644 --- a/fuel_ccp_tests/tests/system/test_daemonsets.py +++ b/fuel_ccp_tests/tests/system/test_daemonsets.py | |||
@@ -167,7 +167,7 @@ class TestDaemonsetsUpdates(): | |||
167 | start_time_after_rollout = self.get_nginx_pod_start_time(k8sclient) | 167 | start_time_after_rollout = self.get_nginx_pod_start_time(k8sclient) |
168 | 168 | ||
169 | assert start_time == start_time_after_rollout, ( | 169 | assert start_time == start_time_after_rollout, ( |
170 | "pod's restarted. pods start time before rollout: \n{} " | 170 | "pod's restarted. pods start time before rollout: \n{}\n " |
171 | "pods start time after rollout: \n{}".format( | 171 | "pods start time after rollout: \n{}".format( |
172 | start_time, | 172 | start_time, |
173 | start_time_after_rollout) | 173 | start_time_after_rollout) |
@@ -870,3 +870,241 @@ class TestDaemonsetsUpdates(): | |||
870 | show_step(6) | 870 | show_step(6) |
871 | self.check_rollout_skipping(k8sclient, config.k8s.kube_host, | 871 | self.check_rollout_skipping(k8sclient, config.k8s.kube_host, |
872 | underlay, revision=True) | 872 | underlay, revision=True) |
873 | |||
874 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) | ||
875 | @pytest.mark.fail_snapshot | ||
876 | @pytest.mark.snapshot_needed | ||
877 | def test_daemonset_rollout_revision_negative_1(self, underlay, k8scluster, | ||
878 | config, show_step): | ||
879 | """Test handling of negative values for --to-revision argument | ||
880 | for kubectl rollout undo daemonset/<name> | ||
881 | |||
882 | Scenario: | ||
883 | 1. Deploy k8s using fuel-ccp-installer | ||
884 | 2. Create a DaemonSet for nginx with image version 1_10 and | ||
885 | update strategy RollingUpdate | ||
886 | 3. Wait until nginx pods are created and become 'ready' | ||
887 | 4. Check that the image version in the nginx pods is 1_10 | ||
888 | Check that the image version in the nginx daemonset is 1_10 | ||
889 | 5. Rollback the nginx daemonset: | ||
890 | kubectl rollout undo daemonset/nginx --to-revision=-1 | ||
891 | Check that rollout was failed and pods were not restarted | ||
892 | Duration: 3000 seconds | ||
893 | """ | ||
894 | |||
895 | # STEP #1 | ||
896 | show_step(1) | ||
897 | k8sclient = k8scluster.api | ||
898 | assert k8sclient.nodes.list() is not None, "Can not get nodes list" | ||
899 | |||
900 | # STEP #2 | ||
901 | show_step(2) | ||
902 | nginx_spec = self.get_nginx_spec() | ||
903 | nginx_spec['spec']['template']['spec']['containers'][0][ | ||
904 | 'image'] = self.from_nginx_image | ||
905 | k8sclient.daemonsets.create(body=nginx_spec) | ||
906 | |||
907 | # STEP #3 | ||
908 | show_step(3) | ||
909 | time.sleep(3) | ||
910 | self.wait_nginx_pods_ready(k8sclient) | ||
911 | |||
912 | # STEP #4 | ||
913 | show_step(4) | ||
914 | self.check_nginx_pods_image(k8sclient, self.from_nginx_image) | ||
915 | self.check_nginx_ds_image(k8sclient, self.from_nginx_image) | ||
916 | |||
917 | # STEP #5 | ||
918 | show_step(5) | ||
919 | pods_start_time = self.get_nginx_pod_start_time(k8sclient) | ||
920 | |||
921 | cmd = "kubectl rollout undo daemonset/nginx --to-revision=-1" | ||
922 | underlay.check_call(cmd, expected=[1], host=config.k8s.kube_host) | ||
923 | |||
924 | pods_start_time_after_cmd = self.get_nginx_pod_start_time(k8sclient) | ||
925 | |||
926 | assert pods_start_time == pods_start_time_after_cmd, ( | ||
927 | "pod's restarted. pods start time before rollout: \n{}\n " | ||
928 | "pods start time after rollout: \n{}".format( | ||
929 | pods_start_time, | ||
930 | pods_start_time_after_cmd) | ||
931 | ) | ||
932 | |||
933 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) | ||
934 | @pytest.mark.fail_snapshot | ||
935 | @pytest.mark.snapshot_needed | ||
936 | def test_daemonset_rollout_revision_negative_2(self, underlay, k8scluster, | ||
937 | config, show_step): | ||
938 | """Test handling of negative values for --to-revision argument | ||
939 | for kubectl rollout undo daemonset/<name> | ||
940 | |||
941 | Scenario: | ||
942 | 1. Deploy k8s using fuel-ccp-installer | ||
943 | 2. Create a DaemonSet for nginx with image version 1_10 and | ||
944 | update strategy RollingUpdate | ||
945 | 3. Wait until nginx pods are created and become 'ready' | ||
946 | 4. Check that the image version in the nginx pods is 1_10 | ||
947 | Check that the image version in the nginx daemonset is 1_10 | ||
948 | 5. Rollback the nginx daemonset: | ||
949 | kubectl rollout undo daemonset/nginx --to-revision="invalid" | ||
950 | Check that rollout was failed and pods were not restarted | ||
951 | |||
952 | Duration: 3000 seconds | ||
953 | """ | ||
954 | |||
955 | # STEP #1 | ||
956 | show_step(1) | ||
957 | k8sclient = k8scluster.api | ||
958 | assert k8sclient.nodes.list() is not None, "Can not get nodes list" | ||
959 | |||
960 | # STEP #2 | ||
961 | show_step(2) | ||
962 | nginx_spec = self.get_nginx_spec() | ||
963 | nginx_spec['spec']['template']['spec']['containers'][0][ | ||
964 | 'image'] = self.from_nginx_image | ||
965 | k8sclient.daemonsets.create(body=nginx_spec) | ||
966 | |||
967 | # STEP #3 | ||
968 | show_step(3) | ||
969 | time.sleep(3) | ||
970 | self.wait_nginx_pods_ready(k8sclient) | ||
971 | |||
972 | # STEP #4 | ||
973 | show_step(4) | ||
974 | self.check_nginx_pods_image(k8sclient, self.from_nginx_image) | ||
975 | self.check_nginx_ds_image(k8sclient, self.from_nginx_image) | ||
976 | |||
977 | # STEP #5 | ||
978 | show_step(5) | ||
979 | pods_start_time = self.get_nginx_pod_start_time(k8sclient) | ||
980 | |||
981 | cmd = "kubectl rollout undo daemonset/nginx --to-revision='invalid'" | ||
982 | underlay.check_call(cmd, expected=[1], host=config.k8s.kube_host) | ||
983 | |||
984 | pods_start_time_after_cmd = self.get_nginx_pod_start_time(k8sclient) | ||
985 | |||
986 | assert pods_start_time == pods_start_time_after_cmd, ( | ||
987 | "pod's restarted. pods start time before rollout: \n{}\n " | ||
988 | "pods start time after rollout: \n{}".format( | ||
989 | pods_start_time, | ||
990 | pods_start_time_after_cmd) | ||
991 | ) | ||
992 | |||
993 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) | ||
994 | @pytest.mark.fail_snapshot | ||
995 | @pytest.mark.snapshot_needed | ||
996 | def test_daemonset_rollout_revision_negative_3(self, underlay, k8scluster, | ||
997 | config, show_step): | ||
998 | """Test handling of negative values for --to-revision argument | ||
999 | for kubectl rollout undo daemonset/<name> | ||
1000 | |||
1001 | Scenario: | ||
1002 | 1. Deploy k8s using fuel-ccp-installer | ||
1003 | 2. Create a DaemonSet for nginx with image version 1_10 and | ||
1004 | update strategy RollingUpdate | ||
1005 | 3. Wait until nginx pods are created and become 'ready' | ||
1006 | 4. Check that the image version in the nginx pods is 1_10 | ||
1007 | Check that the image version in the nginx daemonset is 1_10 | ||
1008 | 5. Rollback the nginx daemonset: | ||
1009 | kubectl rollout undo daemonset/nginx --to-revision=1.0 | ||
1010 | Check that rollout was failed and pods were not restarted | ||
1011 | Duration: 3000 seconds | ||
1012 | """ | ||
1013 | |||
1014 | # STEP #1 | ||
1015 | show_step(1) | ||
1016 | k8sclient = k8scluster.api | ||
1017 | assert k8sclient.nodes.list() is not None, "Can not get nodes list" | ||
1018 | |||
1019 | # STEP #2 | ||
1020 | show_step(2) | ||
1021 | nginx_spec = self.get_nginx_spec() | ||
1022 | nginx_spec['spec']['template']['spec']['containers'][0][ | ||
1023 | 'image'] = self.from_nginx_image | ||
1024 | k8sclient.daemonsets.create(body=nginx_spec) | ||
1025 | |||
1026 | # STEP #3 | ||
1027 | show_step(3) | ||
1028 | time.sleep(3) | ||
1029 | self.wait_nginx_pods_ready(k8sclient) | ||
1030 | |||
1031 | # STEP #4 | ||
1032 | show_step(4) | ||
1033 | self.check_nginx_pods_image(k8sclient, self.from_nginx_image) | ||
1034 | self.check_nginx_ds_image(k8sclient, self.from_nginx_image) | ||
1035 | |||
1036 | # STEP #5 | ||
1037 | show_step(5) | ||
1038 | pods_start_time = self.get_nginx_pod_start_time(k8sclient) | ||
1039 | |||
1040 | cmd = "kubectl rollout undo daemonset/nginx --to-revision=1.0" | ||
1041 | underlay.check_call(cmd, expected=[1], host=config.k8s.kube_host) | ||
1042 | |||
1043 | pods_start_time_after_cmd = self.get_nginx_pod_start_time(k8sclient) | ||
1044 | |||
1045 | assert pods_start_time == pods_start_time_after_cmd, ( | ||
1046 | "pod's restarted. pods start time before rollout: \n{}\n " | ||
1047 | "pods start time after rollout: \n{}".format( | ||
1048 | pods_start_time, | ||
1049 | pods_start_time_after_cmd) | ||
1050 | ) | ||
1051 | |||
1052 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed) | ||
1053 | @pytest.mark.fail_snapshot | ||
1054 | @pytest.mark.snapshot_needed | ||
1055 | def test_daemonset_rollout_revision_negative_4(self, underlay, k8scluster, | ||
1056 | config, show_step): | ||
1057 | """Test handling of negative values for --to-revision argument | ||
1058 | for kubectl rollout undo daemonset/<name> | ||
1059 | |||
1060 | Scenario: | ||
1061 | 1. Deploy k8s using fuel-ccp-installer | ||
1062 | 2. Create a DaemonSet for nginx with image version 1_10 and | ||
1063 | update strategy RollingUpdate | ||
1064 | 3. Wait until nginx pods are created and become 'ready' | ||
1065 | 4. Check that the image version in the nginx pods is 1_10 | ||
1066 | Check that the image version in the nginx daemonset is 1_10 | ||
1067 | 5. Rollback the nginx daemonset: | ||
1068 | kubectl rollout undo daemonset/nginx --to-revision=true | ||
1069 | Check that rollout was failed and pods were not restarted | ||
1070 | |||
1071 | Duration: 3000 seconds | ||
1072 | """ | ||
1073 | |||
1074 | # STEP #1 | ||
1075 | show_step(1) | ||
1076 | k8sclient = k8scluster.api | ||
1077 | assert k8sclient.nodes.list() is not None, "Can not get nodes list" | ||
1078 | |||
1079 | # STEP #2 | ||
1080 | show_step(2) | ||
1081 | nginx_spec = self.get_nginx_spec() | ||
1082 | nginx_spec['spec']['template']['spec']['containers'][0][ | ||
1083 | 'image'] = self.from_nginx_image | ||
1084 | k8sclient.daemonsets.create(body=nginx_spec) | ||
1085 | |||
1086 | # STEP #3 | ||
1087 | show_step(3) | ||
1088 | time.sleep(3) | ||
1089 | self.wait_nginx_pods_ready(k8sclient) | ||
1090 | |||
1091 | # STEP #4 | ||
1092 | show_step(4) | ||
1093 | self.check_nginx_pods_image(k8sclient, self.from_nginx_image) | ||
1094 | self.check_nginx_ds_image(k8sclient, self.from_nginx_image) | ||
1095 | |||
1096 | # STEP #5 | ||
1097 | show_step(5) | ||
1098 | pods_start_time = self.get_nginx_pod_start_time(k8sclient) | ||
1099 | |||
1100 | cmd = "kubectl rollout undo daemonset/nginx --to-revision=true" | ||
1101 | underlay.check_call(cmd, expected=[1], host=config.k8s.kube_host) | ||
1102 | |||
1103 | pods_start_time_after_cmd = self.get_nginx_pod_start_time(k8sclient) | ||
1104 | |||
1105 | assert pods_start_time == pods_start_time_after_cmd, ( | ||
1106 | "pod's restarted. pods start time before rollout: \n{}\n " | ||
1107 | "pods start time after rollout: \n{}".format( | ||
1108 | pods_start_time, | ||
1109 | pods_start_time_after_cmd) | ||
1110 | ) | ||