• Kirill Smelkov's avatar
    tests: Add test for load vs external invalidation race · e923c9a8
    Kirill Smelkov authored
    For ZEO this data corruption bug was reported at
    https://github.com/zopefoundation/ZEO/issues/155 and fixed at
    https://github.com/zopefoundation/ZEO/pull/169.
    
    Without that fix the failure shows e.g. as follows when running ZEO test
    suite:
    
        Failure in test check_race_load_vs_external_invalidate (ZEO.tests.testZEO.BlobAdaptedFileStorageTests)
        Traceback (most recent call last):
          File "/usr/lib/python2.7/unittest/case.py", line 329, in run
            testMethod()
          File "/home/kirr/src/wendelin/z/ZODB/src/ZODB/tests/BasicStorage.py", line 621, in check_race_load_vs_external_invalidate
            self.fail([_ for _ in failure if _])
          File "/usr/lib/python2.7/unittest/case.py", line 410, in fail
            raise self.failureException(msg)
        AssertionError: ['T1: obj1.value (7)  !=  obj2.value (8)']
    
    Even if added test is somewhat similar to
    check_race_loadopen_vs_local_invalidate, it is added anew without trying
    to unify code. The reason here is that the probability to catch load vs
    external invalidation race is significantly reduced when there are only
    1 modify and 1 verify workers. The unification with preserving both
    tests semantic would make test for "load vs local invalidate" harder to
    follow. Sometimes a little copying is better than trying to unify too
    much.
    
    For the test to work, test infrastructure is amended with
    ._new_storage_client() method that complements ._storage attribute:
    client-server storages like ZEO, NEO and RelStorage allow several
    storage clients to be connected to single storage server. For
    client-server storages test subclasses should implement
    _new_storage_client to return new storage client that is connected to
    the same storage server self._storage is connected to.
    
    For ZEO ._new_storage_client() is added by https://github.com/zopefoundation/ZEO/pull/170
    
    Other client-server storages can follow to implement ._new_storage_client()
    and this way automatically activate this "load vs external invalidation"
    test when their testsuite is run.
    
    Contrary to test for "load vs local invalidate" N is set to lower value (100),
    because with 8 workers the bug is usually reproduced at not-so-high iteration
    number (5-10-20).
    
    /cc @d-maurer, @jamadden, @jmuchemb
    /reviewed-on https://github.com/zopefoundation/ZODB/pull/345
    e923c9a8
BasicStorage.py 21.5 KB