From e5410950c4cd3f89bef44f07f354cd71d8038105 Mon Sep 17 00:00:00 2001 From: Paul Bourke Date: Fri, 27 Jan 2017 17:25:56 +0000 Subject: Allow the use of previously built parent images Consider the case where you have a set of tagged / released images to production, and you want to apply a small hotfix, security patch, etc. to one of them, say keystone-ssh. Rebuilding keystone-ssh will cause a rebuild of base, openstack-base, and keystone-base, potentially pulling in updated packages / new dependencies, unless you have access to the exact machine they were previously built on. Ideally you want to use the exact parent images that are in production. This patch adds a new build argument '--skip-parents', which will result in only the image(s) specified by the regex and their children to be built. Parents are expected to exist either on machine or in a registry. Change-Id: I79d5f0b422f48d2dc36ae85dfa21668cf8177837 Implements: blueprint image-build-depth --- kolla/tests/test_build.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'kolla/tests') diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index 1a1e019d5..a97e2c38c 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -209,6 +209,7 @@ class KollaWorkerTest(base.TestCase): image.status = None image_child = FAKE_IMAGE_CHILD.copy() image_child.status = None + image_child.parent.status = None image_unmatched = FAKE_IMAGE_CHILD_UNMATCHED.copy() image_error = FAKE_IMAGE_CHILD_ERROR.copy() image_built = FAKE_IMAGE_CHILD_BUILT.copy() @@ -292,6 +293,15 @@ class KollaWorkerTest(base.TestCase): return [image for image in images if image.status == build.STATUS_MATCHED] + def test_skip_parents(self): + self.conf.set_override('regex', 'image-child') + self.conf.set_override('skip_parents', True) + kolla = build.KollaWorker(self.conf) + kolla.images = self.images + kolla.filter_images() + + self.assertEqual(build.STATUS_SKIPPED, kolla.images[1].parent.status) + def test_without_profile(self): kolla = build.KollaWorker(self.conf) kolla.images = self.images @@ -354,14 +364,14 @@ class MainTest(base.TestCase): @mock.patch.object(build, 'run_build') def test_images_built(self, mock_run_build): - image_statuses = ({}, {'img': 'built'}, {}) + image_statuses = ({}, {'img': 'built'}, {}, {}) mock_run_build.return_value = image_statuses result = build_cmd.main() self.assertEqual(0, result) @mock.patch.object(build, 'run_build') def test_images_unmatched(self, mock_run_build): - image_statuses = ({}, {}, {'img': 'unmatched'}) + image_statuses = ({}, {}, {'img': 'unmatched'}, {}) mock_run_build.return_value = image_statuses result = build_cmd.main() self.assertEqual(0, result) @@ -374,7 +384,7 @@ class MainTest(base.TestCase): @mock.patch.object(build, 'run_build') def test_bad_images(self, mock_run_build): - image_statuses = ({'img': 'error'}, {}, {}) + image_statuses = ({'img': 'error'}, {}, {}, {}) mock_run_build.return_value = image_statuses result = build_cmd.main() self.assertEqual(1, result) @@ -383,3 +393,10 @@ class MainTest(base.TestCase): def test_run_build(self, mock_sys): result = build.run_build() self.assertTrue(result) + + @mock.patch.object(build, 'run_build') + def test_skipped_images(self, mock_run_build): + image_statuses = ({}, {}, {}, {'img': 'skipped'}) + mock_run_build.return_value = image_statuses + result = build_cmd.main() + self.assertEqual(0, result) -- cgit v1.2.3