Search in sources :

Example 6 with WorkspaceImpl

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));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Instance(org.eclipse.che.api.machine.server.spi.Instance) NoOpMachineInstance(org.eclipse.che.api.environment.server.NoOpMachineInstance) WorkspaceRuntimeImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl) Test(org.testng.annotations.Test)

Example 7 with WorkspaceImpl

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));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Instance(org.eclipse.che.api.machine.server.spi.Instance) NoOpMachineInstance(org.eclipse.che.api.environment.server.NoOpMachineInstance) WorkspaceRuntimeImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl) Test(org.testng.annotations.Test)

Example 8 with WorkspaceImpl

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());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) ServerException(org.eclipse.che.api.core.ServerException) WorkspaceRuntimeImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl) Test(org.testng.annotations.Test)

Example 9 with WorkspaceImpl

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()));
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceRuntimeImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl) Test(org.testng.annotations.Test)

Example 10 with WorkspaceImpl

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);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Aggregations

WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)165 Test (org.testng.annotations.Test)130 Response (com.jayway.restassured.response.Response)34 WorkspaceRuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl)15 ServerException (org.eclipse.che.api.core.ServerException)14 SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)12 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 AccountImpl (org.eclipse.che.account.spi.AccountImpl)11 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)10 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)9 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)9 NotFoundException (org.eclipse.che.api.core.NotFoundException)8 MachineImpl (org.eclipse.che.api.machine.server.model.impl.MachineImpl)8 Consumes (javax.ws.rs.Consumes)7 ConflictException (org.eclipse.che.api.core.ConflictException)7 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)7 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)7