use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method createService.
private CheServiceImpl createService() {
CheServiceImpl service = new CheServiceImpl();
service.setId("testId");
service.setImage("image");
service.setCommand(asList("some", "command"));
service.setContainerName("cont_name");
service.setDependsOn(asList("dep1", "dep2"));
service.setEntrypoint(asList("entry", "point"));
service.setExpose(asList("1010", "1111"));
service.setEnvironment(singletonMap("some", "var"));
service.setLabels(singletonMap("some", "label"));
service.setLinks(asList("link1", "link2:alias"));
service.setMemLimit(1000000000L);
service.setPorts(asList("port1", "port2"));
service.setVolumes(asList("vol1", "vol2"));
service.setVolumesFrom(asList("from1", "from2"));
return service;
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldAddEnvVarsFromMachineConfigToContainerOnDevInstanceCreationFromRecipe.
@Test
public void shouldAddEnvVarsFromMachineConfigToContainerOnDevInstanceCreationFromRecipe() throws Exception {
// given
Map<String, String> envVarsFromConfig = new HashMap<>();
envVarsFromConfig.put("ENV_VAR1", "123");
envVarsFromConfig.put("ENV_VAR2", "234");
final boolean isDev = true;
CheServiceImpl machine = createService();
machine.setEnvironment(envVarsFromConfig);
// when
createInstanceFromRecipe(machine, isDev);
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertTrue(asList(argumentCaptor.getValue().getContainerConfig().getEnv()).containsAll(envVarsFromConfig.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.toList())));
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method createInstanceFromSnapshot.
private CheServiceImpl createInstanceFromSnapshot(String repo, String tag, String registry) throws ServerException {
CheServiceImpl machine = createService();
machine.setImage(registry + "/" + repo + ":" + tag);
machine.setBuild(null);
createInstanceFromSnapshot(machine);
return machine;
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldCreateContainerOnInstanceCreationFromRecipe.
@Test
public void shouldCreateContainerOnInstanceCreationFromRecipe() throws Exception {
// when
CheServiceImpl machine = createInstanceFromRecipe();
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue().getContainerConfig().getImage(), "eclipse-che/" + machine.getContainerName());
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldAddEnvVarsFromMachineConfigToContainerOnNonDevInstanceCreationFromSnapshot.
@Test
public void shouldAddEnvVarsFromMachineConfigToContainerOnNonDevInstanceCreationFromSnapshot() throws Exception {
// given
Map<String, String> envVarsFromConfig = new HashMap<>();
envVarsFromConfig.put("ENV_VAR1", "123");
envVarsFromConfig.put("ENV_VAR2", "234");
final boolean isDev = false;
CheServiceImpl machine = createService();
machine.setEnvironment(envVarsFromConfig);
// when
createInstanceFromSnapshot(machine, isDev);
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertTrue(asList(argumentCaptor.getValue().getContainerConfig().getEnv()).containsAll(envVarsFromConfig.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.toList())));
}
Aggregations