Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void firstRecordOtherThanZeroIfNotFirst()
        public virtual void FirstRecordOtherThanZeroIfNotFirst()
        {
            File             storeDir = TestDirectory.databaseDir();
            GraphDatabaseAPI db       = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            Transaction      tx       = Db.beginTx();
            Node             node     = Db.createNode();

            node.SetProperty("name", "Yo");
            tx.Success();
            tx.Close();
            Db.shutdown();

            db = ( GraphDatabaseAPI )_factory.newImpermanentDatabase(storeDir);
            tx = Db.beginTx();
            Properties(db).setProperty("test", "something");
            tx.Success();
            tx.Close();
            Db.shutdown();

            Config       config       = Config.defaults();
            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), config, new DefaultIdGeneratorFactory(Fs.get()), PageCacheRule.getPageCache(Fs.get()), Fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            NeoStores    neoStores    = storeFactory.OpenAllNeoStores();
            long         prop         = neoStores.MetaDataStore.GraphNextProp;

            assertTrue(prop != 0);
            neoStores.Close();
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDelegateDeletionOptionToStores()
        public virtual void ShouldDelegateDeletionOptionToStores()
        {
            // GIVEN
            StoreFactory storeFactory = storeFactory(Config.defaults(), DELETE_ON_CLOSE);

            // WHEN
            _neoStores = storeFactory.OpenAllNeoStores(true);
            assertTrue(_fsRule.get().listFiles(_testDirectory.databaseDir()).length >= StoreType.values().length);

            // THEN
            _neoStores.close();
            assertEquals(0, _fsRule.get().listFiles(_testDirectory.databaseDir()).length);
        }
        private StoreAccess CreateStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes(int nDegreeTwoNodes)
        {
            File storeDirectory           = _testDirectory.databaseDir();
            GraphDatabaseService database = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(storeDirectory).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            using (Transaction transaction = database.BeginTx())
            {
                Node denseNode = database.CreateNode();
                for (int i = 0; i < nDegreeTwoNodes; i++)
                {
                    Node degreeTwoNode = database.CreateNode();
                    Node leafNode      = database.CreateNode();
                    if (i % 2 == 0)
                    {
                        denseNode.CreateRelationshipTo(degreeTwoNode, TestRelationshipType.Connected);
                    }
                    else
                    {
                        degreeTwoNode.CreateRelationshipTo(denseNode, TestRelationshipType.Connected);
                    }
                    degreeTwoNode.CreateRelationshipTo(leafNode, TestRelationshipType.Connected);
                }
                transaction.Success();
            }
            database.Shutdown();
            PageCache   pageCache   = PageCacheRule.getPageCache(_fileSystemRule.get());
            StoreAccess storeAccess = new StoreAccess(_fileSystemRule.get(), pageCache, _testDirectory.databaseLayout(), Config.defaults());

            return(storeAccess.Initialize());
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rebuildReplicatedIdGeneratorsOnRecovery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RebuildReplicatedIdGeneratorsOnRecovery()
        {
            DefaultFileSystemAbstraction fileSystem = FileSystemRule.get();
            File stickyGenerator      = new File(TestDirectory.databaseDir(), "stickyGenerator");
            File nodeStoreIdGenerator = TestDirectory.databaseLayout().idNodeStore();

            StoreFactory storeFactory = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), GetIdGenerationFactory(fileSystem), PageCacheRule.getPageCache(fileSystem), fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = storeFactory.OpenAllNeoStores(true))
            {
                NodeStore nodeStore = neoStores.NodeStore;
                for (int i = 0; i < 50; i++)
                {
                    NodeRecord nodeRecord = nodeStore.NewRecord();
                    nodeRecord.InUse = true;
                    nodeRecord.Id    = nodeStore.NextId();
                    if (i == 47)
                    {
                        FileUtils.copyFile(nodeStoreIdGenerator, stickyGenerator);
                    }
                    nodeStore.UpdateRecord(nodeRecord);
                }
            }

            FileUtils.copyFile(stickyGenerator, nodeStoreIdGenerator);
            using (NeoStores reopenedStores = storeFactory.OpenAllNeoStores())
            {
                reopenedStores.MakeStoreOk();
                assertEquals(51L, reopenedStores.NodeStore.nextId());
            }
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRestoreBySeedingAllMembers() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRestoreBySeedingAllMembers()
        {
            // given
            GraphDatabaseService database = (new GraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDir.storeDir()).setConfig(GraphDatabaseSettings.allow_upgrade, Settings.TRUE).setConfig(GraphDatabaseSettings.record_format, HighLimit.NAME).setConfig(OnlineBackupSettings.online_backup_enabled, false.ToString()).newGraphDatabase();

            database.Shutdown();
            Config           config = Config.defaults(OnlineBackupSettings.online_backup_enabled, Settings.FALSE);
            DbRepresentation before = DbRepresentation.of(TestDir.storeDir(), config);

            // when
            _fsa.copyRecursively(TestDir.databaseDir(), _cluster.getCoreMemberById(0).databaseDirectory());
            _fsa.copyRecursively(TestDir.databaseDir(), _cluster.getCoreMemberById(1).databaseDirectory());
            _fsa.copyRecursively(TestDir.databaseDir(), _cluster.getCoreMemberById(2).databaseDirectory());
            _cluster.start();

            // then
            dataMatchesEventually(before, _cluster.coreMembers());
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHonorsPassedInParams() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestHonorsPassedInParams()
        {
            BatchInserter inserter  = BatchInserters.inserter(_testDirectory.databaseDir(), _fileSystemRule.get(), stringMap(GraphDatabaseSettings.pagecache_memory.name(), "280K"));
            NeoStores     neoStores = ReflectionUtil.getPrivateField(inserter, "neoStores", typeof(NeoStores));
            PageCache     pageCache = ReflectionUtil.getPrivateField(neoStores, "pageCache", typeof(PageCache));

            inserter.Shutdown();
            long mappedMemoryTotalSize = MuninnPageCache.memoryRequiredForPages(pageCache.MaxCachedPages());

            assertThat("memory mapped config is active", mappedMemoryTotalSize, @is(allOf(greaterThan(kibiBytes(270)), lessThan(kibiBytes(290)))));
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteToInternalDiagnosticsLog() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteToInternalDiagnosticsLog()
        {
            // Given
            (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(TestDir.databaseDir()).setConfig(GraphDatabaseSettings.logs_directory, TestDir.directory("logs").AbsolutePath).newGraphDatabase().shutdown();
            File internalLog = new File(TestDir.directory("logs"), INTERNAL_LOG_FILE);

            // Then
            assertThat(internalLog.File, @is(true));
            assertThat(internalLog.length(), greaterThan(0L));

            assertEquals(1, CountOccurrences(internalLog, "Database graph.db is ready."));
            assertEquals(2, CountOccurrences(internalLog, "Database graph.db is unavailable."));
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _databaseLayout       = _testDirectory.databaseLayout();
            _storeDir             = _databaseLayout.databaseDirectory();
            _nativeLabelIndex     = _databaseLayout.labelScanStore();
            _migrationLayout      = _testDirectory.databaseLayout("migrationDir");
            _luceneLabelScanStore = _testDirectory.databaseDir().toPath().resolve(Paths.get("schema", "label", "lucene")).toFile();

            _fileSystem    = _fileSystemRule.get();
            _pageCache     = _pageCacheRule.getPageCache(_fileSystemRule);
            _indexMigrator = new NativeLabelScanStoreMigrator(_fileSystem, _pageCache, Config.defaults());
            _fileSystem.mkdirs(_luceneLabelScanStore);
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenBatchInserterWhenArrayPropertyUpdated4TimesThenShouldNotFail() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenBatchInserterWhenArrayPropertyUpdated4TimesThenShouldNotFail()
        {
            BatchInserter batchInserter = BatchInserters.inserter(TestDirectory.databaseDir(), FileSystemRule.get());

            long nodeId = batchInserter.createNode(Collections.emptyMap());

            for (int i = 0; i < 4; i++)
            {
                batchInserter.SetNodeProperty(nodeId, "array", new sbyte[] { 2, 3, 98, 1, 43, 50, 3, 33, 51, 55, 116, 16, 23, 56, 9, ( sbyte )-10, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
            }

            batchInserter.GetNodeProperties(nodeId);                 //fails here
            batchInserter.Shutdown();
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRotateExistingFileOnOpen()
        public virtual void ShouldRotateExistingFileOnOpen()
        {
            // given
            LabelScanWriteMonitor writeMonitor = new LabelScanWriteMonitor(Fs, Directory.databaseLayout());

            writeMonitor.Close();

            // when
            LabelScanWriteMonitor secondWriteMonitor = new LabelScanWriteMonitor(Fs, Directory.databaseLayout());

            secondWriteMonitor.Close();

            // then
            assertEquals(2, Directory.databaseDir().listFiles((dir, name) => name.StartsWith(_baseName)).length);
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void startBatchInserterOnTopOfEnterpriseDatabase() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StartBatchInserterOnTopOfEnterpriseDatabase()
        {
            File databaseDir = _testDirectory.databaseDir();
            GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir);

            using (Transaction transaction = database.BeginTx())
            {
                database.Execute("CREATE CONSTRAINT ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEY");
                transaction.Success();
            }
            database.Shutdown();

            BatchInserter inserter = BatchInserters.inserter(databaseDir);

            inserter.Shutdown();
        }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOpenInFreshDirectoryAndFinallyAddHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOpenInFreshDirectoryAndFinallyAddHeader()
        {
            // GIVEN
            string name = "log";
            FileSystemAbstraction fs = _fileSystemRule.get();
            LogFiles logFiles        = LogFilesBuilder.builder(_directory.databaseLayout(), fs).withTransactionIdStore(_transactionIdStore).withLogVersionRepository(_logVersionRepository).build();

            // WHEN
            _life.start();
            _life.add(logFiles);
            _life.shutdown();

            // THEN
            File      file   = LogFilesBuilder.logFilesBasedOnlyBuilder(_directory.databaseDir(), fs).build().getLogFileForVersion(1L);
            LogHeader header = readLogHeader(fs, file);

            assertEquals(1L, header.LogVersion);
            assertEquals(2L, header.LastCommittedTxId);
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailToValidateConstraintsIfUnderlyingIndexIsFailed()
        {
            // given a perfectly normal constraint
            File dir = Directory.databaseDir();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(dir);

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.schema().constraintFor(label("Label1")).assertPropertyIsUnique("key1").create();
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }

            // Remove the indexes offline and start up with an index provider which reports FAILED as initial state. An ordeal, I know right...
            FileUtils.deleteRecursively(IndexDirectoryStructure.baseSchemaIndexFolder(dir));
            db = (new TestGraphDatabaseFactory()).removeKernelExtensions(INDEX_PROVIDERS_FILTER).addKernelExtension(new FailingGenericNativeIndexProviderFactory(INITIAL_STATE)).newEmbeddedDatabase(dir);
            // when
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode(label("Label1")).setProperty("key1", "value1");
                    fail("expected exception");
                }
            }
            // then
            catch (ConstraintViolationException e)
            {
                assertThat(e.InnerException, instanceOf(typeof(UnableToValidateConstraintException)));
                assertThat(e.InnerException.InnerException.Message, allOf(containsString("The index is in a failed state:"), containsString(INITIAL_STATE_FAILURE_MESSAGE)));
            }
            finally
            {
                Db.shutdown();
            }
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles()
        {
            // GIVEN
            ToFileStoreWriter writer     = new ToFileStoreWriter(_directory.databaseDir(), _fs, new StoreCopyClientMonitor_Adapter());
            ByteBuffer        tempBuffer = ByteBuffer.allocate(128);

            // WHEN
            foreach (StoreType type in StoreType.values())
            {
                if (type.RecordStore)
                {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                    File[] files = _directory.databaseLayout().file(type.DatabaseFile).toArray(File[] ::new);
                    foreach (File file in files)
                    {
                        WriteAndVerify(writer, tempBuffer, file);
                    }
                }
            }
            WriteAndVerify(writer, tempBuffer, _directory.databaseLayout().labelScanStore());
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles()
        {
            // GIVEN
            Monitors             monitors       = new Monitors();
            StreamToDiskProvider writerProvider = new StreamToDiskProvider(_directory.databaseDir(), _fs, monitors);

            // WHEN
            foreach (StoreType type in StoreType.values())
            {
                if (type.RecordStore)
                {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                    File[] files = _directory.databaseLayout().file(type.DatabaseFile).toArray(File[] ::new);
                    foreach (File file in files)
                    {
                        WriteAndVerify(writerProvider, file);
                    }
                }
            }
            WriteAndVerify(writerProvider, _directory.databaseLayout().labelScanStore());
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void doBefore()
        public virtual void DoBefore()
        {
            _db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newEmbeddedDatabase(TestDirectory.databaseDir());
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setup()
        internal virtual void Setup()
        {
            _graphDbDir = _testDir.databaseDir();
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldShowServerMetrics() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldShowServerMetrics()
        {
            // Given
            File      metrics = Folder.file("metrics");
            NeoServer server  = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(Folder.databaseDir().AbsolutePath).withProperty(MetricsSettings.metricsEnabled.name(), "true").withProperty(MetricsSettings.csvEnabled.name(), "true").withProperty(MetricsSettings.csvPath.name(), metrics.Path).withProperty(MetricsSettings.csvInterval.name(), "100ms").persistent().build();

            try
            {
                // when
                server.Start();

                string host = "http://localhost:" + server.BaseUri().Port + ServerSettings.rest_api_path.DefaultValue + "/transaction/commit";

                for (int i = 0; i < 5; i++)
                {
                    ClientResponse r = Client.create().resource(host).accept(APPLICATION_JSON).type(APPLICATION_JSON).post(typeof(ClientResponse), "{ 'statements': [ { 'statement': 'CREATE ()' } ] }");
                    assertEquals(200, r.Status);
                }

                // then
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_ALL);
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_IDLE);
            }
            finally
            {
                server.Stop();
            }
        }
Example #19
0
 private GraphDatabaseService NewDB(FileSystemAbstraction fs)
 {
     return((new TestGraphDatabaseFactory()).setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs)).newImpermanentDatabase(TestDirectory.databaseDir()));
 }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _storeDir = TestDirectory.databaseDir();
            Restart(FsRule.get());
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            Unzip.unzip(this.GetType(), "2.3-store.zip", TestDir.databaseDir());
        }
Example #22
0
 private GraphDatabaseAPI CreateDatabase(TrackingIndexExtensionFactory indexExtensionFactory)
 {
     return(( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).setKernelExtensions(singletonList(indexExtensionFactory)).newEmbeddedDatabaseBuilder(Directory.databaseDir()).setConfig(default_schema_provider, DESCRIPTOR.name()).newGraphDatabase());
 }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void startAsNormalWhenUpgradeIsNotAllowed()
        public virtual void StartAsNormalWhenUpgradeIsNotAllowed()
        {
            CreateGraphDbAndKillIt();

            // Try to start with upgrading disabled
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.graphdb.GraphDatabaseService db = new org.neo4j.test.TestGraphDatabaseFactory().setFileSystem(fs.get()).newImpermanentDatabaseBuilder(storeDirectory.databaseDir()).setConfig(org.neo4j.graphdb.factory.GraphDatabaseSettings.allow_upgrade, "false").newGraphDatabase();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(_fs.get()).newImpermanentDatabaseBuilder(_storeDirectory.databaseDir()).setConfig(GraphDatabaseSettings.allow_upgrade, "false").newGraphDatabase();

            Db.shutdown();
        }
Example #24
0
        private EphemeralFileSystemAbstraction ProduceUncleanStore()
        {
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).setFileSystem(Fs.get()).newImpermanentDatabase(TestDirectory.databaseDir());

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }
            EphemeralFileSystemAbstraction snapshot = Fs.get().snapshot();

            Db.shutdown();
            return(snapshot);
        }
Example #25
0
 private void CreateAndStartDb()
 {
     _db = ( GraphDatabaseAPI )(new TestGraphDatabaseFactory()).newImpermanentDatabaseBuilder(TestDirectory.databaseDir()).setConfig(_bolt.enabled, "true").setConfig(_bolt.listen_address, "localhost:0").setConfig(GraphDatabaseSettings.bolt_ssl_policy, "bolt").setConfig(_sslPolicy.allow_key_generation, "true").setConfig(_sslPolicy.base_directory, "certificates").setConfig(_sslPolicy.tls_versions, SetupConflict.boltTlsVersions).setConfig(_sslPolicy.client_auth, "none").setConfig(_sslPolicy.verify_hostname, "false").newGraphDatabase();
 }