summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-12-11 16:06:51 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-12-11 16:06:51 +1100
commit58780d223d9462ad2bf1b43c39a68bb242a681a1 (patch)
treec52527081875a744eadea7847759f8e060d42262
parent500c7e17ff813ba33f198f5c19bd13469b900280 (diff)
downloadmongo-58780d223d9462ad2bf1b43c39a68bb242a681a1.tar.gz
In the test suite, when checking that a data source is correctly populated,
include a check on the number of rows. Normalize to creating the specified number of rows, rather than one less.
-rw-r--r--test/suite/helper.py25
-rw-r--r--test/suite/test_backup.py4
-rw-r--r--test/suite/test_dump.py14
-rw-r--r--test/suite/test_rename.py4
-rw-r--r--test/suite/test_truncate01.py2
-rw-r--r--test/suite/test_truncate02.py15
6 files changed, 32 insertions, 32 deletions
diff --git a/test/suite/helper.py b/test/suite/helper.py
index 1fb28024392..728782a3297 100644
--- a/test/suite/helper.py
+++ b/test/suite/helper.py
@@ -131,13 +131,13 @@ def simple_populate(self, uri, config, rows):
self.pr('simple_populate: ' + uri + ' with ' + str(rows) + ' rows')
self.session.create(uri, 'value_format=S,' + config)
cursor = self.session.open_cursor(uri, None)
- for i in range(1, rows):
+ for i in range(1, rows + 1):
cursor.set_key(key_populate(cursor, i))
cursor.set_value(value_populate(cursor, i))
cursor.insert()
cursor.close()
-def simple_populate_check_cursor(self, cursor):
+def simple_populate_check_cursor(self, cursor, rows):
i = 0
for key,val in cursor:
i += 1
@@ -145,19 +145,19 @@ def simple_populate_check_cursor(self, cursor):
if cursor.value_format == '8t' and val == 0: # deleted
continue
self.assertEqual(val, value_populate(cursor, i))
+ self.assertEqual(i, rows)
-def simple_populate_check(self, uri):
+def simple_populate_check(self, uri, rows):
self.pr('simple_populate_check: ' + uri)
cursor = self.session.open_cursor(uri, None)
- simple_populate_check_cursor(self, cursor)
+ simple_populate_check_cursor(self, cursor, rows)
cursor.close()
# Return the value stored in a complex object.
def value_populate_complex(i):
- return [\
- str(i) + ': abcdefghijklmnopqrstuvwxyz'[0:i%26],\
- i,\
- str(i) + ': abcdefghijklmnopqrstuvwxyz'[0:i%23],\
+ return [str(i) + ': abcdefghijklmnopqrstuvwxyz'[0:i%26],
+ i,
+ str(i) + ': abcdefghijklmnopqrstuvwxyz'[0:i%23],
str(i) + ': abcdefghijklmnopqrstuvwxyz'[0:i%18]]
# population of a complex object
@@ -186,14 +186,14 @@ def complex_populate(self, uri, config, rows):
self.session.create(
indxname + ':indx6', 'columns=(column3,column5,column4)')
cursor = self.session.open_cursor(uri, None)
- for i in range(1, rows):
+ for i in range(1, rows + 1):
cursor.set_key(key_populate(cursor, i))
v = value_populate_complex(i)
cursor.set_value(v[0], v[1], v[2], v[3])
cursor.insert()
cursor.close()
-def complex_populate_check_cursor(self, cursor):
+def complex_populate_check_cursor(self, cursor, rows):
i = 0
for key, s1, i2, s3, s4 in cursor:
i += 1
@@ -203,9 +203,10 @@ def complex_populate_check_cursor(self, cursor):
self.assertEqual(i2, v[1])
self.assertEqual(s3, v[2])
self.assertEqual(s4, v[3])
+ self.assertEqual(i, rows)
-def complex_populate_check(self, uri):
+def complex_populate_check(self, uri, rows):
self.pr('complex_populate_check: ' + uri)
cursor = self.session.open_cursor(uri, None)
- complex_populate_check_cursor(self, cursor)
+ complex_populate_check_cursor(self, cursor, rows)
cursor.close()
diff --git a/test/suite/test_backup.py b/test/suite/test_backup.py
index 95903ad3064..59407c3d5ee 100644
--- a/test/suite/test_backup.py
+++ b/test/suite/test_backup.py
@@ -31,9 +31,7 @@ import shutil
import string
from suite_subprocess import suite_subprocess
import wiredtiger, wttest
-from helper import compare_files, confirm_does_not_exist,\
- complex_populate, complex_populate_check,\
- simple_populate, simple_populate_check
+from helper import compare_files, complex_populate, simple_populate
# test_backup.py
# Utilities: wt backup
diff --git a/test/suite/test_dump.py b/test/suite/test_dump.py
index b6aef26ec1f..9968b2c7568 100644
--- a/test/suite/test_dump.py
+++ b/test/suite/test_dump.py
@@ -54,14 +54,14 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess):
]
types = [
('file', dict(type='file:',
- populate=simple_populate,
- populate_check=simple_populate_check_cursor)),
+ populate=simple_populate,
+ populate_check=simple_populate_check_cursor)),
('table-simple', dict(type='table:',
- populate=simple_populate,
- populate_check=simple_populate_check_cursor)),
+ populate=simple_populate,
+ populate_check=simple_populate_check_cursor)),
('table-complex', dict(type='table:',
- populate=complex_populate,
- populate_check=complex_populate_check_cursor))
+ populate=complex_populate,
+ populate_check=complex_populate_check_cursor))
]
scenarios = number_scenarios(
multiply_scenarios('.', types, keyfmt, dumpfmt))
@@ -84,7 +84,7 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess):
conn = wiredtiger.wiredtiger_open(self.dir)
session = conn.open_session()
cursor = session.open_cursor(uri, None, None)
- self.populate_check(self, cursor)
+ self.populate_check(self, cursor, self.nentries)
conn.close()
diff --git a/test/suite/test_rename.py b/test/suite/test_rename.py
index 08a39174657..8f33100ebfa 100644
--- a/test/suite/test_rename.py
+++ b/test/suite/test_rename.py
@@ -58,11 +58,11 @@ class test_rename(wttest.WiredTigerTestCase):
self.session.rename(uri1, uri2, None)
confirm_does_not_exist(self, uri1)
- check(self, uri2)
+ check(self, uri2, 10)
self.session.rename(uri2, uri1, None)
confirm_does_not_exist(self, uri2)
- check(self, uri1)
+ check(self, uri1, 10)
self.session.drop(uri1)
diff --git a/test/suite/test_truncate01.py b/test/suite/test_truncate01.py
index 79c741b3c9e..7361a215e86 100644
--- a/test/suite/test_truncate01.py
+++ b/test/suite/test_truncate01.py
@@ -431,7 +431,7 @@ class test_truncate_cursor(wttest.WiredTigerTestCase):
# Create the object.
complex_populate(
- self, uri, self.config + self.keyfmt, self.nentries + 1)
+ self, uri, self.config + self.keyfmt, self.nentries)
# Build a dictionary of what the object should look like for
# later comparison
diff --git a/test/suite/test_truncate02.py b/test/suite/test_truncate02.py
index eb0f0b9efba..ee4fe758e5a 100644
--- a/test/suite/test_truncate02.py
+++ b/test/suite/test_truncate02.py
@@ -176,17 +176,18 @@ class test_truncate_fast_delete(wttest.WiredTigerTestCase):
cursor.close()
# A cursor involved in the transaction should see the deleted records.
- # The number 18 comes from deleting row 10 (inclusive), to row N - 10,
- # inclusive, or 9 + 9 == 18.
+ # The number 19 comes from deleting row 10 (inclusive), to row N - 10,
+ # exclusive, or 9 + 10 == 19.
+ remaining = 19
cursor = self.session.open_cursor(uri, None)
- self.cursor_count(cursor, 18)
+ self.cursor_count(cursor, remaining)
cursor.close()
# A separate, read_committed cursor should not see the deleted records.
- self.outside_count("isolation=read-committed", self.nentries - 1)
+ self.outside_count("isolation=read-committed", self.nentries)
# A separate, read_uncommitted cursor should see the deleted records.
- self.outside_count("isolation=read-uncommitted", 18)
+ self.outside_count("isolation=read-uncommitted", remaining)
# Commit/rollback the transaction.
if self.commit:
@@ -197,9 +198,9 @@ class test_truncate_fast_delete(wttest.WiredTigerTestCase):
# Check a read_committed cursor sees the right records.
cursor = self.session.open_cursor(uri, None)
if self.commit:
- self.cursor_count(cursor, 18)
+ self.cursor_count(cursor, remaining)
else:
- self.cursor_count(cursor, self.nentries -1)
+ self.cursor_count(cursor, self.nentries)
cursor.close()