Search in sources :

Example 21 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method putEntriesAndValidateResultsWithRedundancy.

private void putEntriesAndValidateResultsWithRedundancy(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().setFields("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    dataStore1.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    dataStore2.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    accessor.invoke(() -> LuceneTestUtilities.pauseSender(getCache()));
    putEntryInEachBucket();
    dataStore1.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    dataStore2.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    accessor.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore2, 60000));
    executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF)

Example 22 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class PaginationDUnitTest method noExceptionWhenOneDataStoreIsClosedButOneIsStillUpWhilePagination.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void noExceptionWhenOneDataStoreIsClosedButOneIsStillUpWhilePagination(RegionTestableType regionTestType) {
    SerializableRunnableIF createIndex = () -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        luceneService.createIndexFactory().setFields("text").create(INDEX_NAME, REGION_NAME);
    };
    dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    accessor.invoke(() -> initAccessor(createIndex, regionTestType));
    putEntryInEachBucket();
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, FLUSH_WAIT_TIME_MS));
    accessor.invoke(() -> {
        List<LuceneResultStruct<Integer, TestObject>> combinedResult = new ArrayList<>();
        Cache cache = getCache();
        LuceneService service = LuceneServiceProvider.get(cache);
        LuceneQuery<Integer, TestObject> query;
        query = service.createLuceneQueryFactory().setLimit(1000).setPageSize(PAGE_SIZE).create(INDEX_NAME, REGION_NAME, "world", "text");
        PageableLuceneQueryResults<Integer, TestObject> pages = query.findPages();
        assertTrue(pages.hasNext());
        List<LuceneResultStruct<Integer, TestObject>> page = pages.next();
        combinedResult.addAll(page);
        assertEquals(PAGE_SIZE, page.size());
        dataStore1.invoke(() -> closeCache());
        for (int i = 0; i < ((NUM_BUCKETS / PAGE_SIZE) - 1); i++) {
            page = pages.next();
            assertEquals(PAGE_SIZE, page.size());
            combinedResult.addAll(page);
        }
        validateTheCombinedResult(combinedResult);
    });
}
Also used : ArrayList(java.util.ArrayList) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Cache(org.apache.geode.cache.Cache) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 23 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class RebalanceDUnitTest method returnCorrectResultsWhenRebalanceHappensWhileSenderIsPaused.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenRebalanceHappensWhileSenderIsPaused(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(() -> initDataStore(createIndex, regionTestType));
    rebalanceRegion(dataStore2);
    dataStore1.invoke(() -> LuceneTestUtilities.resumeSender(getCache()));
    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
    executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 24 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class RebalanceDUnitTest method returnCorrectResultsWhenRebalanceHappensAfterUpdates.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenRebalanceHappensAfterUpdates(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));
    putEntryInEachBucket();
    dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
    assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
    rebalanceRegion(dataStore2);
    executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
}
Also used : SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 25 with SerializableRunnableIF

use of org.apache.geode.test.dunit.SerializableRunnableIF in project geode by apache.

the class FixedPRSinglehopDUnitTest method test_MetadataContents.

// 4 servers, 1 client connected to all 4 servers.
// Put data, get data and make the metadata stable.
// Now verify that metadata has all 8 buckets info.
// Now update and ensure the fetch service is never called.
// GEODE-1176: random ports, time sensitive, waitForCriterion
@Category(FlakyTest.class)
@Test
public void test_MetadataContents() {
    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM server3 = host.getVM(2);
    VM server4 = host.getVM(3);
    List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q1", true, 3));
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q2", false, 3));
    Integer port1 = (Integer) server1.invoke(() -> FixedPRSinglehopDUnitTest.createServer(false, fpaList));
    fpaList.clear();
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q3", true, 3));
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q4", false, 3));
    Integer port2 = (Integer) server2.invoke(() -> FixedPRSinglehopDUnitTest.createServer(false, fpaList));
    fpaList.clear();
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q2", true, 3));
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q3", false, 3));
    Integer port3 = (Integer) server3.invoke(() -> FixedPRSinglehopDUnitTest.createServer(false, fpaList));
    fpaList.clear();
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q4", true, 3));
    fpaList.add(FixedPartitionAttributes.createFixedPartition("Q1", false, 3));
    Integer port4 = (Integer) server4.invoke(() -> FixedPRSinglehopDUnitTest.createServer(false, fpaList));
    createClient(port1, port2, port3, port4);
    putIntoPartitionedRegions();
    getFromPartitionedRegions();
    SerializableRunnableIF printView = () -> FixedPRSinglehopDUnitTest.printView();
    server1.invoke(printView);
    server2.invoke(printView);
    server3.invoke(printView);
    server4.invoke(printView);
    int totalBucketOnServer = 0;
    SerializableCallableIF<Integer> getBucketCount = () -> FixedPRSinglehopDUnitTest.primaryBucketsOnServer();
    totalBucketOnServer += server1.invoke(getBucketCount);
    totalBucketOnServer += server2.invoke(getBucketCount);
    totalBucketOnServer += server3.invoke(getBucketCount);
    totalBucketOnServer += server4.invoke(getBucketCount);
    verifyMetadata(totalBucketOnServer, 2);
    updateIntoSinglePR(true);
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) VM(org.apache.geode.test.dunit.VM) ArrayList(java.util.ArrayList) Host(org.apache.geode.test.dunit.Host) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Category(org.junit.experimental.categories.Category) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)49 Test (org.junit.Test)45 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)44 Parameters (junitparams.Parameters)39 Cache (org.apache.geode.cache.Cache)12 Region (org.apache.geode.cache.Region)12 List (java.util.List)7 ClientCache (org.apache.geode.cache.client.ClientCache)6 Host (org.apache.geode.test.dunit.Host)6 VM (org.apache.geode.test.dunit.VM)6 ArrayList (java.util.ArrayList)5 CacheException (org.apache.geode.cache.CacheException)5 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)5 AbstractIndex (org.apache.geode.cache.query.internal.index.AbstractIndex)5 IOException (java.io.IOException)4 Collection (java.util.Collection)4 HashSet (java.util.HashSet)4 CancellationException (java.util.concurrent.CancellationException)4 DataInput (java.io.DataInput)3 DataOutput (java.io.DataOutput)3