Search in sources :

Example 51 with StackGresClusterInstalledExtension

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

the class ExtensionsMutatorTest method clusterWithExtensionInstalledWithExtraMountsAddSimilarExtension_shouldReplaceToInstall.

@Test
void clusterWithExtensionInstalledWithExtraMountsAddSimilarExtension_shouldReplaceToInstall() throws Exception {
    final StackGresClusterInstalledExtension installedExtension = getInstalledExtension();
    final StackGresClusterExtension extension = getExtension();
    extension.setVersion(installedExtension.getVersion());
    review.getRequest().getObject().getSpec().getPostgres().setExtensions(ImmutableList.of(extension));
    review.getRequest().getObject().getSpec().setToInstallPostgresExtensions(new ArrayList<>());
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().addAll(defaultExtensions);
    final StackGresClusterInstalledExtension installedTestExtension = getInstalledExtension();
    installedTestExtension.setName("test");
    installedTestExtension.setExtraMounts(ImmutableList.of("test"));
    review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
    final StackGresExtensionMetadata extensionMetadata = getExtensionMetadata();
    extensionMetadata.getVersion().setExtraMounts(ImmutableList.of("test"));
    when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(extensionMetadata);
    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 52 with StackGresClusterInstalledExtension

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

the class ContextUtil method toPostgresContext.

public static PostgresContainerContext toPostgresContext(DistributedLogsContainerContext context) {
    StackGresDistributedLogs distributedLogs = context.getDistributedLogsContext().getSource();
    List<StackGresClusterInstalledExtension> installedExtensions = Optional.ofNullable(distributedLogs.getSpec()).map(StackGresDistributedLogsSpec::getToInstallPostgresExtensions).stream().flatMap(Collection::stream).collect(Collectors.toUnmodifiableList());
    return ImmutablePostgresContainerContext.builder().from(context).postgresMajorVersion(StackGresDistributedLogsUtil.getPostgresMajorVersion()).postgresVersion(StackGresDistributedLogsUtil.getPostgresVersion()).imageBuildMajorVersion(StackGresDistributedLogsUtil.getPostgresBuildMajorVersion()).addAllInstalledExtensions(installedExtensions).build();
}
Also used : StackGresDistributedLogs(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs) StackGresClusterInstalledExtension(io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension)

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