示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupIndexWithNoCommits()
        public virtual void BackupIndexWithNoCommits()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = null;

            try
            {
                db = GetEmbeddedTestDataBaseService(backupPort);

                using (Transaction transaction = Db.beginTx())
                {
                    Db.index().forNodes("created-no-commits");
                    transaction.Success();
                }

                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                assertTrue(backup.Consistent);
            }
            finally
            {
                if (db != null)
                {
                    Db.shutdown();
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backupDatabaseWithCustomTransactionLogsLocation() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackupDatabaseWithCustomTransactionLogsLocation()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(_serverStorePath, true, backupPort, "customLogLocation");

            try
            {
                CreateInitialDataSet(db);

                OnlineBackup backup      = OnlineBackup.From("127.0.0.1", backupPort);
                string       backupStore = _backupDatabasePath.Path;
                LogFiles     logFiles    = LogFilesBuilder.logFilesBasedOnlyBuilder(new File(backupStore), _fileSystemRule.get()).build();

                backup.Full(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                DbRepresentation representation = AddLotsOfData(db);
                backup.Incremental(backupStore);
                assertThat(logFiles.LogFilesConflict(), Matchers.arrayWithSize(1));

                assertEquals(representation, DbRepresentation);
            }
            finally
            {
                Db.shutdown();
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void multipleIncrementals() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MultipleIncrementals()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = null;

            try
            {
                db = GetEmbeddedTestDataBaseService(backupPort);

                Index <Node> index;
                using (Transaction tx = Db.beginTx())
                {
                    index = Db.index().forNodes("yo");
                    index.Add(Db.createNode(), "justTo", "commitATx");
                    Db.createNode();
                    tx.Success();
                }

                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                PageCache pageCache       = _pageCacheRule.getPageCache(_fileSystemRule.get());
                long      lastCommittedTx = GetLastCommittedTx(_backupDatabaseLayout, pageCache);

                for (int i = 0; i < 5; i++)
                {
                    using (Transaction tx = Db.beginTx())
                    {
                        Node node = Db.createNode();
                        index.Add(node, "key", "value" + i);
                        tx.Success();
                    }
                    backup = backup.incremental(_backupDatabasePath.Path);
                    assertTrue("Should be consistent", backup.Consistent);
                    assertEquals(lastCommittedTx + i + 1, GetLastCommittedTx(_backupDatabaseLayout, pageCache));
                }
            }
            finally
            {
                if (db != null)
                {
                    Db.shutdown();
                }
            }
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureStoreIdIsEnforced()
        public virtual void MakeSureStoreIdIsEnforced()
        {
            // Create data set X on server A
            DbRepresentation initialDataSetRepresentation = CreateInitialDataSet(_serverStorePath);
            int             backupPort = PortAuthority.allocatePort();
            ServerInterface server     = StartServer(_serverStorePath, backupPort);

            // Grab initial backup from server A
            OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);

            backup.Full(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertEquals(initialDataSetRepresentation, DbRepresentation);
            ShutdownServer(server);

            // Create data set X+Y on server B
            CreateInitialDataSet(_otherServerPath);
            AddMoreData(_otherServerPath);
            server = StartServer(_otherServerPath, backupPort);

            // Try to grab incremental backup from server B.
            // Data should be OK, but store id check should prevent that.
            try
            {
                backup.incremental(_backupDatabasePath.Path);
                fail("Shouldn't work");
            }
            catch (Exception e)
            {
                assertThat(rootCause(e), instanceOf(typeof(MismatchingStoreIdException)));
            }
            ShutdownServer(server);
            // Just make sure incremental backup can be received properly from
            // server A, even after a failed attempt from server B
            DbRepresentation furtherRepresentation = AddMoreData(_serverStorePath);

            server = StartServer(_serverStorePath, backupPort);
            backup.incremental(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertEquals(furtherRepresentation, DbRepresentation);
            ShutdownServer(server);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureFullFailsWhenDbExists()
        public virtual void MakeSureFullFailsWhenDbExists()
        {
            int backupPort = PortAuthority.allocatePort();

            CreateInitialDataSet(_serverStorePath);
            ServerInterface server = StartServer(_serverStorePath, backupPort);
            OnlineBackup    backup = OnlineBackup.From("127.0.0.1", backupPort);

            CreateInitialDataSet(_backupDatabasePath);
            try
            {
                backup.Full(_backupDatabasePath.Path);
                fail("Shouldn't be able to do full backup into existing db");
            }
            catch (Exception)
            {
                // good
            }
            ShutdownServer(server);
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDoIncrementalBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDoIncrementalBackup()
        {
            DbRepresentation initialDataSetRepresentation = CreateInitialDataSet(_serverPath);
            int port = PortAuthority.allocatePort();

            _server = StartServer(_serverPath, "127.0.0.1:" + port);

            OnlineBackup backup = OnlineBackup.From("127.0.0.1", port);

            backup.Full(_backupDatabase.Path);

            assertEquals(initialDataSetRepresentation, BackupDbRepresentation);
            ShutdownServer(_server);

            DbRepresentation furtherRepresentation = AddMoreData2(_serverPath);

            _server = StartServer(_serverPath, "127.0.0.1:" + port);
            backup.incremental(_backupDatabase.Path);
            assertEquals(furtherRepresentation, BackupDbRepresentation);
            ShutdownServer(_server);
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncrementallyBackupDenseNodes()
        public virtual void ShouldIncrementallyBackupDenseNodes()
        {
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(_serverStorePath, true, backupPort);

            try
            {
                CreateInitialDataSet(db);

                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);

                DbRepresentation representation = AddLotsOfData(db);
                backup.incremental(_backupDatabasePath.Path);
                assertEquals(representation, DbRepresentation);
            }
            finally
            {
                Db.shutdown();
            }
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fullThenIncremental()
        public virtual void FullThenIncremental()
        {
            DbRepresentation initialDataSetRepresentation = CreateInitialDataSet(_serverStorePath);
            int             backupPort = PortAuthority.allocatePort();
            ServerInterface server     = StartServer(_serverStorePath, backupPort);

            OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);

            backup.Full(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertEquals(initialDataSetRepresentation, DbRepresentation);
            ShutdownServer(server);

            DbRepresentation furtherRepresentation = AddMoreData(_serverStorePath);

            server = StartServer(_serverStorePath, backupPort);
            backup.incremental(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertEquals(furtherRepresentation, DbRepresentation);
            ShutdownServer(server);
        }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotServeTransactionsWithInvalidHighIds() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotServeTransactionsWithInvalidHighIds()
        {
            /*
             * This is in effect a high level test for an edge case that happens when a relationship group is
             * created and deleted in the same tx. This can end up causing an IllegalArgumentException because
             * the HighIdApplier used when applying incremental updates (batch transactions in general) will postpone
             * processing of added/altered record ids but deleted ids will be processed on application. This can result
             * in a deleted record causing an IllegalArgumentException even though it is not the highest id in the tx.
             *
             * The way we try to trigger this is:
             * 0. In one tx, create a node with 49 relationships, belonging to two types.
             * 1. In another tx, create another relationship on that node (making it dense) and then delete all
             *    relationships of one type. This results in the tx state having a relationship group record that was
             *    created in this tx and also set to not in use.
             * 2. Receipt of this tx will have the offending rel group command apply its id before the groups that are
             *    altered. This will try to update the high id with a value larger than what has been seen previously and
             *    fail the update.
             * The situation is resolved by a check added in TransactionRecordState which skips the creation of such
             * commands.
             * Note that this problem can also happen in HA slaves.
             */
            DbRepresentation initialDataSetRepresentation = CreateInitialDataSet(_serverPath);
            int port = PortAuthority.allocatePort();

            _server = StartServer(_serverPath, "127.0.0.1:" + port);

            OnlineBackup backup = OnlineBackup.From("127.0.0.1", port);

            backup.Full(_backupDatabase.Path);

            assertEquals(initialDataSetRepresentation, BackupDbRepresentation);
            ShutdownServer(_server);

            DbRepresentation furtherRepresentation = CreateTransactionWithWeirdRelationshipGroupRecord(_serverPath);

            _server = StartServer(_serverPath, "127.0.0.1:" + port);
            backup.incremental(_backupDatabase.Path);
            assertEquals(furtherRepresentation, BackupDbRepresentation);
            ShutdownServer(_server);
        }
示例#10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void backedUpDatabaseContainsChecksumOfLastTx() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BackedUpDatabaseContainsChecksumOfLastTx()
        {
            ServerInterface server = null;

            try
            {
                CreateInitialDataSet(_serverStorePath);
                int backupPort = PortAuthority.allocatePort();
                server = StartServer(_serverStorePath, backupPort);
                OnlineBackup backup = OnlineBackup.From("127.0.0.1", backupPort);
                backup.Full(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                ShutdownServer(server);
                server = null;
                PageCache pageCache = _pageCacheRule.getPageCache(_fileSystemRule.get());

                long firstChecksum = LastTxChecksumOf(_serverStoreLayout, pageCache);
                assertEquals(firstChecksum, LastTxChecksumOf(_backupDatabaseLayout, pageCache));

                AddMoreData(_serverStorePath);
                server = StartServer(_serverStorePath, backupPort);
                backup.incremental(_backupDatabasePath.Path);
                assertTrue("Should be consistent", backup.Consistent);
                ShutdownServer(server);
                server = null;

                long secondChecksum = LastTxChecksumOf(_serverStoreLayout, pageCache);
                assertEquals(secondChecksum, LastTxChecksumOf(_backupDatabaseLayout, pageCache));
                assertTrue(firstChecksum != secondChecksum);
            }
            finally
            {
                if (server != null)
                {
                    ShutdownServer(server);
                }
            }
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void makeSureNoLogFileRemains()
        public virtual void MakeSureNoLogFileRemains()
        {
            CreateInitialDataSet(_serverStorePath);
            int             backupPort = PortAuthority.allocatePort();
            ServerInterface server     = StartServer(_serverStorePath, backupPort);
            OnlineBackup    backup     = OnlineBackup.From("127.0.0.1", backupPort);

            // First check full
            backup.Full(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertFalse(CheckLogFileExistence(_backupDatabasePath.Path));
            // Then check empty incremental
            backup.incremental(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertFalse(CheckLogFileExistence(_backupDatabasePath.Path));
            // Then check real incremental
            ShutdownServer(server);
            AddMoreData(_serverStorePath);
            server = StartServer(_serverStorePath, backupPort);
            backup.incremental(_backupDatabasePath.Path);
            assertTrue("Should be consistent", backup.Consistent);
            assertFalse(CheckLogFileExistence(_backupDatabasePath.Path));
            ShutdownServer(server);
        }