[Zodb-checkins]
SVN: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/packing.txt
- Fix timing issues with packing test on windows.
Christian Theune
ct at gocept.com
Wed Nov 29 09:54:24 EST 2006
Log message for revision 71329:
- Fix timing issues with packing test on windows.
Changed:
U ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/packing.txt
-=-
Modified: ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/packing.txt
===================================================================
--- ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/packing.txt 2006-11-29 09:50:45 UTC (rev 71328)
+++ ZODB/branches/blob-merge-branch/src/ZODB/Blobs/tests/packing.txt 2006-11-29 14:54:23 UTC (rev 71329)
@@ -30,15 +30,28 @@
>>> storagefile = mktemp()
>>> blob_dir = mkdtemp()
+A helper method to assure a unique timestamp across multiple platforms. This
+method also makes sure that after retrieving a timestamp that was *before* a
+transaction was committed, that at least one second passes so the packing time
+actually is before the commit time.
+
+ >>> import time
+ >>> def new_time():
+ ... now = new_time = time.time()
+ ... while new_time <= now:
+ ... new_time = time.time()
+ ... time.sleep(1)
+ ... return new_time
+
UNDOING
=======
-We need an database with an undoing blob supporting storage:
+We need a database with an undoing blob supporting storage:
>>> base_storage = FileStorage(storagefile)
>>> blob_storage = BlobStorage(blob_dir, base_storage)
>>> database = DB(blob_storage)
-
+
Create our root object:
>>> connection1 = database.open()
@@ -46,11 +59,11 @@
Put some revisions of a blob object in our database and on the filesystem:
- >>> import time, os
+ >>> import os
>>> tids = []
>>> times = []
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> blob = Blob()
>>> blob.open('w').write('this is blob data 0')
>>> root['blob'] = blob
@@ -58,25 +71,25 @@
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 1')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 2')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 3')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 4')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
@@ -86,10 +99,6 @@
>>> [ os.path.exists(x) for x in fns ]
[True, True, True, True, True]
-Get our blob filenames for this oid.
-
- >>> fns = [ blob_storage.fshelper.getBlobFilename(oid, x) for x in tids ]
-
Do a pack to the slightly before the first revision was written:
>>> packtime = times[0]
@@ -127,7 +136,7 @@
Do a pack to now:
- >>> packtime = time.time()
+ >>> packtime = new_time()
>>> blob_storage.pack(packtime, referencesf)
>>> [ os.path.exists(x) for x in fns ]
[False, False, False, False, True]
@@ -138,7 +147,7 @@
>>> nothing = transaction.begin()
>>> del root['blob']
>>> transaction.commit()
- >>> packtime = time.time()
+ >>> packtime = new_time()
>>> blob_storage.pack(packtime, referencesf)
>>> [ os.path.exists(x) for x in fns ]
[False, False, False, False, False]
@@ -174,7 +183,7 @@
>>> tids = []
>>> times = []
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> blob = Blob()
>>> blob.open('w').write('this is blob data 0')
>>> root['blob'] = blob
@@ -182,25 +191,25 @@
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 1')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 2')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 3')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
>>> nothing = transaction.begin()
- >>> times.append(time.time())
+ >>> times.append(new_time())
>>> root['blob'].open('w').write('this is blob data 4')
>>> transaction.commit()
>>> tids.append(blob_storage._tid)
@@ -223,7 +232,7 @@
Do a pack to now:
- >>> packtime = time.time()
+ >>> packtime = new_time()
>>> blob_storage.pack(packtime, referencesf)
>>> [ os.path.exists(x) for x in fns ]
[False, False, False, False, True]
@@ -234,7 +243,7 @@
>>> nothing = transaction.begin()
>>> del root['blob']
>>> transaction.commit()
- >>> packtime = time.time()
+ >>> packtime = new_time()
>>> blob_storage.pack(packtime, referencesf)
>>> [ os.path.exists(x) for x in fns ]
[False, False, False, False, False]
More information about the Zodb-checkins
mailing list