diff options
| author | Bartosz Bezak <bartosz@stackhpc.com> | 2025-01-30 12:30:06 +0000 |
|---|---|---|
| committer | Bartosz Bezak <bartosz@stackhpc.com> | 2025-03-21 17:06:48 +0000 |
| commit | 9c6f6ae2d9b1d412bde2821c48ff1f414066f566 (patch) | |
| tree | 9bdadec5aa08d2578fb3ebc4fbd797d0f06ad6d9 | |
| parent | 915189d10be83136d54f4216b81310b3dd16b82d (diff) | |
| download | kolla-9c6f6ae2d9b1d412bde2821c48ff1f414066f566.tar.gz kolla-9c6f6ae2d9b1d412bde2821c48ff1f414066f566.zip | |
tests: Add cross-arch test for etcd
Ensure that when building etcd with --base-arch aarch64, Kolla
uses the arm64 tarball instead of amd64.
Related-Bug: #2103810
Change-Id: I6248cb6646b2b0c7af1c29f9a0a244cef1c4cf05
| -rw-r--r-- | kolla/tests/docker/etcd/Dockerfile.j2 | 1 | ||||
| -rw-r--r-- | kolla/tests/test_build.py | 46 |
2 files changed, 47 insertions, 0 deletions
diff --git a/kolla/tests/docker/etcd/Dockerfile.j2 b/kolla/tests/docker/etcd/Dockerfile.j2 new file mode 100644 index 000000000..ae637eec4 --- /dev/null +++ b/kolla/tests/docker/etcd/Dockerfile.j2 @@ -0,0 +1 @@ +FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py index 9b3719c07..ca2faa056 100644 --- a/kolla/tests/test_build.py +++ b/kolla/tests/test_build.py @@ -840,3 +840,49 @@ class MainTest(base.TestCase): mock_run_build.return_value = image_statuses result = build_cmd.main() self.assertEqual(0, result) + + @mock.patch('requests.get') + @mock.patch(engine_client) + def test_build_etcd_cross_arch(self, mock_docker, mock_requests_get): + """Test building etcd with --base-arch aarch64. + + This ensures we fetch the arm64 tarball instead of amd64. + """ + mock_response = mock.Mock() + # Force error (404) so we can inspect the requested URL + mock_response.status_code = 404 + mock_requests_get.return_value = mock_response + + argv = ['kolla-build', '--base-arch', 'aarch64', 'etcd'] + with mock.patch.object(sys, 'argv', argv): + build_cmd.main() + + self.assertTrue( + mock_requests_get.called, + "requests.get was never called; 'etcd' may not have been matched." + ) + + found_url = None + for call_args in mock_requests_get.call_args_list: + url = call_args[0][0] + # Look for a string like 'etcd-vX.Y.Z-linux-...' + if 'etcd-v' in url and 'linux-' in url: + found_url = url + break + + self.assertIsNotNone( + found_url, + "No GET request found for the etcd tarball " + "(expected 'etcd-v' and 'linux-' in the URL)." + ) + + self.assertIn( + 'arm64', + found_url, + "Expected 'arm64' in etcd URL (aarch64), got: %s" % found_url + ) + self.assertNotIn( + 'amd64', + found_url, + "Should not be 'amd64' for aarch64 build, got: %s" % found_url + ) |
