From b8de1f895be391ce6f951550a88a2e216ed4b56c Mon Sep 17 00:00:00 2001 From: MD NADEEM Date: Tue, 2 Aug 2016 11:16:42 +0530 Subject: [PATCH] Added Test case for env and volume comp Change-Id: Ie98072ded6fee96b4e8c43cfe5124ead8e73e885 Implements: blueprint ansible-unit-tests --- tests/test_kolla_docker.py | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index e200ea9aa1..57a885b969 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -628,3 +628,59 @@ class TestAttrComp(base.BaseTestCase): self.dw.check_image = mock.MagicMock(return_value=dict( Labels={'kolla_version': '1.0.1'})) self.assertTrue(self.dw.compare_labels(container_info)) + + def test_compare_volumes_from_neg(self): + container_info = {'HostConfig': dict(VolumesFrom=['777f7dc92da7'])} + self.dw = get_DockerWorker({'volumes_from': ['777f7dc92da7']}) + + self.assertFalse(self.dw.compare_volumes_from(container_info)) + + def test_compare_volumes_from_post(self): + container_info = {'HostConfig': dict(VolumesFrom=['777f7dc92da7'])} + self.dw = get_DockerWorker({'volumes_from': ['ba8c0c54f0f2']}) + + self.assertTrue(self.dw.compare_volumes_from(container_info)) + + def test_compare_volumes_neg(self): + container_info = { + 'Config': dict(Volumes=['/var/log/kolla/']), + 'HostConfig': dict(Binds=['kolla_logs:/var/log/kolla/:rw'])} + self.dw = get_DockerWorker( + {'volumes': ['kolla_logs:/var/log/kolla/:rw']}) + + self.assertFalse(self.dw.compare_volumes(container_info)) + + def test_compare_volumes_pos(self): + container_info = { + 'Config': dict(Volumes=['/var/log/kolla/']), + 'HostConfig': dict(Binds=['kolla_logs:/var/log/kolla/:rw'])} + self.dw = get_DockerWorker( + {'volumes': ['/dev/:/dev/:rw']}) + + self.assertTrue(self.dw.compare_volumes(container_info)) + + def test_compare_environment_neg(self): + container_info = {'Config': dict( + Env=['KOLLA_CONFIG_STRATEGY=COPY_ALWAYS', + 'KOLLA_BASE_DISTRO=ubuntu', + 'KOLLA_INSTALL_TYPE=binary'] + )} + self.dw = get_DockerWorker({ + 'environment': dict(KOLLA_CONFIG_STRATEGY='COPY_ALWAYS', + KOLLA_BASE_DISTRO='ubuntu', + KOLLA_INSTALL_TYPE='binary')}) + + self.assertFalse(self.dw.compare_environment(container_info)) + + def test_compare_environment_pos(self): + container_info = {'Config': dict( + Env=['KOLLA_CONFIG_STRATEGY=COPY_ALWAYS', + 'KOLLA_BASE_DISTRO=ubuntu', + 'KOLLA_INSTALL_TYPE=binary'] + )} + self.dw = get_DockerWorker({ + 'environment': dict(KOLLA_CONFIG_STRATEGY='COPY_ALWAYS', + KOLLA_BASE_DISTRO='centos', + KOLLA_INSTALL_TYPE='binary')}) + + self.assertTrue(self.dw.compare_environment(container_info))