private void setVolume(String volume) { if (cubeContainer.getBinds() == null) { List<String> binds = new ArrayList<>(); binds.add(volume); cubeContainer.setBinds(binds); } else { cubeContainer.getBinds().add(volume); } }
private void setVolume(String volume) { if (cubeContainer.getBinds() == null) { List<String> binds = new ArrayList<>(); binds.add(volume); cubeContainer.setBinds(binds); } else { cubeContainer.getBinds().add(volume); } }
public ContainerBuilder addBinds(Collection<String> volumes) { if (configuration.getBinds() != null) { Collection<String> oldBinds = configuration.getBinds(); oldBinds.addAll(volumes); } else { configuration.setBinds(new HashSet<>(volumes)); } return this; }
public ContainerBuilder addBinds(Collection<String> volumes) { if (configuration.getBinds() != null) { Collection<String> oldBinds = configuration.getBinds(); oldBinds.addAll(volumes); } else { configuration.setBinds(new HashSet<>(volumes)); } return this; }
.map(volume -> volume.hostPath() + ":" + volume.containerPath() + ":Z") .collect(Collectors.toList()); cubeContainer.setBinds(volumeBindings);
.map(volume -> volume.hostPath() + ":" + volume.containerPath() + ":Z") .collect(Collectors.toList()); cubeContainer.setBinds(volumeBindings);
private void mergeContainerObjectConfiguration() { mergedConfiguration = new CubeContainer(); if (providedConfiguration != null) { mergedConfiguration.merge(providedConfiguration); } mergedConfiguration.merge(generatedConfigutation); // TODO if both provided and generated configurations have environment variables or volumes, they must be merged instead. // TODO should this be handled in CubeContainer::merge() instead? if (providedConfiguration != null) { // environment variables if (providedConfiguration.getEnv() != null && generatedConfigutation.getEnv() != null) { Collection<String> env = new ArrayList<>(); env.addAll(mergedConfiguration.getEnv()); env.addAll(generatedConfigutation.getEnv()); mergedConfiguration.setEnv(env); } // volumes if (providedConfiguration.getBinds() != null && generatedConfigutation.getBinds() != null) { Collection<String> binds = new ArrayList<>(); binds.addAll(mergedConfiguration.getBinds()); binds.addAll(generatedConfigutation.getBinds()); mergedConfiguration.setBinds(binds); } } }
private void mergeContainerObjectConfiguration() { mergedConfiguration = new CubeContainer(); if (providedConfiguration != null) { mergedConfiguration.merge(providedConfiguration); } mergedConfiguration.merge(generatedConfigutation); // TODO if both provided and generated configurations have environment variables or volumes, they must be merged instead. // TODO should this be handled in CubeContainer::merge() instead? if (providedConfiguration != null) { // environment variables if (providedConfiguration.getEnv() != null && generatedConfigutation.getEnv() != null) { Collection<String> env = new ArrayList<>(); env.addAll(mergedConfiguration.getEnv()); env.addAll(generatedConfigutation.getEnv()); mergedConfiguration.setEnv(env); } // volumes if (providedConfiguration.getBinds() != null && generatedConfigutation.getBinds() != null) { Collection<String> binds = new ArrayList<>(); binds.addAll(mergedConfiguration.getBinds()); binds.addAll(generatedConfigutation.getBinds()); mergedConfiguration.setBinds(binds); } } }
private static CubeContainer createVncContainer(final Path dockerVolume, String seleniumContainerName) { CubeContainer cubeContainer = new CubeContainer(); cubeContainer.setImage(Image.valueOf(VNC_IMAGE)); cubeContainer.setBinds( Arrays.asList(convertToBind(dockerVolume, VOLUME_DIR, "Z")) ); final Link link = Link.valueOf(seleniumContainerName + ":" + VNC_HOSTNAME); cubeContainer.setLinks(Arrays.asList(link)); // Using sleeping strategy since VNC client is a CLI without exposing a port Await await = new Await(); await.setStrategy("sleeping"); await.setSleepTime("100 ms"); cubeContainer.setAwait(await); cubeContainer.setCmd(Arrays.asList(FLVREC_COMMAND)); // sets container as manual because we need to start and stop for each test case cubeContainer.setManual(true); return cubeContainer; }
private static CubeContainer createVncContainer(final Path dockerVolume, String seleniumContainerName, String dockerRegistry) { CubeContainer cubeContainer = new CubeContainer(); cubeContainer.setImage(Image.valueOf(dockerRegistry + VNC_IMAGE)); cubeContainer.setBinds( Arrays.asList(convertToBind(dockerVolume, VOLUME_DIR, "Z")) ); final Link link = Link.valueOf(seleniumContainerName + ":" + VNC_HOSTNAME); cubeContainer.setLinks(Arrays.asList(link)); // Using sleeping strategy since VNC client is a CLI without exposing a port Await await = new Await(); await.setStrategy("sleeping"); await.setSleepTime("100 ms"); cubeContainer.setAwait(await); cubeContainer.setCmd(Arrays.asList(FLVREC_COMMAND)); // sets container as manual because we need to start and stop for each test case cubeContainer.setManual(true); return cubeContainer; }
.map(volume -> volume.hostPath() + ":" + volume.containerPath() + ":Z") .collect(Collectors.toList()); generatedConfigutation.setBinds(volumeBindings);
.map(volume -> volume.hostPath() + ":" + volume.containerPath() + ":Z") .collect(Collectors.toList()); generatedConfigutation.setBinds(volumeBindings);
private static CubeContainer createVideoConverterContainer(Path dockerVolume, String dockerRegistry) { CubeContainer cubeContainer = new CubeContainer(); cubeContainer.setImage(Image.valueOf(dockerRegistry + CONVERSION_IMAGE)); cubeContainer.setBinds( Arrays.asList(convertToBind(dockerVolume, VOLUME_DIR, "Z")) ); // Using log await strategy to match the echo string indicating completion of conversion Await await = new Await(); await.setStrategy("log"); await.setMatch("CONVERSION COMPLETED"); cubeContainer.setAwait(await); // sets container as manual because we need to start and stop cubeContainer.setManual(true); return cubeContainer; }
private static CubeContainer createVideoConverterContainer(Path dockerVolume) { CubeContainer cubeContainer = new CubeContainer(); cubeContainer.setImage(Image.valueOf(CONVERSION_IMAGE)); cubeContainer.setBinds( Arrays.asList(convertToBind(dockerVolume, VOLUME_DIR, "Z")) ); // Using log await strategy to match the echo string indicating completion of conversion Await await = new Await(); await.setStrategy("log"); await.setMatch("CONVERSION COMPLETED"); cubeContainer.setAwait(await); // sets container as manual because we need to start and stop cubeContainer.setManual(true); return cubeContainer; }
@Test public void shouldStartAContainerObjectDefinedUsingImageAndVolumes() { final AtomicReference<DockerCube> cubeRef = new AtomicReference<>(); try { CubeContainer ccconfig = new CubeContainer(); ccconfig.setBinds(Collections.singleton("/mypath3:/containerPath3:Z")); CubeContainerObjectConfiguration ccoconfig = new CubeContainerObjectConfiguration(ccconfig); TestContainerObjectDefinedUsingImageAndVolumes containerObject = new DockerContainerObjectBuilder<TestContainerObjectDefinedUsingImageAndVolumes>(dockerClientExecutor, cubeController, cubeRegistry) .withContainerObjectClass(TestContainerObjectDefinedUsingImageAndVolumes.class) .withContainerObjectConfiguration(ccoconfig) .onCubeCreated(cubeRef::set) .build(); assertThat(containerObject, is(notNullValue())); } catch (IllegalAccessException|InvocationTargetException|IOException e) { fail(); } DockerCube cube = cubeRef.get(); assertThat(cube, is(notNullValue())); assertThat(cube.hasMetadata(IsContainerObject.class), is(true)); assertThat(cube.getMetadata(IsContainerObject.class).getTestClass(), is(nullValue())); assertThat(cube.configuration().getImage().toImageRef(), is(BASE_IMAGE)); assertThat(cube.configuration().getBinds(), hasItems("/mypath:/containerPath:Z", "/mypath2:/containerPath2:Z", "/mypath3:/containerPath3:Z")); verify(cubeController, times(1)).create("containerWithVolumes"); verify(cubeController, times(1)).start("containerWithVolumes"); }