Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,25 +204,40 @@ public void containerArchiveInfoGetAndPut() throws IOException {
null
);
containerApi.containerCreate(containerCreateRequest, "container-archive-info-test");
containerApi.containerStart("container-archive-info-test", null);

// filesystem operations against a running Hyper-V container are not supported,
// so we prepare the container before starting it
InputStream archive = containerApi.containerArchive("container-archive-info-test", "/gattaca.txt");
File extractedDir = new TarUtil().unTar(archive);
File gattaca = new File(extractedDir, "gattaca.txt");
String fileContent = Okio.buffer(Okio.source(gattaca)).readUtf8();
assertEquals("The wind\ncaught it.\n", fileContent.replaceAll("\r", ""));

String testPath = testImage.isWindowsContainer()
? "tmp\\test"
: "/tmp/test/";
List<String> execCmd = testImage.isWindowsContainer()
? Arrays.asList("cmd", "/C", "mkdir " + testPath)
: Arrays.asList("mkdir", testPath);

containerApi.containerStart("container-archive-info-test", null);
IdResponse containerExec = engineApiClient.getExecApi().containerExec(
"container-archive-info-test",
new ExecConfig(null, null, null, null, null, null,
Arrays.asList("mkdir", "/tmp/test/"), null, null, null));
execCmd,
null, null, null));
engineApiClient.getExecApi().execStart(
containerExec.getId(),
new ExecStartConfig(null, null));

containerApi.putContainerArchive("container-archive-info-test", "/tmp/test/", new TarUtil().tar(gattaca), null, null);
// filesystem operations against a running Hyper-V container are not supported,
// so we stop the container before using the archive container api
containerApi.containerStop("container-archive-info-test", null);
containerApi.containerWait("container-archive-info-test", "not-running");

Map<String, Object> archiveCopyInfo = (Map<String, Object>) containerApi.containerArchiveInfo("container-archive-info-test", "/tmp/test/gattaca.txt");
containerApi.putContainerArchive("container-archive-info-test", testPath, new TarUtil().tar(gattaca), null, null);

Map<String, Object> archiveCopyInfo = (Map<String, Object>) containerApi.containerArchiveInfo("container-archive-info-test", testPath + "/gattaca.txt");
assertEquals("gattaca.txt", archiveCopyInfo == null ? null : archiveCopyInfo.get("name"));

removeContainer(engineApiClient, "container-archive-info-test");
Expand Down Expand Up @@ -351,7 +366,7 @@ public void containerLogsWithoutTty() {
containerApi.containerCreate(containerCreateRequest, "container-logs-test");
containerApi.containerStart("container-logs-test", null);

Duration timeout = Duration.of(5, SECONDS);
Duration timeout = Duration.of(10, SECONDS);
LogFrameStreamCallback callback = new LogFrameStreamCallback();

new Thread(() -> containerApi.containerLogs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ public class TestImage {
private final EngineApiClient engineApiClient;
private final String repository;
private final String tag;
private final boolean useWindowsContainer;

public TestImage(EngineApiClient engineApiClient) {
this.engineApiClient = engineApiClient;

boolean isWindows = Objects.requireNonNull(engineApiClient.getSystemApi().systemVersion().getOs()).equalsIgnoreCase("windows");
this.useWindowsContainer = Objects.requireNonNull(engineApiClient.getSystemApi().systemVersion().getOs()).equalsIgnoreCase("windows");
this.repository = "gesellix/echo-server";
this.tag = isWindows ? "os-windows" : "os-linux";
this.tag = useWindowsContainer ? "os-windows" : "os-linux";

// TODO consider NOT calling prepare inside the constructor
prepare();
Expand All @@ -36,4 +37,8 @@ public String getImageName() {
public String getImageTag() {
return tag;
}

public boolean isWindowsContainer() {
return useWindowsContainer;
}
}