use of org.eclipse.che.api.environment.server.model.CheServiceImpl 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);
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldFailIfMachineContainsVolumesFromByItSelf.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "A machine can not contain 'volumes_from' to itself:.*")
public void shouldFailIfMachineContainsVolumesFromByItSelf() {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("first", new CheServiceImpl().withVolumesFrom(singletonList("first")));
// when
strategy.order(composeEnvironment);
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class DefaultServicesStartStrategyTest method shouldFailIfVolumesFromFieldContainsNonExistingService.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Dependency 'fifth' in machine 'third' points to unknown machine.")
public void shouldFailIfVolumesFromFieldContainsNonExistingService() throws Exception {
// given
CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
composeEnvironment.getServices().put("second", new CheServiceImpl());
composeEnvironment.getServices().put("third", new CheServiceImpl().withVolumesFrom(singletonList("fifth")));
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 CheEnvironmentEngineTest method shouldNotSetDockerfileContentInsteadOfUrlIfUrlDoesNotPointToCheApiOnEnvironmentStart.
@Test
public void shouldNotSetDockerfileContentInsteadOfUrlIfUrlDoesNotPointToCheApiOnEnvironmentStart() throws Exception {
// given
EnvironmentImpl env = createEnv();
String machineName = "machineWithDockerfileNotFromApi";
String contextUrl = "http://another-server.com/recipe/12345";
//prepare CheServicesEnvironmentImpl which should return compose parser
CheServicesEnvironmentImpl cheServicesEnvironment = createCheServicesEnvByName(machineName);
cheServicesEnvironment.getServices().get(machineName).withBuild(new CheServiceBuildContextImpl().withContext(contextUrl));
// when
startEnv(env, cheServicesEnvironment);
// then
ArgumentCaptor<CheServiceImpl> captor = ArgumentCaptor.forClass(CheServiceImpl.class);
verify(machineProvider).startService(anyString(), anyString(), anyString(), eq(machineName), eq(false), anyString(), captor.capture(), any(LineConsumer.class));
CheServiceImpl actualService = captor.getValue();
assertNull(actualService.getBuild().getDockerfilePath());
assertNull(actualService.getBuild().getDockerfileContent());
assertEquals(actualService.getBuild().getContext(), contextUrl);
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class CheEnvironmentEngineTest method createCheServicesEnvByName.
private CheServicesEnvironmentImpl createCheServicesEnvByName(String name) {
CheServicesEnvironmentImpl cheServicesEnvironment = new CheServicesEnvironmentImpl();
Map<String, CheServiceImpl> services = new HashMap<>();
services.put(name, new CheServiceImpl().withBuild(new CheServiceBuildContextImpl().withContext("image")));
cheServicesEnvironment.setServices(services);
return cheServicesEnvironment;
}
Aggregations