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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations