• Kirill Smelkov's avatar
    test/gen_testdata: Generate transactions with both " " and "p" status · 1b480c93
    Kirill Smelkov authored
    Until now we were generating only regular transactions with " " status
    and this does not cover e.g. restore case when it needs to replicate
    packed transaction: instead of recreating it bit-to-bit exactly as
    original with "p" status, restore recreates it with " " status, breaking
    restore promise.
    
    Adjusting testdata this way exposes that bug in restore:
    
        ======================================== FAILURES ========================================
        ________________________________________ test_zodbrestore[!zext] ________________________________________
    
        tmpdir = local('/tmp/pytest-of-kirr/pytest-17/test_zodbrestore__zext_0'), zext = <function _ at 0x7fd6b7a03750>
    
            @func
            def test_zodbrestore(tmpdir, zext):
                zkind = '_!zext' if zext.disabled else ''
    
                # restore from testdata/1.zdump.ok and verify it gives result that is
                # bit-to-bit identical to testdata/1.fs
                tdata = dirname(__file__) + "/testdata"
                @func
                def _():
                    zdump = open("%s/1%s.zdump.raw.ok" % (tdata, zkind), 'rb')
                    defer(zdump.close)
    
                    stor = storageFromURL('%s/2.fs' % tmpdir)
                    defer(stor.close)
    
                    zodbrestore(stor, zdump)
                _()
    
                zfs1 = readfile(fs1_testdata_py23(tmpdir, "%s/1%s.fs" % (tdata, zkind)))
                zfs2 = readfile("%s/2.fs" % tmpdir)
        >       assert zfs1 == zfs2
        E       assert 'FS21\x02\x85...0\x00\x00\xb2' == 'FS21\x02\x85\...0\x00\x00\xb2'
        E         Skipping 49 identical leading characters in diff, use -v to show
        E         Skipping 22871 identical trailing characters in diff, use -v to show
        E         - 0\x00\x00tp\x00\x08\x00\t\x00\x00user0.15step 0.15\x00\x00\x00\x00\x00\x00\x00\x03\x02\x85\xcb\xac\x83i\xd0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x80\x02c__main__
        E         ?           ^
        E         + 0\x00\x00t \x00\x08\x00\t\x00\x00user0.15step 0.15\x00\x00\x00\x00\x00\x00\x00\x03\x02\x85\xcb\xac\x83i\xd0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00...
        E
        E         ...Full output truncated (39 lines hidden), use '-vv' to show
    
        test_restore.py:53: AssertionError
    
    Having "p" transactions in the testdata will also make sure that all tools
    should handle such transactions well.
    
    The problem of restore not handling "p" status properly was reported by Jérome
    at !24.
    
    In the next patch we will fix that problem.
    
    /reviewed-by @jerome
    /reviewed-on !24
    1b480c93