Search in sources :

Example 86 with CheServiceImpl

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);
}
Also used : ContainerConfig(org.eclipse.che.plugin.docker.client.json.ContainerConfig) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CreateContainerParams(org.eclipse.che.plugin.docker.client.params.CreateContainerParams) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 87 with CheServiceImpl

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());
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) TagParams(org.eclipse.che.plugin.docker.client.params.TagParams) Matchers.anyString(org.mockito.Matchers.anyString) RemoveImageParams(org.eclipse.che.plugin.docker.client.params.RemoveImageParams) Test(org.testng.annotations.Test)

Example 88 with CheServiceImpl

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));
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CreateContainerParams(org.eclipse.che.plugin.docker.client.params.CreateContainerParams) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 89 with CheServiceImpl

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;
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl)

Example 90 with CheServiceImpl

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);
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Aggregations

CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)93 Test (org.testng.annotations.Test)63 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)46 Matchers.anyString (org.mockito.Matchers.anyString)32 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)28 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)24 Map (java.util.Map)18 Machine (org.eclipse.che.api.core.model.machine.Machine)17 CreateContainerParams (org.eclipse.che.plugin.docker.client.params.CreateContainerParams)17 ServerException (org.eclipse.che.api.core.ServerException)16 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)16 IOException (java.io.IOException)14 List (java.util.List)14 ServerConf (org.eclipse.che.api.core.model.machine.ServerConf)14 Collections.singletonMap (java.util.Collections.singletonMap)13 Set (java.util.Set)13 CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)13 Instance (org.eclipse.che.api.machine.server.spi.Instance)13 EnvironmentContext (org.eclipse.che.commons.env.EnvironmentContext)13