def test_illegal_extractor(self): ds = ComplexDataSet(self, 'table:A', 10) ds.populate() msg = '/unknown extractor/' self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.create('index:A:xyzzy', 'key_format=S,columns=(column2),extractor="xyzzy"'), msg)
def test_bug025(self): ds = ComplexDataSet(self, self.uri, self.nrows, key_format="S", value_format='S') ds.populate() iname = ds.index_name(0) iname_suffix = iname[iname.rindex(':') + 1:] filename = 'test_bug025_' + iname_suffix + '.wti' self.close_conn() pos = os.path.getsize(filename) - 1024 os.remove(filename) # We get an error message, but the open succeeds. with self.expectedStderrPattern('.*No such file or directory'): self.open_conn() newkey = ds.key(self.nrows) newval = ds.value(self.nrows) cursor = self.session.open_cursor(self.uri) # We get an error message, and the insert fails. # The cursor remains open. with self.expectedStderrPattern('.*No such file or directory'): try: cursor[newkey] = newval except Exception as e: self.pr('Exception in first access: ' + str(e)) # We get an error message, and the insert fails. # Before the associated fix was made, the insert crashed. with self.expectedStderrPattern('.*No such file or directory'): try: cursor[newkey] = newval # point of crash except Exception as e: self.pr('Exception in second access: ' + str(e)) cursor.close()
def test_truncate_complex(self): # We only care about tables. if self.type == 'file:': return uri = self.type + self.name # list: truncation patterns # # begin and end: -1 means pass None for the cursor arg to truncate. An # integer N, with 1 <= N < self.nentries, truncates from/to a cursor # positioned at that row. list = [ (-1, self.nentries), # begin to end, begin = None (1, -1), # begin to end, end = None (1, self.nentries), # begin to end (-1, self.nentries - self.skip), # begin to middle, begin = None (1, self.nentries - self.skip), # begin to middle (self.skip, -1), # middle to end, end = None (self.skip, self.nentries), # middle to end ( self.skip, # middle to different middle self.nentries - self.skip), (1, 1), # begin to begin (self.nentries, self.nentries), # end to end (self.skip, self.skip) # middle to same middle ] # Build the layout we're going to test for begin, end in list: ''' print '===== run:', uri print 'key:', self.keyfmt, 'begin:', begin, 'end:', end ''' # Create the object. ds = ComplexDataSet(self, uri, self.nentries, config=self.config, key_format=self.keyfmt) ds.populate() # Build a dictionary of what the object should look like for # later comparison cursor = self.session.open_cursor(uri, None) expected = {} for i in range(1, self.nentries + 1): expected[ds.key(i)] = ds.comparable_value(i) cursor.close() # Optionally close and re-open the object to get a disk image # instead of a big insert list. if self.reopen: self.reopen_conn() self.truncateRangeAndCheck(ds, uri, begin, end, expected) self.session.drop(uri, None)
def test_truncate_complex(self): # We only care about tables. if self.type == 'file:': return uri = self.type + self.name # list: truncation patterns # # begin and end: -1 means pass None for the cursor arg to truncate. An # integer N, with 1 <= N < self.nentries, truncates from/to a cursor # positioned at that row. list = [ (-1, self.nentries), # begin to end, begin = None (1, -1), # begin to end, end = None (1, self.nentries), # begin to end (-1, self.nentries - self.skip), # begin to middle, begin = None (1, self.nentries - self.skip), # begin to middle (self.skip, -1), # middle to end, end = None (self.skip, self.nentries), # middle to end (self.skip, # middle to different middle self.nentries - self.skip), (1, 1), # begin to begin (self.nentries, self.nentries), # end to end (self.skip, self.skip) # middle to same middle ] # Build the layout we're going to test for begin,end in list: ''' print '===== run:', uri print 'key:', self.keyfmt, 'begin:', begin, 'end:', end ''' # Create the object. ds = ComplexDataSet(self, uri, self.nentries, config=self.config, key_format=self.keyfmt) ds.populate() # Build a dictionary of what the object should look like for # later comparison cursor = self.session.open_cursor(uri, None) expected = {} for i in range(1, self.nentries + 1): expected[ds.key(i)] = ds.comparable_value(i) cursor.close() # Optionally close and re-open the object to get a disk image # instead of a big insert list. if self.reopen: self.reopen_conn() self.truncateRangeAndCheck(ds, uri, begin, end, expected) self.session.drop(uri, None)
def test_bug025(self): ds = ComplexDataSet(self, self.uri, self.nrows, key_format="S", value_format='S') ds.populate() iname = ds.index_name(0) iname_suffix = iname[iname.rindex(':') + 1:] filename = 'test_bug025_' + iname_suffix + '.wti' self.close_conn() pos = os.path.getsize(filename) - 1024 os.remove(filename) # We will get error output, but not always in the same API calls from run to run, # in particular the open connection doesn't always report the missing file, as # index files are usually lazily loaded. As long as the missing file is reported # at least once in the following code, it's good. with self.expectedStderrPattern('.*No such file or directory.*'): self.open_conn() newkey = ds.key(self.nrows) newval = ds.value(self.nrows) cursor = self.session.open_cursor(self.uri) # The insert fails, and the cursor remains open. try: cursor[newkey] = newval except Exception as e: self.pr('Exception in first access: ' + str(e)) # The insert fails again. Before the associated fix was made, the insert crashed. try: cursor[newkey] = newval # point of crash except Exception as e: self.pr('Exception in second access: ' + str(e)) cursor.close()