From de7c08d5b9ab240328609ebcfa4648e0d6f7f0ab Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Thu, 30 Jul 2026 16:06:23 +0200 Subject: Allow lowercase from Change-Id: I42cf2aac795e9f61692deec956de0bedab55086f Signed-off-by: Michal Nasiadka --- kolla/tests/test_build.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'kolla/tests') diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index 21f7fc59c..48023cc1c 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -962,6 +962,48 @@ class KollaWorkerTest(base.TestCase): self.assertRaises(jinja2.exceptions.SecurityError, kolla.create_dockerfiles) + @mock.patch(engine_client) + def test_create_dockerfiles_pip_args_lowercase_from(self, mock_client): + tmpdir = self.useFixture(fixtures.TempDir()).path + base_dir = os.path.join(tmpdir, 'base') + os.makedirs(base_dir) + with open(os.path.join(base_dir, 'Dockerfile.j2'), 'w') as f: + f.write('from {{ base_distro }}:{{ base_distro_tag }}\n') + self.conf.set_override('pip_index_url', 'https://example.org/simple') + with mock.patch.object(build.KollaWorker, '_get_images_dir', + return_value=tmpdir): + kolla = build.KollaWorker(self.conf) + kolla.setup_working_dir() + kolla.find_dockerfiles() + kolla.create_dockerfiles() + dockerfile = os.path.join(kolla.working_dir, 'base', 'Dockerfile') + with open(dockerfile) as f: + content = f.read() + self.assertIn('ARG PIP_INDEX_URL', content) + + @mock.patch(engine_client) + def test_build_image_list_parent_name_lowercase_from(self, mock_client): + tmpdir = self.useFixture(fixtures.TempDir()).path + base_dir = os.path.join(tmpdir, 'base') + os.makedirs(base_dir) + with open(os.path.join(base_dir, 'Dockerfile.j2'), 'w') as f: + f.write('FROM {{ base_distro }}:{{ base_distro_tag }}\n') + child_dir = os.path.join(tmpdir, 'child') + os.makedirs(child_dir) + with open(os.path.join(child_dir, 'Dockerfile.j2'), 'w') as f: + f.write('from {{ namespace }}/{{ image_prefix }}base:{{ tag }}\n') + with mock.patch.object(build.KollaWorker, '_get_images_dir', + return_value=tmpdir): + kolla = build.KollaWorker(self.conf) + kolla.setup_working_dir() + kolla.find_dockerfiles() + kolla.create_dockerfiles() + kolla.build_image_list() + expected_parent = '{}/{}base:{}'.format( + kolla.namespace, kolla.image_prefix, kolla.tag) + child = [i for i in kolla.images if i.name == 'child'][0] + self.assertEqual(expected_parent, child.parent_name) + def _get_matched_images(self, images): return [image for image in images if image.status == utils.Status.MATCHED] -- cgit v1.2.3