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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations