Test rollout skipping
Change-Id: Iff0eef8115486d98013009d2d35e07a259142f03
This commit is contained in:
parent
a1f1304fba
commit
de0f5deced
|
@ -136,6 +136,43 @@ class TestDaemonsetsUpdates():
|
|||
"revision {0} has image {1} while expected {2}".format(
|
||||
revision, nginx_revision_image, nginx_image))
|
||||
|
||||
def get_nginx_pod_start_time(self, k8sclient):
|
||||
start_time = {}
|
||||
for pod in self.get_nginx_pods(k8sclient):
|
||||
start_time[pod.name] = pod.status._container_statuses[
|
||||
0].state.running.started_at
|
||||
return start_time
|
||||
|
||||
def check_rollout_skipping(self, k8sclient,
|
||||
config, underlay, revision=None):
|
||||
|
||||
# collect pods start time
|
||||
start_time = self.get_nginx_pod_start_time(k8sclient)
|
||||
|
||||
# try to rollout
|
||||
if revision:
|
||||
cmd = "kubectl rollout undo daemonset/nginx --to-revision=0"
|
||||
else:
|
||||
cmd = "kubectl rollout undo daemonset/nginx"
|
||||
stdout = underlay.check_call(cmd, host=config)['stdout_str']
|
||||
warning_message = 'daemonset "nginx" skipped rollback ' \
|
||||
'(DaemonRollbackRevisionNotFound: ' \
|
||||
'Unable to find last revision.)'
|
||||
assert stdout == warning_message, (
|
||||
"wrong warning message: \n{}. Expected: \n{}".format(
|
||||
stdout, warning_message))
|
||||
|
||||
# check that pods start time don't changed
|
||||
# collect pods start time
|
||||
start_time_after_rollout = self.get_nginx_pod_start_time(k8sclient)
|
||||
|
||||
assert start_time == start_time_after_rollout, (
|
||||
"pod's restarted. pods start time before rollout: \n{} "
|
||||
"pods start time after rollout: \n{}".format(
|
||||
start_time,
|
||||
start_time_after_rollout)
|
||||
)
|
||||
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
|
||||
@pytest.mark.fail_snapshot
|
||||
@pytest.mark.snapshot_needed
|
||||
|
@ -734,3 +771,102 @@ class TestDaemonsetsUpdates():
|
|||
self.from_nginx_image),
|
||||
timeout=2 * 60
|
||||
)
|
||||
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
|
||||
@pytest.mark.fail_snapshot
|
||||
@pytest.mark.snapshot_needed
|
||||
def test_daemonset_skip_rollout(self, underlay, k8scluster,
|
||||
config, show_step):
|
||||
"""Testing of skipping rollout for a daemonset
|
||||
using updateStrategy type: RollingUpdate if no updates after initial
|
||||
daemonset creacting
|
||||
|
||||
Scenario:
|
||||
1. Deploy k8s using fuel-ccp-installer
|
||||
2. Create a DaemonSet for nginx with image version 1_10 and
|
||||
update strategy RollingUpdate
|
||||
3. Wait until nginx pods are created and become 'ready'
|
||||
4. Check that the image version in the nginx pods is 1_10
|
||||
Check that the image version in the nginx daemonset is 1_10
|
||||
5. Rollback the nginx daemonset:
|
||||
kubectl rollout undo daemonset/nginx
|
||||
6. Check that rollout was skipped and pods were not restarted
|
||||
Duration: 3000 seconds
|
||||
"""
|
||||
|
||||
# STEP #1
|
||||
show_step(1)
|
||||
k8sclient = k8scluster.api
|
||||
assert k8sclient.nodes.list() is not None, "Can not get nodes list"
|
||||
|
||||
# STEP #2
|
||||
show_step(2)
|
||||
nginx_spec = self.get_nginx_spec()
|
||||
nginx_spec['spec']['template']['spec']['containers'][0][
|
||||
'image'] = self.from_nginx_image
|
||||
k8sclient.daemonsets.create(body=nginx_spec)
|
||||
|
||||
# STEP #3
|
||||
show_step(3)
|
||||
time.sleep(3)
|
||||
self.wait_nginx_pods_ready(k8sclient)
|
||||
|
||||
# STEP #4
|
||||
show_step(4)
|
||||
self.check_nginx_pods_image(k8sclient, self.from_nginx_image)
|
||||
self.check_nginx_ds_image(k8sclient, self.from_nginx_image)
|
||||
|
||||
# STEP #5,6
|
||||
show_step(5)
|
||||
show_step(6)
|
||||
self.check_rollout_skipping(k8sclient, config.k8s.kube_host, underlay)
|
||||
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
|
||||
@pytest.mark.fail_snapshot
|
||||
@pytest.mark.snapshot_needed
|
||||
def test_daemonset_skip_rollout_revision(self, underlay, k8scluster,
|
||||
config, show_step):
|
||||
"""Testing of skipping rollout for a daemonset
|
||||
using updateStrategy type: RollingUpdate if no updates after initial
|
||||
daemonset creacting
|
||||
|
||||
Scenario:
|
||||
1. Deploy k8s using fuel-ccp-installer
|
||||
2. Create a DaemonSet for nginx with image version 1_10 and
|
||||
update strategy RollingUpdate
|
||||
3. Wait until nginx pods are created and become 'ready'
|
||||
4. Check that the image version in the nginx pods is 1_10
|
||||
Check that the image version in the nginx daemonset is 1_10
|
||||
5. Rollback the nginx daemonset:
|
||||
kubectl rollout undo daemonset/nginx --to-revision
|
||||
6. Check that rollout was skipped and pods were not restarted
|
||||
Duration: 3000 seconds
|
||||
"""
|
||||
|
||||
# STEP #1
|
||||
show_step(1)
|
||||
k8sclient = k8scluster.api
|
||||
assert k8sclient.nodes.list() is not None, "Can not get nodes list"
|
||||
|
||||
# STEP #2
|
||||
show_step(2)
|
||||
nginx_spec = self.get_nginx_spec()
|
||||
nginx_spec['spec']['template']['spec']['containers'][0][
|
||||
'image'] = self.from_nginx_image
|
||||
k8sclient.daemonsets.create(body=nginx_spec)
|
||||
|
||||
# STEP #3
|
||||
show_step(3)
|
||||
time.sleep(3)
|
||||
self.wait_nginx_pods_ready(k8sclient)
|
||||
|
||||
# STEP #4
|
||||
show_step(4)
|
||||
self.check_nginx_pods_image(k8sclient, self.from_nginx_image)
|
||||
self.check_nginx_ds_image(k8sclient, self.from_nginx_image)
|
||||
|
||||
# STEP #5,6
|
||||
show_step(5)
|
||||
show_step(6)
|
||||
self.check_rollout_skipping(k8sclient, config.k8s.kube_host,
|
||||
underlay, revision=True)
|
||||
|
|
Loading…
Reference in New Issue