use of org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToStartMachineInRunningWs.
@Test
public void shouldBeAbleToStartMachineInRunningWs() throws Exception {
// given
WorkspaceImpl workspace = createAndMockWorkspace();
WorkspaceRuntimeImpl runtime = mockRuntime(workspace, RUNNING);
MachineConfigImpl machineConfig = createMachine(workspace.getId(), runtime.getActiveEnv(), false).getConfig();
// when
workspaceManager.startMachine(machineConfig, workspace.getId());
// then
captureExecuteCallsAndRunSynchronously();
verify(runtimes).startMachine(workspace.getId(), machineConfig);
}
use of org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl in project che by eclipse.
the class CheEnvironmentEngineTest method shouldBeAbleToStartMachine.
@Test
public void shouldBeAbleToStartMachine() throws Exception {
// given
List<Instance> instances = startEnv();
verify(machineProvider, times(2)).startService(anyString(), anyString(), anyString(), anyString(), anyBoolean(), anyString(), any(CheServiceImpl.class), any(LineConsumer.class));
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);
// when
Instance actualInstance = engine.startMachine(workspaceId, config, emptyList());
// then
assertEquals(actualInstance, newMachine);
verify(instanceProvider, never()).createInstance(any(Machine.class), any(LineConsumer.class));
verify(machineProvider, times(3)).startService(anyString(), anyString(), anyString(), anyString(), anyBoolean(), anyString(), any(CheServiceImpl.class), any(LineConsumer.class));
}
use of org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl in project che by eclipse.
the class CheEnvironmentEngineTest method shouldUseConfiguredInMachineRamInsteadOfSetDefaultOnMachineStart.
@Test
public void shouldUseConfiguredInMachineRamInsteadOfSetDefaultOnMachineStart() 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);
String machineName = "extraMachine";
config.setName(machineName);
config.setLimits(new MachineLimitsImpl(4096));
// when
engine.startMachine(workspaceId, config, emptyList());
// 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();
assertEquals((long) actualService.getMemLimit(), 4096L * 1024L * 1024L);
}
use of org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl in project che by eclipse.
the class CheEnvironmentEngineTest method shouldThrowExceptionOnMachineStartIfEnvironmentIsNotRunning.
@Test(expectedExceptions = EnvironmentNotRunningException.class, expectedExceptionsMessageRegExp = "Environment '.*' is not running")
public void shouldThrowExceptionOnMachineStartIfEnvironmentIsNotRunning() throws Exception {
MachineConfigImpl config = createConfig(false);
// when
engine.startMachine("wsIdOfNotRunningEnv", config, emptyList());
}
use of org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl in project che by eclipse.
the class CheEnvironmentEngineTest method shouldSetDockerfileContentInsteadOfUrlIfUrlPointsToCheApiOnMachineStart.
@Test
public void shouldSetDockerfileContentInsteadOfUrlIfUrlPointsToCheApiOnMachineStart() 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);
String machineName = "extraMachine";
config.setName(machineName);
config.setSource(new MachineSourceImpl("docker").setLocation(API_ENDPOINT + "/recipe/12345"));
String dockerfileContent = "this is dockerfile content";
when(recipeDownloader.getRecipe(anyString())).thenReturn("this is dockerfile content");
// when
engine.startMachine(workspaceId, config, emptyList());
// 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().getContext());
assertNull(actualService.getBuild().getDockerfilePath());
assertEquals(actualService.getBuild().getDockerfileContent(), dockerfileContent);
}
Aggregations