@@ -180,6 +180,44 @@ def test_get_file_error(self):
180180 with self .assertRaises (IOError ):
181181 host .get_file ("not-a-file" , "not-another-file" , print_output = True )
182182
183+ def test_docker_platform (self ):
184+ inventory = make_inventory (
185+ hosts = ((f"@{ self .connector_name } /not-an-image" , {"docker_platform" : "linux/amd64" }),),
186+ )
187+ State (inventory , Config ())
188+
189+ host = inventory .get_host (f"@{ self .connector_name } /not-an-image" )
190+ assert host .data .docker_platform == "linux/amd64"
191+
192+ def test_docker_architecture (self ):
193+ inventory = make_inventory (
194+ hosts = ((f"@{ self .connector_name } /not-an-image" , {"docker_architecture" : "arm64" }),),
195+ )
196+ State (inventory , Config ())
197+
198+ host = inventory .get_host (f"@{ self .connector_name } /not-an-image" )
199+ assert host .data .docker_architecture == "arm64"
200+
201+ def test_connect_with_docker_platform (self ):
202+ inventory = make_inventory (
203+ hosts = ((f"@{ self .connector_name } /not-an-image" , {"docker_platform" : "linux/amd64" }),),
204+ )
205+ state = State (inventory , Config ())
206+ host = inventory .get_host (f"@{ self .connector_name } /not-an-image" )
207+ host .connect (reason = True )
208+ assert len (state .active_hosts ) == 0
209+ host .disconnect ()
210+
211+ def test_connect_with_docker_architecture (self ):
212+ inventory = make_inventory (
213+ hosts = ((f"@{ self .connector_name } /not-an-image" , {"docker_architecture" : "arm64" }),),
214+ )
215+ state = State (inventory , Config ())
216+ host = inventory .get_host (f"@{ self .connector_name } /not-an-image" )
217+ host .connect (reason = True )
218+ assert len (state .active_hosts ) == 0
219+ host .disconnect ()
220+
183221
184222# Reuse the container testing code for docker and podman
185223
@@ -188,6 +226,12 @@ def fake_docker_shell(command, splitlines=None):
188226 if command == "docker run -d not-an-image tail -f /dev/null" :
189227 return ["containerid" ]
190228
229+ if command == "docker run -d --platform linux/amd64 not-an-image tail -f /dev/null" :
230+ return ["containerid" ]
231+
232+ if command == "docker run -d --arch arm64 not-an-image tail -f /dev/null" :
233+ return ["containerid" ]
234+
191235 if command == "docker commit containerid" :
192236 return ["sha256:blahsomerandomstringdata" ]
193237
@@ -213,6 +257,12 @@ def fake_podman_shell(command, splitlines=None):
213257 if command == "podman run -d not-an-image tail -f /dev/null" :
214258 return ["containerid" ]
215259
260+ if command == "podman run -d --platform linux/amd64 not-an-image tail -f /dev/null" :
261+ return ["containerid" ]
262+
263+ if command == "podman run -d --arch arm64 not-an-image tail -f /dev/null" :
264+ return ["containerid" ]
265+
216266 if command == "podman commit containerid" :
217267 return ["sha256:blahsomerandomstringdata" ]
218268
0 commit comments