Search in sources :

Example 1 with StackGresDistributedLogsPostgresServices

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.

the class DefaultPostgresServicesMutatorTest method setupDistributedLogsPgServices.

private void setupDistributedLogsPgServices(StackGresPostgresService primary, StackGresPostgresService replicas) {
    this.sgDistributedLogs = new StackGresDistributedLogsPostgresServices(primary, replicas);
    review.getRequest().getObject().getSpec().setPostgresServices(sgDistributedLogs);
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices)

Example 2 with StackGresDistributedLogsPostgresServices

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.

the class DefaultPostgresServicesMutatorTest method clusterWithNoPostgresService_shouldBeSetup.

@Test
void clusterWithNoPostgresService_shouldBeSetup() {
    review.getRequest().getObject().getSpec().setPostgresServices(null);
    StackGresDistributedLogsPostgresServices pgServicesMuted = mutate(review);
    assertNull(pgServicesMuted.getPrimary().getEnabled());
    assertEquals(CLUSTER_IP.toString(), pgServicesMuted.getPrimary().getType());
    assertEquals(Boolean.TRUE, pgServicesMuted.getReplicas().getEnabled());
    assertEquals(CLUSTER_IP.toString(), pgServicesMuted.getReplicas().getType());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) Test(org.junit.jupiter.api.Test)

Example 3 with StackGresDistributedLogsPostgresServices

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.

the class DefaultPostgresServicesMutatorTest method clusterWithPgServiceReplicaNoEnabled_shouldBeSetup.

@Test
void clusterWithPgServiceReplicaNoEnabled_shouldBeSetup() {
    setupDistributedLogsPgServices(withPgPrimaryService(TRUE, LOAD_BALANCER.toString()), withPgReplicasService(null, LOAD_BALANCER.toString()));
    StackGresDistributedLogsPostgresServices pgServicesMuted = mutate(review);
    assertNull(pgServicesMuted.getPrimary().getEnabled());
    assertEquals(LOAD_BALANCER.toString(), pgServicesMuted.getPrimary().getType());
    assertEquals(Boolean.TRUE, pgServicesMuted.getReplicas().getEnabled());
    assertEquals(LOAD_BALANCER.toString(), pgServicesMuted.getReplicas().getType());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) Test(org.junit.jupiter.api.Test)

Example 4 with StackGresDistributedLogsPostgresServices

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.

the class DefaultPostgresServicesMutatorTest method clusterWithNoPgServiceReplicas_shouldSetValue.

@Test
void clusterWithNoPgServiceReplicas_shouldSetValue() {
    setupDistributedLogsPgServices(withPgPrimaryService(FALSE, LOAD_BALANCER.toString()), withNoPgReplicasService());
    StackGresDistributedLogsPostgresServices pgServicesMuted = mutate(review);
    assertNull(pgServicesMuted.getPrimary().getEnabled());
    assertEquals(LOAD_BALANCER.toString(), pgServicesMuted.getPrimary().getType());
    assertEquals(Boolean.TRUE, pgServicesMuted.getReplicas().getEnabled());
    assertEquals(CLUSTER_IP.toString(), pgServicesMuted.getReplicas().getType());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) Test(org.junit.jupiter.api.Test)

Example 5 with StackGresDistributedLogsPostgresServices

use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.

the class DefaultPostgresServicesMutatorTest method clusterWithPostgresServiceNoEnabled_shouldSetValue.

@Test
void clusterWithPostgresServiceNoEnabled_shouldSetValue() {
    setupDistributedLogsPgServices(withPgPrimaryService(null, LOAD_BALANCER.toString()), withNoPgReplicasService());
    StackGresDistributedLogsPostgresServices pgServicesMuted = mutate(review);
    assertNull(pgServicesMuted.getPrimary().getEnabled());
    assertEquals(LOAD_BALANCER.toString(), pgServicesMuted.getPrimary().getType());
    assertEquals(Boolean.TRUE, pgServicesMuted.getReplicas().getEnabled());
    assertEquals(CLUSTER_IP.toString(), pgServicesMuted.getReplicas().getType());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) Test(org.junit.jupiter.api.Test)

Aggregations

StackGresDistributedLogsPostgresServices (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices)16 Test (org.junit.jupiter.api.Test)14 StackGresDistributedLogsPostgresServicesFixture (io.stackgres.apiweb.transformer.distributedlogs.converter.fixture.StackGresDistributedLogsPostgresServicesFixture)6 DistributedLogsPostgresServices (io.stackgres.apiweb.dto.distributedlogs.DistributedLogsPostgresServices)3 StackGresPostgresService (io.stackgres.common.crd.postgres.service.StackGresPostgresService)3 PostgresService (io.stackgres.apiweb.app.postgres.service.PostgresService)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)1 JsonPointer (com.github.fge.jackson.jsonpointer.JsonPointer)1 JsonPatchOperation (com.github.fge.jsonpatch.JsonPatchOperation)1 ImmutableList (com.google.common.collect.ImmutableList)1 StackGresPostgresServiceType (io.stackgres.common.crd.postgres.service.StackGresPostgresServiceType)1 CLUSTER_IP (io.stackgres.common.crd.postgres.service.StackGresPostgresServiceType.CLUSTER_IP)1 StackGresDistributedLogs (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs)1 StackGresDistributedLogsSpec (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec)1 StackGresDistributedLogsReview (io.stackgres.operator.common.StackGresDistributedLogsReview)1 AdmissionRequest (io.stackgres.operatorframework.admissionwebhook.AdmissionRequest)1 Operation (io.stackgres.operatorframework.admissionwebhook.Operation)1 List (java.util.List)1 Optional (java.util.Optional)1