use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project devspaces-images by redhat-developer.
the class JpaTckModule method configure.
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class).runningOn(server).addEntityClasses(WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, SourceStorageImpl.class, EnvironmentImpl.class, MachineConfigImpl.class, ServerConfigImpl.class, VolumeImpl.class, CommandImpl.class, AccountImpl.class, KubernetesRuntimeState.class, KubernetesRuntimeCommandImpl.class, KubernetesMachineImpl.class, MachineId.class, KubernetesServerImpl.class, ServerId.class, // devfile
ActionImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.CommandImpl.class, ComponentImpl.class, DevfileImpl.class, EndpointImpl.class, EntrypointImpl.class, EnvImpl.class, ProjectImpl.class, SourceImpl.class, org.eclipse.che.api.workspace.server.model.impl.devfile.VolumeImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").addClass(SerializableConverter.class).setExceptionHandler(H2ExceptionHandler.class).build());
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new JpaTckRepository<>(WorkspaceImpl.class));
bind(new TypeLiteral<TckRepository<KubernetesRuntimeState>>() {
}).toInstance(new JpaTckRepository<>(KubernetesRuntimeState.class));
bind(new TypeLiteral<TckRepository<KubernetesMachineImpl>>() {
}).toInstance(new JpaTckRepository<>(KubernetesMachineImpl.class));
bind(KubernetesRuntimeStateCache.class).to(JpaKubernetesRuntimeStateCache.class);
bind(KubernetesMachineCache.class).to(JpaKubernetesMachineCache.class);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(server.getDataSource(), "che-schema"));
bind(DBInitializer.class).asEagerSingleton();
bind(TckResourcesCleaner.class).toInstance(new H2JpaCleaner(server));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project devspaces-images by redhat-developer.
the class KubernetesRuntimeStateCacheTest method shouldUpdateStatus.
@Test(dependsOnMethods = "shouldReturnRuntimeStatus")
public void shouldUpdateStatus() throws Exception {
// given
KubernetesRuntimeState stateToUpdate = runtimesStates[0];
// when
runtimesStatesCache.updateStatus(stateToUpdate.getRuntimeId(), WorkspaceStatus.STOPPED);
// then
Optional<WorkspaceStatus> updatedStatusOpt = runtimesStatesCache.getStatus(stateToUpdate.getRuntimeId());
assertTrue(updatedStatusOpt.isPresent());
assertEquals(updatedStatusOpt.get(), WorkspaceStatus.STOPPED);
assertNotEquals(stateToUpdate, WorkspaceStatus.STOPPED);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project devspaces-images by redhat-developer.
the class KubernetesRuntimeStateCacheTest method shouldRemoveRuntimeState.
@Test(dependsOnMethods = "shouldReturnEmptyOptionalIfRuntimeStateIsNotFound")
public void shouldRemoveRuntimeState() throws Exception {
// given
KubernetesRuntimeState runtimeState = createRuntimeState(workspaces[0]);
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 devspaces-images by redhat-developer.
the class KubernetesRuntimeStateCacheTest method shouldReturnEmptyOptionalIfRuntimeStateIsNotFound.
@Test
public void shouldReturnEmptyOptionalIfRuntimeStateIsNotFound() throws Exception {
// given
KubernetesRuntimeState nonExisting = createRuntimeState(workspaces[2]);
// when
Optional<KubernetesRuntimeState> fetchedOpt = runtimesStatesCache.get(nonExisting.getRuntimeId());
// then
assertFalse(fetchedOpt.isPresent());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project devspaces-images by redhat-developer.
the class KubernetesRuntimeStateCacheTest method shouldNotUpdateStatusIfPreviousValueDoesNotMatchesPredicate.
@Test(dependsOnMethods = "shouldReturnRuntimeStatus")
public void shouldNotUpdateStatusIfPreviousValueDoesNotMatchesPredicate() throws Exception {
// given
KubernetesRuntimeState stateToUpdate = runtimesStates[0];
// when
boolean isUpdated = runtimesStatesCache.updateStatus(stateToUpdate.getRuntimeId(), s -> s == WorkspaceStatus.STARTING, WorkspaceStatus.STOPPED);
// then
assertFalse(isUpdated);
Optional<WorkspaceStatus> updatedStatusOpt = runtimesStatesCache.getStatus(stateToUpdate.getRuntimeId());
assertTrue(updatedStatusOpt.isPresent());
assertEquals(updatedStatusOpt.get(), WorkspaceStatus.RUNNING);
assertEquals(stateToUpdate.getStatus(), WorkspaceStatus.RUNNING);
}
Aggregations