use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldOrderServicesWithDependenciesWhereOrderIsNotStrict.
@Test
public void shouldOrderServicesWithDependenciesWhereOrderIsNotStrict() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl().withDependsOn(singletonList("first")));
composeEnvironment.getServices().put("third", new CheServiceImpl().withDependsOn(singletonList("second")));
composeEnvironment.getServices().put("first", new CheServiceImpl().withDependsOn(emptyList()));
composeEnvironment.getServices().put("forth", new CheServiceImpl().withDependsOn(singletonList("second")));
composeEnvironment.getServices().put("fifth", new CheServiceImpl().withDependsOn(singletonList("second")));
// when
List<String> actual = strategy.order(composeEnvironment);
// then
assertEquals(actual.get(0), "first");
assertEquals(actual.get(1), "second");
assertTrue(actual.contains("third"));
assertTrue(actual.contains("forth"));
assertTrue(actual.contains("fifth"));
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldOrderServicesWithMixedDependenciesInDependsOnVolumesFromAndLinks.
@Test
public void shouldOrderServicesWithMixedDependenciesInDependsOnVolumesFromAndLinks() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl().withDependsOn(singletonList("first")));
composeEnvironment.getServices().put("third", new CheServiceImpl().withVolumesFrom(asList("first", "second")));
composeEnvironment.getServices().put("first", new CheServiceImpl().withLinks(emptyList()));
composeEnvironment.getServices().put("forth", new CheServiceImpl().withLinks(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);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldFailIfMachineLinksByItSelf.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "A machine can not link to itself: .*")
public void shouldFailIfMachineLinksByItSelf() {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("first", new CheServiceImpl().withLinks(singletonList("first")));
// when
strategy.order(composeEnvironment);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DockerImageEnvironmentParser method parse.
@Override
public CheServicesEnvironmentImpl parse(Environment environment) throws IllegalArgumentException, ServerException {
EnvironmentRecipe recipe = environment.getRecipe();
if (!"dockerimage".equals(recipe.getType())) {
throw new IllegalArgumentException(format("Docker image environment parser doesn't support recipe type '%s'", recipe.getType()));
}
CheServicesEnvironmentImpl cheServiceEnv = new CheServicesEnvironmentImpl();
CheServiceImpl service = new CheServiceImpl();
cheServiceEnv.getServices().put(getMachineName(environment), service);
service.setImage(recipe.getLocation());
return cheServiceEnv;
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class DockerfileEnvironmentParser method parse.
@Override
public CheServicesEnvironmentImpl parse(Environment environment) throws IllegalArgumentException, ServerException {
EnvironmentRecipe recipe = environment.getRecipe();
if (!"dockerfile".equals(recipe.getType())) {
throw new IllegalArgumentException(format("Dockerfile environment parser doesn't support recipe type '%s'", recipe.getType()));
}
if (!"text/x-dockerfile".equals(recipe.getContentType())) {
throw new IllegalArgumentException(format("Content type '%s' of recipe of environment is unsupported." + " Supported values are: text/x-dockerfile", recipe.getContentType()));
}
CheServicesEnvironmentImpl cheServiceEnv = new CheServicesEnvironmentImpl();
CheServiceImpl service = new CheServiceImpl();
cheServiceEnv.getServices().put(getMachineName(environment), service);
if (recipe.getLocation() != null) {
service.setBuild(new CheServiceBuildContextImpl().withContext(recipe.getLocation()));
} else {
service.setBuild(new CheServiceBuildContextImpl().withDockerfileContent(recipe.getContent()));
}
return cheServiceEnv;
}
Aggregations