Search in sources :

Example 21 with StackGresClusterInstalledExtension

use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.

the class ExtensionsMutatorTest method clusterWithExtensionInstalledAddADifferntExtension_shouldAddToInstallPostgresExtensions.

@Test
void clusterWithExtensionInstalledAddADifferntExtension_shouldAddToInstallPostgresExtensions() throws Exception {
    final StackGresClusterInstalledExtension installedTestExtension = getInstalledExtension();
    installedTestExtension.setName("test");
    final StackGresClusterExtension testExtension = getExtension();
    testExtension.setName("test");
    testExtension.setVersion(installedTestExtension.getVersion());
    final StackGresClusterInstalledExtension installedExtension = getInstalledExtension();
    final StackGresClusterExtension extension = getExtension();
    extension.setVersion(installedExtension.getVersion());
    review.getRequest().getObject().getSpec().getPostgres().setExtensions(ImmutableList.of(extension, testExtension));
    review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
    final StackGresExtensionMetadata extensionTestMetadata = getExtensionMetadata();
    extensionTestMetadata.getExtension().setName("test");
    when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(testExtension))).thenReturn(extensionTestMetadata);
    final StackGresExtensionMetadata extensionMetadata = getExtensionMetadata();
    when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(extensionMetadata);
    final List<JsonPatchOperation> operations = mutator.mutate(review);
    assertEquals(1, operations.size());
}
Also used : StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension) StackGresClusterExtension(io.stackgres.common.crd.sgcluster.StackGresClusterExtension) StackGresExtensionMetadata(io.stackgres.common.extension.StackGresExtensionMetadata) JsonPatchOperation(com.github.fge.jsonpatch.JsonPatchOperation) Test(org.junit.jupiter.api.Test)

Example 22 with StackGresClusterInstalledExtension

use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.

the class ExtensionsMutatorTest method clusterWithAnAlreadyInstalledMissingExtension_shouldReplaceToInstall.

@Test
void clusterWithAnAlreadyInstalledMissingExtension_shouldReplaceToInstall() throws Exception {
    final StackGresClusterInstalledExtension installedTestExtension = getInstalledExtension();
    installedTestExtension.setName("test");
    final StackGresClusterExtension testExtension = getExtension();
    testExtension.setName("test");
    testExtension.setVersion(installedTestExtension.getVersion());
    review.getRequest().getObject().getSpec().getPostgres().setExtensions(ImmutableList.of(testExtension));
    review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
    final StackGresExtensionMetadata extensionTestMetadata = getExtensionMetadata();
    extensionTestMetadata.getExtension().setName("test");
    when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(testExtension))).thenThrow(IllegalArgumentException.class);
    final List<JsonPatchOperation> operations = mutator.mutate(review);
    assertEquals(1, operations.size());
    assertEquals(1, operations.stream().filter(o -> o instanceof ReplaceOperation).count());
}
Also used : ReplaceOperation(com.github.fge.jsonpatch.ReplaceOperation) StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension) StackGresClusterExtension(io.stackgres.common.crd.sgcluster.StackGresClusterExtension) StackGresExtensionMetadata(io.stackgres.common.extension.StackGresExtensionMetadata) JsonPatchOperation(com.github.fge.jsonpatch.JsonPatchOperation) Test(org.junit.jupiter.api.Test)

Example 23 with StackGresClusterInstalledExtension

use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.

the class ExtensionsMutatorTest method getDefaultExtension.

private StackGresClusterInstalledExtension getDefaultExtension(String name) {
    final StackGresClusterInstalledExtension installedExtension = new StackGresClusterInstalledExtension();
    installedExtension.setName(name);
    installedExtension.setPublisher("com.ongres");
    installedExtension.setRepository(OperatorProperty.EXTENSIONS_REPOSITORY_URLS.getString());
    installedExtension.setVersion("1.0.0");
    installedExtension.setPostgresVersion(POSTGRES_MAJOR_VERSION);
    installedExtension.setBuild(BUILD_VERSION);
    return installedExtension;
}
Also used : StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension)

Example 24 with StackGresClusterInstalledExtension

use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.

the class DistributedLogsTransformer method getClusterInstalledExtension.

private ClusterInstalledExtension getClusterInstalledExtension(StackGresClusterInstalledExtension source) {
    if (source == null) {
        return null;
    }
    ClusterInstalledExtension transformation = new ClusterInstalledExtension();
    transformation.setName(source.getName());
    transformation.setPublisher(source.getPublisher());
    transformation.setRepository(source.getRepository());
    transformation.setVersion(source.getVersion());
    transformation.setPostgresVersion(source.getPostgresVersion());
    transformation.setBuild(source.getBuild());
    transformation.setExtraMounts(source.getExtraMounts());
    return transformation;
}
Also used : StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension) ClusterInstalledExtension(io.stackgres.apiweb.dto.cluster.ClusterInstalledExtension)

Example 25 with StackGresClusterInstalledExtension

use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.

the class ClusterTransformer method getClusterInstalledExtension.

private ClusterInstalledExtension getClusterInstalledExtension(StackGresClusterInstalledExtension source) {
    if (source == null) {
        return null;
    }
    ClusterInstalledExtension transformation = new ClusterInstalledExtension();
    transformation.setName(source.getName());
    transformation.setPublisher(source.getPublisher());
    transformation.setRepository(source.getRepository());
    transformation.setVersion(source.getVersion());
    transformation.setPostgresVersion(source.getPostgresVersion());
    transformation.setBuild(source.getBuild());
    transformation.setExtraMounts(source.getExtraMounts());
    return transformation;
}
Also used : StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension) ClusterInstalledExtension(io.stackgres.apiweb.dto.cluster.ClusterInstalledExtension)

Aggregations

StackGresClusterInstalledExtension (io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension)52 Test (org.junit.jupiter.api.Test)35 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)24 List (java.util.List)15 Optional (java.util.Optional)15 JsonPatchOperation (com.github.fge.jsonpatch.JsonPatchOperation)14 ImmutableList (com.google.common.collect.ImmutableList)14 StackGresClusterExtension (io.stackgres.common.crd.sgcluster.StackGresClusterExtension)14 ExtensionInstaller (io.stackgres.common.extension.ExtensionManager.ExtensionInstaller)14 StackGresClusterSpec (io.stackgres.common.crd.sgcluster.StackGresClusterSpec)13 StackGresClusterStatus (io.stackgres.common.crd.sgcluster.StackGresClusterStatus)13 BeforeEach (org.junit.jupiter.api.BeforeEach)13 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)12 StackGresComponent (io.stackgres.common.StackGresComponent)12 StackGresClusterPodStatus (io.stackgres.common.crd.sgcluster.StackGresClusterPodStatus)12 ExtensionUninstaller (io.stackgres.common.extension.ExtensionManager.ExtensionUninstaller)12 ArrayList (java.util.ArrayList)12 ReplaceOperation (com.github.fge.jsonpatch.ReplaceOperation)11 StackGresClusterList (io.stackgres.common.crd.sgcluster.StackGresClusterList)11 JsonUtil (io.stackgres.testutil.JsonUtil)11