use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldAddLinksToContainerOnCreation.
@Test
public void shouldAddLinksToContainerOnCreation() throws Exception {
// given
String[] links = new String[] { "container1", "container2:alias" };
CheServiceImpl service = createService();
service.setLinks(asList(links));
// when
createInstanceFromRecipe(service, true);
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
ContainerConfig containerConfig = argumentCaptor.getValue().getContainerConfig();
assertEquals(containerConfig.getHostConfig().getLinks(), links);
assertEquals(containerConfig.getNetworkingConfig().getEndpointsConfig().get(NETWORK_NAME).getLinks(), links);
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldReTagBuiltImageWithPredictableOnInstanceCreationFromRecipe.
@Test
public void shouldReTagBuiltImageWithPredictableOnInstanceCreationFromRecipe() throws Exception {
// given
String repo = MACHINE_SNAPSHOT_PREFIX + "repo1";
String tag = "tag1";
String registry = "registry1";
// when
CheServiceImpl machine = createInstanceFromSnapshot(repo, tag, registry);
// then
TagParams tagParams = TagParams.create(registry + "/" + repo + ":" + tag, "eclipse-che/" + machine.getContainerName());
verify(dockerConnector).tag(eq(tagParams));
ArgumentCaptor<RemoveImageParams> argumentCaptor = ArgumentCaptor.forClass(RemoveImageParams.class);
verify(dockerConnector).removeImage(argumentCaptor.capture());
RemoveImageParams imageParams = argumentCaptor.getValue();
assertEquals(imageParams.getImage(), registry + "/" + repo + ":" + tag);
assertFalse(imageParams.isForce());
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method shouldAddServersConfsPortsFromMachineConfigToExposedPortsOnNonDevInstanceCreationFromRecipe.
@Test
public void shouldAddServersConfsPortsFromMachineConfigToExposedPortsOnNonDevInstanceCreationFromRecipe() throws Exception {
// given
final boolean isDev = false;
CheServiceImpl machine = createService();
machine.setExpose(asList("9090", "8080"));
List<String> expectedExposedPorts = asList("9090", "8080");
// when
createInstanceFromRecipe(machine, isDev);
// then
ArgumentCaptor<CreateContainerParams> argumentCaptor = ArgumentCaptor.forClass(CreateContainerParams.class);
verify(dockerConnector).createContainer(argumentCaptor.capture());
assertTrue(new ArrayList<>(argumentCaptor.getValue().getContainerConfig().getExposedPorts().keySet()).containsAll(expectedExposedPorts));
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class MachineProviderImplTest method createInstanceFromSnapshot.
private CheServiceImpl createInstanceFromSnapshot() throws ServerException {
CheServiceImpl service = createService();
createInstanceFromSnapshot(service, false, WORKSPACE_ID);
return service;
}
use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.
the class DockerImageEnvironmentParserTest method shouldBeAbleToParseDockerImageEnvironment.
@Test
public void shouldBeAbleToParseDockerImageEnvironment() throws Exception {
// given
EnvironmentImpl environment = createDockerimageEnvConfig(DEFAULT_DOCKER_IMAGE, DEFAULT_MACHINE_NAME);
CheServicesEnvironmentImpl expected = new CheServicesEnvironmentImpl();
expected.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withImage(DEFAULT_DOCKER_IMAGE));
// when
CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
// then
assertEquals(cheServicesEnvironment, expected);
}
Aggregations