Search in sources :

Example 1 with GIITestHook

use of org.apache.geode.internal.cache.InitialImageOperation.GIITestHook in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method returnCorrectResultsWhenIndexUpdateHappensIntheMiddleofGII.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenIndexUpdateHappensIntheMiddleofGII(RegionTestableType regionTestType) throws InterruptedException {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().setFields("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    dataStore1.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    putEntryInEachBucket();
    dataStore2.invoke(() -> {
        InitialImageOperation.setGIITestHook(new GIITestHook(GIITestHookType.AfterSentRequestImage, "Do puts during request") {

            @Override
            public void reset() {
            }

            @Override
            public String getRegionName() {
                return "_B__index#__region.files_0";
            }

            @Override
            public void run() {
                dataStore1.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
                waitForFlushBeforeExecuteTextSearch(dataStore1, 30000);
            }
        });
    });
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 30000));
    dataStore2.invoke(() -> {
        PartitionedRegion region = (PartitionedRegion) getCache().getRegion(REGION_NAME);
        Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> assertEquals(0, region.getPrStats().getLowRedundancyBucketCount()));
    });
    dataStore1.invoke(() -> getCache().close());
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore2, 30000));
    executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
}
Also used : GIITestHook(org.apache.geode.internal.cache.InitialImageOperation.GIITestHook) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 with GIITestHook

use of org.apache.geode.internal.cache.InitialImageOperation.GIITestHook in project geode by apache.

the class GIIDeltaDUnitTest method waitForCallbackStarted.

public void waitForCallbackStarted(final VM vm, final GIITestHookType callbacktype) {
    SerializableRunnable waitForCallbackStarted = new SerializableRunnable() {

        public void run() {
            final GIITestHook callback = InitialImageOperation.getGIITestHookForCheckingPurpose(callbacktype);
            WaitCriterion ev = new WaitCriterion() {

                public boolean done() {
                    return (callback != null && callback.isRunning);
                }

                public String description() {
                    return null;
                }
            };
            Wait.waitForCriterion(ev, 30000, 200, true);
            if (callback == null || !callback.isRunning) {
                fail("GII tesk hook is not started yet");
            }
        }
    };
    vm.invoke(waitForCallbackStarted);
}
Also used : GIITestHook(org.apache.geode.internal.cache.InitialImageOperation.GIITestHook)

Aggregations

GIITestHook (org.apache.geode.internal.cache.InitialImageOperation.GIITestHook)2 Parameters (junitparams.Parameters)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1