Search in sources :

Example 26 with KubernetesRuntimeState

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState in project devspaces-images by redhat-developer.

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());
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Example 27 with KubernetesRuntimeState

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

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));
}
Also used : TckResourcesCleaner(org.eclipse.che.commons.test.tck.TckResourcesCleaner) MachineId(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl.MachineId) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Driver(org.h2.Driver) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) ServerConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl) ComponentImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl) H2JpaCleaner(org.eclipse.che.commons.test.db.H2JpaCleaner) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) FlywaySchemaInitializer(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer) KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) ServerId(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl.ServerId) TypeLiteral(com.google.inject.TypeLiteral) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) DBInitializer(org.eclipse.che.core.db.DBInitializer) DevfileImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.DevfileImpl) KubernetesMachineCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) CommandImpl(org.eclipse.che.api.workspace.server.model.impl.CommandImpl) KubernetesRuntimeCommandImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeCommandImpl) EntrypointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EntrypointImpl) H2DBTestServer(org.eclipse.che.commons.test.db.H2DBTestServer) ProjectImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ProjectImpl) EndpointImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EndpointImpl) EnvImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.EnvImpl) KubernetesRuntimeStateCache(org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache) SourceStorageImpl(org.eclipse.che.api.workspace.server.model.impl.SourceStorageImpl) PersistTestModuleBuilder(org.eclipse.che.commons.test.db.PersistTestModuleBuilder) SerializableConverter(org.eclipse.che.api.workspace.server.devfile.SerializableConverter) MachineConfigImpl(org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl) SourceImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.SourceImpl) VolumeImpl(org.eclipse.che.api.workspace.server.model.impl.VolumeImpl) ActionImpl(org.eclipse.che.api.workspace.server.model.impl.devfile.ActionImpl) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)

Example 28 with KubernetesRuntimeState

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

the class KubernetesInternalRuntimeTest method shouldScheduleServerCheckersForStartingRuntime.

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

Example 29 with KubernetesRuntimeState

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

the class KubernetesInternalRuntimeTest method shouldThrowExceptionWhenTryToMakeNonRunningNorStartingRuntimeAsStopping.

@Test(expectedExceptions = StateException.class, expectedExceptionsMessageRegExp = "The environment must be running or starting", dataProvider = "nonRunningStatuses")
public void shouldThrowExceptionWhenTryToMakeNonRunningNorStartingRuntimeAsStopping(WorkspaceStatus status) throws Exception {
    // given
    runtimeStatesCache.putIfAbsent(new KubernetesRuntimeState(internalRuntime.getContext().getIdentity(), status, emptyList()));
    // when
    internalRuntime.markStopping();
}
Also used : KubernetesRuntimeState(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesRuntimeState) Test(org.testng.annotations.Test)

Example 30 with KubernetesRuntimeState

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

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());
}
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