Exemple #1
0
 def test_exclusive_create(self):
     self.conn = wiredtiger.wiredtiger_open('.', 'create,exclusive')
     self.conn.close()
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open('.', 'exclusive'),
         '/WiredTiger database already exists/')
Exemple #2
0
 def test_multi_create(self):
     self.conn = wiredtiger.wiredtiger_open('.', 'create')
     self.session = self.conn.open_session(None)
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open('.', 'create'),
         '/WiredTiger database is already being managed/')
    def test_multi_create(self):
        self.conn = wiredtiger.wiredtiger_open('.', 'create')
        self.session = self.conn.open_session(None)
        self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
            lambda: wiredtiger.wiredtiger_open('.', 'create'),
            '/WiredTiger database is already being managed by another thread\
 in this process/')
Exemple #4
0
 def test_exclusive_create(self):
     self.conn = wiredtiger.wiredtiger_open(".", "create,exclusive")
     self.conn.close()
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(".", "exclusive"),
         "/WiredTiger database already exists/",
     )
Exemple #5
0
 def test_multi_create(self):
     self.conn = wiredtiger.wiredtiger_open(".", "create")
     self.session = self.conn.open_session(None)
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(".", "create"),
         "/WiredTiger database is already being managed/",
     )
Exemple #6
0
    def setUpConnectionOpen(self, dir):
        args = ''
        # add names to args, e.g. args += ',session_max=30'
        for var in self.config_vars:
            value = getattr(self, 's_' + var)
            if value != None:
                if var == 'verbose':
                    value = '[' + str(value) + ']'
                if value == True:
                    value = 'true'
                if value == False:
                    value = 'false'
                args += ',' + var + '=' + str(value)
        args += ','
        self.pr('wiredtiger_open with args: ' + args)

        expect_fail = False
        successargs = args
        if self.s_create == False:
            successargs = successargs.replace(',create=false,', ',create,')
            expect_fail = True
            fail_msg = '/(No such file or directory|The system cannot find the file specified)/'
        elif self.s_create == None:
            successargs = successargs + 'create=true,'
            expect_fail = True
            fail_msg = '/(No such file or directory|The system cannot find the file specified)/'

        if self.s_eviction_target >= self.s_eviction_trigger:
            # construct args that guarantee that target < trigger
            # we know that trigger >= 1
            repfrom = ',eviction_target=' + str(self.s_eviction_target)
            repto = ',eviction_target=' + str(self.s_eviction_trigger - 1)
            successargs = successargs.replace(repfrom, repto)
            if not expect_fail:
                expect_fail = True
                fail_msg = \
                    '/eviction target must be lower than the eviction trigger/'

        if expect_fail:
            self.verbose(3, 'wiredtiger_open (should fail) with args: ' + args)
            self.assertRaisesWithMessage(
                wiredtiger.WiredTigerError,
                lambda: wiredtiger.wiredtiger_open(dir, args), fail_msg)
            args = successargs

        self.verbose(3, 'wiredtiger_open with args: ' + args)
        conn = wiredtiger.wiredtiger_open(dir, args)
        self.pr( ` conn `)
        return conn
Exemple #7
0
    def setUpConnectionOpen(self, dir):
        args = ''
        # add names to args, e.g. args += ',session_max=30'
        for var in self.config_vars:
            value = getattr(self, 's_' + var)
            if value != None:
                if var == 'verbose':
                    value = '[' + str(value) + ']'
                if value == True:
                    value = 'true'
                if value == False:
                    value = 'false'
                args += ',' + var + '=' + str(value)
        args += ','
        self.pr('wiredtiger_open with args: ' + args)

        expect_fail = False
        successargs = args
        if self.s_create == False:
            successargs = successargs.replace(',create=false,',',create,')
            expect_fail = True
            fail_msg = '/(No such file or directory|The system cannot find the file specified)/'
        elif self.s_create == None:
            successargs = successargs + 'create=true,'
            expect_fail = True
            fail_msg = '/(No such file or directory|The system cannot find the file specified)/'

        if self.s_eviction_target >= self.s_eviction_trigger:
            # construct args that guarantee that target < trigger
            # we know that trigger >= 1
            repfrom = ',eviction_target=' + str(self.s_eviction_target)
            repto = ',eviction_target=' + str(self.s_eviction_trigger - 1)
            successargs = successargs.replace(repfrom, repto)
            if not expect_fail:
                expect_fail = True
                fail_msg = \
                    '/eviction target must be lower than the eviction trigger/'

        if expect_fail:
            self.verbose(3, 'wiredtiger_open (should fail) with args: ' + args)
            self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
                lambda: wiredtiger.wiredtiger_open(dir, args), fail_msg)
            args = successargs

        self.verbose(3, 'wiredtiger_open with args: ' + args)
        conn = wiredtiger.wiredtiger_open(dir, args)
        self.pr(`conn`)
        return conn
Exemple #8
0
 def test_home_does_not_exist(self):
     dir = 'nondir'
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, 'create'),
         '/(No such file or directory|The system cannot find the path specified)/'
     )
Exemple #9
0
 def test_home_does_not_exist(self):
     dir = "nondir"
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, "create"),
         "wiredtiger_open: WiredTiger: No such file or directory\n",
     )
Exemple #10
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     # Cycle through the different transaction_sync values in a
     # deterministic manner.
     self.txn_sync = self.sync_list[self.scenario_number %
                                    len(self.sync_list)]
     #
     # We don't want to run zero fill with only the same settings, such
     # as archive or sync, which are an even number of options.
     #
     freq = 3
     zerofill = 'false'
     if self.scenario_number % freq == 0:
         zerofill = 'true'
     self.backup_dir = os.path.join(self.home, "WT_BACKUP")
     conn_params = \
             'log=(archive=false,enabled,file_max=%s),' % self.logmax + \
             'log=(zero_fill=%s),' % zerofill + \
             'create,error_prefix="%s: ",' % self.shortid() + \
             'transaction_sync="%s",' % self.txn_sync
     # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
     conn = wiredtiger_open(dir, conn_params)
     self.pr( ` conn `)
     self.session2 = conn.open_session()
     return conn
Exemple #11
0
 def test_cache_too_large(self):
     T11 = 11 * self.T  # 11 Terabytes
     configstr = 'create,cache_size=' + str(T11)
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open('.', configstr),
         "/Value too large for key 'cache_size' the maximum is/")
Exemple #12
0
 def setUpConnectionOpen(self, dir):
     wtopen_args = \
         'create,cache_size=1G,log=(archive=false,enabled,file_max=%s)' % \
         self.logmax
     conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
     self.pr(`conn`)
     return conn
Exemple #13
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     # Cycle through the different transaction_sync values in a
     # deterministic manner.
     self.txn_sync = self.sync_list[
         self.scenario_number % len(self.sync_list)]
     #
     # We don't want to run zero fill with only the same settings, such
     # as archive or sync, which are an even number of options.
     #
     freq = 3
     zerofill = 'false'
     if self.scenario_number % freq == 0:
         zerofill = 'true'
     self.backup_dir = os.path.join(self.home, "WT_BACKUP")
     conn_params = \
             'log=(archive=false,enabled,file_max=%s),' % self.logmax + \
             'log=(zero_fill=%s),' % zerofill + \
             'create,error_prefix="%s: ",' % self.shortid() + \
             'transaction_sync="%s",' % self.txn_sync
     # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
     conn = wiredtiger_open(dir, conn_params)
     self.pr(`conn`)
     self.session2 = conn.open_session()
     return conn
Exemple #14
0
 def test_too_many_sessions(self):
     self.conn = wiredtiger.wiredtiger_open(".", "create,session_max=1")
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: [self.conn.open_session(None) for i in range(100)],
         "/configured to support/",
     )
Exemple #15
0
 def setUpConnectionOpen(self, dir):
     extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')])
     connarg = 'create,error_prefix="{0}: ",{1}'.format(
         self.shortid(), extarg)
     conn = wiredtiger.wiredtiger_open(dir, connarg)
     self.pr( ` conn `)
     return conn
Exemple #16
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     conn_params = 'create,cache_size=10MB,' \
                   'hazard_max=' + str(self.ntables / 2)
     conn = wiredtiger.wiredtiger_open(dir, conn_params)
     self.pr(`conn`)
     return conn
Exemple #17
0
 def setUpConnectionOpen(self, dir):
     wtopen_args = 'create'
     if hasattr(self, 'cache_size'):
         wtopen_args += ',cache_size=' + str(self.cache_size)
     conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
     self.pr(`conn`)
     return conn
 def test_stats_log_on_close_and_log(self):
     self.conn = wiredtiger.wiredtiger_open(None,
         "create,statistics=(fast),statistics_log=(on_close=true,wait=1)")
     # Wait for the default interval, to ensure stats have been written.
     time.sleep(2)
     self.close_conn()
     self.check_stats_file("WiredTigerStat")
Exemple #19
0
 def setUpConnectionOpen(self, dir):
     wtopen_args = 'create'
     if hasattr(self, 'cache_size'):
         wtopen_args += ',cache_size=' + str(self.cache_size)
     conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
     self.pr( ` conn `)
     return conn
Exemple #20
0
 def test_stat_cursor_conn_error(self):
     args = ['none', 'all', 'fast']
     for i in list(itertools.permutations(args, 2)):
         config = 'create,statistics=(' + i[0] + ',' + i[1] + ')'
         msg = '/only one statistics configuration value/'
         self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
             lambda: wiredtiger.wiredtiger_open('.', config), msg)
Exemple #21
0
 def test_home_not_writeable(self):
     dir = 'subdir'
     os.mkdir(dir)
     os.chmod(dir, 0555)
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, 'create'),
         '/Permission denied/')
Exemple #22
0
 def setUpConnectionOpen(self, dir):
     conn = wiredtiger.wiredtiger_open(dir, 'create,' +
             ('error_prefix="%s: ",' % self.shortid()) +
             'transactional,')
     self.pr(`conn`)
     self.session2 = conn.open_session()
     return conn
Exemple #23
0
    def __init__(self, path, logging=False):
        # init wiredtiger
        config = 'create,log=(enabled=true)' if logging else 'create'
        self._wiredtiger = wiredtiger_open(path, config)
        session = self._wiredtiger.open_session()

        # sequence table of uids
        session.create('table:uids', 'key_format=r,value_format=u')
        self._uids = session.open_cursor('table:uids', None, 'append')

        # tuples
        session.create('table:tuples', 'key_format=QS,value_format=S,columns=(uid,key,value)')
        self._tuples = session.open_cursor('table:tuples')

        # reversed index for (key, value) querying
        session.create('index:tuples:index', 'columns=(key,value)')
        self._reversed = session.open_cursor('index:tuples:index(uid)')

        # fuzzy search
        config = 'key_format=r,value_format=SQS,columns=(x,trigram,uid,string)'
        session.create('table:trigrams', config)
        self._trigrams = session.open_cursor('table:trigrams', None, 'append')
        session.create('index:trigrams:index', 'columns=(trigram)')
        self._trigrams_index = session.open_cursor('index:trigrams:index(uid,string)')

        self._session = session
 def setUpConnectionOpen(self, dir):
     extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')])
     connarg = 'create,error_prefix="{0}: ",{1}'.format(
         self.shortid(), extarg)
     conn = wiredtiger.wiredtiger_open(dir, connarg)
     self.pr(`conn`)
     return conn
Exemple #25
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     # Disable checkpoint sync, to make checkpoints faster and
     # increase the likelyhood of triggering the symptom
     conn_params = ',create,checkpoint_sync=false'
     conn = wiredtiger.wiredtiger_open(dir, conn_params)
     return conn
Exemple #26
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     # Disable checkpoint sync, to make checkpoints faster and
     # increase the likelyhood of triggering the symptom
     conn_params = ',create,checkpoint_sync=false'
     conn = wiredtiger.wiredtiger_open(dir, conn_params)
     return conn
Exemple #27
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     conn_params = 'create,cache_size=10MB,' \
                   'hazard_max=' + str(self.ntables / 2)
     conn = wiredtiger.wiredtiger_open(dir, conn_params)
     self.pr( ` conn `)
     return conn
Exemple #28
0
 def setUpConnectionOpen(self, dir):
     wtopen_args = "create"
     if hasattr(self, "cache_size"):
         wtopen_args += ",cache_size=" + str(self.cache_size)
     conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
     self.pr(` conn `)
     return conn
Exemple #29
0
    def doExport(self, outf):
        # Attempt to connect to the specified WiredTiger database
        try:
            conn = wiredtiger.wiredtiger_open(
                self.dbpath,
                'log=(compressor=snappy,path=journal,recover=error),readonly=true')
        except Exception as e:
            sys.stderr.write('Failed to open dbpath "{0}": {1}\n'.format(self.dbpath, e))
            return

        session = conn.open_session()

        # Find all collections in the database
        catalog = session.open_cursor('table:_mdb_catalog')
        sizeStorer = session.open_cursor('table:sizeStorer')
        wtMeta = session.open_cursor('metadata:')
        wtMetaCreate = session.open_cursor('metadata:create')
        for _, meta_raw in catalog:
            meta = bson.decode(meta_raw, codec_options=codec_options)
            ns = meta[u'ns']
            if not ns or not ns.startswith(self.nsprefix):
                continue
            assert ns == meta[u'md'][u'ns']

            # Iterate through indexes first
            indexes = {}
            for idxName, idxIdent in meta[u'idxIdent'].items():
                ident = str('table:' + idxIdent)
                filename = ident[len('table:'):] + '.wt'
                file_ident = 'file:' + filename
                wtmeta_file = wtMeta[file_ident]
                wtmeta_table = wtMetaCreate[ident]
                basename = filename[len(self.nsprefix):]
                indexes[idxName] = {'filename': basename,
                                    'wtmeta_table': wtmeta_table,
                                    'wtmeta_file': wtmeta_file}

            collname = ns[len(self.nsprefix):]
            ident = str('table:' + meta[u'ident'])
            size = bson.decode(sizeStorer[ident.encode()])
            filename = ident[len('table:'):] + '.wt'
            file_ident = 'file:' + filename
            wtmeta_file = wtMeta[file_ident]
            wtmeta_table = wtMetaCreate[ident]
            basename = filename[len(self.nsprefix):]
            export = {
                'collname': collname,
                'filename': basename,
                'mdb_catalog': meta,
                'sizeStorer': size,
                'wtmeta_table': wtmeta_table,
                'wtmeta_file': wtmeta_file,
                'indexes': indexes,
                'version': __version__,
            }
            self.message(str(export))
            outf.write(bson.encode(export, codec_options=codec_options))

        conn.close()
    def test_baseconfig(self):
        # Open up another database and modify the baseconfig
        os.mkdir("A")
        conn = wiredtiger.wiredtiger_open("A", 'create')
        self.assertTrue(os.path.exists("A/WiredTiger.basecfg"))
        with open("A/WiredTiger.basecfg", "a") as basecfg_file:
            basecfg_file.write("foo!")
        conn.close()

        # Open a database, we should assert here as the basecfg is invalid
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError,
            lambda: wiredtiger.wiredtiger_open("A", ''),
            '/unknown configuration key/')

        conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
        conn.close()
Exemple #31
0
 def test_stats_log_on_close_and_log(self):
     self.conn = wiredtiger.wiredtiger_open(
         None,
         "create,statistics=(fast),statistics_log=(on_close=true,wait=1)")
     # Wait for the default interval, to ensure stats have been written.
     time.sleep(2)
     self.close_conn()
     self.check_stats_file("WiredTigerStat")
 def test_home_not_writeable(self):
     dir = 'subdir'
     os.mkdir(dir)
     os.chmod(dir, 0555)
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, 'create'),
         '/Permission denied/')
Exemple #33
0
    def test_baseconfig(self):
        # Open up another database and modify the baseconfig
        os.mkdir("A")
        conn = wiredtiger.wiredtiger_open("A", 'create')
        self.assertTrue(os.path.exists("A/WiredTiger.basecfg"))
        with open("A/WiredTiger.basecfg", "a") as basecfg_file:
            basecfg_file.write("foo!")
        conn.close()

        # Open a database, we should assert here as the basecfg is invalid
        self.assertRaisesWithMessage(
            wiredtiger.WiredTigerError,
            lambda: wiredtiger.wiredtiger_open("A", ''),
            '/unknown configuration key/')

        conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
        conn.close()
Exemple #34
0
    def test_base_config(self):
        # We just created a database, there should be a base configuration file.
        self.assertTrue(os.path.exists("./WiredTiger.basecfg"))

        # Open up another database, configure without base configuration.
        os.mkdir("A")
        conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
        self.assertFalse(os.path.exists("A/WiredTiger.basecfg"))
Exemple #35
0
    def test_base_config(self):
        # We just created a database, there should be a base configuration file.
        self.assertTrue(os.path.exists("./WiredTiger.basecfg"))

        # Open up another database, configure without base configuration.
        os.mkdir("A")
        conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
        self.assertFalse(os.path.exists("A/WiredTiger.basecfg"))
Exemple #36
0
 def test_stat_cursor_conn_error(self):
     args = ['none', 'all', 'fast']
     for i in list(itertools.permutations(args, 2)):
         config = 'create,statistics=(' + i[0] + ',' + i[1] + ')'
         msg = '/only one statistics configuration value/'
         self.assertRaisesWithMessage(
             wiredtiger.WiredTigerError,
             lambda: wiredtiger.wiredtiger_open('.', config), msg)
Exemple #37
0
 def test_stat_cursor_conn_error(self):
     args = ["none", "all", "fast"]
     for i in list(itertools.permutations(args, 2)):
         config = "create,statistics=(" + i[0] + "," + i[1] + ")"
         msg = "/only one statistics configuration value/"
         self.assertRaisesWithMessage(
             wiredtiger.WiredTigerError, lambda: wiredtiger.wiredtiger_open(".", config), msg
         )
Exemple #38
0
    def test_dump(self):
        # Create the object.
        uri = self.type + self.name
        self.populate(self, uri, 'key_format=' + self.keyfmt, self.nentries)

        # Dump the object.
        os.mkdir(self.dir)
        if self.hex == 1:
            self.runWt(['dump', '-x', uri], outfilename='dump.out')
        else:
            self.runWt(['dump', uri], outfilename='dump.out')

        # Re-load the object.
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the contents
        conn = wiredtiger.wiredtiger_open(self.dir)
        session = conn.open_session()
        cursor = session.open_cursor(uri, None, None)
        self.populate_check(self, cursor, self.nentries)
        conn.close()

        # Re-load the object again.
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the contents, they shouldn't have changed.
        conn = wiredtiger.wiredtiger_open(self.dir)
        session = conn.open_session()
        cursor = session.open_cursor(uri, None, None)
        self.populate_check(self, cursor, self.nentries)
        conn.close()

        # Re-load the object again, but confirm -n (no overwrite) fails.
        self.runWt(['-h', self.dir,
            'load', '-n', '-f', 'dump.out'], errfilename='errfile.out')
        self.check_non_empty_file('errfile.out')

        # If there is are indices, dump one of them and check the output.
        if self.populate == complex_populate:
            indexuri = 'index:' + self.name + ':indx1'
            hexopt = ['-x'] if self.hex == 1 else []
            self.runWt(['-h', self.dir, 'dump'] + hexopt + [indexuri],
                       outfilename='dumpidx.out')
            self.check_non_empty_file('dumpidx.out')
            self.compare_dump_values('dump.out', 'dumpidx.out')
Exemple #39
0
    def test_dump(self):
        # Create the object.
        uri = self.type + self.name
        self.populate(self, uri, 'key_format=' + self.keyfmt, self.nentries)

        # Dump the object.
        os.mkdir(self.dir)
        if self.hex == 1:
            self.runWt(['dump', '-x', uri], outfilename='dump.out')
        else:
            self.runWt(['dump', uri], outfilename='dump.out')

        # Re-load the object.
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the contents
        conn = wiredtiger.wiredtiger_open(self.dir)
        session = conn.open_session()
        cursor = session.open_cursor(uri, None, None)
        self.populate_check(self, cursor, self.nentries)
        conn.close()

        # Re-load the object again.
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the contents, they shouldn't have changed.
        conn = wiredtiger.wiredtiger_open(self.dir)
        session = conn.open_session()
        cursor = session.open_cursor(uri, None, None)
        self.populate_check(self, cursor, self.nentries)
        conn.close()

        # Re-load the object again, but confirm -n (no overwrite) fails.
        self.runWt(['-h', self.dir, 'load', '-n', '-f', 'dump.out'],
                   errfilename='errfile.out')
        self.check_non_empty_file('errfile.out')

        # If there is are indices, dump one of them and check the output.
        if self.populate == complex_populate:
            indexuri = 'index:' + self.name + ':indx1'
            hexopt = ['-x'] if self.hex == 1 else []
            self.runWt(['-h', self.dir, 'dump'] + hexopt + [indexuri],
                       outfilename='dumpidx.out')
            self.check_non_empty_file('dumpidx.out')
            self.compare_dump_values('dump.out', 'dumpidx.out')
Exemple #40
0
    def test_txn25(self):
        uri = 'file:test_txn25'
        create_config = 'key_format={},value_format={}'.format(self.key_format, self.value_format)
        self.session.create(uri, 'allocation_size=512,' + create_config)

        # Populate the file and ensure that we start seeing some high transaction IDs in the system.
        nrows = 1000
        if self.value_format == '8t':
            # Values are 1/500 the size, but for this we don't need to generate a lot of data,
            # just a lot of transactions, so we can keep the same nrows. This will generate only
            # one page, but that shouldn't affect the test criteria.
            value1 = 97
            value2 = 98
            value3 = 99
        else:
            value1 = 'aaaaa' * 100
            value2 = 'bbbbb' * 100
            value3 = 'ccccc' * 100

        # Keep transaction ids around.
        session2 = self.conn.open_session()
        session2.begin_transaction()

        cursor = self.session.open_cursor(uri)
        for i in range(1, nrows):
            self.session.begin_transaction()
            cursor[self.getkey(i)] = value1
            self.session.commit_transaction()

        for i in range(1, nrows):
            self.session.begin_transaction()
            cursor[self.getkey(i)] = value2
            self.session.commit_transaction()

        for i in range(1, nrows):
            self.session.begin_transaction()
            cursor[self.getkey(i)] = value3
            self.session.commit_transaction()

        session2.rollback_transaction()
        session2.close()

        # Close and re-open the connection.
        cursor.close()
        self.conn.close()
        self.conn = wiredtiger.wiredtiger_open(self.home, self.conn_config)
        self.session = self.conn.open_session(self.session_config)

        # Now that we've reopened, check that we can view the latest data from the previous run.
        #
        # Since we've restarted the system, our transaction IDs are going to begin from 1 again
        # so we have to wipe the cell's transaction IDs in order to see them.
        cursor = self.session.open_cursor(uri)
        self.session.begin_transaction()
        for i in range(1, nrows):
            self.assertEqual(cursor[self.getkey(i)], value3)
        self.session.rollback_transaction()
Exemple #41
0
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,' + \
         cacheSize + ',error_prefix="%s" %s' % (self.shortid(), self.conn_config)
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
     self.session = self.conn.open_session(None)
 def test_home_not_writeable(self):
     if os.name == "nt":
         self.skipTest('Unix specific test skipped on Windows')
     dir = 'subdir'
     os.mkdir(dir)
     os.chmod(dir, 0555)
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, 'create'),
         '/Permission denied/')
Exemple #43
0
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,' + \
         cacheSize + ',error_prefix="%s" %s' % (self.shortid(), self.conn_config)
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
     self.session = self.conn.open_session(None)
Exemple #44
0
 def setUpConnectionOpen(self, dir):
     encarg = 'encryption=(name={0}{1}),'.format(self.sys_encrypt,
                                                 self.sys_encrypt_args)
     extarg = self.extensionArg([('encryptors', self.sys_encrypt)])
     conn = wiredtiger.wiredtiger_open(
         dir, 'create,error_prefix="{0}: ",{1}{2}'.format(
             self.shortid(), encarg, extarg))
     self.pr( ` conn `)
     return conn
Exemple #45
0
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,statistics=(fast),' + \
         cacheSize + ',error_prefix="%s" %s' % (self.shortid(), self.conn_config)
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print("Failed conn at '%s' with config '%s'" % (dir, conn_params))
     self.session = wttest.WiredTigerTestCase.setUpSessionOpen(self, self.conn)
 def __init__(self, path, config='create'):
     path = os.path.abspath(os.path.expanduser(path))
     print("WT Path:", path)
     self._cnx = wiredtiger_open(path, config)
     self._session = self._cnx.open_session()
     # define key value table
     self._session.create('table:keyvalue',
                          'key_format=S,value_format=I')
     self._keyvalue = self._session.open_cursor('table:keyvalue')
Exemple #47
0
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,statistics=(fast),' + \
         cacheSize + ',error_prefix="%s" %s' % (self.shortid(), self.conn_config)
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print("Failed conn at '%s' with config '%s'" % (dir, conn_params))
     self.session = wttest.WiredTigerTestCase.setUpSessionOpen(self, self.conn)
Exemple #48
0
 def test_home_not_writeable(self):
     if os.name == "nt":
         self.skipTest('Unix specific test skipped on Windows')
     dir = 'subdir'
     os.mkdir(dir)
     os.chmod(dir, 0555)
     self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, 'create'),
         '/Permission denied/')
Exemple #49
0
 def test_home_not_writeable(self):
     dir = "subdir"
     os.mkdir(dir)
     os.chmod(dir, 0555)
     self.assertRaisesWithMessage(
         wiredtiger.WiredTigerError,
         lambda: wiredtiger.wiredtiger_open(dir, "create"),
         "wiredtiger_open: WiredTiger: Permission denied\n",
     )
Exemple #50
0
 def setUpConnectionOpen(self, dir):
     encarg = 'encryption=(name={0}{1}),'.format(
         self.sys_encrypt, self.sys_encrypt_args)
     extarg = self.extensionArg([('encryptors', self.sys_encrypt)])
     conn = wiredtiger.wiredtiger_open(dir,
            'create,error_prefix="{0}: ",{1}{2}'.format(
             self.shortid(), encarg, extarg))
     self.pr(`conn`)
     return conn
Exemple #51
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     conn_params = \
         'create,error_prefix="%s: ",' % self.shortid() + \
         'log=(archive=%s,enabled,file_max=%s,prealloc=false),' % (self.archive, self.logmax) + \
         'transaction_sync=(enabled=false),'
     conn = wiredtiger_open(dir, conn_params)
     self.pr(`conn`)
     return conn
 def setUpConnectionOpen(self, dir):
     self.home = dir
     conn_params = \
             'create,error_prefix="%s: ",' % self.shortid() + \
             'async=(enabled=true,ops_max=%s,' % self.async_ops + \
             'threads=%s)' % self.async_threads
     sys.stdout.flush()
     conn = wiredtiger_open(dir, conn_params)
     self.pr(`conn`)
     return conn
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,' + \
         cacheSize + ',error_prefix="%s: ",' % self.shortid() + \
         'statistics=(all),eviction_dirty_target=99,eviction_dirty_trigger=99'
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
     self.session = self.conn.open_session(None)
Exemple #54
0
    def __init__(self, home, **config):
        self._home = home

        # TODO: take into account CONFIG
        config = "create,log=(enabled=true,file_max=512MB),cache_size=1024MB"
        self._cnx = wiredtiger_open(home, config)
        # init table
        session = self._cnx.open_session()
        session.create("table:hoply", "key_format=u,value_format=u")
        session.close()
Exemple #55
0
 def ConnectionOpen(self, cacheSize):
     self.home = '.'
     conn_params = 'create,' + \
         cacheSize + ',error_prefix="%s: ",' % self.shortid() + \
         'statistics=(fast),eviction_dirty_target=99,eviction_dirty_trigger=99'
     try:
         self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
     except wiredtiger.WiredTigerError as e:
         print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
     self.session = self.conn.open_session(None)
Exemple #56
0
 def setUpConnectionOpen(self, dir):
     self.home = dir
     conn_params = \
             'create,error_prefix="%s: ",' % self.shortid() + \
             'async=(enabled=true,ops_max=%s,' % self.async_ops + \
             'threads=%s)' % self.async_threads
     sys.stdout.flush()
     conn = wiredtiger_open(dir, conn_params)
     self.pr( ` conn `)
     return conn
Exemple #57
0
    def ConnectionOpen(self):
        self.home = '.'

        conn_params = 'create,log=(file_max=100K,remove=false,%s)' % self.uselog

        try:
            self.conn = wiredtiger.wiredtiger_open(self.home, conn_params)
        except wiredtiger.WiredTigerError as e:
            print("Failed conn at '%s' with config '%s'" % (dir, conn_params))
        self.session = self.conn.open_session()
Exemple #58
0
    def check_backup(self, session):
        backupdir = 'backup.dir'
        self.backup(backupdir, session)

        # Open the target directory, and confirm the object has no contents.
        conn = wiredtiger.wiredtiger_open(backupdir)
        session = conn.open_session()
        cursor = session.open_cursor(self.uri, None, None)
        self.assertEqual(cursor.next(), wiredtiger.WT_NOTFOUND)
        conn.close()