Search in sources :

Example 1 with DockerProcess

use of org.eclipse.che.plugin.docker.machine.DockerProcess 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

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 DockerApiVersionPathPrefixProvider (org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider)1 DockerConnector (org.eclipse.che.plugin.docker.client.DockerConnector)1 DockerConnectorConfiguration (org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration)1 DockerRegistryAuthResolver (org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver)1 InitialAuthConfig (org.eclipse.che.plugin.docker.client.InitialAuthConfig)1 DockerConnectionFactory (org.eclipse.che.plugin.docker.client.connection.DockerConnectionFactory)1 DefaultNetworkFinder (org.eclipse.che.plugin.docker.client.helper.DefaultNetworkFinder)1 DockerProcess (org.eclipse.che.plugin.docker.machine.DockerProcess)1 Test (org.testng.annotations.Test)1