use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method injectsRuntime.
@Test
public void injectsRuntime() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING, "env-name");
List<Instance> machines = prepareMachines("workspace", "env-name");
WorkspaceImpl workspace = WorkspaceImpl.builder().setId("workspace").build();
runtimes.injectRuntime(workspace);
assertEquals(workspace.getStatus(), WorkspaceStatus.RUNNING);
assertEquals(workspace.getRuntime(), new WorkspaceRuntimeImpl("env-name", machines));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method startsWorkspace.
@Test
public void startsWorkspace() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
List<Instance> machines = allowEnvironmentStart(workspace, "env-name");
prepareMachines(workspace.getId(), machines);
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAsyncTaskAndExecuteSynchronously();
WorkspaceRuntimeImpl runtime = cmpFuture.get();
assertEquals(runtimes.getStatus(workspace.getId()), WorkspaceStatus.RUNNING);
assertEquals(runtime.getActiveEnv(), "env-name");
assertEquals(runtime.getMachines().size(), machines.size());
verifyEventsSequence(event("workspace", WorkspaceStatus.STOPPED, WorkspaceStatus.STARTING, EventType.STARTING, null), event("workspace", WorkspaceStatus.STARTING, WorkspaceStatus.RUNNING, EventType.RUNNING, null));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method throwsStartInterruptedExceptionWhenStartIsInterruptedAndEnvironmentStopIsFailed.
@Test
public void throwsStartInterruptedExceptionWhenStartIsInterruptedAndEnvironmentStopIsFailed() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
// let's say status is changed to STOPPING by stop method,
// but starting thread hasn't been interrupted yet
allowEnvironmentStart(workspace, "env-name", () -> Thread.currentThread().interrupt());
rejectEnvironmentStop(workspace, new ServerException("no!"));
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAndVerifyRuntimeStateAfterInterruption(workspace, cmpFuture);
verifyEventsSequence(event("workspace", WorkspaceStatus.STOPPED, WorkspaceStatus.STARTING, EventType.STARTING, null), event("workspace", WorkspaceStatus.STARTING, WorkspaceStatus.STOPPING, EventType.STOPPING, null), event("workspace", WorkspaceStatus.STOPPING, WorkspaceStatus.STOPPED, EventType.ERROR, "no!"));
verify(envEngine).stop(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method startedRuntimeAndReturnedFromGetMethodAreTheSame.
@Test
public void startedRuntimeAndReturnedFromGetMethodAreTheSame() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
allowEnvironmentStart(workspace, "env-name");
prepareMachines(workspace.getId(), "env-name");
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAsyncTaskAndExecuteSynchronously();
assertEquals(cmpFuture.get(), runtimes.getRuntime(workspace.getId()));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method throwsConflictExceptionWhenWorkspaceIsRunning.
@Test(expectedExceptions = ConflictException.class, expectedExceptionsMessageRegExp = "Could not start workspace 'test-workspace' because its status is 'RUNNING'")
public void throwsConflictExceptionWhenWorkspaceIsRunning() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
setRuntime(workspace.getId(), WorkspaceStatus.RUNNING);
runtimes.startAsync(workspace, "env-name", false);
}
Aggregations