use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class CheEnvironmentEngineTest method stopOfEnvironmentShouldDestroyNetworkWhenNoMachineExists.
@Test
public void stopOfEnvironmentShouldDestroyNetworkWhenNoMachineExists() throws Exception {
// given
List<Instance> instances = startEnv();
String workspaceId = instances.get(0).getWorkspaceId();
for (Instance instance : instances) {
engine.removeMachineFromEnvironment(instance.getWorkspaceId(), instance.getId());
}
// when
engine.stop(workspaceId);
// then
for (Instance instance : instances) {
verify(instance, never()).destroy();
}
verify(machineProvider).destroyNetwork(anyString());
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class CheEnvironmentEngineTest method shouldApplyAgentsOnDockerMachineStart.
@Test
public void shouldApplyAgentsOnDockerMachineStart() throws Exception {
// given
List<Instance> instances = startEnv();
String workspaceId = instances.get(0).getWorkspaceId();
when(engine.generateMachineId()).thenReturn("newMachineId");
Instance newMachine = mock(Instance.class);
when(newMachine.getId()).thenReturn("newMachineId");
when(newMachine.getWorkspaceId()).thenReturn(workspaceId);
when(machineProvider.startService(anyString(), anyString(), anyString(), anyString(), anyBoolean(), anyString(), any(CheServiceImpl.class), any(LineConsumer.class))).thenReturn(newMachine);
MachineConfigImpl config = createConfig(false);
List<String> agents = asList("agent1", "agent2");
// when
engine.startMachine(workspaceId, config, agents);
// then
verify(infrastructureProvisioner).provision(any(ExtendedMachineImpl.class), any(CheServiceImpl.class));
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class CheEnvironmentEngineTest method shouldBeAbleToStopEnv.
@Test
public void shouldBeAbleToStopEnv() throws Exception {
// given
List<Instance> instances = startEnv();
Instance instance = instances.get(0);
// when
engine.stop(instance.getWorkspaceId());
// then
for (Instance instance1 : instances) {
verify(instance1).destroy();
}
verify(machineProvider).destroyNetwork(anyString());
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class CheEnvironmentEngineTest method shouldBeAbleToStopMachine.
@Test
public void shouldBeAbleToStopMachine() throws Exception {
// given
List<Instance> instances = startEnv();
Optional<Instance> instanceOpt = instances.stream().filter(machine -> !machine.getConfig().isDev()).findAny();
assertTrue(instanceOpt.isPresent(), "Required for test non-dev machine is not found");
Instance instance = instanceOpt.get();
// when
engine.stopMachine(instance.getWorkspaceId(), instance.getId());
// then
verify(instance).destroy();
}
use of org.eclipse.che.api.machine.server.spi.Instance in project che by eclipse.
the class CheEnvironmentEngineTest method shouldBeAbleToGetMachineOfEnv.
@Test
public void shouldBeAbleToGetMachineOfEnv() throws Exception {
// given
List<Instance> instances = startEnv();
Instance instance = instances.get(0);
String workspaceId = instance.getWorkspaceId();
// when
Instance actualInstance = engine.getMachine(workspaceId, instance.getId());
// then
assertEquals(actualInstance, instance);
}
Aggregations