Search in sources :

Example 6 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class CheEnvironmentValidatorTest method createServicesEnv.

private static CheServicesEnvironmentImpl createServicesEnv() {
    CheServicesEnvironmentImpl cheServicesEnvironment = new CheServicesEnvironmentImpl();
    Map<String, CheServiceImpl> services = new HashMap<>();
    Map<String, String> buildArgs = new HashMap<String, String>() {

        {
            put("argkey", "argvalue");
        }
    };
    cheServicesEnvironment.setServices(services);
    services.put("dev-machine", createCheService("_dev", 1024L * 1024L * 1024L, singletonList("machine2"), singletonList("machine2"), singletonList("machine2")));
    CheServiceImpl service = createCheService("_machine2", 100L, null, emptyList(), null);
    service.setBuild(new CheServiceBuildContextImpl("context", "file", null, buildArgs));
    services.put("machine2", service);
    return cheServicesEnvironment;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Example 7 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class EnvironmentParserTest method createExpectedEnv.

private static CheServicesEnvironmentImpl createExpectedEnv(String image, String dockerfile, List<String> expectedExpose, Map<String, String> expectedLabels) {
    CheServiceBuildContextImpl build = dockerfile != null ? new CheServiceBuildContextImpl(null, null, dockerfile, null) : null;
    CheServicesEnvironmentImpl environment = new CheServicesEnvironmentImpl();
    environment.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withImage(image).withLabels(expectedLabels).withBuild(build).withExpose(expectedExpose));
    return environment;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Example 8 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldOrderServicesWithDependenciesWhereOrderIsStrict.

@Test
public void shouldOrderServicesWithDependenciesWhereOrderIsStrict() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withDependsOn(singletonList("first")));
    composeEnvironment.getServices().put("third", new CheServiceImpl().withDependsOn(asList("first", "second")));
    composeEnvironment.getServices().put("first", new CheServiceImpl().withDependsOn(emptyList()));
    composeEnvironment.getServices().put("forth", new CheServiceImpl().withDependsOn(singletonList("third")));
    composeEnvironment.getServices().put("fifth", new CheServiceImpl().withDependsOn(asList("forth", "first")));
    List<String> expected = asList("first", "second", "third", "forth", "fifth");
    // when
    List<String> actual = strategy.order(composeEnvironment);
    // then
    assertEquals(actual, expected);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 9 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldFailIfLinksFieldHasIllegalFormat.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Service link '.*' is invalid")
public void shouldFailIfLinksFieldHasIllegalFormat() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withLinks(singletonList("first:broken:dependency")));
    composeEnvironment.getServices().put("third", new CheServiceImpl());
    composeEnvironment.getServices().put("first", new CheServiceImpl());
    // when
    strategy.order(composeEnvironment);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 10 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldOrderServicesWithDependenciesWhereOrderIsStrict2.

@Test
public void shouldOrderServicesWithDependenciesWhereOrderIsStrict2() {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("web", new CheServiceImpl().withDependsOn(asList("db", "redis")));
    composeEnvironment.getServices().put("redis", new CheServiceImpl().withDependsOn(singletonList("dev-machine")));
    composeEnvironment.getServices().put("db", new CheServiceImpl().withDependsOn(singletonList("redis")));
    composeEnvironment.getServices().put("dev-machine", new CheServiceImpl().withDependsOn(emptyList()));
    List<String> expected = asList("dev-machine", "redis", "db", "web");
    // when
    List<String> actual = strategy.order(composeEnvironment);
    // then
    assertEquals(actual, expected);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Aggregations

CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)93 Test (org.testng.annotations.Test)63 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)46 Matchers.anyString (org.mockito.Matchers.anyString)32 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)28 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)24 Map (java.util.Map)18 Machine (org.eclipse.che.api.core.model.machine.Machine)17 CreateContainerParams (org.eclipse.che.plugin.docker.client.params.CreateContainerParams)17 ServerException (org.eclipse.che.api.core.ServerException)16 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)16 IOException (java.io.IOException)14 List (java.util.List)14 ServerConf (org.eclipse.che.api.core.model.machine.ServerConf)14 Collections.singletonMap (java.util.Collections.singletonMap)13 Set (java.util.Set)13 CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)13 Instance (org.eclipse.che.api.machine.server.spi.Instance)13 EnvironmentContext (org.eclipse.che.commons.env.EnvironmentContext)13