use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class UniqueConstraintCompatibility method setUp.
/*
* There are a quite a number of permutations to consider, when it comes to unique
* constraints.
*
* We have two supported providers:
* - InMemoryIndexProvider
* - LuceneIndexProvider
*
* An index can be in a number of states, two of which are interesting:
* - ONLINE: the index is in active duty
* - POPULATING: the index is in the process of being created and filled with data
*
* Further more, indexes that are POPULATING have two ways of ingesting data:
* - Through add()'ing existing data
* - Through NodePropertyUpdates sent to a "populating updater"
*
* Then, when we add data to an index, two outcomes are possible, depending on the
* data:
* - The index does not contain an equivalent value, and the entity id is added to
* the index.
* - The index already contains an equivalent value, and the addition is rejected.
*
* And when it comes to observing these outcomes, there are a whole bunch of
* interesting transaction states that are worth exploring:
* - Adding a label to a node
* - Removing a label from a node
* - Combinations of adding and removing a label, ultimately adding it
* - Combinations of adding and removing a label, ultimately removing it
* - Adding a property
* - Removing a property
* - Changing an existing property
* - Combinations of adding and removing a property, ultimately adding it
* - Combinations of adding and removing a property, ultimately removing it
* - Likewise combinations of adding, removing and changing a property
*
* To make matters worse, we index a number of different types, some of which may or
* may not collide in the index because of coercion. We need to make sure that the
* indexes deal with these values correctly. And we also have the ways in which these
* operations can be performed in any number of transactions, for instance, if all
* the conflicting nodes were added in the same transaction or not.
*
* All in all, we have many cases to test for!
*
* Still, it is possible to boil things down a little bit, because there are fewer
* outcomes than there are scenarios that lead to those outcomes. With a bit of
* luck, we can abstract over the scenarios that lead to those outcomes, and then
* only write a test per outcome. These are the outcomes I see:
* - Populating an index succeeds
* - Populating an index fails because of the existing data
* - Populating an index fails because of updates to data
* - Adding to an online index succeeds
* - Adding to an online index fails because of existing data
* - Adding to an online index fails because of data in the same transaction
*
* There's a lot of work to be done here.
*/
@Before
public void setUp() {
managementService = new TestDatabaseManagementServiceBuilder(graphDbDir).setExtensions(asList(new PredefinedIndexProviderFactory(indexProvider), new TokenIndexProviderFactory())).noOpSystemGraphInitializer().impermanent().setConfig(default_schema_provider, indexProvider.getProviderDescriptor().name()).build();
db = managementService.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class SystemTimeZoneLoggingIT method checkStartLogLine.
private void checkStartLogLine(int hoursShift, String timeZoneSuffix) throws IOException {
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.ofHours(hoursShift)));
Path storeDir = testDirectory.homePath(String.valueOf(hoursShift));
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setConfig(GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM).build();
managementService.database(DEFAULT_DATABASE_NAME);
managementService.shutdown();
Path debugLog = Paths.get("logs", "debug.log");
String debugLogLine = getLogLine(storeDir, debugLog);
assertTrue(debugLogLine.contains(timeZoneSuffix), debugLogLine);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method dbmsAction.
/**
* Open dbms with schemaIndex as default index provider on provided file system abstraction and apply dbSetup to DEFAULT_DATABASE.
*/
private void dbmsAction(Path neo4jHome, FileSystemAbstraction fs, GraphDatabaseSettings.SchemaIndex schemaIndex, Consumer<GraphDatabaseService> dbSetup, Consumer<DatabaseManagementServiceBuilder> dbConfiguration) {
TestDatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(neo4jHome).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
dbConfiguration.accept(builder);
final DatabaseManagementService dbms = builder.setConfig(GraphDatabaseSettings.default_schema_provider, schemaIndex.providerName()).build();
try {
final GraphDatabaseService db = dbms.database(DEFAULT_DATABASE_NAME);
dbSetup.accept(db);
} finally {
dbms.shutdown();
}
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class GraphStoreFixture method startDatabaseAndExtractComponents.
private void startDatabaseAndExtractComponents() {
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setFileSystem(testDirectory.getFileSystem()).setConfig(GraphDatabaseSettings.record_format, formatName).setConfig(GraphDatabaseInternalSettings.label_block_size, 60).setConfig(GraphDatabaseInternalSettings.consistency_check_on_apply, false).setConfig(getConfig()).build();
database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
DependencyResolver dependencyResolver = database.getDependencyResolver();
commitProcess = new InternalTransactionCommitProcess(dependencyResolver.resolveDependency(TransactionAppender.class), dependencyResolver.resolveDependency(StorageEngine.class));
transactionIdStore = database.getDependencyResolver().resolveDependency(TransactionIdStore.class);
storageEngine = dependencyResolver.resolveDependency(RecordStorageEngine.class);
neoStores = storageEngine.testAccessNeoStores();
indexingService = dependencyResolver.resolveDependency(IndexingService.class);
directStoreAccess = new DirectStoreAccess(neoStores, dependencyResolver.resolveDependency(IndexProviderMap.class), dependencyResolver.resolveDependency(TokenHolders.class), dependencyResolver.resolveDependency(IndexStatisticsStore.class), dependencyResolver.resolveDependency(IdGeneratorFactory.class));
countsStore = storageEngine.countsAccessor();
groupDegreesStore = storageEngine.relationshipGroupDegreesStore();
pageCache = dependencyResolver.resolveDependency(PageCache.class);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class TestExceptionTypeOnInvalidIds method createDatabase.
@BeforeEach
void createDatabase() {
Path writableLayout = testDirectory.homePath("writable");
writableService = new TestDatabaseManagementServiceBuilder(writableLayout).build();
writableDb = writableService.database(DEFAULT_DATABASE_NAME);
Path readOnlyLayout = testDirectory.homePath("readOnly");
TestDatabaseManagementServiceBuilder readOnlyBuilder = new TestDatabaseManagementServiceBuilder(readOnlyLayout);
// Create database
readOnlyBuilder.build().shutdown();
readOnlyService = readOnlyBuilder.setConfig(read_only_database_default, true).build();
readOnlyDb = readOnlyService.database(DEFAULT_DATABASE_NAME);
}
Aggregations