use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.
the class IndexingServiceIntegrationTest method dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint.
@ParameterizedTest
@MethodSource("parameters")
void dropIndexDirectlyOnIndexingServiceRaceWithCheckpoint(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Throwable {
setUp(schemaIndex);
IndexingService indexingService = getIndexingService(database);
CheckPointer checkPointer = getCheckPointer(database);
IndexDescriptor indexDescriptor;
try (Transaction tx = database.beginTx()) {
IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label("label")).on("prop").create();
indexDescriptor = indexDefinition.getIndexReference();
tx.commit();
}
try (Transaction tx = database.beginTx()) {
tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
tx.commit();
}
Race race = new Race();
race.addContestant(Race.throwing(() -> checkPointer.forceCheckPoint(new SimpleTriggerInfo("Test force"))));
race.addContestant(Race.throwing(() -> indexingService.dropIndex(indexDescriptor)));
race.go();
}
use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.
the class FulltextIndexTransactionStateTest method queryResultsMustIncludeOldPropertyValuesWhenRemovalsAreUndone.
@MethodSource("entityTypeProvider")
@ParameterizedTest
void queryResultsMustIncludeOldPropertyValuesWhenRemovalsAreUndone(EntityUtil entityUtil) {
createIndexAndWait(entityUtil);
long entityId;
try (Transaction tx = db.beginTx()) {
entityId = entityUtil.createEntityWithProperty(tx, "primo");
tx.commit();
}
try (Transaction tx = db.beginTx()) {
entityUtil.assertQueryFindsIdsInOrder(tx, "primo", entityId);
Entity entity = entityUtil.getEntity(tx, entityId);
entity.removeProperty(PROP);
entityUtil.assertQueryFindsIdsInOrder(tx, "primo");
entity.setProperty(PROP, "primo");
entityUtil.assertQueryFindsIdsInOrder(tx, "primo", entityId);
tx.commit();
}
}
use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.
the class FulltextIndexTransactionStateTest method queryingIndexInPopulatingStateMustBlockUntilIndexIsOnlineEvenWhenTransactionHasState.
@MethodSource("entityTypeProvider")
@ParameterizedTest
void queryingIndexInPopulatingStateMustBlockUntilIndexIsOnlineEvenWhenTransactionHasState(EntityUtil entityUtil) throws InterruptedException {
trapPopulation.set(true);
try (Transaction tx = db.beginTx()) {
entityUtil.createEntityWithProperty(tx, "value");
tx.commit();
}
try (Transaction tx = db.beginTx()) {
entityUtil.createIndex(tx);
tx.commit();
}
try (Transaction tx = db.beginTx()) {
entityUtil.createEntityWithProperty(tx, "value");
try (var resultStream = entityUtil.queryIndex(tx, "value").stream()) {
populationScanFinished.await();
populationScanFinished.release();
assertThat(resultStream.count()).isEqualTo(2);
}
tx.commit();
}
}
use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.
the class FulltextIndexTransactionStateTest method fulltextIndexMustWorkAfterRestartWithTxStateChanges.
@MethodSource("entityTypeProvider")
@ParameterizedTest
void fulltextIndexMustWorkAfterRestartWithTxStateChanges(EntityUtil entityUtil) {
createIndexAndWait(entityUtil);
restartDatabase();
try (Transaction tx = db.beginTx()) {
// create an indexed entity ...
long id = entityUtil.createEntityWithProperty(tx, "value");
// ... and not indexed one
entityUtil.createEntity(tx);
entityUtil.assertQueryFindsIdsInOrder(tx, "*", id);
tx.commit();
}
}
use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.
the class BTreeIndexKeySizeValidationIT method shouldEnforceSizeCapSingleValueSingleType.
/**
* Key size validation test for single type.
*
* Validate that we handle index reads and writes correctly for dynamically sized values (arrays and strings)
* of all different types with length close to and over the max limit for given type.
*
* We do this by inserting arrays of increasing size (doubling each iteration) and when we hit the upper limit
* we do binary search between the established min and max limit.
* We also verify that the largest successful array length for each type is as expected because this value
* is documented and if it changes, documentation also needs to change.
*/
@ParameterizedTest
@MethodSource("pageSizes")
void shouldEnforceSizeCapSingleValueSingleType(int pageSize) {
startDb(pageSize);
List<String> failureMessages = new ArrayList<>();
NamedDynamicValueGenerator[] dynamicValueGenerators = NamedDynamicValueGenerator.values();
for (NamedDynamicValueGenerator generator : dynamicValueGenerators) {
int expectedMax = pageSize == PAGE_SIZE_16K ? generator.expectedMax16k : generator.expectedMax;
String propKey = PROP_KEYS[0] + generator.name();
createIndex(propKey);
BinarySearch binarySearch = new BinarySearch();
Object propValue;
while (!binarySearch.finished()) {
propValue = generator.dynamicValue(random, binarySearch.arrayLength);
long expectedNodeId = -1;
// Write
boolean wasAbleToWrite = true;
try (Transaction tx = db.beginTx()) {
Node node = tx.createNode(LABEL_ONE);
node.setProperty(propKey, propValue);
expectedNodeId = node.getId();
tx.commit();
} catch (Exception e) {
wasAbleToWrite = false;
}
// Read
verifyReadExpected(propKey, propValue, expectedNodeId, wasAbleToWrite);
// Progress binary search
binarySearch.progress(wasAbleToWrite);
}
if (expectedMax != binarySearch.longestSuccessful) {
failureMessages.add(generator.name() + ": expected=" + expectedMax + ", actual=" + binarySearch.longestSuccessful);
}
}
if (failureMessages.size() > 0) {
StringJoiner joiner = new StringJoiner(System.lineSeparator(), "Some value types did not have expected longest successful array. " + "This is a strong indicator that documentation of max limit needs to be updated." + System.lineSeparator(), "");
for (String failureMessage : failureMessages) {
joiner.add(failureMessage);
}
fail(joiner.toString());
}
}
Aggregations