Search in sources :

Example 1 with StackGresDistributedLogsContext

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

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithRetentionUpdated_isPerformedWithoutUpdatingRetention.

@Test
void testReconciliationWithRetentionUpdated_isPerformedWithoutUpdatingRetention() 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");
    databaseStatus.setRetention("1 minute");
    distributedLogsContext.getDistributedLogs().getStatus().setDatabases(Seq.of(databaseStatus).toList());
    Assertions.assertFalse(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(1)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(1)).createDatabase(any(), any());
    verify(databaseReconciliator, times(0)).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 2 with StackGresDistributedLogsContext

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

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithEmptyStatus_isPerformed.

@Test
void testReconciliationWithEmptyStatus_isPerformed() throws Exception {
    when(propertyContext.getString(same(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_CONTROLLER_POD_NAME))).thenReturn("stackgres-0");
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    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) Test(org.junit.jupiter.api.Test)

Example 3 with StackGresDistributedLogsContext

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

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithNonReadyPatroni_isSkipped.

@Test
void testReconciliationWithNonReadyPatroni_isSkipped() throws Exception {
    when(propertyContext.getString(same(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_CONTROLLER_POD_NAME))).thenReturn("stackgres-0");
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    Pod.class.cast(distributedLogsContext.getExistingResources().get(0).v1).getStatus().getContainerStatuses().get(0).setReady(false);
    Assertions.assertFalse(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(0)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(0)).createDatabase(any(), any());
    verify(databaseReconciliator, times(0)).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)

Example 4 with StackGresDistributedLogsContext

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

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithDatabaseCreated_isPerformedWithoutDatabaseCreation.

@Test
void testReconciliationWithDatabaseCreated_isPerformedWithoutDatabaseCreation() throws Exception {
    when(propertyContext.getString(same(DistributedLogsControllerProperty.DISTRIBUTEDLOGS_CONTROLLER_POD_NAME))).thenReturn("stackgres-0");
    when(databaseReconciliator.existsDatabase(any(), any())).thenReturn(true);
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    Assertions.assertTrue(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(1)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(0)).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) Test(org.junit.jupiter.api.Test)

Example 5 with StackGresDistributedLogsContext

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

the class DistributedLogsClusterReconciliatorTest method testReconciliationWithNullStatus_isSkipped.

@Test
void testReconciliationWithNullStatus_isSkipped() throws Exception {
    StackGresDistributedLogsContext distributedLogsContext = getDistributedLogsContext();
    distributedLogsContext.getDistributedLogs().setStatus(null);
    Assertions.assertFalse(reconciliator.reconcile(null, distributedLogsContext).result().get());
    verify(databaseReconciliator, times(0)).existsDatabase(any(), any());
    verify(databaseReconciliator, times(0)).createDatabase(any(), any());
    verify(databaseReconciliator, times(0)).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