Search in sources :

Example 1 with LOCK_POD_KEY

use of io.stackgres.common.StackGresContext.LOCK_POD_KEY in project stackgres by ongres.

the class LockAcquirerImplTest method asycRunTaskSuccessfully.

private AtomicBoolean asycRunTaskSuccessfully(int delay) {
    AtomicBoolean taskRan = new AtomicBoolean(false);
    executorService.execute(() -> lockAcquirer.lockRun(lockRequest, (cluster) -> {
        if (delay > 0) {
            sleep(delay);
        }
        StackGresCluster lastPatch = kubeDb.getCluster(clusterName, clusterNamespace);
        final Map<String, String> annotations = lastPatch.getMetadata().getAnnotations();
        assertEquals(lockRequest.getPodName(), annotations.get(LOCK_POD_KEY), "Task ran without Lock!!");
        assertNotNull(annotations.get(LOCK_TIMESTAMP_KEY));
        taskRan.set(true);
    }));
    return taskRan;
}
Also used : LOCK_POD_KEY(io.stackgres.common.StackGresContext.LOCK_POD_KEY) LOCK_TIMESTAMP_KEY(io.stackgres.common.StackGresContext.LOCK_TIMESTAMP_KEY) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Executors(java.util.concurrent.Executors) JsonUtil(io.stackgres.testutil.JsonUtil) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Inject(javax.inject.Inject) Test(org.junit.jupiter.api.Test) StringUtils(io.stackgres.testutil.StringUtils) AfterEach(org.junit.jupiter.api.AfterEach) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ExecutorService(java.util.concurrent.ExecutorService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StackGresCluster(io.stackgres.common.crd.sgcluster.StackGresCluster) Map(java.util.Map)

Aggregations

QuarkusTest (io.quarkus.test.junit.QuarkusTest)1 LOCK_POD_KEY (io.stackgres.common.StackGresContext.LOCK_POD_KEY)1 LOCK_TIMESTAMP_KEY (io.stackgres.common.StackGresContext.LOCK_TIMESTAMP_KEY)1 StackGresCluster (io.stackgres.common.crd.sgcluster.StackGresCluster)1 JsonUtil (io.stackgres.testutil.JsonUtil)1 StringUtils (io.stackgres.testutil.StringUtils)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Inject (javax.inject.Inject)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1