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