Skip to content

Commit 9ef6688

Browse files
committed
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 (cherry picked from commit 9c6f6ae)
1 parent 6053fef commit 9ef6688

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}

kolla/tests/test_build.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,3 +858,49 @@ def test_unbuildable_images(self, mock_run_build):
858858
mock_run_build.return_value = image_statuses
859859
result = build_cmd.main()
860860
self.assertEqual(0, result)
861+
862+
@mock.patch('requests.get')
863+
@mock.patch(engine_client)
864+
def test_build_etcd_cross_arch(self, mock_docker, mock_requests_get):
865+
"""Test building etcd with --base-arch aarch64.
866+
867+
This ensures we fetch the arm64 tarball instead of amd64.
868+
"""
869+
mock_response = mock.Mock()
870+
# Force error (404) so we can inspect the requested URL
871+
mock_response.status_code = 404
872+
mock_requests_get.return_value = mock_response
873+
874+
argv = ['kolla-build', '--base-arch', 'aarch64', 'etcd']
875+
with mock.patch.object(sys, 'argv', argv):
876+
build_cmd.main()
877+
878+
self.assertTrue(
879+
mock_requests_get.called,
880+
"requests.get was never called; 'etcd' may not have been matched."
881+
)
882+
883+
found_url = None
884+
for call_args in mock_requests_get.call_args_list:
885+
url = call_args[0][0]
886+
# Look for a string like 'etcd-vX.Y.Z-linux-...'
887+
if 'etcd-v' in url and 'linux-' in url:
888+
found_url = url
889+
break
890+
891+
self.assertIsNotNone(
892+
found_url,
893+
"No GET request found for the etcd tarball "
894+
"(expected 'etcd-v' and 'linux-' in the URL)."
895+
)
896+
897+
self.assertIn(
898+
'arm64',
899+
found_url,
900+
"Expected 'arm64' in etcd URL (aarch64), got: %s" % found_url
901+
)
902+
self.assertNotIn(
903+
'amd64',
904+
found_url,
905+
"Should not be 'amd64' for aarch64 build, got: %s" % found_url
906+
)

0 commit comments

Comments
 (0)