use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class PatroniTemplatesConfigMap method buildSource.
@NotNull
public HasMetadata buildSource(StackGresDistributedLogsContext context) {
Map<String, String> data = getPatroniTemplates();
final StackGresDistributedLogs cluster = context.getSource();
return new ConfigMapBuilder().withNewMetadata().withNamespace(cluster.getMetadata().getNamespace()).withName(name(cluster)).withLabels(labelFactory.clusterLabels(cluster)).endMetadata().withData(data).build();
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsTransformer method toCustomResource.
@Override
public StackGresDistributedLogs toCustomResource(DistributedLogsDto source, StackGresDistributedLogs original) {
StackGresDistributedLogs transformation = Optional.ofNullable(original).orElseGet(StackGresDistributedLogs::new);
transformation.setMetadata(getCustomResourceMetadata(source, original));
final DistributedLogsSpec spec = source.getSpec();
if (spec != null) {
transformation.setSpec(getCustomResourceSpec(spec));
}
return transformation;
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsRequiredResourcesGeneratorTest method givenADistributedLogsIn095_shouldGenerateAInitTemplateConfigmapCompatibleWithThatVersion.
@Test
void givenADistributedLogsIn095_shouldGenerateAInitTemplateConfigmapCompatibleWithThatVersion() {
StackGresDistributedLogs distributedLogs = get095Cluster();
ConfigMap expectedConfigMap = get095InitTemplateConfigMap(distributedLogs);
ConfigMap generatedConfigMap = generator.getRequiredResources(distributedLogs).stream().filter(r -> r.getKind().equals("ConfigMap")).filter(r -> r.getMetadata().getName().equals(expectedConfigMap.getMetadata().getName())).map(r -> (ConfigMap) r).findFirst().orElseThrow();
assertTrue(configMapComparator.isTheSameResource(generatedConfigMap, expectedConfigMap));
assertTrue(configMapComparator.isResourceContentEqual(generatedConfigMap, expectedConfigMap));
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsRequiredResourcesGeneratorTest method givenADistributedLogsIn095_shouldGenerateAFluentdConfigmapCompatibleWithThatVersion.
@Test
void givenADistributedLogsIn095_shouldGenerateAFluentdConfigmapCompatibleWithThatVersion() {
StackGresDistributedLogs distributedLogs = get095Cluster();
ConfigMap expectedConfigMap = get095FluentdConfigMap(distributedLogs);
ConfigMap generatedConfigMap = generator.getRequiredResources(distributedLogs).stream().filter(r -> r.getKind().equals("ConfigMap")).filter(r -> r.getMetadata().getName().equals(expectedConfigMap.getMetadata().getName())).map(r -> (ConfigMap) r).findFirst().orElseThrow();
assertTrue(configMapComparator.isTheSameResource(generatedConfigMap, expectedConfigMap));
assertTrue(configMapComparator.isResourceContentEqual(generatedConfigMap, expectedConfigMap));
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogs in project stackgres by ongres.
the class DistributedLogsConciliatorTest method shouldNotIgnoreDeletionsMarkedPauseUntilRestartAnnotationClusterIsNotPendingToRestart.
@Test
@DisplayName("Conciliation Should Not Ignore Deletions On Resources Marked With Reconciliation " + "Pause Until Restart Annotation If The Cluster Is Not Pending To Restart")
void shouldNotIgnoreDeletionsMarkedPauseUntilRestartAnnotationClusterIsNotPendingToRestart() {
final List<HasMetadata> requiredResources = KubernetessMockResourceGenerationUtil.buildResources("test", "test");
final List<HasMetadata> deployedResources = new ArrayList<>(requiredResources);
int indexToRemove = new Random().nextInt(requiredResources.size());
deployedResources.get(indexToRemove).getMetadata().setAnnotations(Map.of(StackGresContext.RECONCILIATION_PAUSE_UNTIL_RESTART_KEY, Boolean.TRUE.toString()));
requiredResources.remove(indexToRemove);
Conciliator<StackGresDistributedLogs> conciliator = buildConciliator(requiredResources, deployedResources);
when(statusManager.isPendingRestart(distributedLogs)).thenReturn(false);
ReconciliationResult result = conciliator.evalReconciliationState(getConciliationResource());
assertEquals(1, result.getDeletions().size());
assertFalse(result.isUpToDate());
}
Aggregations