Skip to content

Commit 9c6f6ae

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
1 parent 915189d commit 9c6f6ae

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
@@ -840,3 +840,49 @@ def test_unbuildable_images(self, mock_run_build):
840840
mock_run_build.return_value = image_statuses
841841
result = build_cmd.main()
842842
self.assertEqual(0, result)
843+
844+
@mock.patch('requests.get')
845+
@mock.patch(engine_client)
846+
def test_build_etcd_cross_arch(self, mock_docker, mock_requests_get):
847+
"""Test building etcd with --base-arch aarch64.
848+
849+
This ensures we fetch the arm64 tarball instead of amd64.
850+
"""
851+
mock_response = mock.Mock()
852+
# Force error (404) so we can inspect the requested URL
853+
mock_response.status_code = 404
854+
mock_requests_get.return_value = mock_response
855+
856+
argv = ['kolla-build', '--base-arch', 'aarch64', 'etcd']
857+
with mock.patch.object(sys, 'argv', argv):
858+
build_cmd.main()
859+
860+
self.assertTrue(
861+
mock_requests_get.called,
862+
"requests.get was never called; 'etcd' may not have been matched."
863+
)
864+
865+
found_url = None
866+
for call_args in mock_requests_get.call_args_list:
867+
url = call_args[0][0]
868+
# Look for a string like 'etcd-vX.Y.Z-linux-...'
869+
if 'etcd-v' in url and 'linux-' in url:
870+
found_url = url
871+
break
872+
873+
self.assertIsNotNone(
874+
found_url,
875+
"No GET request found for the etcd tarball "
876+
"(expected 'etcd-v' and 'linux-' in the URL)."
877+
)
878+
879+
self.assertIn(
880+
'arm64',
881+
found_url,
882+
"Expected 'arm64' in etcd URL (aarch64), got: %s" % found_url
883+
)
884+
self.assertNotIn(
885+
'amd64',
886+
found_url,
887+
"Should not be 'amd64' for aarch64 build, got: %s" % found_url
888+
)

0 commit comments

Comments
 (0)