Search in sources :

Example 16 with CheServicesEnvironmentImpl

use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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 17 with CheServicesEnvironmentImpl

use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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 18 with CheServicesEnvironmentImpl

use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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 19 with CheServicesEnvironmentImpl

use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl 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)

Example 20 with CheServicesEnvironmentImpl

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

the class DefaultServicesStartStrategyTest method shouldOrderServicesWithTheSameDependenciesInDependsOnVolumesFromAndLinks.

@Test
public void shouldOrderServicesWithTheSameDependenciesInDependsOnVolumesFromAndLinks() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withVolumesFrom(singletonList("first")).withDependsOn(singletonList("first")).withLinks(singletonList("first:alias")));
    composeEnvironment.getServices().put("third", new CheServiceImpl().withVolumesFrom(asList("first", "second")).withDependsOn(asList("first", "second")).withLinks(asList("first", "second")));
    composeEnvironment.getServices().put("first", new CheServiceImpl());
    composeEnvironment.getServices().put("forth", new CheServiceImpl().withVolumesFrom(singletonList("third")).withDependsOn(singletonList("third")).withLinks(singletonList("third")));
    composeEnvironment.getServices().put("fifth", new CheServiceImpl().withVolumesFrom(asList("forth", "first")).withDependsOn(asList("forth", "first")).withLinks(asList("forth:alias", "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)

Aggregations

CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)54 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)44 Test (org.testng.annotations.Test)38 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)15 CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)13 Matchers.anyString (org.mockito.Matchers.anyString)8 HashMap (java.util.HashMap)7 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)7 Environment (org.eclipse.che.api.core.model.workspace.Environment)6 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)6 Map (java.util.Map)3 EnvironmentRecipe (org.eclipse.che.api.core.model.workspace.EnvironmentRecipe)3 ExtendedMachine (org.eclipse.che.api.core.model.workspace.ExtendedMachine)3 EnvironmentRecipeImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl)3 Joiner (com.google.common.base.Joiner)2 String.format (java.lang.String.format)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NotFoundException (org.eclipse.che.api.core.NotFoundException)2 ServerException (org.eclipse.che.api.core.ServerException)2