Search in sources :

Example 1 with DefaultNetworkFinder

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);
}
Also used : ContainerConfig(org.eclipse.che.plugin.docker.client.json.ContainerConfig) DockerRegistryAuthResolver(org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver) ContainerCreated(org.eclipse.che.plugin.docker.client.json.ContainerCreated) DockerConnector(org.eclipse.che.plugin.docker.client.DockerConnector) DockerConnectorConfiguration(org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration) InitialAuthConfig(org.eclipse.che.plugin.docker.client.InitialAuthConfig) DockerApiVersionPathPrefixProvider(org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider) DefaultNetworkFinder(org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder) DockerConnectionFactory(org.eclipse.che.plugin.docker.client.connection.DockerConnectionFactory) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DefaultNetworkFinder

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());
}
Also used : CommandImpl(org.eclipse.che.api.machine.server.model.impl.CommandImpl) DockerRegistryAuthResolver(org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver) DockerConnector(org.eclipse.che.plugin.docker.client.DockerConnector) Command(org.eclipse.che.api.core.model.machine.Command) DockerConnectorConfiguration(org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration) InitialAuthConfig(org.eclipse.che.plugin.docker.client.InitialAuthConfig) DockerApiVersionPathPrefixProvider(org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider) DefaultNetworkFinder(org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder) DockerProcess(org.eclipse.che.plugin.docker.machine.DockerProcess) URI(java.net.URI) DockerConnectionFactory(org.eclipse.che.plugin.docker.client.connection.DockerConnectionFactory) Test(org.testng.annotations.Test)

Aggregations

DockerApiVersionPathPrefixProvider (org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider)2 DockerConnector (org.eclipse.che.plugin.docker.client.DockerConnector)2 DockerConnectorConfiguration (org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration)2 DockerRegistryAuthResolver (org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver)2 InitialAuthConfig (org.eclipse.che.plugin.docker.client.InitialAuthConfig)2 DockerConnectionFactory (org.eclipse.che.plugin.docker.client.connection.DockerConnectionFactory)2 DefaultNetworkFinder (org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder)2 URI (java.net.URI)1 Command (org.eclipse.che.api.core.model.machine.Command)1 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)1 ContainerConfig (org.eclipse.che.plugin.docker.client.json.ContainerConfig)1 ContainerCreated (org.eclipse.che.plugin.docker.client.json.ContainerCreated)1 DockerProcess (org.eclipse.che.plugin.docker.machine.DockerProcess)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1