Search in sources :

Example 6 with StackGresDistributedLogsPostgresServices

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

the class DistributedLogsPostgresServicesConverterTest method shouldTranslateFromDistributedLogsPostgresServices_toSgDLogsPgServices.

@Test
void shouldTranslateFromDistributedLogsPostgresServices_toSgDLogsPgServices() {
    StackGresDistributedLogsPostgresServices postgresServices = converter.to(new DistributedLogsPostgresServicesFixture().withPrimary().withReplicas().build());
    assertNotNull(postgresServices.getPrimary());
    assertNotNull(postgresServices.getReplicas());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) StackGresDistributedLogsPostgresServicesFixture(io.stackgres.apiweb.transformer.distributedlogs.converter.fixture.StackGresDistributedLogsPostgresServicesFixture) Test(org.junit.jupiter.api.Test)

Example 7 with StackGresDistributedLogsPostgresServices

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

the class DistributedLogsPostgresServicesConverterTest method shouldTranslateDistributedLogsPostgresServices_toSgDLogsPgServicesWithOnlyPrimaryInstace.

@Test
void shouldTranslateDistributedLogsPostgresServices_toSgDLogsPgServicesWithOnlyPrimaryInstace() {
    StackGresDistributedLogsPostgresServices postgresServices = converter.to(new DistributedLogsPostgresServicesFixture().withPrimary().build());
    assertNotNull(postgresServices.getPrimary());
    assertNull(postgresServices.getReplicas());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) StackGresDistributedLogsPostgresServicesFixture(io.stackgres.apiweb.transformer.distributedlogs.converter.fixture.StackGresDistributedLogsPostgresServicesFixture) Test(org.junit.jupiter.api.Test)

Example 8 with StackGresDistributedLogsPostgresServices

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

the class DistributedLogsPostgresServicesConverterTest method shouldTranslateANullDistributedLogsPostgresServices_toNullSgDLogsPgServicesObject.

@Test
void shouldTranslateANullDistributedLogsPostgresServices_toNullSgDLogsPgServicesObject() {
    StackGresDistributedLogsPostgresServices postgresServices = converter.to(null);
    assertNull(postgresServices);
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) Test(org.junit.jupiter.api.Test)

Example 9 with StackGresDistributedLogsPostgresServices

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

the class DefaultPostgresServicesMutator method validatePgServices.

private ImmutableList<JsonPatchOperation> validatePgServices(ImmutableList.Builder<JsonPatchOperation> operations, StackGresDistributedLogsSpec spec) {
    return Optional.ofNullable(spec.getPostgresServices()).map(pgServices -> {
        mapPgPrimaryService(pgServices);
        mapPgReplicasService(pgServices);
        JsonNode target = JSON_MAPPER.valueToTree(pgServices);
        operations.add(applyReplaceValue(postgresServicesPointer, target));
        return operations.build();
    }).orElseGet(() -> {
        StackGresDistributedLogsPostgresServices pgServices = new StackGresDistributedLogsPostgresServices();
        pgServices.setPrimary(createPostgresServicePrimary());
        pgServices.setReplicas(createPostgresServiceReplicas());
        JsonNode target = JSON_MAPPER.valueToTree(pgServices);
        operations.add(applyAddValue(postgresServicesPointer, target));
        return operations.build();
    });
}
Also used : Operation(io.stackgres.operatorframework.admissionwebhook.Operation) StackGresDistributedLogsSpec(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsSpec) JsonPointer(com.github.fge.jackson.jsonpointer.JsonPointer) CLUSTER_IP(io.stackgres.common.crd.postgres.service.StackGresPostgresServiceType.CLUSTER_IP) JsonMapper(com.fasterxml.jackson.databind.json.JsonMapper) StackGresPostgresServiceType(io.stackgres.common.crd.postgres.service.StackGresPostgresServiceType) StackGresDistributedLogsReview(io.stackgres.operator.common.StackGresDistributedLogsReview) List(java.util.List) JsonPatchOperation(com.github.fge.jsonpatch.JsonPatchOperation) StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) ImmutableList(com.google.common.collect.ImmutableList) StackGresPostgresService(io.stackgres.common.crd.postgres.service.StackGresPostgresService) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) JsonNode(com.fasterxml.jackson.databind.JsonNode) StackGresDistributedLogs(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs) AdmissionRequest(io.stackgres.operatorframework.admissionwebhook.AdmissionRequest) StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 10 with StackGresDistributedLogsPostgresServices

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

the class DistributedLogsPostgresServicesConverterTest method shouldPgServicePrimaryBeConvertedSuccessfully_fromSgDistributedLogsPgServicePrimary.

@Test
void shouldPgServicePrimaryBeConvertedSuccessfully_fromSgDistributedLogsPgServicePrimary() {
    StackGresDistributedLogsPostgresServices sgPostgresServices = new StackGresDistributedLogsPostgresServicesFixture().withPrimary().build();
    DistributedLogsPostgresServices pgServicesConverted = converter.from(sgPostgresServices);
    StackGresPostgresService sgPgPrimary = sgPostgresServices.getPrimary();
    PostgresService dlPgPrimary = pgServicesConverted.getPrimary();
    assertEquals(sgPgPrimary.getEnabled(), dlPgPrimary.getEnabled());
    assertEquals(sgPgPrimary.getType(), dlPgPrimary.getType());
    assertNull(pgServicesConverted.getReplicas());
}
Also used : StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) DistributedLogsPostgresServices(io.stackgres.apiweb.dto.distributedlogs.DistributedLogsPostgresServices) StackGresDistributedLogsPostgresServices(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices) StackGresDistributedLogsPostgresServicesFixture(io.stackgres.apiweb.transformer.distributedlogs.converter.fixture.StackGresDistributedLogsPostgresServicesFixture) StackGresPostgresService(io.stackgres.common.crd.postgres.service.StackGresPostgresService) PostgresService(io.stackgres.apiweb.app.postgres.service.PostgresService) StackGresPostgresService(io.stackgres.common.crd.postgres.service.StackGresPostgresService) 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