Search in sources :

Example 66 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldFailIfVolumesFromFieldHasIllegalFormat.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Service volumes_from '.*' is invalid")
public void shouldFailIfVolumesFromFieldHasIllegalFormat() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withVolumesFrom(singletonList("first:broken:dependency")));
    composeEnvironment.getServices().put("third", new CheServiceImpl());
    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 67 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldFailIfMachineDependsOnByItSelf.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "A machine can not depend on itself: .*")
public void shouldFailIfMachineDependsOnByItSelf() {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("first", new CheServiceImpl().withDependsOn(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 68 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldFailIfLinksFieldContainsNonExistingService.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Dependency 'fifth' in machine 'second' points to unknown machine.")
public void shouldFailIfLinksFieldContainsNonExistingService() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withLinks(singletonList("fifth")));
    composeEnvironment.getServices().put("third", new CheServiceImpl());
    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 69 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldOrderServicesWithComplementaryDependenciesInDependsOnLinksAndVolumesFrom.

@Test
public void shouldOrderServicesWithComplementaryDependenciesInDependsOnLinksAndVolumesFrom() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withVolumesFrom(singletonList("first")));
    composeEnvironment.getServices().put("third", new CheServiceImpl().withVolumesFrom(singletonList("second")).withDependsOn(singletonList("first")));
    composeEnvironment.getServices().put("first", new CheServiceImpl());
    composeEnvironment.getServices().put("forth", new CheServiceImpl().withVolumesFrom(singletonList("third")).withDependsOn(singletonList("second")).withLinks(singletonList("first:alias")));
    composeEnvironment.getServices().put("fifth", new CheServiceImpl().withVolumesFrom(singletonList("first")).withLinks(singletonList("forth")).withDependsOn(singletonList("second")));
    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 70 with CheServiceImpl

use of org.eclipse.che.api.environment.server.model.CheServiceImpl in project che by eclipse.

the class DefaultServicesStartStrategyTest method shouldOrderServicesWithLinks.

@Test
public void shouldOrderServicesWithLinks() throws Exception {
    // given
    CheServicesEnvironmentImpl composeEnvironment = new CheServicesEnvironmentImpl();
    composeEnvironment.getServices().put("second", new CheServiceImpl().withLinks(singletonList("first:alias")));
    composeEnvironment.getServices().put("third", new CheServiceImpl().withLinks(asList("first", "second")));
    composeEnvironment.getServices().put("first", new CheServiceImpl().withLinks(emptyList()));
    composeEnvironment.getServices().put("forth", new CheServiceImpl().withLinks(singletonList("third")));
    composeEnvironment.getServices().put("fifth", new CheServiceImpl().withLinks(asList("forth:alias", "first:alias")));
    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)

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