Commit 6ee6f211 authored by Jim Fulton's avatar Jim Fulton

TestThread objects expect to have a _testcase attr, but didn't have

one. Added a constructor argument to give them one.
parent 8bdffbf6
...@@ -35,11 +35,11 @@ class WorkerThread(TestThread): ...@@ -35,11 +35,11 @@ class WorkerThread(TestThread):
# run the entire test in a thread so that the blocking call for # run the entire test in a thread so that the blocking call for
# tpc_vote() doesn't hang the test suite. # tpc_vote() doesn't hang the test suite.
def __init__(self, storage, trans): def __init__(self, test, storage, trans):
self.storage = storage self.storage = storage
self.trans = trans self.trans = trans
self.ready = threading.Event() self.ready = threading.Event()
TestThread.__init__(self) TestThread.__init__(self, test)
def testrun(self): def testrun(self):
try: try:
...@@ -111,7 +111,7 @@ class CommitLockTests: ...@@ -111,7 +111,7 @@ class CommitLockTests:
txn = transaction.Transaction() txn = transaction.Transaction()
tid = self._get_timestamp() tid = self._get_timestamp()
t = WorkerThread(storage, txn) t = WorkerThread(self, storage, txn)
self._threads.append(t) self._threads.append(t)
t.start() t.start()
t.ready.wait() t.ready.wait()
......
...@@ -130,9 +130,9 @@ class StressThread(FailableThread): ...@@ -130,9 +130,9 @@ class StressThread(FailableThread):
# to 'tree' until Event stop is set. If sleep is given, sleep # to 'tree' until Event stop is set. If sleep is given, sleep
# that long after each append. At the end, instance var .added_keys # that long after each append. At the end, instance var .added_keys
# is a list of the ints the thread believes it added successfully. # is a list of the ints the thread believes it added successfully.
def __init__(self, db, stop, threadnum, commitdict, def __init__(self, testcase, db, stop, threadnum, commitdict,
startnum, step=2, sleep=None): startnum, step=2, sleep=None):
TestThread.__init__(self) TestThread.__init__(self, testcase)
self.db = db self.db = db
self.stop = stop self.stop = stop
self.threadnum = threadnum self.threadnum = threadnum
...@@ -173,9 +173,9 @@ class LargeUpdatesThread(FailableThread): ...@@ -173,9 +173,9 @@ class LargeUpdatesThread(FailableThread):
# more than 25 objects so that it can test code that runs vote # more than 25 objects so that it can test code that runs vote
# in a separate thread when it modifies more than 25 objects. # in a separate thread when it modifies more than 25 objects.
def __init__(self, db, stop, threadnum, commitdict, startnum, def __init__(self, test, db, stop, threadnum, commitdict, startnum,
step=2, sleep=None): step=2, sleep=None):
TestThread.__init__(self) TestThread.__init__(self, test)
self.db = db self.db = db
self.stop = stop self.stop = stop
self.threadnum = threadnum self.threadnum = threadnum
...@@ -361,8 +361,8 @@ class InvalidationTests: ...@@ -361,8 +361,8 @@ class InvalidationTests:
# Run two threads that update the BTree # Run two threads that update the BTree
cd = {} cd = {}
t1 = self.StressThread(db1, stop, 1, cd, 1) t1 = self.StressThread(self, db1, stop, 1, cd, 1)
t2 = self.StressThread(db2, stop, 2, cd, 2) t2 = self.StressThread(self, db2, stop, 2, cd, 2)
self.go(stop, cd, t1, t2) self.go(stop, cd, t1, t2)
while db1.lastTransaction() != db2.lastTransaction(): while db1.lastTransaction() != db2.lastTransaction():
...@@ -391,7 +391,7 @@ class InvalidationTests: ...@@ -391,7 +391,7 @@ class InvalidationTests:
# Run threads that update the BTree # Run threads that update the BTree
cd = {} cd = {}
threads = [self.StressThread(dbs[i], stop, i, cd, i, n) threads = [self.StressThread(self, dbs[i], stop, i, cd, i, n)
for i in range(n)] for i in range(n)]
self.go(stop, cd, *threads) self.go(stop, cd, *threads)
...@@ -418,8 +418,8 @@ class InvalidationTests: ...@@ -418,8 +418,8 @@ class InvalidationTests:
# Run two threads that update the BTree # Run two threads that update the BTree
cd = {} cd = {}
t1 = self.StressThread(db1, stop, 1, cd, 1, sleep=0.01) t1 = self.StressThread(self, db1, stop, 1, cd, 1, sleep=0.01)
t2 = self.StressThread(db1, stop, 2, cd, 2, sleep=0.01) t2 = self.StressThread(self, db1, stop, 2, cd, 2, sleep=0.01)
self.go(stop, cd, t1, t2) self.go(stop, cd, t1, t2)
cn = db1.open() cn = db1.open()
...@@ -447,9 +447,9 @@ class InvalidationTests: ...@@ -447,9 +447,9 @@ class InvalidationTests:
# at the same time. # at the same time.
cd = {} cd = {}
t1 = self.StressThread(db1, stop, 1, cd, 1, 3) t1 = self.StressThread(self, db1, stop, 1, cd, 1, 3)
t2 = self.StressThread(db2, stop, 2, cd, 2, 3, 0.01) t2 = self.StressThread(self, db2, stop, 2, cd, 2, 3, 0.01)
t3 = self.StressThread(db2, stop, 3, cd, 3, 3, 0.01) t3 = self.StressThread(self, db2, stop, 3, cd, 3, 3, 0.01)
self.go(stop, cd, t1, t2, t3) self.go(stop, cd, t1, t2, t3)
while db1.lastTransaction() != db2.lastTransaction(): while db1.lastTransaction() != db2.lastTransaction():
...@@ -485,9 +485,9 @@ class InvalidationTests: ...@@ -485,9 +485,9 @@ class InvalidationTests:
# at the same time. # at the same time.
cd = {} cd = {}
t1 = LargeUpdatesThread(db1, stop, 1, cd, 1, 3, 0.02) t1 = LargeUpdatesThread(self, db1, stop, 1, cd, 1, 3, 0.02)
t2 = LargeUpdatesThread(db2, stop, 2, cd, 2, 3, 0.01) t2 = LargeUpdatesThread(self, db2, stop, 2, cd, 2, 3, 0.01)
t3 = LargeUpdatesThread(db2, stop, 3, cd, 3, 3, 0.01) t3 = LargeUpdatesThread(self, db2, stop, 3, cd, 3, 3, 0.01)
self.go(stop, cd, t1, t2, t3) self.go(stop, cd, t1, t2, t3)
while db1.lastTransaction() != db2.lastTransaction(): while db1.lastTransaction() != db2.lastTransaction():
......
...@@ -36,11 +36,12 @@ class TestThread(threading.Thread): ...@@ -36,11 +36,12 @@ class TestThread(threading.Thread):
message. message.
""" """
def __init__(self): def __init__(self, testcase):
threading.Thread.__init__(self) threading.Thread.__init__(self)
# In case this thread hangs, don't stop Python from exiting. # In case this thread hangs, don't stop Python from exiting.
self.setDaemon(1) self.setDaemon(1)
self._exc_info = None self._exc_info = None
self._testcase = testcase
def run(self): def run(self):
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment