@@ -858,3 +858,49 @@ def test_unbuildable_images(self, mock_run_build):
858
858
mock_run_build .return_value = image_statuses
859
859
result = build_cmd .main ()
860
860
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