use of org.eclipse.che.plugin.docker.client.DockerConnector in project che by eclipse.
the class MachineProviderImplTest method shouldAddEnvVarsFromMachineConfigToContainerOnNonDevInstanceCreationFromSnapshot.
@Test
public void shouldAddEnvVarsFromMachineConfigToContainerOnNonDevInstanceCreationFromSnapshot() throws Exception {
// given
Map<String, String> envVarsFromConfig = new HashMap<>();
envVarsFromConfig.put("ENV_VAR1", "123");
envVarsFromConfig.put("ENV_VAR2", "234");
final boolean isDev = false;
CheServiceImpl machine = createService();
machine.setEnvironment(envVarsFromConfig);
// when
createInstanceFromSnapshot(machine, isDev);
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertTrue(asList(argumentCaptor.getValue().getContainerConfig().getEnv()).containsAll(envVarsFromConfig.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.toList())));
}
use of org.eclipse.che.plugin.docker.client.DockerConnector in project che by eclipse.
the class DockerProcessTest method shouldThrowErrorWithRealPIDIfSocketTimeoutExceptionHappens.
/**
* This test requires TCP access to docker API to get timeout exception.<br>
* If default access to docker is UNIX socket try to reconfigure docker connector for this test.<br>
* This test may fail if system doesn't allow such access.
*/
@Test(expectedExceptions = MachineException.class, expectedExceptionsMessageRegExp = "Command output read timeout is reached. Process is still running and has id \\d+ inside machine")
public void shouldThrowErrorWithRealPIDIfSocketTimeoutExceptionHappens() throws Exception {
DockerConnectorConfiguration dockerConnectorConfiguration = this.dockerConnectorConfiguration;
DockerConnector docker = this.docker;
if ("unix".equals(dockerConnectorConfiguration.getDockerDaemonUri().getScheme())) {
// access through unix socket - reconfigure to use tcp
dockerConnectorConfiguration = new DockerConnectorConfiguration(new URI("http://localhost:2375"), null, new InitialAuthConfig(), new DefaultNetworkFinder());
docker = new DockerConnector(dockerConnectorConfiguration, new DockerConnectionFactory(dockerConnectorConfiguration), new DockerRegistryAuthResolver(null, null), new DockerApiVersionPathPrefixProvider(""));
}
Command command = new CommandImpl("tailf", "tail -f /dev/null", "mvn");
final DockerProcess dockerProcess = new DockerProcess(dockerConnectorProvider, command, container, "outputChannel", "/tmp/chetests", pidGenerator.incrementAndGet());
dockerProcess.start(new SOUTLineConsumer());
}
Aggregations