Search in sources :

Example 16 with RuntimeIdentityImpl

use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project che-server by eclipse-che.

the class StartSynchronizerTest method shouldAddSubscribersAfterStart.

@Test
public void shouldAddSubscribersAfterStart() throws Exception {
    // given
    runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
    EventService eventService = new EventService();
    startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
    // when
    startSynchronizer.start();
    // then
    assertSubscriberTypesNumber(eventService, 2);
    assertSubscribersNumber(eventService, KubernetesRuntimeStoppingEvent.class, 1);
    assertSubscribersNumber(eventService, KubernetesRuntimeStoppedEvent.class, 1);
}
Also used : EventService(org.eclipse.che.api.core.notification.EventService) RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) Test(org.testng.annotations.Test)

Example 17 with RuntimeIdentityImpl

use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project che-server by eclipse-che.

the class StartSynchronizerTest method shouldUnsubscribeEventsWhenItIscCompleteExceptionally.

@Test
public void shouldUnsubscribeEventsWhenItIscCompleteExceptionally() throws Exception {
    // given
    runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
    EventService eventService = new EventService();
    startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
    startSynchronizer.start();
    // when
    startSynchronizer.completeExceptionally(new Exception());
    // then
    assertSubscribersNumber(eventService, KubernetesRuntimeStoppingEvent.class, 0);
    assertSubscribersNumber(eventService, KubernetesRuntimeStoppedEvent.class, 0);
}
Also used : EventService(org.eclipse.che.api.core.notification.EventService) RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) InternalInfrastructureException(org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException) CompletionException(java.util.concurrent.CompletionException) RuntimeStartInterruptedException(org.eclipse.che.api.workspace.server.spi.RuntimeStartInterruptedException) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Test(org.testng.annotations.Test)

Example 18 with RuntimeIdentityImpl

use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project che-server by eclipse-che.

the class StartSynchronizerTest method setUp.

@BeforeMethod
public void setUp() {
    runtimeId = new RuntimeIdentityImpl("workspace123", "envName", "ownerId", "infraNamespace");
    startSynchronizer = new StartSynchronizer(eventService, 5, runtimeId);
}
Also used : RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 19 with RuntimeIdentityImpl

use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project che-server by eclipse-che.

the class KubernetesRuntimeStateCacheTest method shouldReturnEmptyOptionalWhenThereIsNotRuntimeStateWhileStatusRetrieving.

@Test
public void shouldReturnEmptyOptionalWhenThereIsNotRuntimeStateWhileStatusRetrieving() throws Exception {
    // when
    Optional<WorkspaceStatus> statusOpt = runtimesStatesCache.getStatus(new RuntimeIdentityImpl("non-existent-ws", "defEnv", "acc1", "infraNamespace"));
    // then
    assertFalse(statusOpt.isPresent());
}
Also used : WorkspaceStatus(org.eclipse.che.api.core.model.workspace.WorkspaceStatus) RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) Test(org.testng.annotations.Test)

Example 20 with RuntimeIdentityImpl

use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project che-server by eclipse-che.

the class KubernetesRuntimeStateCacheTest method shouldReturnEmptyCommandsListIfStateDoesNotExist.

@Test
public void shouldReturnEmptyCommandsListIfStateDoesNotExist() throws Exception {
    // when
    List<? extends Command> commands = runtimesStatesCache.getCommands(new RuntimeIdentityImpl("non-existent-ws", "defEnv", "acc1", "infraNamespace"));
    // then
    assertTrue(commands.isEmpty());
}
Also used : RuntimeIdentityImpl(org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl) Test(org.testng.annotations.Test)

Aggregations

RuntimeIdentityImpl (org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl)98 Test (org.testng.annotations.Test)92 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)68 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)22 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)18 RuntimeContext (org.eclipse.che.api.workspace.server.spi.RuntimeContext)18 InternalEnvironment (org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironment)16 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)14 SubjectImpl (org.eclipse.che.commons.subject.SubjectImpl)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)10 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)8 Secret (io.fabric8.kubernetes.api.model.Secret)8 ValidationException (org.eclipse.che.api.core.ValidationException)8 Environment (org.eclipse.che.api.core.model.workspace.config.Environment)8 EventService (org.eclipse.che.api.core.notification.EventService)8 InternalInfrastructureException (org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException)8 CredentialsSecretConfigurator (org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.CredentialsSecretConfigurator)8 PreferencesConfigMapConfigurator (org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.PreferencesConfigMapConfigurator)8 WorkspaceServiceAccountConfigurator (org.eclipse.che.workspace.infrastructure.kubernetes.namespace.configurator.WorkspaceServiceAccountConfigurator)8