Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failureDuringMoveCausesAbsoluteFailure() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailureDuringMoveCausesAbsoluteFailure()
        {
            // given moves fail
            doThrow(typeof(IOException)).when(_backupCopyService).moveBackupLocation(any(), any());

            // and fallback to full
            _requiredArguments   = _requiredArguments(true);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // and backup exists
            when(_backupCopyService.backupExists(any())).thenReturn(true);

            // and incremental fails
            when(_backupStrategyImplementation.performIncrementalBackup(any(), any(), any())).thenReturn(new Fallible <>(BackupStageOutcome.Failure, null));

            // and full passes
            when(_backupStrategyImplementation.performFullBackup(any(), any(), any())).thenReturn(new Fallible <>(BackupStageOutcome.Success, null));

            // when
            Fallible <BackupStrategyOutcome> state = _subject.doBackup(_onlineBackupContext);

            // then result was catastrophic and contained reason
            assertEquals(BackupStrategyOutcome.AbsoluteFailure, state.State);
            assertEquals(typeof(IOException), state.Cause.get().GetType());

            // and full backup was definitely performed
            verify(_backupStrategyImplementation).performFullBackup(any(), any(), any());
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInterpretAUnitlessTimeoutAsSeconds() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInterpretAUnitlessTimeoutAsSeconds()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext("--timeout=10", "--backup-dir=/", "--name=mybackup");
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(SECONDS.toMillis(10), requiredArguments.Timeout);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDefaultTimeoutToTwentyMinutes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDefaultTimeoutToTwentyMinutes()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext("--backup-dir=/", "--name=mybackup");
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(MINUTES.toMillis(20), requiredArguments.Timeout);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseATimeoutWithUnits() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseATimeoutWithUnits()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--timeout=10h"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(HOURS.toMillis(10), requiredArguments.Timeout);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acceptBothIfSpecified() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcceptBothIfSpecified()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=foo.bar.server:1234"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("foo.bar.server", requiredArguments.Address.Hostname.get());
            assertEquals(1234, requiredArguments.Address.Port.Value.intValue());
        }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acceptHostWithTrailingPort() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcceptHostWithTrailingPort()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=foo.bar.server:"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("foo.bar.server", requiredArguments.Address.Hostname.get());
            assertFalse(requiredArguments.Address.Port.HasValue);
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRespectPageCacheConfigFromCommandLineArguments() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustRespectPageCacheConfigFromCommandLineArguments()
        {
            // when
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext(RequiredAnd("--pagecache=42m"));

            // then
            assertThat(context.Config.get(pagecache_memory), @is("42m"));
        }
Example #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unspecifiedPortIsEmptyOptional() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnspecifiedPortIsEmptyOptional()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=abc"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("abc", requiredArguments.Address.Hostname.get());
            assertFalse(requiredArguments.Address.Port.HasValue);
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unspecifiedHostnameIsEmptyOptional() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnspecifiedHostnameIsEmptyOptional()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=:1234"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertFalse(requiredArguments.Address.Hostname.Present);
            assertEquals(1234, requiredArguments.Address.Port.Value.intValue());
        }
Example #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void defaultProtocolIsAny() throws org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DefaultProtocolIsAny()
        {
            // given
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);

            // when context resolved without proto override value
            OnlineBackupContext context = builder.CreateContext(RequiredAnd());

            // then
            assertEquals(ANY, context.RequiredArguments.SelectedBackupProtocol);
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void ipv6CanBeProcessed() throws org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Ipv6CanBeProcessed()
        {
            // given
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);

            // when
            OnlineBackupContext context = builder.CreateContext(RequiredAnd("--from=[fd00:ce10::2]:6362"));

            // then
            assertEquals("fd00:ce10::2", context.RequiredArguments.Address.Hostname.get());
            assertEquals(Convert.ToInt32(6362), context.RequiredArguments.Address.Port.Value);
        }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void successfulBackupsAreRecovered()
        public virtual void SuccessfulBackupsAreRecovered()
        {
            // given
            FallbackToFullPasses();
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupRecoveryService).recoverWithDatabase(any(), any(), any());
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unsuccessfulBackupsAreNotRecovered()
        public virtual void UnsuccessfulBackupsAreNotRecovered()
        {
            // given
            BothBackupsFail();
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupRecoveryService, never()).recoverWithDatabase(any(), any(), any());
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void performingFullBackupInvokesRecovery()
        public virtual void PerformingFullBackupInvokesRecovery()
        {
            // given full backup flag is set
            _requiredArguments   = _requiredArguments(true);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupRecoveryService).recoverWithDatabase(any(), any(), any());
        }
Example #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustIgnorePageCacheConfigInConfigFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustIgnorePageCacheConfigInConfigFile()
        {
            // given
            Files.write(_configFile, singletonList(pagecache_memory.name() + "=42m"));

            // when
            OnlineBackupContextFactory contextBuilder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context        = contextBuilder.CreateContext(RequiredAnd());

            // then
            assertThat(context.Config.get(pagecache_memory), @is("8m"));
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void logsMustBePlacedInTargetBackupDirectory() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LogsMustBePlacedInTargetBackupDirectory()
        {
            // when
            string name       = "mybackup";
            Path   backupDir  = _homeDir.resolve("poke");
            Path   backupPath = backupDir.resolve(name);

            Files.createDirectories(backupDir);
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext("--backup-dir=" + backupDir, "--name=" + name);

            assertThat(context.Config.get(logical_logs_location).AbsolutePath, @is(backupPath.ToString()));
        }
Example #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void lifecycleIsRun() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LifecycleIsRun()
        {
            // given
            _onlineBackupContext = new OnlineBackupContext(RequiredArguments(true), _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupStrategyImplementation).init();
            verify(_backupStrategyImplementation).start();
            verify(_backupStrategyImplementation).stop();
            verify(_backupStrategyImplementation).shutdown();
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustIgnorePageCacheConfigInAdditionalConfigFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustIgnorePageCacheConfigInAdditionalConfigFile()
        {
            // given
            Path additionalConf = _homeDir.resolve("additional-neo4j.conf");

            Files.write(additionalConf, singletonList(pagecache_memory.name() + "=42m"));

            // when
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext(RequiredAnd("--additional-config=" + additionalConf));

            // then
            assertThat(context.Config.get(pagecache_memory), @is("8m"));
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fullBackupIsPerformedWhenNoOtherBackupExists()
        public virtual void FullBackupIsPerformedWhenNoOtherBackupExists()
        {
            // given
            _requiredArguments   = _requiredArguments(true);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // and
            when(_backupCopyService.backupExists(any())).thenReturn(false);

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupStrategyImplementation).performFullBackup(any(), any(), any());
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _backupDirectory = TestDirectory.directory("backupDirectory").toPath();
            _reportDirectory = TestDirectory.directory("reportDirectory/").toPath();
            BackupSupportingClasses backupSupportingClasses = new BackupSupportingClasses(mock(typeof(BackupDelegator)), mock(typeof(BackupProtocolService)), mock(typeof(PageCache)), Collections.emptyList());

            when(_backupSupportingClassesFactory.createSupportingClasses(any())).thenReturn(backupSupportingClasses);

            _requiredArguments = new OnlineBackupRequiredArguments(_address, _backupDirectory, _backupName, SelectedBackupProtocol.Any, _fallbackToFull, _doConsistencyCheck, _timeout, _reportDirectory);
            OnlineBackupContext onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, _consistencyFlags);

            when(_backupStrategyCoordinatorFactory.backupStrategyCoordinator(any(), any(), any(), any())).thenReturn(_backupStrategyCoordinator);

            _subject = NewOnlineBackupCommand(_outsideWorld, onlineBackupContext, _backupSupportingClassesFactory, _backupStrategyCoordinatorFactory);
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void successfulFullBackupsAreRecoveredEvenIfNoBackupExisted()
        public virtual void SuccessfulFullBackupsAreRecoveredEvenIfNoBackupExisted()
        {
            // given a backup exists
            when(_backupCopyService.backupExists(_desiredBackupLayout)).thenReturn(false);
            when(_backupCopyService.findAnAvailableLocationForNewFullBackup(_desiredBackupLayout.databaseDirectory().toPath())).thenReturn(_desiredBackupLayout.databaseDirectory().toPath());

            // and
            FallbackToFullPasses();
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupRecoveryService).recoverWithDatabase(any(), any(), any());
        }
Example #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fallbackDoesNotHappenIfNotSpecified()
        public virtual void FallbackDoesNotHappenIfNotSpecified()
        {
            // given
            when(_backupCopyService.backupExists(any())).thenReturn(true);
            when(_backupStrategyImplementation.performIncrementalBackup(any(), any(), any())).thenReturn(new Fallible <>(BackupStageOutcome.Failure, null));

            // and
            _requiredArguments   = _requiredArguments(false);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupStrategyImplementation, never()).performFullBackup(any(), any(), any());
        }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failedIncrementalFallsBackToFullWhenOptionSet()
        public virtual void FailedIncrementalFallsBackToFullWhenOptionSet()
        {
            // given conditions for incremental exist
            when(_backupCopyService.backupExists(any())).thenReturn(true);
            _requiredArguments   = _requiredArguments(true);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // and incremental fails
            when(_backupStrategyImplementation.performIncrementalBackup(any(), any(), any())).thenReturn(new Fallible <>(BackupStageOutcome.Failure, null));

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupStrategyImplementation).performFullBackup(any(), any(), any());
        }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void performingIncrementalBackupInvokesRecovery()
        public virtual void PerformingIncrementalBackupInvokesRecovery()
        {
            // given backup exists
            when(_backupCopyService.backupExists(any())).thenReturn(true);
            _requiredArguments   = _requiredArguments(true);
            _onlineBackupContext = new OnlineBackupContext(_requiredArguments, _config, ConsistencyFlags());

            // and incremental backups are successful
            when(_backupStrategyImplementation.performIncrementalBackup(any(), any(), any())).thenReturn(_success);

            // when
            _subject.doBackup(_onlineBackupContext);

            // then
            verify(_backupRecoveryService).recoverWithDatabase(any(), any(), any());
        }