summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2015-11-30 16:50:15 -0500
committerDon Anderson <dda@ddanderson.com>2015-11-30 16:50:15 -0500
commit91a6c9254168c46409aa8fcb48687fcee16217c5 (patch)
treea76a653350e2a1c0677e60b2d4e47b5f7ea63394 /test
parent2d01a566ba7b3576cb5b45af55479b3c06995589 (diff)
downloadmongo-91a6c9254168c46409aa8fcb48687fcee16217c5.tar.gz
WT-2142. At the end of a test run, all open connections should be closed
to prevent cascading errors. Clean up and (mostly) standardize how connection configuration is added to and modified. Details: - class TestSuiteConnection wraps an opened Connection, calls to close() remove it from the list of active connections. - WiredTigerTestCase.wiredtiger_open uses a TestSuiteConnection, and this version of wiredtiger_open is now used everywhere. - in tearDown(), active connections are explicitly closed. - In WiredTigerTestCase derived classes, we now use use self.conn_config if possible in tests in preference to overloading setUpConnectionOpen(). - Explicitly call close on extra connections created dynamically. - Remove some unused code.
Diffstat (limited to 'test')
-rw-r--r--test/suite/test_async01.py13
-rw-r--r--test/suite/test_async02.py23
-rw-r--r--test/suite/test_async03.py18
-rw-r--r--test/suite/test_backup01.py2
-rw-r--r--test/suite/test_backup03.py9
-rw-r--r--test/suite/test_backup04.py9
-rw-r--r--test/suite/test_backup05.py1
-rw-r--r--test/suite/test_baseconfig.py6
-rw-r--r--test/suite/test_bug010.py11
-rw-r--r--test/suite/test_bug011.py11
-rw-r--r--test/suite/test_bulk02.py2
-rw-r--r--test/suite/test_compact.py11
-rw-r--r--test/suite/test_compress01.py9
-rw-r--r--test/suite/test_config01.py2
-rw-r--r--test/suite/test_config02.py6
-rw-r--r--test/suite/test_config03.py2
-rw-r--r--test/suite/test_config04.py16
-rw-r--r--test/suite/test_config05.py14
-rw-r--r--test/suite/test_cursor07.py22
-rw-r--r--test/suite/test_cursor08.py26
-rw-r--r--test/suite/test_dump.py4
-rw-r--r--test/suite/test_durability01.py1
-rw-r--r--test/suite/test_encrypt01.py2
-rw-r--r--test/suite/test_encrypt02.py2
-rw-r--r--test/suite/test_encrypt03.py2
-rw-r--r--test/suite/test_encrypt04.py2
-rw-r--r--test/suite/test_encrypt05.py2
-rw-r--r--test/suite/test_encrypt06.py2
-rw-r--r--test/suite/test_encrypt07.py2
-rw-r--r--test/suite/test_env01.py2
-rw-r--r--test/suite/test_home.py3
-rw-r--r--test/suite/test_index01.py5
-rw-r--r--test/suite/test_inmem01.py9
-rw-r--r--test/suite/test_join01.py8
-rw-r--r--test/suite/test_join03.py2
-rw-r--r--test/suite/test_perf001.py7
-rw-r--r--test/suite/test_schema01.py7
-rw-r--r--test/suite/test_schema03.py9
-rw-r--r--test/suite/test_schema05.py2
-rw-r--r--test/suite/test_shared_cache01.py2
-rw-r--r--test/suite/test_shared_cache02.py2
-rw-r--r--test/suite/test_stat01.py6
-rw-r--r--test/suite/test_stat02.py42
-rw-r--r--test/suite/test_stat03.py8
-rw-r--r--test/suite/test_stat04.py8
-rw-r--r--test/suite/test_stat05.py9
-rw-r--r--test/suite/test_stat_log01.py8
-rw-r--r--test/suite/test_sweep01.py25
-rw-r--r--test/suite/test_sweep02.py11
-rw-r--r--test/suite/test_sweep03.py23
-rw-r--r--test/suite/test_txn01.py7
-rw-r--r--test/suite/test_txn02.py8
-rw-r--r--test/suite/test_txn03.py7
-rw-r--r--test/suite/test_txn04.py5
-rw-r--r--test/suite/test_txn05.py8
-rw-r--r--test/suite/test_txn07.py6
-rw-r--r--test/suite/test_txn08.py23
-rw-r--r--test/suite/test_txn09.py3
-rw-r--r--test/suite/test_txn10.py8
-rw-r--r--test/suite/test_txn11.py12
-rw-r--r--test/suite/test_txn13.py17
-rw-r--r--test/suite/test_txn14.py7
-rw-r--r--test/suite/test_txn15.py25
-rw-r--r--test/suite/wttest.py67
-rw-r--r--test/suite/wtthread.py47
65 files changed, 230 insertions, 450 deletions
diff --git a/test/suite/test_async01.py b/test/suite/test_async01.py
index fee5e8232f1..15e2fbf64ae 100644
--- a/test/suite/test_async01.py
+++ b/test/suite/test_async01.py
@@ -28,7 +28,7 @@
import sys, threading, wiredtiger, wttest
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, WiredTigerError
+from wiredtiger import WiredTigerError
from wtscenario import check_scenarios
# TODO - tmp code
@@ -132,18 +132,9 @@ class test_async01(wttest.WiredTigerTestCase, suite_subprocess):
('table-row', dict(tablekind='row',uri='table')),
])
- # Overrides WiredTigerTestCase so that we can configure
- # async operations.
- def setUpConnectionOpen(self, dir):
- self.home = dir
- conn_params = \
- 'create,error_prefix="%s: ",' % self.shortid() + \
+ conn_config = lambda self, dir: \
'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 genkey(self, i):
if self.tablekind == 'row':
diff --git a/test/suite/test_async02.py b/test/suite/test_async02.py
index c878e8dd114..775adb239ef 100644
--- a/test/suite/test_async02.py
+++ b/test/suite/test_async02.py
@@ -28,15 +28,9 @@
import sys, threading, wiredtiger, wttest
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, WiredTigerError
+from wiredtiger import WiredTigerError
from wtscenario import check_scenarios
-# TODO - tmp code
-def tty_pr(s):
- o = open('/dev/tty', 'w')
- o.write(s + '\n')
- o.close()
-
class Callback(wiredtiger.AsyncCallback):
def __init__(self, current):
self.current = current
@@ -49,7 +43,7 @@ class Callback(wiredtiger.AsyncCallback):
self.lock = threading.RLock()
def notify_error(self, key, value, optype, exp, desc):
- tty_pr('ERROR: notify(' + str(key) + ',' + str(value) + ',' +
+ self.tty('ERROR: notify(' + str(key) + ',' + str(value) + ',' +
str(optype) + '): ' + 'Expected: ' + str(exp) + ' ' + desc)
def notify(self, op, op_ret, flags):
@@ -105,7 +99,7 @@ class Callback(wiredtiger.AsyncCallback):
self.nerror += 1
self.lock.release()
except (BaseException) as err:
- tty_pr('ERROR: exception in notify: ' + str(err))
+ self.tty('ERROR: exception in notify: ' + str(err))
raise
return 0
@@ -135,18 +129,9 @@ class test_async02(wttest.WiredTigerTestCase, suite_subprocess):
('table-row', dict(tablekind='row',uri='table')),
])
- # Overrides WiredTigerTestCase so that we can configure
- # async operations.
- def setUpConnectionOpen(self, dir):
- self.home = dir
- conn_params = \
- 'create,error_prefix="%s: ",' % self.shortid() + \
+ conn_config = lambda self, dir: \
'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 genkey(self, i):
if self.tablekind == 'row':
diff --git a/test/suite/test_async03.py b/test/suite/test_async03.py
index ea62f8c525b..9193792ef60 100644
--- a/test/suite/test_async03.py
+++ b/test/suite/test_async03.py
@@ -26,7 +26,7 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-from wiredtiger import wiredtiger_open, WiredTigerError
+from wiredtiger import WiredTigerError
import sys, threading, wiredtiger, wttest
class Callback(wiredtiger.AsyncCallback):
@@ -47,19 +47,9 @@ class test_async03(wttest.WiredTigerTestCase):
"""
table_name1 = 'test_async03'
- # Overrides WiredTigerTestCase so that we can configure
- # async operations.
- def setUpConnectionOpen(self, dir):
- self.home = dir
- # Note: this usage is intentionally wrong,
- # it is missing async=(enabled=true,...
- conn_params = \
- 'create,error_prefix="%s: ",' % self.shortid() + \
- 'async=(ops_max=50,threads=3)' # missing enabled=true !
- sys.stdout.flush()
- conn = wiredtiger_open(dir, conn_params)
- self.pr(`conn`)
- return conn
+ # Note: this usage is intentionally wrong, it is missing
+ # async=(enabled=true,...
+ conn_config = 'async=(ops_max=50,threads=3)'
def test_ops(self):
tablearg = 'table:' + self.table_name1
diff --git a/test/suite/test_backup01.py b/test/suite/test_backup01.py
index f6e9cd87291..36f73cdb3d7 100644
--- a/test/suite/test_backup01.py
+++ b/test/suite/test_backup01.py
@@ -98,7 +98,7 @@ class test_backup(wttest.WiredTigerTestCase, suite_subprocess):
# Check that a URI doesn't exist, both the meta-data and the file names.
def confirmPathDoesNotExist(self, uri):
- conn = wiredtiger.wiredtiger_open(self.dir)
+ conn = self.wiredtiger_open(self.dir)
session = conn.open_session()
self.assertRaises(wiredtiger.WiredTigerError,
lambda: session.open_cursor(uri, None, None))
diff --git a/test/suite/test_backup03.py b/test/suite/test_backup03.py
index 880469c2486..165ae651bfc 100644
--- a/test/suite/test_backup03.py
+++ b/test/suite/test_backup03.py
@@ -75,13 +75,8 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess):
]
scenarios = number_scenarios(multiply_scenarios('.', list))
-
# Create a large cache, otherwise this test runs quite slowly.
- def setUpConnectionOpen(self, dir):
- wtopen_args = 'create,cache_size=1G'
- conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
- self.pr(`conn`)
- return conn
+ conn_config = 'cache_size=1G'
# Populate a set of objects.
def populate(self):
@@ -102,7 +97,7 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess):
# Check that a URI doesn't exist, both the meta-data and the file names.
def confirmPathDoesNotExist(self, uri):
- conn = wiredtiger.wiredtiger_open(self.dir)
+ conn = self.wiredtiger_open(self.dir)
session = conn.open_session()
self.assertRaises(wiredtiger.WiredTigerError,
lambda: session.open_cursor(uri, None, None))
diff --git a/test/suite/test_backup04.py b/test/suite/test_backup04.py
index a0a52f49817..142b0d5faa6 100644
--- a/test/suite/test_backup04.py
+++ b/test/suite/test_backup04.py
@@ -57,15 +57,10 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess):
scenarios = check_scenarios([
('table', dict(uri='table:test',dsize=100,nops=2000,nthreads=1,time=30)),
])
-
# Create a large cache, otherwise this test runs quite slowly.
- def setUpConnectionOpen(self, dir):
- wtopen_args = \
- 'create,cache_size=1G,log=(archive=false,enabled,file_max=%s)' % \
+ conn_config = lambda self, dir: \
+ 'cache_size=1G,log=(archive=false,enabled,file_max=%s)' % \
self.logmax
- conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
- self.pr(`conn`)
- return conn
def populate(self, uri, dsize, rows):
self.pr('populate: ' + uri + ' with ' + str(rows) + ' rows')
diff --git a/test/suite/test_backup05.py b/test/suite/test_backup05.py
index 8ab329f761a..65ce613a2f0 100644
--- a/test/suite/test_backup05.py
+++ b/test/suite/test_backup05.py
@@ -35,7 +35,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
from helper import copy_wiredtiger_home
import wttest
diff --git a/test/suite/test_baseconfig.py b/test/suite/test_baseconfig.py
index 6ac3654af11..0fb3f5f0371 100644
--- a/test/suite/test_baseconfig.py
+++ b/test/suite/test_baseconfig.py
@@ -35,7 +35,7 @@ class test_baseconfig(wttest.WiredTigerTestCase):
def test_baseconfig(self):
# Open up another database and modify the baseconfig
os.mkdir("A")
- conn = wiredtiger.wiredtiger_open("A", 'create')
+ conn = self.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!")
@@ -44,10 +44,10 @@ class test_baseconfig(wttest.WiredTigerTestCase):
# Open a database, we should assert here as the basecfg is invalid
self.assertRaisesWithMessage(
wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open("A", ''),
+ lambda: self.wiredtiger_open("A", ''),
'/unknown configuration key/')
- conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
+ conn = self.wiredtiger_open("A", "create,config_base=false")
conn.close()
if __name__ == '__main__':
diff --git a/test/suite/test_bug010.py b/test/suite/test_bug010.py
index 0266cb82446..5d78306a08d 100644
--- a/test/suite/test_bug010.py
+++ b/test/suite/test_bug010.py
@@ -39,14 +39,9 @@ class test_bug010(wttest.WiredTigerTestCase):
uri = 'table:' + name
num_tables = 1000
- # Overrides WiredTigerTestCase
- 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
+ # Disable checkpoint sync, to make checkpoints faster and
+ # increase the likelyhood of triggering the symptom
+ conn_config = 'checkpoint_sync=false'
def test_checkpoint_dirty(self):
# Create a lot of tables
diff --git a/test/suite/test_bug011.py b/test/suite/test_bug011.py
index b93fc3a75b7..d412c1c0d01 100644
--- a/test/suite/test_bug011.py
+++ b/test/suite/test_bug011.py
@@ -40,15 +40,8 @@ class test_bug011(wttest.WiredTigerTestCase):
ntables = 50
nrows = 10000
nops = 10000
-
- # Overrides WiredTigerTestCase
- 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
+ conn_config = lambda self, dir: \
+ 'cache_size=10MB,hazard_max=' + str(self.ntables / 2)
def test_eviction(self):
cursors = []
diff --git a/test/suite/test_bulk02.py b/test/suite/test_bulk02.py
index 4af1314c0d8..93f85d0b824 100644
--- a/test/suite/test_bulk02.py
+++ b/test/suite/test_bulk02.py
@@ -104,7 +104,7 @@ class test_bulkload_backup(wttest.WiredTigerTestCase, suite_subprocess):
self.backup(backupdir, session)
# Open the target directory, and confirm the object has no contents.
- conn = wiredtiger.wiredtiger_open(backupdir)
+ conn = self.wiredtiger_open(backupdir)
session = conn.open_session()
cursor = session.open_cursor(self.uri, None, None)
self.assertEqual(cursor.next(), wiredtiger.WT_NOTFOUND)
diff --git a/test/suite/test_compact.py b/test/suite/test_compact.py
index c7269785115..1116c278d95 100644
--- a/test/suite/test_compact.py
+++ b/test/suite/test_compact.py
@@ -54,14 +54,9 @@ class test_compact(wttest.WiredTigerTestCase, suite_subprocess):
('utility', dict(utility=1,reopen=0)),
]
scenarios = number_scenarios(multiply_scenarios('.', types, compact))
-
- # Override WiredTigerTestCase, we want a large cache so that eviction
- # doesn't happen (which could skew our compaction results).
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,cache_size=250MB,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ # We want a large cache so that eviction doesn't happen
+ # (which could skew our compaction results).
+ conn_config = 'cache_size=250MB,statistics=(all)'
# Test compaction.
def test_compact(self):
diff --git a/test/suite/test_compress01.py b/test/suite/test_compress01.py
index 17d87403a0f..a9b97143b0c 100644
--- a/test/suite/test_compress01.py
+++ b/test/suite/test_compress01.py
@@ -52,13 +52,8 @@ class test_compress01(wttest.WiredTigerTestCase):
nrecords = 10000
bigvalue = "abcdefghij" * 1000
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open( dir, 'create,' +
- ('error_prefix="%s: ",' % self.shortid()) +
- self.extensionArg(self.compress))
- self.pr(`conn`)
- return conn
+ conn_config = lambda self, dir: \
+ self.extensionArg(self.compress)
# Return the wiredtiger_open extension argument for a shared library.
def extensionArg(self, name):
diff --git a/test/suite/test_config01.py b/test/suite/test_config01.py
index f40f9df3b20..6e499e8584a 100644
--- a/test/suite/test_config01.py
+++ b/test/suite/test_config01.py
@@ -41,7 +41,7 @@ class test_config01(test_base03.test_base03):
wtopen_args = 'create'
if hasattr(self, 'cache_size'):
wtopen_args += ',cache_size=' + str(self.cache_size)
- conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
+ conn = self.wiredtiger_open(dir, wtopen_args)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_config02.py b/test/suite/test_config02.py
index 53c9989eb5d..fb1bccaa896 100644
--- a/test/suite/test_config02.py
+++ b/test/suite/test_config02.py
@@ -82,7 +82,7 @@ class test_config02(wttest.WiredTigerTestCase):
else:
os.putenv('WIREDTIGER_HOME', homeenv)
try:
- self.conn = wiredtiger.wiredtiger_open(homearg, configarg)
+ self.conn = self.wiredtiger_open(homearg, configarg)
self.session = self.conn.open_session(None)
self.populate_and_check()
finally:
@@ -144,7 +144,7 @@ class test_config02(wttest.WiredTigerTestCase):
def test_home_does_not_exist(self):
dir = 'nondir'
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open(dir, 'create'),
+ lambda: self.wiredtiger_open(dir, 'create'),
'/(No such file or directory|The system cannot find the path specified)/')
def test_home_not_writeable(self):
@@ -154,7 +154,7 @@ class test_config02(wttest.WiredTigerTestCase):
os.mkdir(dir)
os.chmod(dir, 0555)
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open(dir, 'create'),
+ lambda: self.wiredtiger_open(dir, 'create'),
'/Permission denied/')
if __name__ == '__main__':
diff --git a/test/suite/test_config03.py b/test/suite/test_config03.py
index 3a1bbd76773..0d8c1ef40de 100644
--- a/test/suite/test_config03.py
+++ b/test/suite/test_config03.py
@@ -127,7 +127,7 @@ class test_config03(test_base03.test_base03):
args = successargs
self.verbose(3, 'wiredtiger_open with args: ' + args)
- conn = wiredtiger.wiredtiger_open(dir, args)
+ conn = self.wiredtiger_open(dir, args)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_config04.py b/test/suite/test_config04.py
index 31deced73d0..09f1559fea6 100644
--- a/test/suite/test_config04.py
+++ b/test/suite/test_config04.py
@@ -76,7 +76,7 @@ class test_config04(wttest.WiredTigerTestCase):
configarg = 'create,statistics=(fast)'
if configextra != None:
configarg += ',' + configextra
- self.conn = wiredtiger.wiredtiger_open('.', configarg)
+ self.conn = self.wiredtiger_open('.', configarg)
self.session = self.conn.open_session(None)
self.populate_and_check()
@@ -89,7 +89,7 @@ class test_config04(wttest.WiredTigerTestCase):
def test_bad_config(self):
msg = '/unknown configuration key/'
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open('.', 'not_valid,another_bad=10'),
+ lambda: self.wiredtiger_open('.', 'not_valid,another_bad=10'),
msg)
def test_cache_size_number(self):
@@ -123,14 +123,14 @@ class test_config04(wttest.WiredTigerTestCase):
def test_cache_too_small(self):
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open('.', 'create,cache_size=900000'),
+ lambda: self.wiredtiger_open('.', 'create,cache_size=900000'),
"/Value too small for key 'cache_size' the minimum is/")
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),
+ lambda: self.wiredtiger_open('.', configstr),
"/Value too large for key 'cache_size' the maximum is/")
def test_eviction(self):
@@ -139,14 +139,14 @@ class test_config04(wttest.WiredTigerTestCase):
def test_eviction_bad(self):
self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda:
- wiredtiger.wiredtiger_open('.', 'create,eviction_target=91,' +
- 'eviction_trigger=81'),
+ self.wiredtiger_open('.', 'create,eviction_target=91,' +
+ 'eviction_trigger=81'),
"/eviction target must be lower than the eviction trigger/")
def test_eviction_bad2(self):
self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda:
- wiredtiger.wiredtiger_open('.', 'create,eviction_target=86,' +
- 'eviction_trigger=86'),
+ self.wiredtiger_open('.', 'create,eviction_target=86,' +
+ 'eviction_trigger=86'),
"/eviction target must be lower than the eviction trigger/")
def test_hazard_max(self):
diff --git a/test/suite/test_config05.py b/test/suite/test_config05.py
index 8687552eefe..083b6dbd547 100644
--- a/test/suite/test_config05.py
+++ b/test/suite/test_config05.py
@@ -75,35 +75,35 @@ class test_config05(wttest.WiredTigerTestCase):
cursor.close()
def test_one(self):
- self.conn = wiredtiger.wiredtiger_open('.', 'create')
+ self.conn = self.wiredtiger_open('.', 'create')
self.session = self.conn.open_session(None)
self.populate(self.session)
self.verify_entries(self.session)
def test_one_session(self):
- self.conn = wiredtiger.wiredtiger_open('.', 'create,session_max=1')
+ self.conn = self.wiredtiger_open('.', 'create,session_max=1')
self.session = self.conn.open_session(None)
self.populate(self.session)
self.verify_entries(self.session)
def test_too_many_sessions(self):
- self.conn = wiredtiger.wiredtiger_open('.', 'create,session_max=1')
+ self.conn = self.wiredtiger_open('.', 'create,session_max=1')
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda: [self.conn.open_session(None) for i in range(100)],
'/configured to support/')
def test_exclusive_create(self):
- self.conn = wiredtiger.wiredtiger_open('.', 'create,exclusive')
+ self.conn = self.wiredtiger_open('.', 'create,exclusive')
self.conn.close()
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open('.', 'exclusive'),
+ lambda: self.wiredtiger_open('.', 'exclusive'),
'/WiredTiger database already exists/')
def test_multi_create(self):
- self.conn = wiredtiger.wiredtiger_open('.', 'create')
+ self.conn = self.wiredtiger_open('.', 'create')
self.session = self.conn.open_session(None)
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open('.', 'create'),
+ lambda: self.wiredtiger_open('.', 'create'),
'/WiredTiger database is already being managed/')
if __name__ == '__main__':
diff --git a/test/suite/test_cursor07.py b/test/suite/test_cursor07.py
index 1fadf58c81f..6de4c1686e0 100644
--- a/test/suite/test_cursor07.py
+++ b/test/suite/test_cursor07.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import check_scenarios
import wttest
@@ -48,23 +48,9 @@ class test_cursor07(wttest.WiredTigerTestCase, suite_subprocess):
('regular', dict(reopen=False)),
('reopen', dict(reopen=True))
])
-
- # Overrides WiredTigerTestCase - add logging
- def setUpConnectionOpen(self, dir):
- self.home = dir
- self.txn_sync = '(method=dsync,enabled)'
- conn_params = \
- 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \
- ',create,error_prefix="%s: ",' % self.shortid() + \
- 'transaction_sync="%s",' % self.txn_sync
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except wiredtiger.WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- self.session2 = conn.open_session()
- return conn
+ conn_config = lambda self, dir: \
+ 'log=(archive=false,enabled,file_max=%s),' % self.logmax + \
+ 'transaction_sync="(method=dsync,enabled)"'
def test_log_cursor(self):
# print "Creating %s with config '%s'" % (self.uri, self.create_params)
diff --git a/test/suite/test_cursor08.py b/test/suite/test_cursor08.py
index 663451eb5b5..f7e8534fb88 100644
--- a/test/suite/test_cursor08.py
+++ b/test/suite/test_cursor08.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat, WiredTigerError
+from wiredtiger import stat, WiredTigerError
from wtscenario import multiply_scenarios, number_scenarios, check_scenarios
import wttest
@@ -54,6 +54,11 @@ class test_cursor08(wttest.WiredTigerTestCase, suite_subprocess):
('none', dict(compress='none')),
])
scenarios = number_scenarios(multiply_scenarios('.', reopens, compress))
+ conn_config = lambda self, dir: \
+ 'log=(archive=false,enabled,file_max=%s,' % self.logmax + \
+ 'compressor=%s),' % self.compress + \
+ 'transaction_sync="(method=dsync,enabled)",' + \
+ self.extensionArg(self.compress)
# Return the wiredtiger_open extension argument for a shared library.
def extensionArg(self, name):
@@ -68,25 +73,6 @@ class test_cursor08(wttest.WiredTigerTestCase, suite_subprocess):
self.skipTest('compression extension "' + extfile + '" not built')
return ',extensions=["' + extfile + '"]'
- # Overrides WiredTigerTestCase - add logging
- def setUpConnectionOpen(self, dir):
- self.home = dir
- self.txn_sync = '(method=dsync,enabled)'
- conn_params = \
- 'log=(archive=false,enabled,file_max=%s,' % self.logmax + \
- 'compressor=%s)' % self.compress + \
- ',create,error_prefix="%s: ",' % self.shortid() + \
- 'transaction_sync="%s",' % self.txn_sync + \
- self.extensionArg(self.compress)
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- self.session2 = conn.open_session()
- return conn
-
def test_log_cursor(self):
# print "Creating %s with config '%s'" % (self.uri, self.create_params)
create_params = 'key_format=i,value_format=S'
diff --git a/test/suite/test_dump.py b/test/suite/test_dump.py
index 6d81c102028..4c3dcae0712 100644
--- a/test/suite/test_dump.py
+++ b/test/suite/test_dump.py
@@ -109,7 +109,7 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess):
self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])
# Check the contents
- conn = wiredtiger.wiredtiger_open(self.dir)
+ conn = self.wiredtiger_open(self.dir)
session = conn.open_session()
cursor = session.open_cursor(uri, None, None)
self.populate_check(self, cursor, self.nentries)
@@ -119,7 +119,7 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess):
self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])
# Check the contents, they shouldn't have changed.
- conn = wiredtiger.wiredtiger_open(self.dir)
+ conn = self.wiredtiger_open(self.dir)
session = conn.open_session()
cursor = session.open_cursor(uri, None, None)
self.populate_check(self, cursor, self.nentries)
diff --git a/test/suite/test_durability01.py b/test/suite/test_durability01.py
index 8d00d05fa14..4517794c63a 100644
--- a/test/suite/test_durability01.py
+++ b/test/suite/test_durability01.py
@@ -34,7 +34,6 @@
import fnmatch, os, shutil, time
from helper import copy_wiredtiger_home
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
diff --git a/test/suite/test_encrypt01.py b/test/suite/test_encrypt01.py
index 9feaa7f88a3..498b0031c1f 100644
--- a/test/suite/test_encrypt01.py
+++ b/test/suite/test_encrypt01.py
@@ -79,7 +79,7 @@ class test_encrypt01(wttest.WiredTigerTestCase):
('encryptors', self.file_encrypt),
('compressors', self.block_compress),
('compressors', self.log_compress)])
- conn = wiredtiger.wiredtiger_open(dir,
+ conn = self.wiredtiger_open(dir,
'create,error_prefix="{0}: ",{1}{2}{3}'.format(
self.shortid(), encarg, comparg, extarg))
self.pr(`conn`)
diff --git a/test/suite/test_encrypt02.py b/test/suite/test_encrypt02.py
index db6cdedf983..3f9bdde8f65 100644
--- a/test/suite/test_encrypt02.py
+++ b/test/suite/test_encrypt02.py
@@ -81,7 +81,7 @@ class test_encrypt02(wttest.WiredTigerTestCase, suite_subprocess):
extarg = self.extensionArg([('encryptors', self.encrypt)])
connarg = 'create,error_prefix="{0}: ",{1},{2}'.format(
self.shortid(), encarg, extarg)
- conn = wiredtiger.wiredtiger_open(dir, connarg)
+ conn = self.wiredtiger_open(dir, connarg)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_encrypt03.py b/test/suite/test_encrypt03.py
index 0e19ad39263..571d07e681d 100644
--- a/test/suite/test_encrypt03.py
+++ b/test/suite/test_encrypt03.py
@@ -57,7 +57,7 @@ class test_encrypt03(wttest.WiredTigerTestCase):
extarg = self.extensionArg([('encryptors', self.sys_encrypt),
('encryptors', self.file_encrypt)])
self.pr('encarg = ' + encarg + ' extarg = ' + extarg)
- conn = wiredtiger.wiredtiger_open(dir,
+ conn = self.wiredtiger_open(dir,
'create,error_prefix="{0}: ",{1}{2}'.format(
self.shortid(), encarg, extarg))
self.pr(`conn`)
diff --git a/test/suite/test_encrypt04.py b/test/suite/test_encrypt04.py
index 41fd0f6dd48..baaeddffd1a 100644
--- a/test/suite/test_encrypt04.py
+++ b/test/suite/test_encrypt04.py
@@ -107,7 +107,7 @@ class test_encrypt04(wttest.WiredTigerTestCase, suite_subprocess):
self.pr('encarg = ' + encarg + ' extarg = ' + extarg)
completed = False
try:
- conn = wiredtiger.wiredtiger_open(dir,
+ conn = self.wiredtiger_open(dir,
'create,error_prefix="{0}: ",{1}{2}'.format(
self.shortid(), encarg, extarg))
except (BaseException) as err:
diff --git a/test/suite/test_encrypt05.py b/test/suite/test_encrypt05.py
index 8a69e5f909f..04265d04df5 100644
--- a/test/suite/test_encrypt05.py
+++ b/test/suite/test_encrypt05.py
@@ -61,7 +61,7 @@ class test_encrypt05(wttest.WiredTigerTestCase):
('encryptors', self.file_encrypt),
('compressors', self.block_compress),
('compressors', self.log_compress)])
- conn = wiredtiger.wiredtiger_open(dir,
+ conn = self.wiredtiger_open(dir,
'create,error_prefix="{0}: ",{1}{2}{3}'.format(
self.shortid(), encarg, comparg, extarg))
self.pr(`conn`)
diff --git a/test/suite/test_encrypt06.py b/test/suite/test_encrypt06.py
index 5b2007fe6e7..6c3c67ccd87 100644
--- a/test/suite/test_encrypt06.py
+++ b/test/suite/test_encrypt06.py
@@ -99,7 +99,7 @@ class test_encrypt06(wttest.WiredTigerTestCase):
('encryptors', self.file1_encrypt)])
self.open_params = 'create,error_prefix="{0}: ",{1}{2}{3}'.format(
self.shortid(), encarg, comparg, extarg)
- conn = wiredtiger.wiredtiger_open(dir, self.open_params)
+ conn = self.wiredtiger_open(dir, self.open_params)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_encrypt07.py b/test/suite/test_encrypt07.py
index cf55e4f16b4..5fd58a20c4f 100644
--- a/test/suite/test_encrypt07.py
+++ b/test/suite/test_encrypt07.py
@@ -50,7 +50,7 @@ class test_encrypt07(test_salvage.test_salvage):
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,
+ conn = self.wiredtiger_open(dir,
'create,error_prefix="{0}: ",{1}{2}'.format(
self.shortid(), encarg, extarg))
self.pr(`conn`)
diff --git a/test/suite/test_env01.py b/test/suite/test_env01.py
index 0d650426383..a60cdf13619 100644
--- a/test/suite/test_env01.py
+++ b/test/suite/test_env01.py
@@ -99,7 +99,7 @@ class test_priv01(wttest.WiredTigerTestCase):
else:
os.putenv('WIREDTIGER_HOME', homeenv)
try:
- self.conn = wiredtiger.wiredtiger_open(homearg, configarg)
+ self.conn = self.wiredtiger_open(homearg, configarg)
self.session = self.conn.open_session(None)
self.populate_and_check()
finally:
diff --git a/test/suite/test_home.py b/test/suite/test_home.py
index ed85a3224c2..0a73012fdd3 100644
--- a/test/suite/test_home.py
+++ b/test/suite/test_home.py
@@ -70,8 +70,9 @@ class test_base_config(wttest.WiredTigerTestCase):
# Open up another database, configure without base configuration.
os.mkdir("A")
- conn = wiredtiger.wiredtiger_open("A", "create,config_base=false")
+ conn = self.wiredtiger_open("A", "create,config_base=false")
self.assertFalse(os.path.exists("A/WiredTiger.basecfg"))
+ conn.close()
if __name__ == '__main__':
diff --git a/test/suite/test_index01.py b/test/suite/test_index01.py
index f2398fee5e8..6fe6e92b5f7 100644
--- a/test/suite/test_index01.py
+++ b/test/suite/test_index01.py
@@ -39,11 +39,6 @@ class test_index01(wttest.WiredTigerTestCase):
NUM_INDICES = 6
index = ['%s:index%d' % (indexbase, i) for i in xrange(NUM_INDICES)]
- def reopen(self):
- self.conn.close()
- self.conn = wiredtiger.wiredtiger_open('.', None)
- self.session = self.conn.open_session()
-
def create_table(self):
self.pr('create table')
self.session.create(self.tablename, 'key_format=Si,value_format=SSii,columns=(name,ID,dept,job,salary,year)')
diff --git a/test/suite/test_inmem01.py b/test/suite/test_inmem01.py
index fa7ca787056..c9211989f9e 100644
--- a/test/suite/test_inmem01.py
+++ b/test/suite/test_inmem01.py
@@ -54,12 +54,9 @@ class test_inmem01(wttest.WiredTigerTestCase):
('row', dict(tablekind='row'))
])
- # Override WiredTigerTestCase to create an in-memory database
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'cache_size=5MB,create,' +
- 'file_manager=(close_idle_time=0),in_memory=true,cache_size=5MB')
- return conn
+ # create an in-memory database
+ conn_config = 'cache_size=5MB,' + \
+ 'file_manager=(close_idle_time=0),in_memory=true'
def get_table_config(self):
kf = 'key_format='
diff --git a/test/suite/test_join01.py b/test/suite/test_join01.py
index ca6e5fbcabb..e033d0f9bbf 100644
--- a/test/suite/test_join01.py
+++ b/test/suite/test_join01.py
@@ -40,12 +40,8 @@ class test_join01(wttest.WiredTigerTestCase):
('table', dict(ref='table')),
('index', dict(ref='index'))
]
-
- # Override WiredTigerTestCase, we have statistics tests.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' + 'error_prefix="%s: "' % self.shortid())
- return conn
+ # We need statistics for these tests.
+ conn_config = 'statistics=(all)'
def gen_key(self, i):
return [ i + 1 ]
diff --git a/test/suite/test_join03.py b/test/suite/test_join03.py
index 552e3b41748..9d97232b81e 100644
--- a/test/suite/test_join03.py
+++ b/test/suite/test_join03.py
@@ -61,7 +61,7 @@ class test_join03(wttest.WiredTigerTestCase):
extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')])
connarg = 'create,error_prefix="{0}: ",{1}'.format(
self.shortid(), extarg)
- conn = wiredtiger.wiredtiger_open(dir, connarg)
+ conn = self.wiredtiger_open(dir, connarg)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_perf001.py b/test/suite/test_perf001.py
index 4f99e552b79..b6377e2f728 100644
--- a/test/suite/test_perf001.py
+++ b/test/suite/test_perf001.py
@@ -44,12 +44,7 @@ class test_perf001(wttest.WiredTigerTestCase):
#('lsm-file', dict(tabletype='lsm',indextype='file')),
#('lsm-lsm', dict(tabletype='lsm',indextype='lsm')),
])
-
- def setUpConnectionOpen(self, dir):
- wtopen_args = 'create,cache_size=512M'
- conn = wiredtiger.wiredtiger_open(dir, wtopen_args)
- self.pr(`conn`)
- return conn
+ conn_config = 'cache_size=512M'
def test_performance_of_indices(self):
uri = 'table:' + self.table_name
diff --git a/test/suite/test_schema01.py b/test/suite/test_schema01.py
index 44c4462cdc2..dff7b28ca24 100644
--- a/test/suite/test_schema01.py
+++ b/test/suite/test_schema01.py
@@ -56,11 +56,6 @@ class test_schema01(wttest.WiredTigerTestCase):
wttest.WiredTigerTestCase.__init__(self, *args, **kwargs)
self.reconcile = False
- def reopen(self):
- self.conn.close()
- self.conn = wiredtiger.wiredtiger_open('.', None)
- self.session = self.conn.open_session()
-
def create_table(self):
self.pr('create table')
self.session.create(self.tablename, 'key_format=5s,value_format=HQ,' +
@@ -89,7 +84,7 @@ class test_schema01(wttest.WiredTigerTestCase):
c.close()
if reopen:
- self.reopen()
+ self.reopen_conn()
c = self.cursor()
expectpos = 0
diff --git a/test/suite/test_schema03.py b/test/suite/test_schema03.py
index 6e535b60850..e461132f075 100644
--- a/test/suite/test_schema03.py
+++ b/test/suite/test_schema03.py
@@ -219,6 +219,9 @@ class test_schema03(wttest.WiredTigerTestCase):
- between each step, whether to close/reopen the connection
"""
+ # Boost cache size and number of sessions for this test
+ conn_config = 'cache_size=100m,session_max=1000'
+
################################################################
# These three variables can be altered to help generate
# and pare down failing test cases.
@@ -297,12 +300,6 @@ class test_schema03(wttest.WiredTigerTestCase):
resource.setrlimit(resource.RLIMIT_NOFILE, newlimit)
super(test_schema03, self).setUp()
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,cache_size=100m,session_max=1000')
- self.pr(`conn`)
- return conn
-
def tearDown(self):
super(test_schema03, self).tearDown()
resource.setrlimit(resource.RLIMIT_NOFILE, self.origFileLimit)
diff --git a/test/suite/test_schema05.py b/test/suite/test_schema05.py
index b0562f7983c..9245a407f35 100644
--- a/test/suite/test_schema05.py
+++ b/test/suite/test_schema05.py
@@ -81,7 +81,7 @@ class test_schema05(wttest.WiredTigerTestCase):
extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')])
connarg = 'create,error_prefix="{0}: ",{1}'.format(
self.shortid(), extarg)
- conn = wiredtiger.wiredtiger_open(dir, connarg)
+ conn = self.wiredtiger_open(dir, connarg)
self.pr(`conn`)
return conn
diff --git a/test/suite/test_shared_cache01.py b/test/suite/test_shared_cache01.py
index b5abc047334..193a3c70c4b 100644
--- a/test/suite/test_shared_cache01.py
+++ b/test/suite/test_shared_cache01.py
@@ -72,7 +72,7 @@ class test_shared_cache01(wttest.WiredTigerTestCase):
for name in connections:
shutil.rmtree(name, True)
os.mkdir(name)
- next_conn = wiredtiger.wiredtiger_open(
+ next_conn = self.wiredtiger_open(
name,
'create,error_prefix="' + self.shortid() + ': "' +
pool_opts + extra_opts)
diff --git a/test/suite/test_shared_cache02.py b/test/suite/test_shared_cache02.py
index ffe27360399..d3f4eb25e18 100644
--- a/test/suite/test_shared_cache02.py
+++ b/test/suite/test_shared_cache02.py
@@ -72,7 +72,7 @@ class test_shared_cache02(wttest.WiredTigerTestCase):
for name in connections:
shutil.rmtree(name, True)
os.mkdir(name)
- next_conn = wiredtiger.wiredtiger_open(
+ next_conn = self.wiredtiger_open(
name,
'create,error_prefix="' + self.shortid() + ': "' +
pool_opts + extra_opts)
diff --git a/test/suite/test_stat01.py b/test/suite/test_stat01.py
index 96f246e3c8a..9ba7bd85415 100644
--- a/test/suite/test_stat01.py
+++ b/test/suite/test_stat01.py
@@ -51,11 +51,7 @@ class test_stat01(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(multiply_scenarios('.', types, keyfmt))
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' + 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def statstr_to_int(self, str):
"""
diff --git a/test/suite/test_stat02.py b/test/suite/test_stat02.py
index 8643d700793..1d869d20326 100644
--- a/test/suite/test_stat02.py
+++ b/test/suite/test_stat02.py
@@ -60,13 +60,7 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase):
scenarios = number_scenarios(
multiply_scenarios('.', uri, data_config, cursor_config))
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,' +
- 'statistics=(' + self.data_config + '),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = lambda self, dir: 'statistics=(%s)' % self.data_config
# For each database/cursor configuration, confirm the right combinations
# succeed or fail.
@@ -87,13 +81,7 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase):
# Test the connection "clear" configuration.
class test_stat_cursor_conn_clear(wttest.WiredTigerTestCase):
pfx = 'test_stat_cursor_conn_clear'
-
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def test_stat_cursor_conn_clear(self):
uri = 'table:' + self.pfx
@@ -123,13 +111,7 @@ class test_stat_cursor_dsrc_clear(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(multiply_scenarios('.', uri))
-
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def test_stat_cursor_dsrc_clear(self):
self.pop(self, self.uri, 'key_format=S', 100)
@@ -159,13 +141,7 @@ class test_stat_cursor_fast(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(multiply_scenarios('.', uri))
-
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def test_stat_cursor_fast(self):
self.pop(self, self.uri, 'key_format=S', 100)
@@ -194,7 +170,7 @@ class test_stat_cursor_conn_error(wttest.WiredTigerTestCase):
config = 'create,statistics=(' + i[0] + ',' + i[1] + ')'
msg = '/only one statistics configuration value/'
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
- lambda: wiredtiger.wiredtiger_open('.', config), msg)
+ lambda: self.wiredtiger_open('.', config), msg)
# Test data-source error combinations.
@@ -209,13 +185,7 @@ class test_stat_cursor_dsrc_error(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(multiply_scenarios('.', uri))
-
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def test_stat_cursor_dsrc_error(self):
self.pop(self, self.uri, 'key_format=S', 100)
diff --git a/test/suite/test_stat03.py b/test/suite/test_stat03.py
index 2e2af16f953..4bc50f8b210 100644
--- a/test/suite/test_stat03.py
+++ b/test/suite/test_stat03.py
@@ -52,13 +52,7 @@ class test_stat_cursor_reset(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(multiply_scenarios('.', uri))
-
- # Override WiredTigerTestCase, we have extensions.
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(all)'
def stat_cursor(self, uri):
return self.session.open_cursor(
diff --git a/test/suite/test_stat04.py b/test/suite/test_stat04.py
index 33e7a925c6a..3ea0c5c593a 100644
--- a/test/suite/test_stat04.py
+++ b/test/suite/test_stat04.py
@@ -50,13 +50,7 @@ class test_stat04(wttest.WiredTigerTestCase, suite_subprocess):
('jumboval', dict(nentries=100, valuesize=4200000)),
]
scenarios = number_scenarios(multiply_scenarios('.', keyfmt, nentries))
-
- # Override WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- return wiredtiger.wiredtiger_open(dir,
- 'create,' +
- 'statistics=(all),' +
- 'error_prefix="%s: "' % self.shortid())
+ conn_config = 'statistics=(all)'
def init_test(self):
self.valuepfx = self.valuesize * 'X'
diff --git a/test/suite/test_stat05.py b/test/suite/test_stat05.py
index f147b93ce81..f763d4dc5a8 100644
--- a/test/suite/test_stat05.py
+++ b/test/suite/test_stat05.py
@@ -49,14 +49,7 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase):
]
scenarios = number_scenarios(uri)
-
- # Override WiredTigerTestCase to enable statistics
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,' +
- 'statistics=(fast),' +
- 'error_prefix="%s: "' % self.shortid())
- return conn
+ conn_config = 'statistics=(fast)'
def openAndWalkStatCursor(self):
c = self.session.open_cursor(
diff --git a/test/suite/test_stat_log01.py b/test/suite/test_stat_log01.py
index 6b0ba52cae1..c95d0a940c9 100644
--- a/test/suite/test_stat_log01.py
+++ b/test/suite/test_stat_log01.py
@@ -47,21 +47,21 @@ class test_stat_log01(wttest.WiredTigerTestCase):
return None
def test_stats_log_default(self):
- self.conn = wiredtiger.wiredtiger_open(
+ self.conn = self.wiredtiger_open(
None, "create,statistics=(fast),statistics_log=(wait=1)")
# Wait for the default interval, to ensure stats have been written.
time.sleep(2)
self.check_stats_file("WiredTigerStat")
def test_stats_log_name(self):
- self.conn = wiredtiger.wiredtiger_open(
+ self.conn = self.wiredtiger_open(
None, "create,statistics=(fast),statistics_log=(wait=1,path=foo)")
# Wait for the default interval, to ensure stats have been written.
time.sleep(2)
self.check_stats_file("foo")
def test_stats_log_on_close_and_log(self):
- self.conn = wiredtiger.wiredtiger_open(None,
+ self.conn = self.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)
@@ -69,7 +69,7 @@ class test_stat_log01(wttest.WiredTigerTestCase):
self.check_stats_file("WiredTigerStat")
def test_stats_log_on_close(self):
- self.conn = wiredtiger.wiredtiger_open(None,
+ self.conn = self.wiredtiger_open(None,
"create,statistics=(fast),statistics_log=(on_close=true)")
# Close the connection to ensure the statistics get generated.
self.close_conn()
diff --git a/test/suite/test_sweep01.py b/test/suite/test_sweep01.py
index 13422a75a61..c7baea39127 100644
--- a/test/suite/test_sweep01.py
+++ b/test/suite/test_sweep01.py
@@ -33,7 +33,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -42,6 +42,9 @@ class test_sweep01(wttest.WiredTigerTestCase, suite_subprocess):
uri = 'table:' + tablebase
numfiles = 50
numkv = 1000
+ conn_config = 'file_manager=(close_handle_minimum=0,' + \
+ 'close_idle_time=6,close_scan_interval=2),' + \
+ 'statistics=(fast),'
types = [
('row', dict(tabletype='row',
@@ -54,26 +57,6 @@ class test_sweep01(wttest.WiredTigerTestCase, suite_subprocess):
scenarios = types
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- self.home = dir
- self.backup_dir = os.path.join(self.home, "WT_BACKUP")
- # Configure sweep to run every 2 seconds with a 6 second timeout.
- # That matches the ratio of the default 10 and 30 seconds.
- conn_params = \
- ',create,error_prefix="%s: ",' % self.shortid() + \
- 'file_manager=(close_handle_minimum=0,' + \
- 'close_idle_time=6,close_scan_interval=2),' + \
- 'statistics=(fast),'
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except wiredtiger.WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- self.session2 = conn.open_session()
- return conn
-
def test_ops(self):
#
# Set up numfiles with numkv entries. We just want some data in there
diff --git a/test/suite/test_sweep02.py b/test/suite/test_sweep02.py
index ac389418b7e..767c4bc2c0c 100644
--- a/test/suite/test_sweep02.py
+++ b/test/suite/test_sweep02.py
@@ -31,7 +31,6 @@
#
import wiredtiger, wttest
-from wiredtiger import wiredtiger_open
from wttest import unittest
class test_sweep02(wttest.WiredTigerTestCase):
@@ -49,23 +48,23 @@ class test_sweep02(wttest.WiredTigerTestCase):
return None
def test_config01(self):
- self.conn = wiredtiger_open(self.dir,
+ self.conn = self.wiredtiger_open(self.dir,
self.base_config + "file_manager=()")
def test_config02(self):
- self.conn = wiredtiger_open(self.dir,
+ self.conn = self.wiredtiger_open(self.dir,
self.base_config + "file_manager=(close_scan_interval=1)")
def test_config03(self):
- self.conn = wiredtiger_open(self.dir,
+ self.conn = self.wiredtiger_open(self.dir,
self.base_config + "file_manager=(close_idle_time=1)")
def test_config04(self):
- self.conn = wiredtiger_open(self.dir,
+ self.conn = self.wiredtiger_open(self.dir,
self.base_config + "file_manager=(close_handle_minimum=500)")
def test_config05(self):
- self.conn = wiredtiger_open(self.dir, self.base_config + \
+ self.conn = self.wiredtiger_open(self.dir, self.base_config + \
"file_manager=(close_scan_interval=1,close_idle_time=1)")
if __name__ == '__main__':
diff --git a/test/suite/test_sweep03.py b/test/suite/test_sweep03.py
index 684c87695c5..30051dcce1e 100644
--- a/test/suite/test_sweep03.py
+++ b/test/suite/test_sweep03.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -41,6 +41,9 @@ class test_sweep03(wttest.WiredTigerTestCase, suite_subprocess):
uri = 'table:' + tablebase
numfiles = 400 # Make this more than the default close_handle_minimum
numkv = 100
+ conn_config = 'file_manager=(close_handle_minimum=10,' + \
+ 'close_idle_time=0,close_scan_interval=1),' + \
+ 'statistics=(fast),'
types = [
('row', dict(tabletype='row',
@@ -53,24 +56,6 @@ class test_sweep03(wttest.WiredTigerTestCase, suite_subprocess):
scenarios = types
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- self.home = dir
-
- conn_params = \
- ',create,error_prefix="%s: ",' % self.shortid() + \
- 'file_manager=(close_handle_minimum=10,' + \
- 'close_idle_time=0,close_scan_interval=1),' + \
- 'statistics=(fast),'
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except wiredtiger.WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- self.session2 = conn.open_session()
- return conn
-
def test_disable_idle_timeout1(self):
#
# Set up numfiles with numkv entries. We just want some data in there
diff --git a/test/suite/test_txn01.py b/test/suite/test_txn01.py
index cbb771273a6..37f3d132dd3 100644
--- a/test/suite/test_txn01.py
+++ b/test/suite/test_txn01.py
@@ -42,13 +42,6 @@ class test_txn01(wttest.WiredTigerTestCase):
('row-t', dict(uri='table:text_txn01',key_format='S',value_format='S')),
])
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir, 'create,' +
- ('error_prefix="%s: ",' % self.shortid()))
- self.pr(`conn`)
- return conn
-
# Return the number of records visible to the cursor.
def cursor_count(self, cursor):
count = 0
diff --git a/test/suite/test_txn02.py b/test/suite/test_txn02.py
index 17d0b97b50f..06c012a2986 100644
--- a/test/suite/test_txn02.py
+++ b/test/suite/test_txn02.py
@@ -32,7 +32,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -119,7 +118,7 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess):
'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)
+ conn = self.wiredtiger_open(dir, conn_params)
self.pr(`conn`)
self.session2 = conn.open_session()
return conn
@@ -154,7 +153,7 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess):
# recovery and see the committed results.
self.backup(self.backup_dir)
backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
finally:
@@ -178,7 +177,8 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess):
endcount = 2
count = 0
while count < endcount:
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir,
+ backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
finally:
diff --git a/test/suite/test_txn03.py b/test/suite/test_txn03.py
index e2efef1742e..b2926618278 100644
--- a/test/suite/test_txn03.py
+++ b/test/suite/test_txn03.py
@@ -46,13 +46,6 @@ class test_txn03(wttest.WiredTigerTestCase):
('var', dict(create_params = "key_format=S,value_format=S")),
])
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir, 'create,' +
- ('error_prefix="%s: ",' % self.shortid()))
- self.pr(`conn`)
- return conn
-
def test_ops(self):
self.session.create(self.uri1, self.create_params)
self.session.create(self.uri2, self.create_params)
diff --git a/test/suite/test_txn04.py b/test/suite/test_txn04.py
index f9f660223da..cc3f1f2aec0 100644
--- a/test/suite/test_txn04.py
+++ b/test/suite/test_txn04.py
@@ -32,7 +32,6 @@
import shutil, os
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios
import wttest
@@ -78,7 +77,7 @@ class test_txn04(wttest.WiredTigerTestCase, suite_subprocess):
'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)
+ conn = self.wiredtiger_open(dir, conn_params)
self.pr(`conn`)
self.session2 = conn.open_session()
return conn
@@ -124,7 +123,7 @@ class test_txn04(wttest.WiredTigerTestCase, suite_subprocess):
self.runWt(cmd.split())
self.exception='false'
backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
except:
diff --git a/test/suite/test_txn05.py b/test/suite/test_txn05.py
index d427b893b17..a4e0c0bc189 100644
--- a/test/suite/test_txn05.py
+++ b/test/suite/test_txn05.py
@@ -32,7 +32,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios
import wttest
@@ -79,7 +78,7 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess):
'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)
+ conn = self.wiredtiger_open(dir, conn_params)
self.pr(`conn`)
self.session2 = conn.open_session()
return conn
@@ -114,7 +113,7 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess):
# recovery and see the committed results.
self.backup(self.backup_dir)
backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
finally:
@@ -138,7 +137,8 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess):
endcount = 2
count = 0
while count < endcount:
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir,
+ backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
finally:
diff --git a/test/suite/test_txn07.py b/test/suite/test_txn07.py
index fa522582a8e..3bf5463782b 100644
--- a/test/suite/test_txn07.py
+++ b/test/suite/test_txn07.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import multiply_scenarios, number_scenarios
import wttest
@@ -90,7 +90,7 @@ class test_txn07(wttest.WiredTigerTestCase, suite_subprocess):
'transaction_sync="%s",' % self.txn_sync
# print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
try:
- conn = wiredtiger_open(dir, conn_params)
+ conn = self.wiredtiger_open(dir, conn_params)
except wiredtiger.WiredTigerError as e:
print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
self.pr(`conn`)
@@ -142,7 +142,7 @@ class test_txn07(wttest.WiredTigerTestCase, suite_subprocess):
backup_conn_params = 'log=(enabled,file_max=%s,' % self.logmax + \
'compressor=%s)' % self.compress + \
self.extensionArg(self.compress)
- backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params)
+ backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params)
try:
self.check(backup_conn.open_session(), None, committed)
finally:
diff --git a/test/suite/test_txn08.py b/test/suite/test_txn08.py
index d35a0c70b3b..218e80c0379 100644
--- a/test/suite/test_txn08.py
+++ b/test/suite/test_txn08.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import multiply_scenarios, number_scenarios
import wttest
@@ -41,24 +41,9 @@ class test_txn08(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_txn08'
uri = 'table:' + tablename
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- self.home = dir
- # Cycle through the different transaction_sync values in a
- # deterministic manner.
- self.txn_sync = '(method=dsync,enabled)'
- conn_params = \
- 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \
- ',create,error_prefix="%s: ",' % self.shortid() + \
- 'transaction_sync="%s",' % self.txn_sync
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except wiredtiger.WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- self.session2 = conn.open_session()
- return conn
+ conn_config = lambda self, dir: \
+ 'log=(archive=false,enabled,file_max=%s),' % self.logmax + \
+ 'transaction_sync="(method=dsync,enabled)"'
def test_printlog_unicode(self):
# print "Creating %s with config '%s'" % (self.uri, self.create_params)
diff --git a/test/suite/test_txn09.py b/test/suite/test_txn09.py
index df085a75d67..2885f60ba44 100644
--- a/test/suite/test_txn09.py
+++ b/test/suite/test_txn09.py
@@ -32,7 +32,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -91,7 +90,7 @@ class test_txn09(wttest.WiredTigerTestCase, suite_subprocess):
'transaction_sync=(enabled=false),'
# print "Opening conn at '%s' with config '%s'" % (dir, conn_params)
- conn = wiredtiger_open(dir, conn_params)
+ conn = self.wiredtiger_open(dir, conn_params)
self.pr(`conn`)
self.session2 = conn.open_session()
return conn
diff --git a/test/suite/test_txn10.py b/test/suite/test_txn10.py
index 49ef2b10abe..0d808e2f7da 100644
--- a/test/suite/test_txn10.py
+++ b/test/suite/test_txn10.py
@@ -32,7 +32,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -40,13 +39,8 @@ class test_txn10(wttest.WiredTigerTestCase, suite_subprocess):
t1 = 'table:test_txn10_1'
t2 = 'table:test_txn10_2'
create_params = 'key_format=i,value_format=i'
-
- # Overrides WiredTigerTestCase, add extra config params
- def setUpConnectionOpen(self, dir):
- self.conn_config = \
- 'log=(archive=false,enabled,file_max=100K),' + \
+ conn_config = 'log=(archive=false,enabled,file_max=100K),' + \
'transaction_sync=(method=dsync,enabled)'
- return wttest.WiredTigerTestCase.setUpConnectionOpen(self, dir)
def simulate_crash_restart(self, olddir, newdir):
''' Simulate a crash from olddir and restart in newdir. '''
diff --git a/test/suite/test_txn11.py b/test/suite/test_txn11.py
index b97df689905..b8da7859306 100644
--- a/test/suite/test_txn11.py
+++ b/test/suite/test_txn11.py
@@ -32,7 +32,6 @@
import fnmatch, os, time
from suite_subprocess import suite_subprocess
from helper import simple_populate
-from wiredtiger import wiredtiger_open
import wttest
class test_txn11(wttest.WiredTigerTestCase, suite_subprocess):
@@ -44,15 +43,10 @@ class test_txn11(wttest.WiredTigerTestCase, suite_subprocess):
source_uri = 'table:' + tablename + "_src"
uri = 'table:' + tablename
- 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) + \
+ conn_config = lambda self, dir: \
+ 'log=(archive=%s,' % self.archive + \
+ 'enabled,file_max=%s,prealloc=false),' % self.logmax + \
'transaction_sync=(enabled=false),'
- conn = wiredtiger_open(dir, conn_params)
- self.pr(`conn`)
- return conn
def run_checkpoints(self):
orig_logs = fnmatch.filter(os.listdir(self.home), "*Log*")
diff --git a/test/suite/test_txn13.py b/test/suite/test_txn13.py
index d60fee65bce..060ba17b212 100644
--- a/test/suite/test_txn13.py
+++ b/test/suite/test_txn13.py
@@ -33,7 +33,6 @@
#import fnmatch, os, shutil, run, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import check_scenarios
import wiredtiger, wttest
@@ -50,19 +49,9 @@ class test_txn13(wttest.WiredTigerTestCase, suite_subprocess):
('4gb', dict(expect_err=True, valuesize=4194304))
])
- # Overrides WiredTigerTestCase
- def setUpConnectionOpen(self, dir):
- self.home = dir
- conn_params = \
- 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \
- ',create,cache_size=8G,error_prefix="%s: ",' % self.shortid()
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- try:
- conn = wiredtiger_open(dir, conn_params)
- except wiredtiger.WiredTigerError as e:
- print "Failed conn at '%s' with config '%s'" % (dir, conn_params)
- self.pr(`conn`)
- return conn
+ conn_config = lambda self, dir: \
+ 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \
+ ',cache_size=8G'
@wttest.longtest('txn tests with huge values')
def test_large_values(self):
diff --git a/test/suite/test_txn14.py b/test/suite/test_txn14.py
index a126f843768..f49bdc3a618 100644
--- a/test/suite/test_txn14.py
+++ b/test/suite/test_txn14.py
@@ -32,7 +32,6 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -41,6 +40,7 @@ class test_txn14(wttest.WiredTigerTestCase, suite_subprocess):
create_params = 'key_format=i,value_format=i'
entries = 10000
extra_entries = 5
+ conn_config = 'log=(archive=false,enabled,file_max=100K)'
sync_list = [
('write', dict(sync='off')),
@@ -49,11 +49,6 @@ class test_txn14(wttest.WiredTigerTestCase, suite_subprocess):
]
scenarios = multiply_scenarios('.', sync_list)
- # Overrides WiredTigerTestCase, add extra config params
- def setUpConnectionOpen(self, dir):
- self.conn_config = 'log=(archive=false,enabled,file_max=100K),'
- return wttest.WiredTigerTestCase.setUpConnectionOpen(self, dir)
-
def simulate_crash_restart(self, olddir, newdir):
''' Simulate a crash from olddir and restart in newdir. '''
# with the connection still open, copy files to new directory
diff --git a/test/suite/test_txn15.py b/test/suite/test_txn15.py
index e36e8556d1e..9e9906a5fe5 100644
--- a/test/suite/test_txn15.py
+++ b/test/suite/test_txn15.py
@@ -32,7 +32,7 @@
import fnmatch, os, shutil, time
from suite_subprocess import suite_subprocess
-from wiredtiger import wiredtiger_open, stat
+from wiredtiger import stat
from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios
import wttest
@@ -40,6 +40,12 @@ class test_txn15(wttest.WiredTigerTestCase, suite_subprocess):
uri = 'table:test_txn15_1'
create_params = 'key_format=i,value_format=i'
entries = 100
+ conn_config = lambda self, dir: \
+ 'statistics=(fast),' + \
+ 'log=(archive=false,enabled,file_max=100K),' + \
+ 'use_environment=false,' + \
+ 'transaction_sync=(enabled=%s),' % self.conn_enable + \
+ 'transaction_sync=(method=%s),' % self.conn_method
conn_sync_enabled = [
('en_off', dict(conn_enable='false')),
@@ -67,23 +73,6 @@ class test_txn15(wttest.WiredTigerTestCase, suite_subprocess):
scenarios = multiply_scenarios('.', conn_sync_enabled, conn_sync_method,
begin_sync, commit_sync)
- # Overrides WiredTigerTestCase, add extra config params
- def setUpConnectionOpen(self, dir):
- self.home = dir
- #
- # Turn off using any environment variables that may be set by the
- # testing infrastructure.
- #
- conn_params = \
- 'create,statistics=(fast),error_prefix="%s: ",' % self.shortid() + \
- 'log=(archive=false,enabled,file_max=100K),' + \
- 'use_environment=false,' + \
- 'transaction_sync=(enabled=%s),' % self.conn_enable + \
- 'transaction_sync=(method=%s),' % self.conn_method
- # print "Creating conn at '%s' with config '%s'" % (dir, conn_params)
- conn = wiredtiger_open(dir, conn_params)
- return conn
-
# Given the different configuration settings determine if this group
# of settings would result in either a wait for write or sync.
# Returns None, "write" or "sync". None means no waiting for either.
diff --git a/test/suite/wttest.py b/test/suite/wttest.py
index 443fabb00b2..906e1418328 100644
--- a/test/suite/wttest.py
+++ b/test/suite/wttest.py
@@ -135,9 +135,31 @@ class CapturedFd(object):
self.expectpos = os.path.getsize(self.filename)
+class TestSuiteConnection(object):
+ def __init__(self, conn, connlist):
+ connlist.append(conn)
+ self._conn = conn
+ self._connlist = connlist
+
+ def close(self):
+ self._connlist.remove(self._conn)
+ return self._conn.close()
+
+ # Proxy everything except what we explicitly define to the
+ # wrapped connection
+ def __getattr__(self, attr):
+ if attr in self.__dict__:
+ return getattr(self, attr)
+ else:
+ return getattr(self._conn, attr)
+
+
class WiredTigerTestCase(unittest.TestCase):
_globalSetup = False
_printOnceSeen = {}
+
+ # conn_config can be overridden to add to basic connection configuration.
+ # Can be a string or a callable function or lambda expression.
conn_config = ''
@staticmethod
@@ -198,13 +220,32 @@ class WiredTigerTestCase(unittest.TestCase):
return "%s.%s.%s" % (self.__module__,
self.className(), self._testMethodName)
- # Can be overridden
- def setUpConnectionOpen(self, dir):
- conn = wiredtiger.wiredtiger_open(dir,
- 'create,error_prefix="%s",%s' % (self.shortid(), self.conn_config))
+ # Can be overridden, but first consider setting self.conn_config .
+ def setUpConnectionOpen(self, home):
+ self.home = home
+ config = self.conn_config
+ if hasattr(config, '__call__'):
+ config = config(home)
+ # In case the open starts additional threads, flush first to
+ # avoid confusion.
+ sys.stdout.flush()
+ conn_param = 'create,error_prefix="%s: ",%s' % (self.shortid(), config)
+ try:
+ conn = self.wiredtiger_open(home, conn_param)
+ except wiredtiger.WiredTigerError as e:
+ print "Failed wiredtiger_open: dir '%s', config '%s'" % \
+ (home, conn_param)
+ raise e
self.pr(`conn`)
return conn
+ # Replacement for wiredtiger.wiredtiger_open that returns
+ # a proxied connection that knows to close it itself at the
+ # end of the run, unless it was already closed.
+ def wiredtiger_open(self, home=None, config=''):
+ conn = wiredtiger.wiredtiger_open(home, config)
+ return TestSuiteConnection(conn, self._connections)
+
# Can be overridden
def setUpSessionOpen(self, conn):
return conn.open_session(None)
@@ -244,6 +285,8 @@ class WiredTigerTestCase(unittest.TestCase):
self.__class__.wt_ntests += 1
if WiredTigerTestCase._verbose > 2:
self.prhead('started in ' + self.testdir, True)
+ # tearDown needs connections list, set it here in case the open fails.
+ self._connections = []
self.origcwd = os.getcwd()
shutil.rmtree(self.testdir, ignore_errors=True)
if os.path.exists(self.testdir):
@@ -269,10 +312,18 @@ class WiredTigerTestCase(unittest.TestCase):
skipped = (excinfo[0] == unittest.SkipTest)
self.pr('finishing')
- try:
- self.close_conn()
- except:
- pass
+ # Close all connections that weren't explicitly closed.
+ # Connections left open (as a result of a test failure)
+ # can result in cascading errors. We also make sure
+ # self.conn is on the list of active connections.
+ if not self.conn in self._connections:
+ self._connections.append(self.conn)
+ for conn in self._connections:
+ try:
+ conn.close()
+ except:
+ pass
+ self._connections = []
try:
self.fdTearDown()
diff --git a/test/suite/wtthread.py b/test/suite/wtthread.py
index 33c5c61e00f..7f447e36038 100644
--- a/test/suite/wtthread.py
+++ b/test/suite/wtthread.py
@@ -70,30 +70,35 @@ class backup_thread(threading.Thread):
cursor.close()
- 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)
+ 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 - but need to be a wttest to
- # do that..
- if not compare_tables(
+ # 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")
+ 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")
- bkp_conn.close()
+ 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()