use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl in project che by eclipse.
the class WorkspaceRuntimesTest method interruptsStartAfterEnvironmentIsStartedButRuntimeStatusIsNotRunning.
@Test
public void interruptsStartAfterEnvironmentIsStartedButRuntimeStatusIsNotRunning() 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", () -> setRuntime("workspace", WorkspaceStatus.STOPPING));
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.STOPPED, null));
verify(envEngine).stop(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl in project che by eclipse.
the class WorkspaceRuntimesTest method interruptsStartAfterEnvironmentIsStartedButThreadIsInterrupted.
@Test
public void interruptsStartAfterEnvironmentIsStartedButThreadIsInterrupted() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
// the status is successfully updated from STARTING -> RUNNING but after
// that thread is interrupted so #stop is waiting for starting thread to stop the environment
allowEnvironmentStart(workspace, "env-name", () -> Thread.currentThread().interrupt());
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.STOPPED, null));
verify(envEngine).stop(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl 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.WorkspaceRuntimeImpl 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.WorkspaceRuntimeImpl in project che by eclipse.
the class WorkspaceRuntimesTest method getsRuntime.
@Test
public void getsRuntime() throws Exception {
setRuntime("workspace", WorkspaceStatus.RUNNING, "env-name");
List<Instance> machines = prepareMachines("workspace", "env-name");
assertEquals(runtimes.getRuntime("workspace"), new WorkspaceRuntimeImpl("env-name", machines));
verify(envEngine).getMachines("workspace");
}
Aggregations