Search in sources :

Example 81 with Parameters

use of junitparams.Parameters in project geode by apache.

the class MixedObjectIndexDUnitTest method luceneMustIndexFieldsWithTheSameNameDifferentDataTypeInARegionWithMixedObjects.

@Test
@Parameters(method = "getPartitionRegionTypes")
public void luceneMustIndexFieldsWithTheSameNameDifferentDataTypeInARegionWithMixedObjects(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(2 * NUM_BUCKETS, 3 * NUM_BUCKETS).forEach(i -> region.put(i, new TestObjectSameFieldNameButDifferentDataTypeInteger(new Integer(1000))));
        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 TestObjectSameFieldNameButDifferentDataTypeFloat(new Float(999.1f))));
    });
    assertTrue(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, TestObjectSameFieldNameButDifferentDataTypeFloat.class, 0, TestObjectSameFieldNameButDifferentDataTypeInteger.class, 0);
        FloatRangeQueryProvider floatRangeQueryProvider = new FloatRangeQueryProvider("text", 999.0f, 999.2f);
        luceneQueryForTextField = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, floatRangeQueryProvider);
        luceneResults = luceneQueryForTextField.findResults();
        validateObjectResultCounts(luceneResults, TestObject.class, 0, TestObjectSameFieldNameButDifferentDataTypeFloat.class, NUM_BUCKETS, TestObjectSameFieldNameButDifferentDataTypeInteger.class, 0);
        IntRangeQueryProvider intRangeQueryProvider = new IntRangeQueryProvider("text", 1000, 1000);
        luceneQueryForTextField = luceneService.createLuceneQueryFactory().setLimit(100).create(INDEX_NAME, REGION_NAME, intRangeQueryProvider);
        luceneResults = luceneQueryForTextField.findResults();
        validateObjectResultCounts(luceneResults, TestObject.class, 0, TestObjectSameFieldNameButDifferentDataTypeFloat.class, 0, TestObjectSameFieldNameButDifferentDataTypeInteger.class, NUM_BUCKETS);
    });
}
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 82 with Parameters

use of junitparams.Parameters in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method returnCorrectResultsWhenCloseCacheHappensOnIndexUpdate.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenCloseCacheHappensOnIndexUpdate(RegionTestableType regionTestType) throws InterruptedException {
    dataStore1.invoke(() -> {
        IndexRepositorySpy spy = IndexRepositorySpy.injectSpy();
        spy.beforeWriteIndexRepository(doAfterN(key -> getCache().close(), 2));
    });
    final String expectedExceptions = CacheClosedException.class.getName();
    dataStore1.invoke(addExceptionTag1(expectedExceptions));
    putEntriesAndValidateResultsWithRedundancy(regionTestType);
    // Wait until the cache is closed in datastore1
    dataStore1.invoke(() -> Awaitility.await().atMost(60, TimeUnit.SECONDS).until(basicGetCache()::isClosed));
}
Also used : IntStream(java.util.stream.IntStream) GIITestHook(org.apache.geode.internal.cache.InitialImageOperation.GIITestHook) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) IndexRegionSpy(org.apache.geode.cache.lucene.test.IndexRegionSpy) Category(org.junit.experimental.categories.Category) TimeUnit(java.util.concurrent.TimeUnit) Cache(org.apache.geode.cache.Cache) GIITestHookType(org.apache.geode.internal.cache.InitialImageOperation.GIITestHookType) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) LuceneTestUtilities(org.apache.geode.cache.lucene.test.LuceneTestUtilities) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) CacheClosedException(org.apache.geode.cache.CacheClosedException) Region(org.apache.geode.cache.Region) After(org.junit.After) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) JUnitParamsRunner(junitparams.JUnitParamsRunner) DistributedMember(org.apache.geode.distributed.DistributedMember) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Assert(org.junit.Assert) Awaitility(org.awaitility.Awaitility) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) Parameters(junitparams.Parameters) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 83 with Parameters

use of junitparams.Parameters in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method returnCorrectResultsWhenMovePrimaryHappensOnIndexUpdate.

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

Example 84 with Parameters

use of junitparams.Parameters in project geode by apache.

the class RebalanceWithRedundancyDUnitTest method returnCorrectResultsWhenCloseCacheHappensOnPartialIndexWrite.

@Test
@Parameters(method = "getListOfRegionTestTypes")
public void returnCorrectResultsWhenCloseCacheHappensOnPartialIndexWrite(RegionTestableType regionTestType) throws InterruptedException {
    final DistributedMember member2 = dataStore2.invoke(() -> getCache().getDistributedSystem().getDistributedMember());
    dataStore1.invoke(() -> {
        IndexRegionSpy.beforeWrite(getCache(), doAfterN(key -> getCache().close(), 100));
    });
    putEntriesAndValidateResultsWithRedundancy(regionTestType);
    // Wait until the cache is closed in datastore1
    dataStore1.invoke(() -> Awaitility.await().atMost(60, TimeUnit.SECONDS).until(basicGetCache()::isClosed));
}
Also used : IntStream(java.util.stream.IntStream) GIITestHook(org.apache.geode.internal.cache.InitialImageOperation.GIITestHook) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) IndexRegionSpy(org.apache.geode.cache.lucene.test.IndexRegionSpy) Category(org.junit.experimental.categories.Category) TimeUnit(java.util.concurrent.TimeUnit) Cache(org.apache.geode.cache.Cache) GIITestHookType(org.apache.geode.internal.cache.InitialImageOperation.GIITestHookType) SerializableRunnableIF(org.apache.geode.test.dunit.SerializableRunnableIF) LuceneTestUtilities(org.apache.geode.cache.lucene.test.LuceneTestUtilities) InitialImageOperation(org.apache.geode.internal.cache.InitialImageOperation) CacheClosedException(org.apache.geode.cache.CacheClosedException) Region(org.apache.geode.cache.Region) After(org.junit.After) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) JUnitParamsRunner(junitparams.JUnitParamsRunner) DistributedMember(org.apache.geode.distributed.DistributedMember) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Assert(org.junit.Assert) Awaitility(org.awaitility.Awaitility) IndexRepositorySpy(org.apache.geode.cache.lucene.test.IndexRepositorySpy) Parameters(junitparams.Parameters) DistributedMember(org.apache.geode.distributed.DistributedMember) Parameters(junitparams.Parameters) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 85 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneIndexCreationPersistenceIntegrationTest method shouldHandleMultipleIndexes.

@Test
@Parameters(method = "getRegionShortcuts")
public void shouldHandleMultipleIndexes(RegionShortcut shortcut) throws Exception {
    LuceneServiceProvider.get(this.cache).createIndexFactory().setFields("field1").create(INDEX_NAME + "_1", REGION_NAME);
    LuceneServiceProvider.get(this.cache).createIndexFactory().setFields("field2").create(INDEX_NAME + "_2", REGION_NAME);
    Region region = cache.createRegionFactory(shortcut).create(REGION_NAME);
    region.put("key1", new TestObject());
    verifyQueryResultSize(INDEX_NAME + "_1", REGION_NAME, "field1:world", DEFAULT_FIELD, 1);
    verifyQueryResultSize(INDEX_NAME + "_2", REGION_NAME, "field2:field", DEFAULT_FIELD, 1);
}
Also used : LocalRegion(org.apache.geode.internal.cache.LocalRegion) Region(org.apache.geode.cache.Region) TestObject(org.apache.geode.cache.lucene.test.TestObject) Parameters(junitparams.Parameters) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

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