diff --git a/kolla/image/build.py b/kolla/image/build.py index b400dbf9a4..4f10a75d7a 100644 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -868,7 +868,7 @@ class KollaWorker(object): return def list_children(images, ancestry): - children = six.next(ancestry.values()) + children = six.next(iter(ancestry.values())) for image in images: if image.status not in [STATUS_MATCHED]: continue diff --git a/kolla/tests/etc/default.conf b/kolla/tests/etc/default.conf index 933e1f8c4b..214ca8841a 100644 --- a/kolla/tests/etc/default.conf +++ b/kolla/tests/etc/default.conf @@ -8,3 +8,4 @@ type = git [profiles] default = image-base +all = image-base,image-child diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index e769259602..515aa1ddd7 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -21,9 +21,14 @@ from kolla.image import build from kolla.tests import base -FAKE_IMAGE = build.Image('image-base', 'image-base:latest', - '/fake/path', parent_name=None, - parent=None, status=build.STATUS_MATCHED) +FAKE_IMAGE = build.Image( + 'image-base', 'image-base:latest', + '/fake/path', parent_name=None, + parent=None, status=build.STATUS_MATCHED) +FAKE_IMAGE_CHILD = build.Image( + 'image-child', 'image-child:latest', + '/fake/path2', parent_name='image-base', + parent=FAKE_IMAGE, status=build.STATUS_MATCHED) class TasksTest(base.TestCase): @@ -142,7 +147,9 @@ class KollaWorkerTest(base.TestCase): super(KollaWorkerTest, self).setUp() image = FAKE_IMAGE.copy() image.status = None - self.images = [image] + image_child = FAKE_IMAGE_CHILD.copy() + image_child.status = None + self.images = [image, image_child] def test_supported_base_type(self): rh_base = ['fedora', 'centos', 'oraclelinux', 'rhel'] @@ -197,7 +204,7 @@ class KollaWorkerTest(base.TestCase): kolla.images = self.images kolla.filter_images() - self.assertEqual(1, len(self._get_matched_images(kolla.images))) + self.assertEqual(2, len(self._get_matched_images(kolla.images))) def test_pre_defined_exist_profile(self): # default profile include the fake image: image-base @@ -225,6 +232,15 @@ class KollaWorkerTest(base.TestCase): self.assertRaises(ValueError, kolla.filter_images) + @mock.patch('pprint.pprint') + def test_list_dependencies(self, pprint_mock): + self.conf.set_override('profile', ['all']) + kolla = build.KollaWorker(self.conf) + kolla.images = self.images + kolla.filter_images() + kolla.list_dependencies() + pprint_mock.assert_called_once_with(mock.ANY) + @mock.patch.object(build, 'run_build') class MainTest(base.TestCase):