@@ -204,25 +204,40 @@ public void containerArchiveInfoGetAndPut() throws IOException {
204204 null
205205 );
206206 containerApi .containerCreate (containerCreateRequest , "container-archive-info-test" );
207- containerApi .containerStart ("container-archive-info-test" , null );
208207
208+ // filesystem operations against a running Hyper-V container are not supported,
209+ // so we prepare the container before starting it
209210 InputStream archive = containerApi .containerArchive ("container-archive-info-test" , "/gattaca.txt" );
210211 File extractedDir = new TarUtil ().unTar (archive );
211212 File gattaca = new File (extractedDir , "gattaca.txt" );
212213 String fileContent = Okio .buffer (Okio .source (gattaca )).readUtf8 ();
213214 assertEquals ("The wind\n caught it.\n " , fileContent .replaceAll ("\r " , "" ));
214215
216+ String testPath = testImage .isWindowsContainer ()
217+ ? "tmp\\ test"
218+ : "/tmp/test/" ;
219+ List <String > execCmd = testImage .isWindowsContainer ()
220+ ? Arrays .asList ("cmd" , "/C" , "mkdir " + testPath )
221+ : Arrays .asList ("mkdir" , testPath );
222+
223+ containerApi .containerStart ("container-archive-info-test" , null );
215224 IdResponse containerExec = engineApiClient .getExecApi ().containerExec (
216225 "container-archive-info-test" ,
217226 new ExecConfig (null , null , null , null , null , null ,
218- Arrays .asList ("mkdir" , "/tmp/test/" ), null , null , null ));
227+ execCmd ,
228+ null , null , null ));
219229 engineApiClient .getExecApi ().execStart (
220230 containerExec .getId (),
221231 new ExecStartConfig (null , null ));
222232
223- containerApi .putContainerArchive ("container-archive-info-test" , "/tmp/test/" , new TarUtil ().tar (gattaca ), null , null );
233+ // filesystem operations against a running Hyper-V container are not supported,
234+ // so we stop the container before using the archive container api
235+ containerApi .containerStop ("container-archive-info-test" , null );
236+ containerApi .containerWait ("container-archive-info-test" , "not-running" );
237+
238+ containerApi .putContainerArchive ("container-archive-info-test" , testPath , new TarUtil ().tar (gattaca ), null , null );
224239
225- Map <String , Object > archiveCopyInfo = (Map <String , Object >) containerApi .containerArchiveInfo ("container-archive-info-test" , "/tmp/test /gattaca.txt" );
240+ Map <String , Object > archiveCopyInfo = (Map <String , Object >) containerApi .containerArchiveInfo ("container-archive-info-test" , testPath + " /gattaca.txt" );
226241 assertEquals ("gattaca.txt" , archiveCopyInfo == null ? null : archiveCopyInfo .get ("name" ));
227242
228243 removeContainer (engineApiClient , "container-archive-info-test" );
0 commit comments