use of junitparams.Parameters in project geode by apache.
the class LuceneQueriesDUnitTest method transactionWithLuceneQueriesShouldThrowException.
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void transactionWithLuceneQueriesShouldThrowException(RegionTestableType regionTestType) {
SerializableRunnableIF createIndex = () -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
};
dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
accessor.invoke(() -> initAccessor(createIndex, regionTestType));
putDataInRegion(accessor);
assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
accessor.invoke(() -> {
Cache cache = getCache();
try {
LuceneService service = LuceneServiceProvider.get(cache);
LuceneQuery<Integer, TestObject> query;
query = service.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "text:world", DEFAULT_FIELD);
cache.getCacheTransactionManager().begin();
PageableLuceneQueryResults<Integer, TestObject> results = query.findPages();
fail();
} catch (LuceneQueryException e) {
if (!e.getMessage().equals(LuceneQueryImpl.LUCENE_QUERY_CANNOT_BE_EXECUTED_WITHIN_A_TRANSACTION)) {
fail();
}
} finally {
cache.getCacheTransactionManager().rollback();
}
});
}
use of junitparams.Parameters in project geode by apache.
the class LuceneQueriesDUnitTest method verifyWildcardQueriesSucceed.
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyWildcardQueriesSucceed(RegionTestableType regionTestType) {
SerializableRunnableIF createIndex = () -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
luceneService.createIndexFactory().addField("text").create(INDEX_NAME, REGION_NAME);
};
dataStore1.invoke(() -> initDataStore(createIndex, regionTestType));
dataStore2.invoke(() -> initDataStore(createIndex, regionTestType));
accessor.invoke(() -> initAccessor(createIndex, regionTestType));
putDataInRegion(accessor);
assertTrue(waitForFlushBeforeExecuteTextSearch(accessor, 60000));
assertTrue(waitForFlushBeforeExecuteTextSearch(dataStore1, 60000));
executeTextSearch(accessor, "*", "*", 3);
executeTextSearch(accessor, "*:*", "text", 3);
executeTextSearch(accessor, "*:*", "XXX", 3);
executeTextSearch(accessor, "*", "text", 3);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexDestroyDUnitTest method verifyDestroySingleIndexWhileDoingPuts.
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyDestroySingleIndexWhileDoingPuts(RegionTestableType regionType) throws Exception {
// Add ignored exceptions to ignore RegionDestroyExceptions
IgnoredException.addIgnoredException(RegionDestroyedException.class.getSimpleName());
// Create index and region
dataStore1.invoke(() -> initDataStore(createIndex(), regionType));
dataStore2.invoke(() -> initDataStore(createIndex(), regionType));
// Verify index created
dataStore1.invoke(() -> verifyIndexCreated());
dataStore2.invoke(() -> verifyIndexCreated());
// Start puts
AsyncInvocation putter = dataStore1.invokeAsync(() -> doPutsUntilStopped());
// Wait until puts have started
dataStore1.invoke(() -> waitUntilPutsHaveStarted());
// Destroy index (only needs to be done on one member)
dataStore1.invoke(() -> destroyIndex());
// Verify index destroyed
dataStore1.invoke(() -> verifyIndexDestroyed());
dataStore2.invoke(() -> verifyIndexDestroyed());
// End puts
dataStore1.invoke(() -> stopPuts());
// Wait for the putter to complete and verify no exception has occurred
ThreadUtils.join(putter, 60 * 1000);
if (putter.exceptionOccurred()) {
fail(putter.getException());
}
// Verify region size
dataStore1.invoke(() -> verifyRegionSize());
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexDestroyDUnitTest method verifyDestroySingleIndexWhileDoingQueries.
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyDestroySingleIndexWhileDoingQueries(RegionTestableType regionType) throws Exception {
// Create index and region
SerializableRunnableIF createIndex = createIndex();
dataStore1.invoke(() -> initDataStore(createIndex, regionType));
dataStore2.invoke(() -> initDataStore(createIndex, regionType));
accessor.invoke(() -> initAccessor(createIndex, regionType));
// Verify index created
dataStore1.invoke(() -> verifyIndexCreated());
dataStore2.invoke(() -> verifyIndexCreated());
accessor.invoke(() -> verifyIndexCreated());
// Do puts
int numPuts = 100;
accessor.invoke(() -> doPuts(numPuts));
// Wait until queue is flushed
accessor.invoke(() -> waitUntilFlushed(INDEX_NAME));
// Start queries
AsyncInvocation querier = accessor.invokeAsync(() -> doQueriesUntilException(INDEX_NAME, "field1Value", "field1", numPuts));
// Wait until queries have started
accessor.invoke(() -> waitUntilQueriesHaveStarted());
// Destroy index (only needs to be done on one member)
accessor.invoke(() -> destroyIndex());
// Verify index destroyed
dataStore1.invoke(() -> verifyIndexDestroyed());
dataStore2.invoke(() -> verifyIndexDestroyed());
accessor.invoke(() -> verifyIndexDestroyed());
// Wait for the querier to complete and verify no exception has occurred
ThreadUtils.join(querier, 60 * 1000);
if (querier.exceptionOccurred()) {
fail(querier.getException());
}
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexDestroyDUnitTest method verifyDestroyRecreateDifferentIndex.
@Test
@Parameters(method = "getListOfRegionTestTypes")
public void verifyDestroyRecreateDifferentIndex(RegionTestableType regionType) {
SerializableRunnableIF createIndex = createIndex();
dataStore1.invoke(() -> initDataStore(createIndex, regionType));
dataStore2.invoke(() -> initDataStore(createIndex, regionType));
accessor.invoke(() -> initAccessor(createIndex, regionType));
// Verify index created
dataStore1.invoke(() -> verifyIndexCreated());
dataStore2.invoke(() -> verifyIndexCreated());
accessor.invoke(() -> verifyIndexCreated());
// Do puts to cause IndexRepositories to be created
int numPuts = 1000;
accessor.invoke(() -> doPuts(numPuts));
// Wait until queue is flushed
accessor.invoke(() -> waitUntilFlushed(INDEX_NAME));
// Execute query and verify results
accessor.invoke(() -> executeQuery(INDEX_NAME, "field1Value", "field1", numPuts));
// Export entries from region
accessor.invoke(() -> exportData(regionType));
// Destroy indexes (only needs to be done on one member)
dataStore1.invoke(() -> destroyIndexes());
// Verify indexes destroyed
dataStore1.invoke(() -> verifyIndexesDestroyed());
dataStore2.invoke(() -> verifyIndexesDestroyed());
// Destroy data region
dataStore1.invoke(() -> destroyDataRegion(true));
// Create new index and region
SerializableRunnableIF createNewIndex = createIndex(INDEX_NAME, REGION_NAME, "field2");
dataStore1.invoke(() -> initDataStore(createNewIndex, regionType));
dataStore2.invoke(() -> initDataStore(createNewIndex, regionType));
accessor.invoke(() -> initAccessor(createNewIndex, regionType));
// Import entries into region
accessor.invoke(() -> importData(regionType, numPuts));
// Wait until queue is flushed
// This verifies there are no deadlocks
dataStore1.invoke(() -> waitUntilFlushed(INDEX_NAME));
dataStore2.invoke(() -> waitUntilFlushed(INDEX_NAME));
// re-execute query and verify results
accessor.invoke(() -> executeQuery(INDEX_NAME, "field2Value", "field2", numPuts));
}
Aggregations