예제 #1
0
    def run(self):
        sess = self.conn.open_session()
        while not self.done.isSet():
            # Sleep for 2 seconds.
            time.sleep(2)
            sess.checkpoint()
            shutil.rmtree(self.backup_dir, ignore_errors=True)
            os.mkdir(self.backup_dir)
            cursor = sess.open_cursor('backup:', None, None)
            files = list()
            while True:
                ret = cursor.next()
                if ret != 0:
                    break
                files.append(cursor.get_key())
                shutil.copy(cursor.get_key(), self.backup_dir)

            cursor.close()

            bkp_conn = None
            try:
                bkp_conn = wiredtiger.wiredtiger_open(self.backup_dir)
                bkp_session = bkp_conn.open_session()
                # Verify that the backup was OK.
                uris = list()
                for next_file in files:
                    if next_file.startswith("WiredTiger"):
                        continue
                    uri = "file:" + next_file
                    uris.append(uri)

                # TODO: We want a self.assertTrue here - be need to be a
                # wttest to do that..
                if not compare_tables(
                        self, sess, uris, "checkpoint=WiredTigerCheckpoint"):
                    print "Error: checkpoint tables differ."
                else:
                    wttest.WiredTigerTestCase.printVerbose(
                        3, "Checkpoint tables match")

                if not compare_tables(self, bkp_session, uris):
                    print "Error: backup tables differ."
                else:
                    wttest.WiredTigerTestCase.printVerbose(
                        3, "Backup tables match")
            finally:
                if bkp_conn != None:
                    bkp_conn.close()

        sess.close()
예제 #2
0
    def run(self):
        sess = self.conn.open_session()
        while not self.done.isSet():
            # Sleep for 2 seconds.
            time.sleep(2)
            sess.checkpoint()
            shutil.rmtree(self.backup_dir, ignore_errors=True)
            os.mkdir(self.backup_dir)
            cursor = sess.open_cursor('backup:', None, None)
            files = list()
            while True:
                ret = cursor.next()
                if ret != 0:
                    break
                files.append(cursor.get_key())
                shutil.copy(cursor.get_key(), self.backup_dir)

            cursor.close()

            bkp_conn = None
            try:
                bkp_conn = wiredtiger.wiredtiger_open(self.backup_dir)
                bkp_session = bkp_conn.open_session()
                # Verify that the backup was OK.
                uris = list()
                for next_file in files:
                    if next_file.startswith("WiredTiger"):
                        continue
                    uri = "file:" + next_file
                    uris.append(uri)

                # TODO: We want a self.assertTrue here - be need to be a
                # wttest to do that..
                if not compare_tables(
                        self, sess, uris, "checkpoint=WiredTigerCheckpoint"):
                    print("Error: checkpoint tables differ.")
                else:
                    wttest.WiredTigerTestCase.printVerbose(
                        3, "Checkpoint tables match")

                if not compare_tables(self, bkp_session, uris):
                    print("Error: backup tables differ.")
                else:
                    wttest.WiredTigerTestCase.printVerbose(
                        3, "Backup tables match")
            finally:
                if bkp_conn != None:
                    bkp_conn.close()

        sess.close()
예제 #3
0
파일: wtthread.py 프로젝트: Malterlib/mongo
    def run(self):
        sess = self.conn.open_session()
        while not self.done.isSet():
            # Sleep for 2 seconds.
            time.sleep(2)
            sess.checkpoint()
            shutil.rmtree(self.backup_dir, ignore_errors=True)
            os.mkdir(self.backup_dir)
            cursor = sess.open_cursor('backup:', None, None)
            files = list()
            while True:
                ret = cursor.next()
                if ret != 0:
                    break
                files.append(cursor.get_key())
                shutil.copy(cursor.get_key(), self.backup_dir)

            cursor.close()

            bkp_conn = None
            try:
                bkp_conn = wiredtiger.wiredtiger_open(self.backup_dir)
                bkp_session = bkp_conn.open_session()
                # Verify that the backup was OK.
                uris = list()
                for next_file in files:
                    if next_file.startswith("WiredTiger"):
                        continue
                    uri = "file:" + next_file
                    uris.append(uri)

                # Add an assert to stop running the test if any difference in table contents
                # is found. We would have liked to use self.assertTrue instead, but are unable
                # to because backup_thread does not support this method unless it is a wttest.
                wttest.WiredTigerTestCase.printVerbose(
                    3, "Testing if checkpoint tables match:")
                assert compare_tables(self, sess, uris) == True
                wttest.WiredTigerTestCase.printVerbose(
                    3, "Checkpoint tables match")

                wttest.WiredTigerTestCase.printVerbose(
                    3, "Testing if backup tables match:")
                assert compare_tables(self, bkp_session, uris) == True
                wttest.WiredTigerTestCase.printVerbose(3,
                                                       "Backup tables match")
            finally:
                if bkp_conn != None:
                    bkp_conn.close()

        sess.close()