Search in sources :

Example 6 with StackGresDbOpsContext

use of io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext in project stackgres by ongres.

the class DbOpsJobsGeneratorTest method givenAContextWithADbOpsWithAPastRunAt_shouldGenerateAJob.

@Test
void givenAContextWithADbOpsWithAPastRunAt_shouldGenerateAJob() {
    StackGresDbOpsContext context = ImmutableStackGresDbOpsContext.builder().source(dbOps).cluster(cluster).build();
    dbOps.getSpec().setRunAt(Instant.now().minusMillis(1000).toString());
    var generatedResources = dbOpsJobsGenerator.generateResource(context).collect(Collectors.toUnmodifiableList());
    assertEquals(1, generatedResources.size());
}
Also used : StackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext) ImmutableStackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.ImmutableStackGresDbOpsContext) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 7 with StackGresDbOpsContext

use of io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext in project stackgres by ongres.

the class DbOpsJobsGeneratorTest method givenAContextWithASingleDbOpsWithoutRunAt_itShouldGenerateAJob.

@Test
void givenAContextWithASingleDbOpsWithoutRunAt_itShouldGenerateAJob() {
    StackGresDbOpsContext context = ImmutableStackGresDbOpsContext.builder().source(dbOps).cluster(cluster).build();
    dbOps.getSpec().setRunAt(null);
    var generatedResources = dbOpsJobsGenerator.generateResource(context).collect(Collectors.toUnmodifiableList());
    assertEquals(1, generatedResources.stream().filter(r -> r.getKind().equals("Job")).count());
}
Also used : StackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext) ImmutableStackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.ImmutableStackGresDbOpsContext) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 8 with StackGresDbOpsContext

use of io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext in project stackgres by ongres.

the class DbOpsJobsGeneratorTest method givenAContextWithADbOpsWithAFutureRunAt_shouldNotGenerateAJob.

@Test
void givenAContextWithADbOpsWithAFutureRunAt_shouldNotGenerateAJob() {
    StackGresDbOpsContext context = ImmutableStackGresDbOpsContext.builder().source(dbOps).cluster(cluster).build();
    dbOps.getSpec().setRunAt(Instant.now().plusMillis(1000).toString());
    var generatedResources = dbOpsJobsGenerator.generateResource(context).collect(Collectors.toUnmodifiableList());
    assertEquals(0, generatedResources.size());
}
Also used : StackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext) ImmutableStackGresDbOpsContext(io.stackgres.operator.conciliation.dbops.ImmutableStackGresDbOpsContext) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

StackGresDbOpsContext (io.stackgres.operator.conciliation.dbops.StackGresDbOpsContext)8 StackGresDbOps (io.stackgres.common.crd.sgdbops.StackGresDbOps)5 Optional (java.util.Optional)5 Inject (javax.inject.Inject)5 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)4 ImmutableList (com.google.common.collect.ImmutableList)4 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)4 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)4 PodSecurityContext (io.fabric8.kubernetes.api.model.PodSecurityContext)4 ClusterStatefulSetPath (io.stackgres.common.ClusterStatefulSetPath)4 LabelFactoryForCluster (io.stackgres.common.LabelFactoryForCluster)4 LabelFactoryForDbOps (io.stackgres.common.LabelFactoryForDbOps)4 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)4 DbOpsEnvironmentVariables (io.stackgres.operator.cluster.factory.DbOpsEnvironmentVariables)4 StackGresVersion (io.stackgres.operator.common.StackGresVersion)4 OperatorVersionBinder (io.stackgres.operator.conciliation.OperatorVersionBinder)4 ResourceFactory (io.stackgres.operator.conciliation.factory.ResourceFactory)4 List (java.util.List)4 Singleton (javax.inject.Singleton)4 Seq (org.jooq.lambda.Seq)4