Search in sources :

Example 6 with StackGresDistributedLogsContext

use of io.stackgres.distributedlogs.common.StackGresDistributedLogsContext in project stackgres by ongres.

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithEmptyDatabaseStatus_isPerformed.

@Test
void testReconciliationWithEmptyDatabaseStatus_isPerformed() throws Exception {
    when(propertyContext.getString(same(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_CONTROLLER_POD_NAME))).thenReturn("stackgres-0");
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    StackGresDistributedLogsStatusDatabase databaseStatus = new StackGresDistributedLogsStatusDatabase();
    databaseStatus.setName("stackgres_stackgres");
    distributedLogsContext.getDistributedLogs().getStatus().setDatabases(Seq.of(databaseStatus).toList());
    Assertions.assertTrue(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(1)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(1)).createDatabase(any(), any());
    verify(databaseReconciliator, times(2)).updateRetention(any(), any(), any(), any());
    verify(databaseReconciliator, times(2)).reconcileRetention(any(), any(), any(), any());
}
Also used : StackGresDistributedLogsContext(io.stackgres.distributedlogs.common.StackGresDistributedLogsContext) ImmutableStackGresDistributedLogsContext(io.stackgres.distributedlogs.common.ImmutableStackGresDistributedLogsContext) StackGresDistributedLogsStatusDatabase(io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsStatusDatabase) Test(org.junit.jupiter.api.Test)

Example 7 with StackGresDistributedLogsContext

use of io.stackgres.distributedlogs.common.StackGresDistributedLogsContext in project stackgres by ongres.

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithoutRetention_isPerformed.

@Test
void testReconciliationWithoutRetention_isPerformed() throws Exception {
    when(propertyContext.getString(same(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_CONTROLLER_POD_NAME))).thenReturn("stackgres-0");
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    distributedLogsContext.getDistributedLogs().getStatus().getConnectedClusters().get(0).getConfig().setRetention(null);
    Assertions.assertTrue(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(1)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(1)).createDatabase(any(), any());
    verify(databaseReconciliator, times(2)).updateRetention(any(), any(), any(), any());
    verify(databaseReconciliator, times(0)).reconcileRetention(any(), any(), any(), any());
}
Also used : StackGresDistributedLogsContext(io.stackgres.distributedlogs.common.StackGresDistributedLogsContext) ImmutableStackGresDistributedLogsContext(io.stackgres.distributedlogs.common.ImmutableStackGresDistributedLogsContext) Test(org.junit.jupiter.api.Test)

Aggregations

ImmutableStackGresDistributedLogsContext (io.stackgres.distributedlogs.common.ImmutableStackGresDistributedLogsContext)7 StackGresDistributedLogsContext (io.stackgres.distributedlogs.common.StackGresDistributedLogsContext)7 Test (org.junit.jupiter.api.Test)7 StackGresDistributedLogsStatusDatabase (io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsStatusDatabase)2