Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void uniqueIndexWithoutOwningConstraintIsIgnoredDuringCheck() throws ConsistencyCheckTool.ToolFailureException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UniqueIndexWithoutOwningConstraintIsIgnoredDuringCheck()
        {
            File   databaseDir = TestDirectory.databaseDir();
            Label  marker      = Label.label("MARKER");
            string property    = "property";

            GraphDatabaseService database = (new EnterpriseGraphDatabaseFactory()).newEmbeddedDatabase(databaseDir);

            try
            {
                CreateNodes(marker, property, database);
                AddIndex(database);
                WaitForIndexPopulationFailure(database);
            }
            catch (SchemaKernelException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }
            finally
            {
                database.Shutdown();
            }

            ConsistencyCheckService.Result checkResult = ConsistencyCheckTool.RunConsistencyCheckTool(new string[] { databaseDir.AbsolutePath }, EmptyPrintStream(), EmptyPrintStream());
            assertTrue(string.join(Environment.NewLine, Files.readAllLines(checkResult.ReportFile().toPath())), checkResult.Successful);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustDiscoverRelationshipInStoreMissingFromIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustDiscoverRelationshipInStoreMissingFromIndex()
        {
            GraphDatabaseService db = CreateDatabase();

            using (Transaction tx = Db.beginTx())
            {
                Db.execute(format(RELATIONSHIP_CREATE, "rels", array("REL"), array("prop"))).close();
                tx.Success();
            }
            StoreIndexDescriptor indexDescriptor;
            long relId;

            using (Transaction tx = Db.beginTx())
            {
                Db.schema().awaitIndexesOnline(1, TimeUnit.MINUTES);
                indexDescriptor = GetIndexDescriptor(first(Db.schema().Indexes));
                Node         node = Db.createNode();
                Relationship rel  = node.CreateRelationshipTo(node, RelationshipType.withName("REL"));
                rel.SetProperty("prop", "value");
                relId = rel.Id;
                tx.Success();
            }
            IndexingService indexes    = GetIndexingService(db);
            IndexProxy      indexProxy = indexes.GetIndexProxy(indexDescriptor.Schema());

            using (IndexUpdater updater = indexProxy.NewUpdater(IndexUpdateMode.ONLINE))
            {
                updater.Process(IndexEntryUpdate.remove(relId, indexDescriptor, Values.stringValue("value")));
            }

            Db.shutdown();

            ConsistencyCheckService.Result result = CheckConsistency();
            assertFalse(result.Successful);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleCorruptionsInFusionIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MultipleCorruptionsInFusionIndex()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE20, db =>
            {
                using (Transaction tx = Db.beginTx())
                {
                    // Also make sure we have some numbers
                    for (int i = 0; i < 1000; i++)
                    {
                        Node node = Db.createNode(_label);
                        node.setProperty(PROP_KEY1, i);
                        Node secondNode = Db.createNode(_label);
                        secondNode.setProperty(PROP_KEY1, LocalDate.ofEpochDay(i));
                    }
                    tx.success();
                }
            });

            File[] indexFiles = SchemaIndexFiles();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<java.io.File> files = corruptIndexes(true, (tree, inspection) ->
            IList <File> files = CorruptIndexes(true, (tree, inspection) =>
            {
                long leafNode     = inspection.LeafNodes.get(1);
                long internalNode = inspection.InternalNodes.get(0);
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(leafNode, GBPTreeCorruption.rightSiblingPointToNonExisting()));
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(internalNode, GBPTreeCorruption.setChild(0, internalNode)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();
            foreach (File file in files)
            {
                AssertResultContainsMessage(result, "Index file: " + file.AbsolutePath);
            }
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportNotCleanNativeIndex() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportNotCleanNativeIndex()
        {
            DatabaseLayout databaseLayout = Db.databaseLayout();

            SomeData();
            ResolveComponent(typeof(CheckPointer)).forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
            File indexesCopy  = databaseLayout.File("indexesCopy");
            File indexSources = ResolveComponent(typeof(DefaultIndexProviderMap)).DefaultProvider.directoryStructure().rootDirectory();

            copyRecursively(indexSources, indexesCopy, _sourceCopyFileFilter);

            using (Transaction tx = Db.beginTx())
            {
                CreateNewNode(new Label[] { LABEL_ONE });
                tx.Success();
            }

            Db.shutdownAndKeepStore();

            copyRecursively(indexesCopy, indexSources);

            ConsistencyCheckService.Result result = FullConsistencyCheck();
            assertFalse("Expected consistency check to fail", result.Successful);
            assertThat(ReadReport(result), hasItem(containsString("WARN : Index was not properly shutdown and rebuild is required.")));
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void assertIsConsistent(org.neo4j.consistency.ConsistencyCheckService.Result result) throws java.io.IOException
        private static void AssertIsConsistent(ConsistencyCheckService.Result result)
        {
            if (!result.Successful)
            {
                PrintReport(result);
                fail("Expected consistency check to be successful.");
            }
        }
Example #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void assertConsistentStore(org.neo4j.kernel.internal.GraphDatabaseAPI db) throws Exception
        private static void AssertConsistentStore(GraphDatabaseAPI db)
        {
            ConsistencyCheckService service = new ConsistencyCheckService();

            ConsistencyCheckService.Result result = service.RunFullConsistencyCheck(Db.databaseLayout(), Config.defaults(), ProgressMonitorFactory.textual(System.out), FormattedLogProvider.toOutputStream(System.out), true);

            assertTrue("Store is inconsistent", result.Successful);
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void assertConsistentStore(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        public static void AssertConsistentStore(DatabaseLayout databaseLayout)
        {
            Config configuration         = Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m");
            AssertableLogProvider logger = new AssertableLogProvider();

            ConsistencyCheckService.Result result = (new ConsistencyCheckService()).runFullConsistencyCheck(databaseLayout, configuration, ProgressMonitorFactory.NONE, NullLogProvider.Instance, false);

            assertTrue("Consistency check for " + databaseLayout + " found inconsistencies:\n\n" + logger.Serialize(), result.Successful);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void runTest(int nodeCount, int run, boolean multiThreaded) throws Exception
        private void RunTest(int nodeCount, int run, bool multiThreaded)
        {
            // WHEN creating the indexes under stressful updates
            PopulateDbAndIndexes(nodeCount, multiThreaded);
            ConsistencyCheckService cc = new ConsistencyCheckService();

            ConsistencyCheckService.Result result = cc.RunFullConsistencyCheck(_directory.databaseLayout(), Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m"), NONE, NullLogProvider.Instance, false);
            assertTrue(result.Successful);
            DropIndexes();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReportSuccessfulForConsistentLabelScanStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustReportSuccessfulForConsistentLabelScanStore()
        {
            // given
            SomeData();
            Db.shutdownAndKeepStore();

            // when
            ConsistencyCheckService.Result result = FullConsistencyCheck();

            // then
            assertTrue("Expected consistency check to succeed", result.Successful);
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportProgress() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReportProgress()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);

            Writer writer = new StringWriter();
            ProgressMonitorFactory factory = ProgressMonitorFactory.textual(writer);

            ConsistencyCheckService.Result result = RunConsistencyCheck(factory);

            assertTrue("Expected new database to be clean.", result.Successful);
            assertTrue(writer.ToString().Contains("Index structure consistency check"));
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pageIdExceedLastId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PageIdExceedLastId()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                tree.@unsafe(GBPTreeCorruption.decrementFreelistWritePos());
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Index has a leaked page that will never be reclaimed, pageId=");
        }
Example #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void validate() throws Exception
        protected internal override void Validate()
        {
            IEnumerable <ClusterMember> members = Iterables.concat(_cluster.coreMembers(), _cluster.readReplicas());

            foreach (ClusterMember member in members)
            {
                string databasePath = member.databaseDirectory().AbsolutePath;
                ConsistencyCheckService.Result result = runConsistencyCheckTool(new string[] { databasePath }, System.out, System.err);
                if (!result.Successful)
                {
                    throw new Exception("Not consistent database in " + databasePath);
                }
            }
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nodeMetaInconsistency() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NodeMetaInconsistency()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(inspection.RootNode, GBPTreeCorruption.decrementAllocOffsetInDynamicNode()));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "has inconsistent meta data: Meta data for tree node is inconsistent");
        }
        private void AssertDatabaseConsistent()
        {
            LogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);

            try
            {
                ConsistencyCheckService.Result result = (new ConsistencyCheckService()).runFullConsistencyCheck(_testDirectory.databaseLayout(), Config.defaults(), ProgressMonitorFactory.textual(System.err), logProvider, false);
                assertTrue(result.Successful);
            }
            catch (ConsistencyCheckIncompleteException e)
            {
                fail(e.Message);
            }
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeIndexFileInConsistencyReport() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldIncludeIndexFileInConsistencyReport()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[]       indexFiles     = SchemaIndexFiles();
            IList <File> corruptedFiles = CorruptIndexes(true, (tree, inspection) =>
            {
                long rootNode = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(rootNode, GBPTreeCorruption.notATreeNode()));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Index file: " + corruptedFiles[0].AbsolutePath);
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void childNodeFoundAmongParentNodes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ChildNodeFoundAmongParentNodes()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                long rootNode = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(rootNode, GBPTreeCorruption.setChild(0, rootNode)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Circular reference, child tree node found among parent nodes. Parents:");
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void rightmostNodeHasRightSibling() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RightmostNodeHasRightSibling()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                long root = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(root, GBPTreeCorruption.setPointer(GBPTreePointerType.rightSibling(), 10)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Expected rightmost node to have no right sibling but was 10");
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void exception() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Exception()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                long rootNode = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(rootNode, GBPTreeCorruption.setHighestReasonableKeyCount()));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Caught exception during consistency check: org.neo4j.index.internal.gbptree.TreeInconsistencyException: Some internal problem causing out of" + " bounds: pageId:");
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void keysLocatedInWrongNode() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void KeysLocatedInWrongNode()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                long internalNode = inspection.NodesPerLevel.get(1).get(0);
                int keyCount      = inspection.KeyCounts.get(internalNode);
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(internalNode, GBPTreeCorruption.swapChildOrder(0, 1, keyCount)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Expected range for this tree node is");
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unusedPage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnusedPage()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                long?internalNode = inspection.NodesPerLevel.get(1).get(0);
                int keyCount      = inspection.KeyCounts.get(internalNode);
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(internalNode, GBPTreeCorruption.setKeyCount(keyCount - 1)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Index has a leaked page that will never be reclaimed, pageId=");
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSucceedIfStoreIsConsistent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSucceedIfStoreIsConsistent()
        {
            // given
            DateTime timestamp = DateTime.Now;
            ConsistencyCheckService service = new ConsistencyCheckService(timestamp);
            Config configuration            = Config.defaults(Settings());

            // when
            ConsistencyCheckService.Result result = RunFullConsistencyCheck(service, configuration);

            // then
            assertTrue(result.Successful);
            File reportFile = result.ReportFile();

            assertFalse("Unexpected generation of consistency check report file: " + reportFile, reportFile.exists());
        }
Example #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleCorruptionsInLabelScanStore() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MultipleCorruptionsInLabelScanStore()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> rootNode = new MutableObject <long>();
            File labelScanStoreFile       = labelScanStoreFile();

            CorruptIndexes(true, (tree, inspection) =>
            {
                rootNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(rootNode.Value, GBPTreeCorruption.broken(GBPTreePointerType.leftSibling())));
            }, labelScanStoreFile);

            ConsistencyCheckService.Result result = RunConsistencyCheck();
            assertFalse(result.Successful);
            AssertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + rootNode.Value + ", pointerType='left sibling'");
            AssertResultContainsMessage(result, "Number of inconsistent LABEL_SCAN_DOCUMENT records: 1");
        }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unreasonableKeyCount() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnreasonableKeyCount()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.setKeyCount(int.MaxValue)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Unexpected keyCount on pageId " + targetNode.Value + ", keyCount=" + int.MaxValue);
        }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pageIdSeenMultipleTimes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PageIdSeenMultipleTimes()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.addFreelistEntry(targetNode.Value));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Page id seen multiple times, this means either active tree node is present in freelist or pointers in tree create a loop, pageId=" + targetNode.Value);
        }
Example #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void brokenPointer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BrokenPointer()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.broken(GBPTreePointerType.leftSibling())));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Broken pointer found in tree node " + targetNode.Value);
        }
Example #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pointerToOldVersionOfTreeNode() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PointerToOldVersionOfTreeNode()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.setPointer(GBPTreePointerType.successor(), 6)));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "We ended up on tree node " + targetNode.Value + " which has a newer generation, successor is: 6");
        }
Example #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unknownTreeNodeType() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnknownTreeNodeType()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.RootNode;
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.unknownTreeNodeType()));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Page: " + targetNode.Value + " has an unknown tree node type:");
        }
Example #28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void siblingsDontPointToEachOther() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SiblingsDontPointToEachOther()
        {
            Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10);
            MutableObject <long> targetNode = new MutableObject <long>();

            File[] indexFiles = SchemaIndexFiles();
            CorruptIndexes(true, (tree, inspection) =>
            {
                targetNode.Value = inspection.LeafNodes.get(0);
                tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.rightSiblingPointToNonExisting()));
            }, indexFiles);

            ConsistencyCheckService.Result result = RunConsistencyCheck();

            assertFalse("Expected store to be considered inconsistent.", result.Successful);
            AssertResultContainsMessage(result, "Sibling pointers misaligned.");
        }
Example #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportNotUsedRelationshipReferencedInChain() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportNotUsedRelationshipReferencedInChain()
        {
            PrepareDbWithDeletedRelationshipPartOfTheChain();

            DateTime timestamp = DateTime.Now;
            ConsistencyCheckService service = new ConsistencyCheckService(timestamp);
            Config configuration            = Config.defaults(Settings());

            ConsistencyCheckService.Result result = RunFullConsistencyCheck(service, configuration);

            assertFalse(result.Successful);

            File reportFile = result.ReportFile();

            assertTrue("Consistency check report file should be generated.", reportFile.exists());
            assertThat("Expected to see report about not deleted relationship record present as part of a chain", Files.readAllLines(reportFile.toPath()).ToString(), containsString("The relationship record is not in use, but referenced from relationships chain."));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportNotCleanLabelIndexWithCorrectData() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportNotCleanLabelIndexWithCorrectData()
        {
            DatabaseLayout databaseLayout = Db.databaseLayout();

            SomeData();
            Db.resolveDependency(typeof(CheckPointer)).forceCheckPoint(new SimpleTriggerInfo("forcedCheckpoint"));
            File labelIndexFileCopy = databaseLayout.File("label_index_copy");

            copyFile(databaseLayout.LabelScanStore(), labelIndexFileCopy);

            Db.shutdownAndKeepStore();

            copyFile(labelIndexFileCopy, databaseLayout.LabelScanStore());

            ConsistencyCheckService.Result result = FullConsistencyCheck();
            assertTrue("Expected consistency check to fail", result.Successful);
            assertThat(ReadReport(result), hasItem(containsString("WARN : Label index was not properly shutdown and rebuild is required.")));
        }