예제 #1
0
        public virtual GraphDatabaseService NewImpermanentDatabase(File storeDir)
        {
            File absoluteDirectory = storeDir.AbsoluteFile;
            GraphDatabaseBuilder databaseBuilder = NewImpermanentDatabaseBuilder(absoluteDirectory);

            databaseBuilder.setConfig(GraphDatabaseSettings.active_database, absoluteDirectory.Name);
            databaseBuilder.setConfig(GraphDatabaseSettings.databases_root_path, absoluteDirectory.ParentFile.AbsolutePath);
            return(databaseBuilder.NewGraphDatabase());
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpPorts()
        public virtual void SetUpPorts()
        {
            _backupPort = PortAuthority.allocatePort();
            GraphDatabaseFactory factory = new EnterpriseGraphDatabaseFactory();
            GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(_dir.storeDir());

            builder.setConfig(online_backup_enabled, "true");
            builder.setConfig(online_backup_server, "127.0.0.1:" + _backupPort);
            _db = ( GraphDatabaseAPI )builder.NewGraphDatabase();
            _cleanup.add(_db);
        }
예제 #3
0
 protected internal override void Configure(GraphDatabaseBuilder builder)
 {
     // Reduce the default page cache memory size to 8 mega-bytes for test databases.
     builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m");
     builder.setConfig((new BoltConnector("bolt")).type, BOLT.name());
     builder.SetConfig((new BoltConnector("bolt")).enabled, "false");
 }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void migratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void MigratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork()
            {
                // migrate the store using a single instance
                File storeDir                = TestDir.storeDir("initialData");
                File databaseDirectory       = Store.prepareDirectory(TestDir.databaseDir(storeDir));
                GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
                GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(databaseDirectory);

                builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true");
                builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m");
                builder.setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath);
                builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE);
                GraphDatabaseService db = builder.NewGraphDatabase();

                try
                {
                    CheckInstance(Store, ( GraphDatabaseAPI )db);
                }
                finally
                {
                    Db.shutdown();
                }

                assertConsistentStore(DatabaseLayout.of(databaseDirectory));

                // start the cluster with the db migrated from the old instance
                File           haDir          = TestDir.storeDir("ha-stuff");
                ClusterManager clusterManager = (new ClusterManager.Builder(haDir)).withSeedDir(databaseDirectory).withCluster(clusterOfSize(2)).build();

                HighlyAvailableGraphDatabase master;
                HighlyAvailableGraphDatabase slave;

                try
                {
                    clusterManager.Start();
                    ClusterManager.ManagedCluster cluster = clusterManager.Cluster;

                    cluster.Await(allSeesAllAsAvailable());

                    master = cluster.Master;
                    CheckInstance(Store, master);
                    slave = cluster.AnySlave;
                    CheckInstance(Store, slave);
                    clusterManager.SafeShutdown();

                    assertConsistentStore(master.DatabaseLayout());
                    assertConsistentStore(slave.DatabaseLayout());
                }
                finally
                {
                    clusterManager.SafeShutdown();
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseConfiguredIndexProvider() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUseConfiguredIndexProvider()
        {
            // given
            GraphDatabaseService db = _dbBuilder.setConfig(default_schema_provider, Provider == null ? null : Provider.providerName()).newGraphDatabase();

            try
            {
                // when
                CreateIndex(db);

                // then
                AssertIndexProvider(db, Provider == null ? GenericNativeIndexProvider.DESCRIPTOR.name() : Provider.providerName());
            }
            finally
            {
                Db.shutdown();
            }
        }
예제 #6
0
 /// <summary>
 /// Adds or replaces a setting for the database managed by this database rule.
 /// <para>
 /// If this method is called when constructing the rule, the setting is considered a global setting applied to all tests.
 /// </para>
 /// <para>
 /// If this method is called inside a specific test, i.e. after <seealso cref="before()"/>, but before started (a call to <seealso cref="startLazily()"/> have been made),
 /// then this setting will be considered a test-specific setting, adding to or overriding the global settings for this test only.
 /// Test-specific settings will be remembered throughout a test, even between restarts.
 /// </para>
 /// <para>
 /// If this method is called when a database is already started an <seealso cref="System.InvalidOperationException"/> will be thrown since the setting
 /// will have no effect, instead letting the developer notice that and change the test code.
 /// </para>
 /// </summary>
 public virtual DatabaseRule WithSetting <T1>(Setting <T1> key, string value)
 {
     if (_database != null)
     {
         // Database already started
         throw new System.InvalidOperationException("Wanted to set " + key + "=" + value + ", but database has already been started");
     }
     if (_databaseBuilder != null)
     {
         // Test already started, but db not yet started
         _databaseBuilder.setConfig(key, value);
     }
     else
     {
         // Test haven't started, we're still in phase of constructing this rule
         _globalConfig[key] = value;
     }
     return(this);
 }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void embeddedDatabaseShouldStartOnOlderStoreWhenUpgradeIsEnabled() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void EmbeddedDatabaseShouldStartOnOlderStoreWhenUpgradeIsEnabled()
            {
                File databaseDirectory = Store.prepareDirectory(TestDir.databaseDir());

                GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
                GraphDatabaseBuilder builder = factory.NewEmbeddedDatabaseBuilder(TestDir.databaseDir());

                builder.SetConfig(GraphDatabaseSettings.allow_upgrade, "true");
                builder.SetConfig(GraphDatabaseSettings.pagecache_memory, "8m");
                builder.setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath);
                builder.SetConfig(OnlineBackupSettings.online_backup_enabled, Settings.FALSE);
                GraphDatabaseService db = builder.NewGraphDatabase();

                try
                {
                    CheckInstance(Store, ( GraphDatabaseAPI )db);
                }
                finally
                {
                    Db.shutdown();
                }

                assertConsistentStore(DatabaseLayout.of(databaseDirectory));
            }
예제 #8
0
 private void Configure(GraphDatabaseBuilder builder, File storeDir)
 {
     Configure(builder);
     builder.setConfig(GraphDatabaseSettings.logs_directory, (new File(storeDir, "logs")).AbsolutePath);
 }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogTXMetaDataInQueryLog() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogTXMetaDataInQueryLog()
        {
            // turn on query logging
            _databaseBuilder.setConfig(logs_directory, _logsDirectory.Path);
            _databaseBuilder.setConfig(log_queries, Settings.TRUE);
            _db = new EmbeddedInteraction(_databaseBuilder, Collections.emptyMap());
            GraphDatabaseFacade graph = _db.LocalGraph;

            _db.LocalUserManager.setUserPassword("neo4j", password("123"), false);

            EnterpriseLoginContext subject = _db.login("neo4j", "123");

            _db.executeQuery(subject, "UNWIND range(0, 10) AS i CREATE (:Foo {p: i})", Collections.emptyMap(), ResourceIterator.close);

            // Set meta data and execute query in transaction
            using (InternalTransaction tx = _db.beginLocalTransactionAsUser(subject, KernelTransaction.Type.@explicit))
            {
                graph.Execute("CALL dbms.setTXMetaData( { User: '******' } )", Collections.emptyMap());
                graph.Execute("CALL dbms.procedures() YIELD name RETURN name", Collections.emptyMap()).close();
                graph.Execute("MATCH (n) RETURN n", Collections.emptyMap()).close();
                graph.Execute(QUERY, Collections.emptyMap());
                tx.Success();
            }

            // Ensure that old meta data is not retained
            using (InternalTransaction tx = _db.beginLocalTransactionAsUser(subject, KernelTransaction.Type.@explicit))
            {
                graph.Execute("CALL dbms.setTXMetaData( { Location: 'Sweden' } )", Collections.emptyMap());
                graph.Execute("MATCH ()-[r]-() RETURN count(r)", Collections.emptyMap()).close();
                tx.Success();
            }

            _db.tearDown();

            // THEN
            IList <string> logLines = ReadAllLines(_logFilename);

            assertThat(logLines, hasSize(7));
            assertThat(logLines[0], not(containsString("User: '******'")));
            // we don't care if setTXMetaData contains the meta data
            //assertThat( logLines.get( 1 ), containsString( "User: Johan" ) );
            assertThat(logLines[2], containsString("User: '******'"));
            assertThat(logLines[3], containsString("User: '******'"));
            assertThat(logLines[4], containsString("User: '******'"));

            // we want to make sure that the new transaction does not carry old meta data
            assertThat(logLines[5], not(containsString("User: '******'")));
            assertThat(logLines[6], containsString("Location: 'Sweden'"));
        }