Search in sources :

Example 1 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.

the class OpenShiftRuntimeContext method getRuntime.

@Override
public OpenShiftInternalRuntime getRuntime() throws InfrastructureException {
    Optional<KubernetesRuntimeState> runtimeStateOpt = runtimeStatuses.get(getIdentity());
    String workspaceId = getIdentity().getWorkspaceId();
    if (!runtimeStateOpt.isPresent()) {
        // there is no cached runtime, create a new one
        return runtimeFactory.create(this, projectFactory.getOrCreate(getIdentity()));
    }
    // there is cached runtime, restore cached one
    KubernetesRuntimeState runtimeState = runtimeStateOpt.get();
    RuntimeIdentity runtimeId = runtimeState.getRuntimeId();
    LOG.debug("Restoring runtime `{}:{}:{}`", runtimeId.getWorkspaceId(), runtimeId.getEnvName(), runtimeId.getOwnerId());
    OpenShiftInternalRuntime runtime = runtimeFactory.create(this, projectFactory.access(workspaceId, runtimeState.getNamespace()));
    runtime.scheduleRuntimeStateChecks();
    return runtime;
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState)

Example 2 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.

the class KubernetesInternalRuntimeTest method shouldNotScheduleServerCheckersIfRuntimeIsNotStartingOrRunning.

@Test(dataProvider = "nonStartingRunningStatuses")
public void shouldNotScheduleServerCheckersIfRuntimeIsNotStartingOrRunning(WorkspaceStatus status) throws Exception {
    // given
    runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), status, emptyList()));
    // when
    internalRuntime.scheduleServersCheckers();
    // then
    verifyNoMoreInteractions(probesScheduler);
}
Also used : KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Example 3 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.

the class KubernetesInternalRuntimeTest method shouldThrowExceptionIfRuntimeIsAlreadyStarting.

@Test(expectedExceptions = StateException.class, expectedExceptionsMessageRegExp = "Runtime is already started")
public void shouldThrowExceptionIfRuntimeIsAlreadyStarting() throws Exception {
    // given
    runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), WorkspaceStatus.STARTING, emptyList()));
    // when
    internalRuntime.markStarting();
}
Also used : KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Example 4 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.

the class KubernetesInternalRuntimeTest method shouldRemoveRuntimeStateOnMarkingRuntimeStopped.

@Test
public void shouldRemoveRuntimeStateOnMarkingRuntimeStopped() throws Exception {
    // given
    runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), WorkspaceStatus.STOPPING, emptyList()));
    // when
    internalRuntime.markStopped();
    // then
    assertFalse(runtimeStatesCache.get(internalRuntime.getContext().getIdentity()).isPresent());
}
Also used : KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Example 5 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.

the class KubernetesInternalRuntimeTest method shouldScheduleServerCheckersForRunningRuntime.

@Test
public void shouldScheduleServerCheckersForRunningRuntime() throws Exception {
    // given
    runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), WorkspaceStatus.RUNNING, emptyList()));
    // when
    internalRuntime.scheduleServersCheckers();
    // then
    verify(probesScheduler).schedule(any(), any());
}
Also used : KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Aggregations

KubernetesRuntimeState (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState)48 Test (org.testng.annotations.Test)34 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)8 TypeLiteral (com.google.inject.TypeLiteral)6 AccountImpl (org.eclipse.che.account.spi.AccountImpl)6 WorkspaceStatus (org.eclipse.che.api.core.model.workspace.WorkspaceStatus)6 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)6 PersistTestModuleBuilder (org.eclipse.che.commons.test.db.PersistTestModuleBuilder)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)6 DBInitializer (org.eclipse.che.core.db.DBInitializer)6 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)6 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)6 KubernetesMachineCache (org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache)6 KubernetesRuntimeStateCache (org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache)6 KubernetesMachineImpl (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl)6 KubernetesServerImpl (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl)6 AccountDao (org.eclipse.che.account.spi.AccountDao)4 JpaAccountDao (org.eclipse.che.account.spi.jpa.JpaAccountDao)4 JpaUserDevfileDao (org.eclipse.che.api.devfile.server.jpa.JpaUserDevfileDao)4 UserDevfileImpl (org.eclipse.che.api.devfile.server.model.impl.UserDevfileImpl)4