use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithExtensionInstalledAddExtensionWithExtraMounts_shouldReplaceToInstallExtensions.
@Test
void clusterWithExtensionInstalledAddExtensionWithExtraMounts_shouldReplaceToInstallExtensions() 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");
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());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithMissingExtension_shouldNotDoAnything.
@Test
void clusterWithMissingExtension_shouldNotDoAnything() 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);
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(0, operations.size());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithExtensionInstalledAddDifferntExtension_shouldReplaceToInstallPostgresExtensions.
@Test
void clusterWithExtensionInstalledAddDifferntExtension_shouldReplaceToInstallPostgresExtensions() 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");
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(getExtensionMetadata());
final List<JsonPatchOperation> operations = mutator.mutate(review);
assertEquals(1, operations.size());
assertEquals(1, operations.stream().filter(o -> o instanceof ReplaceOperation).count());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithTwoExtensionInstalledAddDifferntExtension_shouldReplaceToInstallExtensions.
@Test
void clusterWithTwoExtensionInstalledAddDifferntExtension_shouldReplaceToInstallExtensions() 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");
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension);
final StackGresClusterInstalledExtension installedTestExtension2 = getInstalledExtension();
installedTestExtension2.setName("test2");
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedTestExtension2);
when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(getExtensionMetadata());
final List<JsonPatchOperation> operations = mutator.mutate(review);
assertEquals(1, operations.size());
assertEquals(1, operations.stream().filter(o -> o instanceof ReplaceOperation).count());
}
use of io.stackgres.common.crd.sgcluster.StackGresClusterInstalledExtension in project stackgres by ongres.
the class ExtensionsMutatorTest method clusterWithAnExtensionAlreadyInstalled_shouldNotDoAnything.
@Test
void clusterWithAnExtensionAlreadyInstalled_shouldNotDoAnything() 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);
review.getRequest().getObject().getSpec().getToInstallPostgresExtensions().add(installedExtension);
when(extensionMetadataManager.getExtensionCandidateSameMajorBuild(same(review.getRequest().getObject()), same(extension))).thenReturn(getExtensionMetadata());
final List<JsonPatchOperation> operations = mutator.mutate(review);
assertTrue(operations.isEmpty());
}
Aggregations