Search in sources :

Example 86 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method aeqShouldAlwaysBeDiskSynchronousWhenUserRegionIsEither.

@Test
@Parameters({ "true", "false" })
public void aeqShouldAlwaysBeDiskSynchronousWhenUserRegionIsEither(boolean synchronous) {
    createIndex(cache, "text");
    cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT).setDiskSynchronous(synchronous).create(REGION_NAME);
    verifyInternalRegions(region -> {
        assertTrue(region.getDataPolicy().withPersistence());
        assertTrue(region.isDiskSynchronous());
    });
    AsyncEventQueue queue = getIndexQueue(cache);
    assertTrue(queue.isDiskSynchronous());
    assertEquals(true, queue.isPersistent());
}
Also used : AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) Parameters(junitparams.Parameters) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 87 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneIndexDestroyDUnitTest method verifyDestroyAllIndexesWhileDoingQueries.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyDestroyAllIndexesWhileDoingQueries(RegionTestableType regionType) throws Exception {
    // Create indexes and region
    SerializableRunnableIF createIndexes = createIndexes();
    dataStore1.invoke(() -> initDataStore(createIndexes, regionType));
    dataStore2.invoke(() -> initDataStore(createIndexes, regionType));
    accessor.invoke(() -> initAccessor(createIndexes, regionType));
    // Verify indexes created
    dataStore1.invoke(() -> verifyIndexesCreated());
    dataStore2.invoke(() -> verifyIndexesCreated());
    accessor.invoke(() -> verifyIndexesCreated());
    // Do puts
    int numPuts = 100;
    accessor.invoke(() -> doPuts(numPuts));
    // Wait until queues are flushed
    accessor.invoke(() -> waitUntilFlushed(INDEX1_NAME));
    accessor.invoke(() -> waitUntilFlushed(INDEX2_NAME));
    // Start queries
    AsyncInvocation querier = accessor.invokeAsync(() -> doQueriesUntilException(INDEX1_NAME, "field1Value", "field1", numPuts));
    // Wait until queries have started
    accessor.invoke(() -> waitUntilQueriesHaveStarted());
    // Destroy indexes (only needs to be done on one member)
    accessor.invoke(() -> destroyIndexes());
    // Verify indexes destroyed
    dataStore1.invoke(() -> verifyIndexesDestroyed());
    dataStore2.invoke(() -> verifyIndexesDestroyed());
    accessor.invoke(() -> verifyIndexesDestroyed());
    // Wait for the querier to complete and verify no unexpected exception has occurred
    ThreadUtils.join(querier, 60 * 1000);
    if (querier.exceptionOccurred()) {
        fail(querier.getException());
    }
}
Also used : AsyncInvocation(org.apache.geode.test.dunit.AsyncInvocation) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 88 with Parameters

use of junitparams.Parameters in project geode by apache.

the class MixedObjectIndexDUnitTest method luceneMustIndexFieldsWithTheSameNameInARegionWithMixedObjects.

@Test
@Parameters(method = "getPartitionRegionTypes")
public void luceneMustIndexFieldsWithTheSameNameInARegionWithMixedObjects(RegionTestableType regionTestableType) {
    SerializableRunnableIF createIndexOnTextField = getSerializableRunnableIFCreateIndexOnFieldText();
    dataStore1.invoke(() -> initDataStore(createIndexOnTextField, regionTestableType));
    dataStore2.invoke(() -> initDataStore(createIndexOnTextField, regionTestableType));
    accessor.invoke(() -> initDataStore(createIndexOnTextField, regionTestableType));
    accessor.invoke(() -> {
        Region region = getCache().getRegion(REGION_NAME);
        IntStream.range(0, NUM_BUCKETS).forEach(i -> region.put(i, new TestObject("hello world")));
        IntStream.range(NUM_BUCKETS, 2 * NUM_BUCKETS).forEach(i -> region.put(i, new TestObjectWithSameFieldName("hello world")));
        IntStream.range(2 * NUM_BUCKETS, 3 * NUM_BUCKETS).forEach(i -> region.put(i, new TestObjectWithNoCommonField("hello world")));
    });
    waitForFlushBeforeExecuteTextSearch(accessor, 60000);
    accessor.invoke(() -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        LuceneQuery luceneQueryForTextField = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, "world", "text");
        List luceneResults = luceneQueryForTextField.findResults();
        validateObjectResultCounts(luceneResults, TestObject.class, NUM_BUCKETS, TestObjectWithSameFieldName.class, NUM_BUCKETS, TestObjectWithNoCommonField.class, 0);
    });
}
Also used : Region(org.apache.geode.cache.Region) List(java.util.List) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 89 with Parameters

use of junitparams.Parameters in project geode by apache.

the class PaginationDUnitTest method partitionedRegionStorageExceptionWhenAllDataStoreAreClosedWhilePagination.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void partitionedRegionStorageExceptionWhenAllDataStoreAreClosedWhilePagination(RegionTestableType regionTestType) {
    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();
    assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, FLUSH_WAIT_TIME_MS));
    accessor.invoke(() -> {
        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();
        assertEquals(page.size(), PAGE_SIZE, page.size());
        dataStore1.invoke(() -> closeCache());
        try {
            page = pages.next();
            fail();
        } catch (Exception e) {
            Assert.assertEquals("Expected Exception = PartitionedRegionStorageException but hit " + e.toString(), true, e instanceof PartitionedRegionStorageException);
        }
    });
}
Also used : PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) PartitionedRegionStorageException(org.apache.geode.cache.PartitionedRegionStorageException) Cache(org.apache.geode.cache.Cache) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 90 with Parameters

use of junitparams.Parameters in project geode by apache.

the class RebalanceDUnitTest method returnCorrectResultsWhenMoveBucketHappensOnIndexUpdate.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenMoveBucketHappensOnIndexUpdate(RegionTestableType regionTestType) throws InterruptedException {
    final DistributedMember member2 = dataStore2.invoke(() -> getCache().getDistributedSystem().getDistributedMember());
    addCallbackToMoveBucket(dataStore1, member2);
    putEntriesAndValidateQueryResults(regionTestType);
}
Also used : DistributedMember(org.apache.geode.distributed.DistributedMember) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

Parameters (junitparams.Parameters)121 Test (org.junit.Test)121 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)55 DescriptorSet (com.spotify.protoman.descriptor.DescriptorSet)43 ValidationViolation (com.spotify.protoman.validation.ValidationViolation)43 SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)41 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)11 Region (org.apache.geode.cache.Region)10 Cache (org.apache.geode.cache.Cache)9 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)9 DistributedMember (org.apache.geode.distributed.DistributedMember)8 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 ArrayList (java.util.ArrayList)6 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)5 List (java.util.List)4 ResultCollector (org.apache.geode.cache.execute.ResultCollector)4 LuceneDestroyIndexFunction (org.apache.geode.cache.lucene.internal.cli.functions.LuceneDestroyIndexFunction)4 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)4 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)4 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)4