Search in sources :

Example 11 with CheServiceImpl

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

Example 12 with CheServiceImpl

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

Example 13 with CheServiceImpl

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

Example 14 with CheServiceImpl

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);
}
Also used : LineConsumer(org.eclipse.che.api.core.util.LineConsumer) CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) 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) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 15 with CheServiceImpl

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;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Matchers.anyString(org.mockito.Matchers.anyString)

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