use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method shouldMarkRuntimeStopping.
@Test
public void shouldMarkRuntimeStopping() throws Exception {
// given
runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), WorkspaceStatus.RUNNING, emptyList()));
// when
internalRuntime.markStopping();
// then
assertEquals(internalRuntime.getStatus(), WorkspaceStatus.STOPPING);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.
the class KubernetesInternalRuntimeTest method shouldMarkRuntimeRunning.
@Test
public void shouldMarkRuntimeRunning() throws Exception {
// given
runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), WorkspaceStatus.STARTING, emptyList()));
// when
internalRuntime.markRunning();
// then
assertEquals(internalRuntime.getStatus(), WorkspaceStatus.RUNNING);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.
the class KubernetesRuntimeStateCacheTest method shouldDoNothingIfStateIsAlreadyRemove.
@Test(dependsOnMethods = "shouldReturnEmptyOptionalIfRuntimeStateIsNotFound")
public void shouldDoNothingIfStateIsAlreadyRemove() throws Exception {
// given
KubernetesRuntimeState runtimeState = createRuntimeState(workspaces[2]);
RuntimeIdentity toRemove = runtimeState.getRuntimeId();
// when
runtimesStatesCache.remove(toRemove);
// then
assertFalse(runtimesStatesCache.get(toRemove).isPresent());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.
the class KubernetesRuntimeStateCacheTest method shouldNotPutRuntimeStateIfRuntimeStateIsAlreadyPut.
@Test(dependsOnMethods = "shouldReturnRuntimeStateByRuntimeId")
public void shouldNotPutRuntimeStateIfRuntimeStateIsAlreadyPut() throws Exception {
// given
KubernetesRuntimeState runtimeState = createRuntimeState(workspaces[0]);
// when
boolean isInserted = runtimesStatesCache.putIfAbsent(runtimeState);
// then
assertFalse(isInserted);
Optional<KubernetesRuntimeState> fetchedState = runtimesStatesCache.get(runtimeState.getRuntimeId());
assertTrue(fetchedState.isPresent());
assertEquals(runtimesStates[0], fetchedState.get());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project che-server by eclipse-che.
the class KubernetesRuntimeStateCacheTest method shouldUpdateStatusIfPreviousValueMatchesPredicate.
@Test(dependsOnMethods = "shouldReturnRuntimeStatus")
public void shouldUpdateStatusIfPreviousValueMatchesPredicate() throws Exception {
// given
KubernetesRuntimeState stateToUpdate = runtimesStates[0];
// when
boolean isUpdated = runtimesStatesCache.updateStatus(stateToUpdate.getRuntimeId(), s -> s == stateToUpdate.getStatus(), WorkspaceStatus.STOPPED);
// then
assertTrue(isUpdated);
Optional<WorkspaceStatus> updatedStatusOpt = runtimesStatesCache.getStatus(stateToUpdate.getRuntimeId());
assertTrue(updatedStatusOpt.isPresent());
assertEquals(updatedStatusOpt.get(), WorkspaceStatus.STOPPED);
assertNotEquals(stateToUpdate, WorkspaceStatus.STOPPED);
}
Aggregations