use of org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder in project che by eclipse.
the class DockerProcessTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
dockerConnectorConfiguration = new DockerConnectorConfiguration(new InitialAuthConfig(), new DefaultNetworkFinder());
docker = new DockerConnector(dockerConnectorConfiguration, new DockerConnectionFactory(dockerConnectorConfiguration), new DockerRegistryAuthResolver(null, null), new DockerApiVersionPathPrefixProvider("1.18"));
final ContainerCreated containerCreated = docker.createContainer(CreateContainerParams.create(new ContainerConfig().withImage("ubuntu").withCmd("tail", "-f", "/dev/null")));
container = containerCreated.getId();
docker.startContainer(StartContainerParams.create(containerCreated.getId()));
when(dockerConnectorProvider.get()).thenReturn(docker);
}
use of org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder 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