use of io.stackgres.operator.conciliation.ReconciliationResult in project stackgres by ongres.
the class DistributedLogsConciliatorTest method shouldNotIgnoreChangesMarkedPauseUntilRestartAnnotationIfClusterIsNotPendingToRestart.
@Test
@DisplayName("Conciliation Should Not Ignore Changes On Resources Marked With Reconciliation " + "Pause Until Restart Annotation If The Cluster Is Not Pending To Restart")
void shouldNotIgnoreChangesMarkedPauseUntilRestartAnnotationIfClusterIsNotPendingToRestart() {
final List<HasMetadata> requiredResources = KubernetessMockResourceGenerationUtil.buildResources("test", "test");
final List<HasMetadata> deployedResources = deepCopy(requiredResources);
deployedResources.stream().findAny().orElseThrow().getMetadata().setAnnotations(Map.of(StackGresContext.RECONCILIATION_PAUSE_UNTIL_RESTART_KEY, Boolean.TRUE.toString()));
Conciliator<StackGresDistributedLogs> conciliator = buildConciliator(requiredResources, deployedResources);
when(statusManager.isPendingRestart(distributedLogs)).thenReturn(false);
ReconciliationResult result = conciliator.evalReconciliationState(distributedLogs);
assertEquals(1, result.getPatches().size());
assertFalse(result.isUpToDate());
}
use of io.stackgres.operator.conciliation.ReconciliationResult in project stackgres by ongres.
the class DistributedLogsConciliatorTest method shouldIgnoreDeletionsMarkedWithPauseUntilRestartAnnotationIfTheClusterIsPendingToRestart.
@Test
@DisplayName("Conciliation Should Ignore Deletions On Resources Marked With Reconciliation " + "Pause Until Restart Annotation If The Cluster Is Pending To Restart")
void shouldIgnoreDeletionsMarkedWithPauseUntilRestartAnnotationIfTheClusterIsPendingToRestart() {
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);
reset(statusManager);
when(statusManager.isPendingRestart(distributedLogs)).thenReturn(true);
ReconciliationResult result = conciliator.evalReconciliationState(getConciliationResource());
assertEquals(0, result.getDeletions().size());
assertTrue(result.isUpToDate());
}
use of io.stackgres.operator.conciliation.ReconciliationResult in project stackgres by ongres.
the class DistributedLogsConciliatorTest method shouldIgnoreChangesMarkedPauseUntilRestartAnnotationIfClusterIsPendingToRestart.
@Test
@DisplayName("Conciliation Should Ignore Changes On Resources Marked With Reconciliation " + "Pause Until Restart Annotation If The Cluster Is Pending To Restart")
void shouldIgnoreChangesMarkedPauseUntilRestartAnnotationIfClusterIsPendingToRestart() {
final List<HasMetadata> requiredResources = KubernetessMockResourceGenerationUtil.buildResources("test", "test");
final List<HasMetadata> deployedResources = deepCopy(requiredResources);
deployedResources.stream().findAny().orElseThrow().getMetadata().setAnnotations(Map.of(StackGresContext.RECONCILIATION_PAUSE_UNTIL_RESTART_KEY, Boolean.TRUE.toString()));
Conciliator<StackGresDistributedLogs> conciliator = buildConciliator(requiredResources, deployedResources);
reset(statusManager);
when(statusManager.isPendingRestart(distributedLogs)).thenReturn(true);
ReconciliationResult result = conciliator.evalReconciliationState(getConciliationResource());
assertEquals(0, result.getPatches().size());
assertTrue(result.isUpToDate());
}
use of io.stackgres.operator.conciliation.ReconciliationResult in project stackgres by ongres.
the class DbOpsConciliator method evalReconciliationState.
@Override
public ReconciliationResult evalReconciliationState(StackGresDbOps config) {
final ReconciliationResult reconciliationResult = super.evalReconciliationState(config);
reconciliationResult.setDeletions(reconciliationResult.getDeletions().stream().filter(ReconciliationUtil::isResourceReconciliationNotPausedUntilRestart).collect(Collectors.toUnmodifiableList()));
reconciliationResult.setPatches(reconciliationResult.getPatches().stream().filter(tuple -> ReconciliationUtil.isResourceReconciliationNotPausedUntilRestart(tuple.v2)).collect(Collectors.toUnmodifiableList()));
return reconciliationResult;
}
use of io.stackgres.operator.conciliation.ReconciliationResult 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