• Carlos Ramos Carreño's avatar
    Fix `bytes`/`str` in wcfs test. · af56bd31
    Carlos Ramos Carreño authored
    The usage of `bytes` and `str` in the wcfs test was not consistent,
    producing comparisons between `bytes` and `str` as well as errors such
    as:
    
    ```python
    ___________________________________________________________________ test_wcfs_crash_old_data ___________________________________________________________________
    
        @func
        def test_wcfs_crash_old_data():
            # start wcfs with ΔFtail/ΔBtail not covering initial data.
            t = tDB(old_data=[{0:'a'}]); zf = t.zfile; at1 = t.head
            defer(t.close)
    
            f = t.open(zf)
    
            # ΔFtail coverage is currently (at1,at1]
            wl = t.openwatch()
            wl.watch(zf, at1, {})
    
            # wcfs was crashing on readPinWatcher -> ΔFtail.BlkRevAt with
            #   "at out of bounds: at: @at1,  (tail,head] = (@at1,@at1]
            # because BlkRevAt(at=tail) query was disallowed.
    >       f.assertBlk(0, 'a')          # [0] becomes tracked
    
    wcfs/wcfs_test.py:1844:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    ../../venvs/wendelin.core/lib/python3.9/site-packages/decorator.py:232: in fun
        return caller(func, *(extras + args), **kw)
    ../pygolang/golang/__init__.py:125: in _
        return f(*argv, **kw)
    wcfs/wcfs_test.py:721: in assertBlk
        t._assertBlk(blk, dataok, pinokByWLink)
    ../../venvs/wendelin.core/lib/python3.9/site-packages/decorator.py:232: in fun
        return caller(func, *(extras + args), **kw)
    ../pygolang/golang/__init__.py:125: in _
        return f(*argv, **kw)
    wcfs/wcfs_test.py:810: in _assertBlk
        ev = doCheckingPin(_, pinokByWLink, pinfunc)
    wcfs/wcfs_test.py:1091: in doCheckingPin
        wg.wait()
    golang/_sync.pyx:246: in golang._sync.PyWorkGroup.wait
        ???
    golang/_sync.pyx:226: in golang._sync.PyWorkGroup.go.pyrunf
        ???
    wcfs/wcfs_test.py:1085: in _
        f(ctx, ev)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    ctx = <golang._context.PyContext object at 0x7fec13e76280>, ev = ['read pre']
    
        def _(ctx, ev):
            assert t.cached()[blk] == cached
            ev.append('read pre')
    
            # access data with released GIL so that the thread that reads data from
            # head/watch can receive pin message. Be careful to handle cancellation,
            # so that on error in another worker we don't get stuck and the
            # error can be propagated to wait and reported.
            #
            # we handle cancellation by spawning read in another thread and
            # waiting for either ctx cancel, or read thread to complete. This
            # way on ctx cancel (e.g. assertion failure in another worker), the
            # read thread can remain running even after _assertBlk returns, and
            # in particular till the point where the whole test is marked as
            # failed and shut down. But on test shutdown .fmmap is unmapped for
            # all opened tFiles, and so read will hit SIGSEGV. Prepare to catch
            # that SIGSEGV here.
            have_read = chan(1)
            def _():
                try:
                    b = read_exfault_nogil(blkview[0:1])
                except SegmentationFault:
                    b = 'FAULT'
                t._blkaccess(blk)
                have_read.send(b)
            go(_)
            _, _rx = select(
                ctx.done().recv,    # 0
                have_read.recv,     # 1
            )
            if _ == 0:
                raise ctx.err()
            b = _rx
    
    >       ev.append('read ' + b)
    E       TypeError: can only concatenate str (not "bytes") to str
    ```
    
    I have changed `bytes` and `str` where necessary to make tests pass.
    af56bd31
wcfs_test.py 68.5 KB