Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void consistencyCheckerLogUseSystemTimezoneIfConfigurable() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ConsistencyCheckerLogUseSystemTimezoneIfConfigurable()
        {
            TimeZone defaultTimeZone = TimeZone.Default;

            try
            {
                ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));
                Mockito.when(service.runFullConsistencyCheck(any(typeof(DatabaseLayout)), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(typeof(ConsistencyFlags)))).then(invocationOnMock =>
                {
                    LogProvider provider = invocationOnMock.getArgument(3);
                    provider.getLog("test").info("testMessage");
                    return(ConsistencyCheckService.Result.success(new File(StringUtils.EMPTY)));
                });
                File       storeDir   = _testDirectory.directory();
                File       configFile = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME);
                Properties properties = new Properties();
                properties.setProperty(GraphDatabaseSettings.db_timezone.name(), LogTimeZone.SYSTEM.name());
                properties.store(new StreamWriter(configFile), null);
                string[] args = new string[] { storeDir.Path, "-config", configFile.Path };

                CheckLogRecordTimeZone(service, args, 5, "+0500");
                CheckLogRecordTimeZone(service, args, -5, "-0500");
            }
            finally
            {
                TimeZone.Default = defaultTimeZone;
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportMissingSchemaIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReportMissingSchemaIndex()
        {
            // given
            DatabaseLayout       databaseLayout = _testDirectory.databaseLayout();
            GraphDatabaseService gds            = GetGraphDatabaseService(databaseLayout.DatabaseDirectory());

            Label  label   = Label.label("label");
            string propKey = "propKey";

            CreateIndex(gds, label, propKey);

            gds.Shutdown();

            // when
            File schemaDir = FindFile(databaseLayout, "schema");

            FileUtils.deleteRecursively(schemaDir);

            ConsistencyCheckService service = new ConsistencyCheckService();
            Config configuration            = Config.defaults(Settings());
            Result result = RunFullConsistencyCheck(service, configuration, databaseLayout);

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

            assertTrue("Consistency check report file should be generated.", reportFile.exists());
            assertThat("Expected to see report about schema index not being online", Files.readAllLines(reportFile.toPath()).ToString(), allOf(containsString("schema rule"), containsString("not online")));
        }
Esempio n. 3
0
 internal ConsistencyCheckTool(ConsistencyCheckService consistencyCheckService, FileSystemAbstraction fs, PrintStream systemOut, PrintStream systemError)
 {
     this._consistencyCheckService = consistencyCheckService;
     this._fs          = fs;
     this._systemOut   = systemOut;
     this._systemError = systemError;
 }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void oldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider()
        {
            DatabaseLayout databaseLayout        = _testDirectory.databaseLayout();
            string         defaultSchemaProvider = GraphDatabaseSettings.default_schema_provider.name();
            Label          label   = Label.label("label");
            string         propKey = "propKey";

            // Given a lucene index
            GraphDatabaseService db = GetGraphDatabaseService(databaseLayout.DatabaseDirectory(), defaultSchemaProvider, LUCENE10.providerName());

            CreateIndex(db, label, propKey);
            using (Transaction tx = Db.beginTx())
            {
                Db.createNode(label).setProperty(propKey, 1);
                Db.createNode(label).setProperty(propKey, "string");
                tx.Success();
            }
            Db.shutdown();

            ConsistencyCheckService service = new ConsistencyCheckService();
            Config configuration            = Config.defaults(Settings(defaultSchemaProvider, NATIVE20.providerName()));
            Result result = RunFullConsistencyCheck(service, configuration, databaseLayout);

            assertTrue(result.Successful);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotReportDuplicateForHugeLongValues() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotReportDuplicateForHugeLongValues()
        {
            // given
            ConsistencyCheckService service = new ConsistencyCheckService();
            Config configuration            = Config.defaults(Settings());
            GraphDatabaseService db         = (new TestGraphDatabaseFactory()).newEmbeddedDatabaseBuilder(_testDirectory.storeDir()).setConfig(GraphDatabaseSettings.record_format, RecordFormatName).setConfig("dbms.backup.enabled", "false").newGraphDatabase();

            string propertyKey = "itemId";
            Label  label       = Label.label("Item");

            using (Transaction tx = Db.beginTx())
            {
                Db.schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create();
                tx.Success();
            }
            using (Transaction tx = Db.beginTx())
            {
                set(Db.createNode(label), property(propertyKey, 973305894188596880L));
                set(Db.createNode(label), property(propertyKey, 973305894188596864L));
                tx.Success();
            }
            Db.shutdown();

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

            // then
            assertTrue(result.Successful);
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void runConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, java.io.PrintStream printStream, String... args) throws org.neo4j.consistency.ConsistencyCheckTool.ToolFailureException, java.io.IOException
        private static void RunConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, PrintStream printStream, params string[] args)
        {
            using (FileSystemAbstraction fileSystemAbstraction = new DefaultFileSystemAbstraction())
            {
                (new ConsistencyCheckTool(consistencyCheckService, fileSystemAbstraction, printStream, printStream)).Run(args);
            }
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private ConsistencyCheckService.Result runConsistencyCheck(org.neo4j.helpers.progress.ProgressMonitorFactory progressFactory, org.neo4j.kernel.configuration.Config config) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        private ConsistencyCheckService.Result RunConsistencyCheck(ProgressMonitorFactory progressFactory, Config config)
        {
            ConsistencyCheckService consistencyCheckService = new ConsistencyCheckService();
            DatabaseLayout          databaseLayout          = DatabaseLayout.of(_testDirectory.storeDir());
            LogProvider             logProvider             = NullLogProvider.Instance;

            return(consistencyCheckService.RunFullConsistencyCheck(databaseLayout, config, progressFactory, logProvider, false));
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void ableToDeleteDatabaseDirectoryAfterConsistencyCheckRun() throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AbleToDeleteDatabaseDirectoryAfterConsistencyCheckRun()
        {
            PrepareDbWithDeletedRelationshipPartOfTheChain();
            ConsistencyCheckService service = new ConsistencyCheckService();
            Result consistencyCheck         = RunFullConsistencyCheck(service, Config.defaults(Settings()));

            assertFalse(consistencyCheck.Successful);
            // using commons file utils since they do not forgive not closed file descriptors on windows
            org.apache.commons.io.FileUtils.deleteDirectory(fixture.databaseLayout().databaseDirectory());
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void checkLogRecordTimeZone(ConsistencyCheckService service, String[] args, int hoursShift, String timeZoneSuffix) throws org.neo4j.consistency.ConsistencyCheckTool.ToolFailureException, java.io.IOException
        private static void CheckLogRecordTimeZone(ConsistencyCheckService service, string[] args, int hoursShift, string timeZoneSuffix)
        {
            TimeZone.Default = TimeZone.getTimeZone(ZoneOffset.ofHours(hoursShift));
            MemoryStream outputStream = new MemoryStream();
            PrintStream  printStream  = new PrintStream(outputStream);

            RunConsistencyCheckToolWith(service, printStream, args);
            string logLine = ReadLogLine(outputStream);

            assertTrue(logLine, logLine.Contains(timeZoneSuffix));
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void passesOnCheckParameters() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void PassesOnCheckParameters()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--check-graph=false", "--check-indexes=false", "--check-index-structure=false", "--check-label-scan-store=false", "--check-property-owners=true" });

            verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), eq(new ConsistencyFlags(false, false, false, false, true)));
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void databaseAndBackupAreMutuallyExclusive() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void DatabaseAndBackupAreMutuallyExclusive()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            IncorrectUsage incorrectUsage = assertThrows(typeof(IncorrectUsage), () => checkConsistencyCommand.execute(new string[] { "--database=foo", "--backup=bar" }));

            assertEquals("Only one of '--database' and '--backup' can be specified.", incorrectUsage.Message);
        }
Esempio n. 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCanonicalizeReportDirectory() throws java.io.IOException, org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldCanonicalizeReportDirectory()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--report-dir=" + Paths.get("..", "bar") });

            verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq((new File("../bar")).CanonicalFile), any(typeof(ConsistencyFlags)));
        }
Esempio n. 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void backupNeedsToBePath()
        internal virtual void BackupNeedsToBePath()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            File backupPath = new File(homeDir.toFile(), "dir/does/not/exist");

            CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => checkConsistencyCommand.execute(new string[] { "--backup=" + backupPath }));

            assertEquals("Specified backup should be a directory: " + backupPath, commandFailed.Message);
        }
Esempio n. 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void canRunOnBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void CanRunOnBackup()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            DatabaseLayout          backupLayout            = _testDir.databaseLayout("backup");
            Path                    homeDir                 = _testDir.directory("home").toPath();
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            when(consistencyCheckService.runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--backup=" + backupLayout.DatabaseDirectory() });

            verify(consistencyCheckService).runFullConsistencyCheck(eq(backupLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(false), any(), any(typeof(ConsistencyFlags)));
        }
Esempio n. 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void runsConsistencyCheck() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void RunsConsistencyCheck()
        {
            // given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            string[] args = new string[] { databaseLayout.DatabaseDirectory().AbsolutePath };
            ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));

            // when
            RunConsistencyCheckToolWith(service, args);

            // then
            verify(service).runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), anyBoolean(), any(typeof(ConsistencyFlags)));
        }
Esempio n. 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void failsWhenInconsistenciesAreFound() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void FailsWhenInconsistenciesAreFound()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir         = _testDir.directory("home").toPath();
            File databasesFolder = GetDatabasesFolder(homeDir);
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);
            DatabaseLayout          databaseLayout          = DatabaseLayout.of(databasesFolder, "mydb");

            when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.failure(new File("/the/report/path")));

            CommandFailed commandFailed = assertThrows(typeof(CommandFailed), () => checkConsistencyCommand.execute(new string[] { "--database=mydb", "--verbose" }));

            assertThat(commandFailed.Message, containsString((new File("/the/report/path")).ToString()));
        }
Esempio n. 18
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());
        }
Esempio n. 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void enablesVerbosity() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void EnablesVerbosity()
        {
            ConsistencyCheckService consistencyCheckService = mock(typeof(ConsistencyCheckService));

            Path homeDir         = _testDir.directory("home").toPath();
            File databasesFolder = GetDatabasesFolder(homeDir);
            CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(homeDir, _testDir.directory("conf").toPath(), consistencyCheckService);

            DatabaseLayout databaseLayout = DatabaseLayout.of(databasesFolder, "mydb");

            when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)))).thenReturn(ConsistencyCheckService.Result.success(null));

            checkConsistencyCommand.Execute(new string[] { "--database=mydb", "--verbose" });

            verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(typeof(Config)), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), eq(true), any(), any(typeof(ConsistencyFlags)));
        }
Esempio n. 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AppliesDefaultTuningConfigurationForConsistencyChecker()
        {
            // given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();

            string[] args = new string[] { databaseLayout.DatabaseDirectory().AbsolutePath };
            ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));

            // when
            RunConsistencyCheckToolWith(service, args);

            // then
            ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config));

            verify(service).runFullConsistencyCheck(eq(databaseLayout), config.capture(), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), anyBoolean(), any(typeof(ConsistencyFlags)));
            assertFalse(config.Value.get(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners));
        }
Esempio n. 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailOnDatabaseInNeedOfRecovery() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailOnDatabaseInNeedOfRecovery()
        {
            NonRecoveredDatabase();
            ConsistencyCheckService service = new ConsistencyCheckService();

            try
            {
                IDictionary <string, string> settings = settings();
                Config defaults = Config.defaults(settings);
                RunFullConsistencyCheck(service, defaults);
                fail();
            }
            catch (ConsistencyCheckIncompleteException e)
            {
                assertEquals(e.InnerException.Message, Strings.joinAsLines("Active logical log detected, this might be a source of inconsistencies.", "Please recover database.", "To perform recovery please start database in single mode and perform clean shutdown."));
            }
        }
Esempio n. 22
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."));
        }
Esempio n. 23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void exitWithFailureIndicatingCorrectUsageIfNoArgumentsSupplied() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExitWithFailureIndicatingCorrectUsageIfNoArgumentsSupplied()
        {
            // given
            ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));

            string[] args = new string[] {};

            try
            {
                // when
                RunConsistencyCheckToolWith(service, args);
                fail("should have thrown exception");
            }
            catch (ConsistencyCheckTool.ToolFailureException e)
            {
                // then
                assertThat(e.Message, containsString("USAGE:"));
            }
        }
Esempio n. 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailIfTheStoreInNotConsistent() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailIfTheStoreInNotConsistent()
        {
            // given
            BreakNodeStore();
            DateTime timestamp = DateTime.Now;
            ConsistencyCheckService service = new ConsistencyCheckService(timestamp);
            string logsDir       = _testDirectory.directory().Path;
            Config configuration = Config.defaults(Settings(GraphDatabaseSettings.logs_directory.name(), logsDir));

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

            // then
            assertFalse(result.Successful);
            string reportFile = format("inconsistencies-%s.report", (new SimpleDateFormat("yyyy-MM-dd.HH.mm.ss")).format(timestamp));

            assertEquals(new File(logsDir, reportFile), result.ReportFile());
            assertTrue("Inconsistency report file not generated", result.ReportFile().exists());
        }
Esempio n. 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowGraphCheckDisabled() throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowGraphCheckDisabled()
        {
            GraphDatabaseService gds = GraphDatabaseService;

            using (Transaction tx = gds.BeginTx())
            {
                gds.CreateNode();
                tx.Success();
            }

            gds.Shutdown();

            ConsistencyCheckService service = new ConsistencyCheckService();
            Config configuration            = Config.defaults(Settings(ConsistencyCheckSettings.ConsistencyCheckGraph.name(), Settings.FALSE));

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

            // then
            assertTrue(result.Successful);
        }
Esempio n. 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void passesOnConfigurationIfProvided() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PassesOnConfigurationIfProvided()
        {
            // given
            DatabaseLayout databaseLayout = _testDirectory.databaseLayout();
            File           configFile     = _testDirectory.file(Config.DEFAULT_CONFIG_FILE_NAME);
            Properties     properties     = new Properties();

            properties.setProperty(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners.name(), "true");
            properties.store(new StreamWriter(configFile), null);

            string[] args = new string[] { databaseLayout.DatabaseDirectory().AbsolutePath, "-config", configFile.Path };
            ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));

            // when
            RunConsistencyCheckToolWith(service, args);

            // then
            ArgumentCaptor <Config> config = ArgumentCaptor.forClass(typeof(Config));

            verify(service).runFullConsistencyCheck(eq(databaseLayout), config.capture(), any(typeof(ProgressMonitorFactory)), any(typeof(LogProvider)), any(typeof(FileSystemAbstraction)), anyBoolean(), any(typeof(ConsistencyFlags)));
            assertTrue(config.Value.get(ConsistencyCheckSettings.ConsistencyCheckPropertyOwners));
        }
Esempio n. 27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void exitWithFailureIfConfigSpecifiedButConfigFileDoesNotExist() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExitWithFailureIfConfigSpecifiedButConfigFileDoesNotExist()
        {
            // given
            File configFile = _testDirectory.file("nonexistent_file");

            string[] args = new string[] { _testDirectory.directory().Path, "-config", configFile.Path };
            ConsistencyCheckService service = mock(typeof(ConsistencyCheckService));

            try
            {
                // when
                RunConsistencyCheckToolWith(service, args);
                fail("should have thrown exception");
            }
            catch (ConsistencyCheckTool.ToolFailureException e)
            {
                // then
                assertThat(e.Message, containsString("Could not read configuration file"));
                assertThat(e.InnerException.Message, containsString("does not exist"));
            }

            verifyZeroInteractions(service);
        }
Esempio n. 28
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.consistency.ConsistencyCheckService.Result runFullConsistencyCheck(ConsistencyCheckService service, org.neo4j.kernel.configuration.Config configuration, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        private static Result RunFullConsistencyCheck(ConsistencyCheckService service, Config configuration, DatabaseLayout databaseLayout)
        {
            return(service.RunFullConsistencyCheck(databaseLayout, configuration, ProgressMonitorFactory.NONE, NullLogProvider.Instance, false));
        }
Esempio n. 29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void runConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, String... args) throws org.neo4j.consistency.ConsistencyCheckTool.ToolFailureException, java.io.IOException
        private static void RunConsistencyCheckToolWith(ConsistencyCheckService consistencyCheckService, params string[] args)
        {
            RunConsistencyCheckToolWith(consistencyCheckService, mock(typeof(PrintStream)), args);
        }
Esempio n. 30
0
 public CheckConsistencyCommand(Path homeDir, Path configDir, ConsistencyCheckService consistencyCheckService)
 {
     this._homeDir   = homeDir;
     this._configDir = configDir;
     this._consistencyCheckService = consistencyCheckService;
 }