Search in sources :

Example 6 with ExecutionContext

use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.

the class CheckConsistencyCommandIT method shouldWriteReportFileToSpecifiedDirectory.

@Test
void shouldWriteReportFileToSpecifiedDirectory() throws IOException, ConsistencyCheckIncompleteException, CommandFailedException {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--report-dir=some-dir-or-other");
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("some-dir-or-other")), any(ConsistencyFlags.class));
}
Also used : ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 7 with ExecutionContext

use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.

the class CheckConsistencyCommandIT method warnsOnUseOfDeprecatedOptions.

@Test
void warnsOnUseOfDeprecatedOptions() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(baos);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath, out, System.err, new DefaultFileSystemAbstraction()), consistencyCheckService);
    DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
    when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--check-label-scan-store=true", "--check-relationship-type-scan-store=true", "--check-property-owners=true");
    checkConsistencyCommand.execute();
    // See that warnings were printed and that command was still run.
    String log = baos.toString();
    assertThat(log).contains("Option '--check-label-scan-store' has been deprecated and its value will be ignored");
    assertThat(log).contains("Option '--check-relationship-type-scan-store' has been deprecated and its value will be ignored");
    assertThat(log).contains("Option '--check-property-owners' has been deprecated and its value will be ignored");
    verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(false), any(), any(ConsistencyFlags.class));
}
Also used : PrintStream(java.io.PrintStream) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.internal.helpers.progress.ProgressMonitorFactory) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) Config(org.neo4j.configuration.Config) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LogProvider(org.neo4j.logging.LogProvider) ExecutionContext(org.neo4j.cli.ExecutionContext) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 8 with ExecutionContext

use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.

the class CheckConsistencyCommandIT method shouldWriteReportFileToCurrentDirectoryByDefault.

@Test
void shouldWriteReportFileToCurrentDirectoryByDefault() throws IOException, ConsistencyCheckIncompleteException, CommandFailedException {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb");
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("")), any(ConsistencyFlags.class));
}
Also used : ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 9 with ExecutionContext

use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.

the class CheckConsistencyCommandIT method shouldCanonicalizeReportDirectory.

@Test
void shouldCanonicalizeReportDirectory() throws IOException, ConsistencyCheckIncompleteException, CommandFailedException {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--report-dir=" + Paths.get("..", "bar"));
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), eq(Path.of("../bar")), any(ConsistencyFlags.class));
}
Also used : ExecutionContext(org.neo4j.cli.ExecutionContext) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Example 10 with ExecutionContext

use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.

the class CheckConsistencyCommandIT method enablesVerbosity.

@Test
void enablesVerbosity() throws Exception {
    ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
    CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
    DatabaseLayout databaseLayout = neo4jLayout.databaseLayout("mydb");
    when(consistencyCheckService.runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
    CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--verbose");
    checkConsistencyCommand.execute();
    verify(consistencyCheckService).runFullConsistencyCheck(eq(databaseLayout), any(Config.class), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), eq(true), any(), any(ConsistencyFlags.class));
}
Also used : LogProvider(org.neo4j.logging.LogProvider) ExecutionContext(org.neo4j.cli.ExecutionContext) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.internal.helpers.progress.ProgressMonitorFactory) ConsistencyFlags(org.neo4j.consistency.checking.full.ConsistencyFlags) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) CheckConsistencyCommand(org.neo4j.consistency.CheckConsistencyCommand) Test(org.junit.jupiter.api.Test)

Aggregations

ExecutionContext (org.neo4j.cli.ExecutionContext)38 Test (org.junit.jupiter.api.Test)30 PrintStream (java.io.PrintStream)21 CheckConsistencyCommand (org.neo4j.consistency.CheckConsistencyCommand)13 Path (java.nio.file.Path)12 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 ConsistencyFlags (org.neo4j.consistency.checking.full.ConsistencyFlags)10 Config (org.neo4j.configuration.Config)8 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)8 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)6 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 ProgressMonitorFactory (org.neo4j.internal.helpers.progress.ProgressMonitorFactory)5 LogProvider (org.neo4j.logging.LogProvider)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 CommandFailedException (org.neo4j.cli.CommandFailedException)4 MemoryRecommendationsCommand.bytesToString (org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString)4 FileSystem (java.nio.file.FileSystem)2 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)1 WireMock.matchingJsonPath (com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath)1