Commit ee942336 authored by Jim Fulton's avatar Jim Fulton Committed by GitHub

Merge pull request #65 from zopefoundation/winbot-failures

Fix winbot failures

Thanks
parents 53c31a5f 1e16897c
......@@ -17,7 +17,8 @@ Any storage that supports the history() method should be able to pass
all these tests.
"""
from time import time
import sys
from time import time, sleep
from ZODB.tests.MinPO import MinPO
class HistoryStorage:
......@@ -31,6 +32,9 @@ class HistoryStorage:
self.assertRaises(KeyError,self._storage.history,oid)
revids = [None]
for data in data:
if sys.platform == 'win32':
# time.time() has a precision of 1ms on Windows.
sleep(0.001)
revids.append(self._dostore(oid, revids[-1], MinPO(data)))
revids.reverse()
del revids[-1]
......
......@@ -70,6 +70,10 @@ weren't called when the transaction commited. None of the test suites
(ZODB's, Zope 2.8's, or Zope3's) caught that, but apparently Zope 3 takes this
path at some point when serving pages.
UPDATE: transaction 1.6.1 introduced a change that causes
newTransaction to be called when a synchronizer registeres with a
transaction manager with an active transaction.
>>> tm = transaction.ThreadTransactionManager()
>>> st.sync_called = False
>>> dummy = tm.begin() # we're doing this _before_ opening a connection
......@@ -77,7 +81,8 @@ path at some point when serving pages.
>>> rt = cn.root() # make a change
>>> rt['c'] = 3
>>> st.sync_called
False
True
>>> st.sync_called = False
Now ensure that ``cn.afterCompletion() -> st.sync()`` gets called by commit
despite that the `Connection` registered after the transaction began:
......@@ -96,7 +101,8 @@ And try the same thing with a non-threaded transaction manager:
>>> rt = cn.root() # make a change
>>> rt['d'] = 4
>>> st.sync_called
False
True
>>> st.sync_called = False
>>> tm.commit()
>>> st.sync_called
True
......
......@@ -15,6 +15,7 @@ import doctest
import os
if os.environ.get('USE_ZOPE_TESTING_DOCTEST'):
from zope.testing import doctest
import sys
import unittest
import transaction
import ZODB.FileStorage
......@@ -302,9 +303,18 @@ class FileStorageTests(
# is based on what was cached during the first load.
self.assertEqual(storage.load(z64)[0], b'foo' if fail else b'bar')
def checkFlushNeededAfterTruncate(self):
self._storage._files.flush = lambda: None
self.checkFlushAfterTruncate(True)
# We want to be sure that the above test detects any regression
# in the code it checks, because any bug here is like a time bomb: not
# obvious, hard to reproduce, with possible data corruption.
# It's even more important that FilePool.flush() is quite aggressive and
# we'd like to optimize it when Python gets an API to flush read buffers.
# Therefore, 'checkFlushAfterTruncate' is tested in turn by another unit
# test.
# On Windows, flushing explicitely is not (always?) necessary.
if sys.platform != 'win32':
def checkFlushNeededAfterTruncate(self):
self._storage._files.flush = lambda: None
self.checkFlushAfterTruncate(True)
class FileStorageHexTests(FileStorageTests):
......@@ -389,7 +399,7 @@ class AnalyzeDotPyTest(StorageTestBase.StorageTestBase):
self._storage = ZODB.FileStorage.FileStorage("Source.fs", create=True)
def checkanalyze(self):
import types, sys
import types
from BTrees.OOBTree import OOBTree
from ZODB.scripts import analyze
......
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