Search in sources :

Example 26 with StartupEvent

use of io.quarkus.runtime.StartupEvent in project entando-k8s-controller-coordinator by entando-k8s.

the class PodManagementTests method shouldGarbageCollectSuccessulPods.

@Test
@Description("Should automatically remove successful controller pods once the resource has progress to the 'successful' phase")
void shouldGarbageCollectSuccessulPods() {
    step("Given  I have activated controller Pod garbage collection with a removal delay of 1 second", () -> {
        System.setProperty(ControllerCoordinatorProperty.ENTANDO_K8S_CONTROLLER_REMOVAL_DELAY.getJvmSystemProperty(), "1");
        System.setProperty(EntandoOperatorConfigProperty.ENTANDO_K8S_OPERATOR_GC_CONTROLLER_PODS.getJvmSystemProperty(), "true");
    });
    step("And the Coordinator observes its own namespace", () -> {
        System.setProperty(EntandoOperatorConfigProperty.ENTANDO_NAMESPACES_TO_OBSERVE.getJvmSystemProperty(), clientDouble.getNamespace());
        coordinator.onStartup(new StartupEvent());
    });
    ValueHolder<SerializedEntandoResource> testResource = new ValueHolder<>();
    step("And I have created a new TestResource resource", () -> {
        TestResource f = new TestResource().withNames(clientDouble.getNamespace(), "test-keycloak").withSpec(new BasicDeploymentSpecBuilder().withDbms(DbmsVendor.EMBEDDED).build());
        f.getMetadata().setGeneration(1L);
        testResource.set(clientDouble.createOrPatchEntandoResource(CoordinatorTestUtils.toSerializedResource(f)));
        attachment("TestResource", objectMapper.writeValueAsString(testResource.get()));
    });
    step("And I have waited for the controller pod to be created", () -> {
        await().ignoreExceptions().atMost(3, TimeUnit.SECONDS).until(() -> clientDouble.loadPod(clientDouble.getNamespace(), labelsFromResource(testResource.get())) != null);
        attachment("Controller Pod", objectMapper.writeValueAsString(clientDouble.loadPod(clientDouble.getNamespace(), labelsFromResource(testResource.get()))));
    });
    step("When I complete the deployment of the TestResource successfully", () -> {
        ExecutorService executor = Executors.newSingleThreadExecutor();
        executor.submit(() -> {
            clientDouble.updatePodStatus(podWithSucceededStatus(clientDouble.loadPod(clientDouble.getNamespace(), labelsFromResource(testResource.get()))));
        });
        attachment("Suffessful Resource", objectMapper.writeValueAsString(clientDouble.updatePhase(testResource.get(), EntandoDeploymentPhase.SUCCESSFUL)));
    });
    step("Then the previously created, but successfully completed controller pod will be removed", () -> await().ignoreExceptions().atMost(3, TimeUnit.SECONDS).until(() -> clientDouble.loadPod(clientDouble.getNamespace(), labelsFromResource(testResource.get())) == null));
}
Also used : SerializedEntandoResource(org.entando.kubernetes.controller.spi.client.SerializedEntandoResource) StartupEvent(io.quarkus.runtime.StartupEvent) ExecutorService(java.util.concurrent.ExecutorService) TestResource(org.entando.kubernetes.fluentspi.TestResource) ValueHolder(org.entando.kubernetes.test.common.ValueHolder) BasicDeploymentSpecBuilder(org.entando.kubernetes.fluentspi.BasicDeploymentSpecBuilder) Description(io.qameta.allure.Description) Test(org.junit.jupiter.api.Test)

Example 27 with StartupEvent

use of io.quarkus.runtime.StartupEvent in project jobrunr by jobrunr.

the class JobRunrStarterTest method jobRunrStarterStartsDashboardIfConfigured.

@Test
void jobRunrStarterStartsDashboardIfConfigured() {
    dashboardConfiguration.enabled = true;
    jobRunrStarter.startup(new StartupEvent());
    verify(dashboardWebServer).start();
}
Also used : StartupEvent(io.quarkus.runtime.StartupEvent) Test(org.junit.jupiter.api.Test)

Example 28 with StartupEvent

use of io.quarkus.runtime.StartupEvent in project jobrunr by jobrunr.

the class JobRunrStarterTest method jobRunrStarterStartsBackgroundJobServerIfConfigured.

@Test
void jobRunrStarterStartsBackgroundJobServerIfConfigured() {
    backgroundJobServerConfiguration.enabled = true;
    jobRunrStarter.startup(new StartupEvent());
    verify(backgroundJobServer).start();
}
Also used : StartupEvent(io.quarkus.runtime.StartupEvent) Test(org.junit.jupiter.api.Test)

Example 29 with StartupEvent

use of io.quarkus.runtime.StartupEvent in project jobrunr by jobrunr.

the class JobRunrStarterTest method jobRunrStarterDoesNotStartDashboardIfNotConfigured.

@Test
void jobRunrStarterDoesNotStartDashboardIfNotConfigured() {
    dashboardConfiguration.enabled = false;
    jobRunrStarter.startup(new StartupEvent());
    verify(dashboardWebServerInstance, never()).get();
}
Also used : StartupEvent(io.quarkus.runtime.StartupEvent) Test(org.junit.jupiter.api.Test)

Example 30 with StartupEvent

use of io.quarkus.runtime.StartupEvent in project jobrunr by jobrunr.

the class JobRunrMetricsStarterTest method metricsStarterDoesNotStartBackgroundJobServerMetricsBinderIfNotAvailable.

@Test
void metricsStarterDoesNotStartBackgroundJobServerMetricsBinderIfNotAvailable() {
    jobRunrMetricsStarter.startup(new StartupEvent());
    verify(backgroundJobServerMetricsBinderInstance, never()).get();
}
Also used : StartupEvent(io.quarkus.runtime.StartupEvent) Test(org.junit.jupiter.api.Test)

Aggregations

StartupEvent (io.quarkus.runtime.StartupEvent)36 Test (org.junit.jupiter.api.Test)29 Description (io.qameta.allure.Description)16 SerializedEntandoResource (org.entando.kubernetes.controller.spi.client.SerializedEntandoResource)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)12 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)12 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition)12 CustomResourceDefinitionBuilder (io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinitionBuilder)12 ValueHolder (org.entando.kubernetes.test.common.ValueHolder)11 BasicDeploymentSpecBuilder (org.entando.kubernetes.fluentspi.BasicDeploymentSpecBuilder)8 TestResource (org.entando.kubernetes.fluentspi.TestResource)8 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)7 IOException (java.io.IOException)7 ProvidedCapabilityBuilder (org.entando.kubernetes.model.capability.ProvidedCapabilityBuilder)7 Pod (io.fabric8.kubernetes.api.model.Pod)6 CustomResourceDefinitionContext (io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext)5 Allure.attachment (io.qameta.allure.Allure.attachment)5 Allure.step (io.qameta.allure.Allure.step)5 Feature (io.qameta.allure.Feature)5 Issue (io.qameta.allure.Issue)5