use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class ComposeEnvironmentParser method asCheEnvironment.
private CheServicesEnvironmentImpl asCheEnvironment(ComposeEnvironment composeEnvironment) {
Map<String, CheServiceImpl> services = Maps.newHashMapWithExpectedSize(composeEnvironment.getServices().size());
for (Map.Entry<String, ComposeServiceImpl> composeServiceEntry : composeEnvironment.getServices().entrySet()) {
ComposeServiceImpl service = composeServiceEntry.getValue();
CheServiceImpl cheService = new CheServiceImpl().withCommand(service.getCommand()).withContainerName(service.getContainerName()).withDependsOn(service.getDependsOn()).withEntrypoint(service.getEntrypoint()).withEnvironment(service.getEnvironment()).withExpose(service.getExpose()).withImage(service.getImage()).withLabels(service.getLabels()).withLinks(service.getLinks()).withMemLimit(service.getMemLimit()).withNetworks(service.getNetworks()).withPorts(service.getPorts()).withVolumes(service.getVolumes()).withVolumesFrom(service.getVolumesFrom());
if (service.getBuild() != null) {
cheService.setBuild(new CheServiceBuildContextImpl().withContext(service.getBuild().getContext()).withDockerfilePath(service.getBuild().getDockerfile()).withArgs(service.getBuild().getArgs()));
}
services.put(composeServiceEntry.getKey(), cheService);
}
return new CheServicesEnvironmentImpl(services);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class ComposeEnvironmentParserTest method shouldBeAbleToParseComposeEnvironmentWithApplicationByLocation.
@Test
public void shouldBeAbleToParseComposeEnvironmentWithApplicationByLocation() throws ServerException {
// given
when(recipe.getContentType()).thenReturn("text/yaml");
when(recipeDownloader.getRecipe(TEXT)).thenReturn(COMPOSE_CONTENT);
when(recipe.getLocation()).thenReturn(TEXT);
CheServicesEnvironmentImpl expectedEnv = createTestEnv();
//when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
//then
assertEquals(cheServicesEnvironment, expectedEnv);
}
use of org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl in project che by eclipse.
the class ComposeEnvironmentParserTest method shouldBeAbleToParseComposeEnvironmentWithTextXYamlContentType.
@Test
public void shouldBeAbleToParseComposeEnvironmentWithTextXYamlContentType() throws Exception {
// given
when(recipe.getContentType()).thenReturn("text/x-yaml");
when(recipe.getContent()).thenReturn(COMPOSE_CONTENT);
CheServicesEnvironmentImpl expectedEnv = createTestEnv();
//when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
//then
assertEquals(cheServicesEnvironment, expectedEnv);
}
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);
}
Aggregations