diff options
| author | Radosław Piliszek <radoslaw.piliszek@gmail.com> | 2020-04-27 10:40:15 +0200 |
|---|---|---|
| committer | Radosław Piliszek <radoslaw.piliszek@gmail.com> | 2020-10-04 16:58:24 +0200 |
| commit | c2d0bf30ea0718f0f415af6b6b7dfc232b6e4706 (patch) | |
| tree | fb4977c4607f1b0a163ed53e9d5a8f67997b14bb /tests | |
| parent | 4c4ad2b87bb53e127422e449c72dd2923a7049e2 (diff) | |
| download | kolla-ansible-c2d0bf30ea0718f0f415af6b6b7dfc232b6e4706.tar.gz kolla-ansible-c2d0bf30ea0718f0f415af6b6b7dfc232b6e4706.zip | |
Coordinate haproxy and keepalived restarts
Keepalived and haproxy cooperate to provide control plane HA in
kolla-ansible deployments.
Certain care should be exerted to avoid prolonged availability
loss during reconfigurations and upgrades.
This patch aims to provide this care.
There is nothing special about keepalived upgrade compared to
reconfig, hence it is simplified to run the same code as for
deploy.
The broken logic of safe upgrade is replaced by common handler
code which's goal is to ensure we down current master only after
we have backups ready.
This change introduces a switch to kolla_docker module that allows
to ignore missing containers (as they are logically stopped).
ignore_missing is the switch's name.
All tests are included.
Change-Id: I22ddec5f7ee4a7d3d502649a158a7e005fe29c48
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_kolla_docker.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index fae1898be..c8dca3572 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -94,6 +94,7 @@ class ModuleArgsTest(base.BaseTestCase): tty=dict(required=False, type='bool', default=False), client_timeout=dict(required=False, type='int', default=120), healthcheck=dict(required=False, type='dict'), + ignore_missing=dict(required=False, type='bool', default=False), ) required_if = [ ['action', 'pull_image', ['image']], @@ -175,7 +176,15 @@ FAKE_DATA = { 'Image': 'myregistrydomain.com:5000/ubuntu:16.04', 'ImageID': 'sha256:c5f1cf30', 'Labels': {}, - 'Names': '/my_container'} + 'Names': '/my_container'}, + {'Created': 1463578195, + 'Status': 'Exited (0) 2 hours ago', + 'HostConfig': {'NetworkMode': 'default'}, + 'Id': 'e40d8e7188', + 'Image': 'myregistrydomain.com:5000/ubuntu:16.04', + 'ImageID': 'sha256:c5f1cf30', + 'Labels': {}, + 'Names': '/exited_container'}, ], 'container_inspect': { @@ -396,6 +405,18 @@ class TestContainer(base.BaseTestCase): self.assertTrue(self.dw.changed) self.dw.dc.containers.assert_called_once_with(all=True) self.dw.dc.stop.assert_called_once_with('my_container', timeout=10) + self.dw.module.fail_json.assert_not_called() + + def test_stop_container_already_stopped(self): + self.dw = get_DockerWorker({'name': 'exited_container', + 'action': 'stop_container'}) + self.dw.dc.containers.return_value = self.fake_data['containers'] + self.dw.stop_container() + + self.assertFalse(self.dw.changed) + self.dw.dc.containers.assert_called_once_with(all=True) + self.dw.module.fail_json.assert_not_called() + self.dw.dc.stop.assert_not_called() def test_stop_container_not_exists(self): self.dw = get_DockerWorker({'name': 'fake_container', @@ -405,9 +426,22 @@ class TestContainer(base.BaseTestCase): self.assertFalse(self.dw.changed) self.dw.dc.containers.assert_called_once_with(all=True) + self.dw.dc.stop.assert_not_called() self.dw.module.fail_json.assert_called_once_with( msg="No such container: fake_container to stop") + def test_stop_container_not_exists_ignore_missing(self): + self.dw = get_DockerWorker({'name': 'fake_container', + 'action': 'stop_container', + 'ignore_missing': True}) + self.dw.dc.containers.return_value = self.fake_data['containers'] + self.dw.stop_container() + + self.assertFalse(self.dw.changed) + self.dw.dc.containers.assert_called_once_with(all=True) + self.dw.dc.stop.assert_not_called() + self.dw.module.fail_json.assert_not_called() + def test_stop_and_remove_container(self): self.dw = get_DockerWorker({'name': 'my_container', 'action': 'stop_and_remove_container'}) |
