aboutsummaryrefslogtreecommitdiff
path: root/tests/kolla_container_tests
diff options
context:
space:
mode:
authorIvan Halomi <ivan.halomi@tietoevry.com>2024-07-02 13:52:42 +0200
committerIvan Halomi <ivan.halomi@tietoevry.com>2024-07-08 08:52:44 +0200
commit59bebd41eb768653f8bbccab0df46da3eac5c47c (patch)
tree91ac786dd4b09db05e4a04113fd9e0f4438e5a4b /tests/kolla_container_tests
parent4ed5f7537ddaa515fe00a4caaea8750f5d7cb419 (diff)
downloadkolla-ansible-59bebd41eb768653f8bbccab0df46da3eac5c47c.tar.gz
kolla-ansible-59bebd41eb768653f8bbccab0df46da3eac5c47c.zip
Fix podman healtcheck when not enabled
There was a bug where setting the test command for the health check to 'NONE' would throw an error in podman_worker. This was problematic since K-A uses 'NONE' as an indicator that the health check is not enabled. Closes-Bug: #2071912 Change-Id: I3140bb79eace58b23f579be3da569c502c52c38c Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com>
Diffstat (limited to 'tests/kolla_container_tests')
-rw-r--r--tests/kolla_container_tests/test_docker_worker.py15
-rw-r--r--tests/kolla_container_tests/test_podman_worker.py12
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/kolla_container_tests/test_docker_worker.py b/tests/kolla_container_tests/test_docker_worker.py
index 021bdf7e6..e6e6f0de2 100644
--- a/tests/kolla_container_tests/test_docker_worker.py
+++ b/tests/kolla_container_tests/test_docker_worker.py
@@ -365,6 +365,21 @@ class TestContainer(base.BaseTestCase):
self.dw.dc.create_container.assert_called_once_with(
**{k: self.fake_data['params'][k] for k in expected_args})
+ def test_create_container_with_None_healthcheck(self):
+ self.fake_data['params']['healthcheck'] = \
+ {'test': ['NONE']}
+ self.dw = get_DockerWorker(self.fake_data['params'])
+ self.dw.dc.create_host_config = mock.MagicMock(
+ return_value=self.fake_data['params']['host_config'])
+ self.dw.create_container()
+ inject_env_when_create_container(self.fake_data['params'])
+ self.assertTrue(self.dw.changed)
+ expected_args = {'command', 'detach', 'environment', 'host_config',
+ 'image', 'labels', 'name', 'tty',
+ 'volumes'}
+ self.dw.dc.create_container.assert_called_once_with(
+ **{k: self.fake_data['params'][k] for k in expected_args})
+
def test_create_container_with_tmpfs(self):
self.fake_data['params']['tmpfs'] = ['/tmp'] # nosec: B108
self.dw = get_DockerWorker(self.fake_data['params'])
diff --git a/tests/kolla_container_tests/test_podman_worker.py b/tests/kolla_container_tests/test_podman_worker.py
index e1fd358a8..60691b1a2 100644
--- a/tests/kolla_container_tests/test_podman_worker.py
+++ b/tests/kolla_container_tests/test_podman_worker.py
@@ -246,6 +246,18 @@ class TestContainer(base.BaseTestCase):
self.assertIsNotNone(hc_call)
self.assertEqual(hc, hc_call)
+ def test_create_container_with_None_healthcheck(self):
+ hc = {'test': ['NONE']}
+ self.fake_data['params']['healthcheck'] = hc
+ self.pw = get_PodmanWorker(self.fake_data['params'].copy())
+
+ self.pw.create_container()
+ self.assertTrue(self.pw.changed)
+ podman_create_kwargs = self.pw.pc.containers.create.call_args.kwargs
+ hc_call = podman_create_kwargs.get('healthcheck', None)
+ self.pw.pc.containers.create.assert_called_once()
+ self.assertIsNone(hc_call)
+
@unittest.skip("Skipping because tmpfs is currently"
" not supported by podman API.")
def test_create_container_with_tmpfs(self):