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_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()