示例#1
0
def testEMCGetLayout(t, env):
    """Verify layout handling

    Debugging test that looks for pre-existing file (server2fs1/dump.eth)
    so we don't have to worry about creating a file.

    FLAGS: 
    CODE: GETLAYOUT100
    """
    sess = env.c1.new_pnfs_client_session(env.testname(t))
    blocksize = get_blocksize(sess, use_obj(env.opts.path))
    # Create the file
    file = ["server2fs1", "dump.eth"]
    res = open_file(sess, env.testname(t), file)
    check(res)
    # Get layout
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid
    stateid.seqid = 0
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_READ,
                        0, 0xffffffffffffffff, 4*blocksize, stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    # Parse opaque
    for layout in  res.resarray[-1].logr_layout:
        if layout.loc_type == LAYOUT4_BLOCK_VOLUME:
            p = BlockUnpacker(layout.loc_body)
            opaque = p.unpack_pnfs_block_layout4()
            p.done()
            print opaque
示例#2
0
def testReclaimAfterRECC(t, env):
    """If client does subsequent reclaims of locking state after
       RECLAIM_COMPLETE is done, server will return NFS4ERR_NO_GRACE.
       rfc5661 18.51.3

    FLAGS: reclaim_complete all
    CODE: RECC2
    """
    name = env.testname(t)
    c = env.c1.new_client(name)
    sess = c.create_session()

    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res)

    owner = "owner_%s" % name
    path = sess.c.homedir + [name]
    fh, stateid = create_confirm(sess, owner)

    # Try to reclaims a file which is noexist after RECLAIM_COMPLETE
    res = open_file(sess,
                    owner,
                    path=fh,
                    claim_type=CLAIM_PREVIOUS,
                    access=OPEN4_SHARE_ACCESS_BOTH,
                    deny=OPEN4_SHARE_DENY_NONE,
                    deleg_type=OPEN_DELEGATE_NONE)

    check(res,
          NFS4ERR_NO_GRACE,
          warnlist=[NFS4ERR_EXIST | NFS4ERR_RECLAIM_BAD])

    # Cleanup
    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
    check(res)
示例#3
0
def testReclaimAfterRECC(t, env):
    """If client does subsequent reclaims of locking state after
       RECLAIM_COMPLETE is done, server will return NFS4ERR_NO_GRACE.
       rfc5661 18.51.3

    FLAGS: reclaim_complete all
    CODE: RECC2
    """
    name = env.testname(t)
    c = env.c1.new_client(name)
    sess = c.create_session()

    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res)

    owner = "owner_%s" % name
    path = sess.c.homedir + [name]
    fh, stateid = create_confirm(sess, owner)

    # Try to reclaims a file which is noexist after RECLAIM_COMPLETE
    res = open_file(sess, owner, path=fh, claim_type=CLAIM_PREVIOUS,
                    access=OPEN4_SHARE_ACCESS_BOTH,
                    deny=OPEN4_SHARE_DENY_NONE,
                    deleg_type=OPEN_DELEGATE_NONE)

    check(res, NFS4ERR_NO_GRACE, warnlist = [NFS4ERR_EXIST | NFS4ERR_RECLAIM_BAD])

    # Cleanup
    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
    check(res)
示例#4
0
def testRebootValid(t, env):
    """REBOOT with valid CLAIM_PREVIOUS

    FLAGS: reboot
    DEPEND:
    CODE: REBT1
    """
    name = env.testname(t)
    owner = "owner_%s" % name
    c = env.c1.new_client(env.testname(t))
    sess = c.create_session()
    reclaim_complete(sess)
    fh, stateid = create_confirm(sess, owner)
    sleeptime = 5 + _getleasetime(sess)
    _waitForReboot(c, sess, env)
    try:
        res = create_session(c)
        check(res, NFS4ERR_STALE_CLIENTID, "Reclaim using old clientid")
        c = env.c1.new_client(env.testname(t))
        sess = c.create_session()
        newleasetime = _getleasetime(sess)
        sleeptime = max(sleeptime, 5 + newleasetime)
        res = open_file(sess,
                        owner,
                        path=fh,
                        claim_type=CLAIM_PREVIOUS,
                        access=OPEN4_SHARE_ACCESS_BOTH,
                        deny=OPEN4_SHARE_DENY_NONE,
                        deleg_type=OPEN_DELEGATE_NONE)
        check(res, msg="Reclaim using newly created clientid")
        reclaim_complete(sess)
    finally:
        env.sleep(sleeptime, "Waiting for grace period to end")
示例#5
0
文件: st_reboot.py 项目: mauser/pynfs
def testRebootValid(t, env):
    """REBOOT with valid CLAIM_PREVIOUS

    FLAGS: reboot
    DEPEND:
    CODE: REBT1
    """
    name = env.testname(t)
    owner = "owner_%s" % name
    c = env.c1.new_client(env.testname(t))
    sess = c.create_session()
    reclaim_complete(sess)
    fh, stateid = create_confirm(sess, owner)
    oldleasetime = _getleasetime(sess)
    _waitForReboot(c, sess, env)
    try:
        res = create_session(c)
        check(res, NFS4ERR_STALE_CLIENTID, "Reclaim using old clientid")
        c = env.c1.new_client(env.testname(t))
        sess = c.create_session()
        newleasetime = _getleasetime(sess)
        sleeptime = 5 + max(oldleasetime, newleasetime)
        res = open_file(sess, owner, path=fh, claim_type=CLAIM_PREVIOUS,
                       access=OPEN4_SHARE_ACCESS_BOTH,
                       deny=OPEN4_SHARE_DENY_NONE,
                       deleg_type=OPEN_DELEGATE_NONE)
        check(res, msg="Reclaim using newly created clientid")
        reclaim_complete(sess)
    finally:
        env.sleep(sleeptime, "Waiting for grace period to end")
示例#6
0
def __create_file_with_deleg(sess, name, access):
    res = create_file(sess, name, access = access)
    check(res)
    fh = res.resarray[-1].object
    deleg = res.resarray[-2].delegation
    if (not _got_deleg(deleg)):
        res = open_file(sess, name, access = access)
        fh = res.resarray[-1].object
        deleg = res.resarray[-2].delegation
        if (not _got_deleg(deleg)):
            fail("Could not get delegation")
    return (fh, deleg)
示例#7
0
def __create_file_with_deleg(sess, name, access):
    res = create_file(sess, name, access=access)
    check(res)
    fh = res.resarray[-1].object
    deleg = res.resarray[-2].delegation
    if (not _got_deleg(deleg)):
        res = open_file(sess, name, access=access)
        fh = res.resarray[-1].object
        deleg = res.resarray[-2].delegation
        if (not _got_deleg(deleg)):
            fail("Could not get delegation")
    return (fh, deleg)
示例#8
0
def testServerStateSeqid(t, env):
    """Do multiple OPENs of a file, check that server bumps stateid.seqid

    FLAGS: open all
    CODE: OPEN2
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_READ)
    check(res)
    expect(res, seqid=2)
示例#9
0
def testServerStateSeqid(t, env):
    """Do multiple OPENs of a file, check that server bumps stateid.seqid

    FLAGS: open all
    CODE: OPEN2
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_READ)
    check(res)
    expect(res, seqid=2)
示例#10
0
def testEMCGetLayout(t, env):
    """Verify layout handling

    Debugging test that looks for pre-existing file (server2fs1/dump.eth)
    so we don't have to worry about creating a file.

    FLAGS: 
    CODE: GETLAYOUT100
    """
    # Make sure E_ID returns MDS capabilities
    c1 = env.c1.new_client(env.testname(t), flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    if not c1.flags & EXCHGID4_FLAG_USE_PNFS_MDS:
        fail("Server can not be used as pnfs metadata server")
    sess = c1.create_session()
    # Test that fs handles block layouts
    ops = use_obj(env.opts.path) + [op.getattr(1 << FATTR4_FS_LAYOUT_TYPE)]
    res = sess.compound(ops)
    check(res)
    if FATTR4_FS_LAYOUT_TYPE not in res.resarray[-1].obj_attributes:
        fail("fs_layout_type not available")
    if LAYOUT4_BLOCK_VOLUME not in res.resarray[-1].obj_attributes[
            FATTR4_FS_LAYOUT_TYPE]:
        fail("layout_type does not contain BLOCK")
    # Create the file
    file = ["server2fs1", "dump.eth"]
    res = open_file(sess, env.testname(t), file)
    check(res)
    # Get layout
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid
    stateid.seqid = 0
    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_READ, 0,
                     0xffffffffffffffff, 0, stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    # Parse opaque
    for layout in res.resarray[-1].logr_layout:
        if layout.loc_type == LAYOUT4_BLOCK_VOLUME:
            p = BlockUnpacker(layout.loc_body)
            opaque = p.unpack_pnfs_block_layout4()
            p.done()
            print opaque
示例#11
0
def xtestOpenSeqid(t, env):
    """Verify server enforces seqid==0

    See 8.13(draft-10): Such vestigial fields in existing operations
                        should be set by the client to zero

    FLAGS: open all
    CODE: OPEN4
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_READ,
                    seqid=1)
    check(res, NFS4ERR_INVAL, msg="Using non-zero seqid in OPEN")
示例#12
0
def testEMCGetLayout(t, env):
    """Verify layout handling

    Debugging test that looks for pre-existing file (server2fs1/dump.eth)
    so we don't have to worry about creating a file.

    FLAGS: 
    CODE: GETLAYOUT100
    """
    # Make sure E_ID returns MDS capabilities
    c1 = env.c1.new_client(env.testname(t), flags=EXCHGID4_FLAG_USE_PNFS_MDS)
    if not c1.flags & EXCHGID4_FLAG_USE_PNFS_MDS:
        fail("Server can not be used as pnfs metadata server")
    sess = c1.create_session()
    # Test that fs handles block layouts
    ops = use_obj(env.opts.path) + [op.getattr(1<<FATTR4_FS_LAYOUT_TYPE)]
    res = sess.compound(ops)
    check(res)
    if FATTR4_FS_LAYOUT_TYPE not in res.resarray[-1].obj_attributes:
        fail("fs_layout_type not available")
    if LAYOUT4_BLOCK_VOLUME not in res.resarray[-1].obj_attributes[FATTR4_FS_LAYOUT_TYPE]:
        fail("layout_type does not contain BLOCK")
    # Create the file
    file = ["server2fs1", "dump.eth"]
    res = open_file(sess, env.testname(t), file)
    check(res)
    # Get layout
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid
    stateid.seqid = 0
    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_READ,
                        0, 0xffffffffffffffff, 0, stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    # Parse opaque
    for layout in  res.resarray[-1].logr_layout:
        if layout.loc_type == LAYOUT4_BLOCK_VOLUME:
            p = BlockUnpacker(layout.loc_body)
            opaque = p.unpack_pnfs_block_layout4()
            p.done()
            print opaque
示例#13
0
def xtestOpenSeqid(t, env):
    """Verify server enforces seqid==0

    See 8.13(draft-10): Such vestigial fields in existing operations
                        should be set by the client to zero

    FLAGS: open all
    CODE: OPEN4
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1,
                    owner,
                    path,
                    access=OPEN4_SHARE_ACCESS_READ,
                    seqid=1)
    check(res, NFS4ERR_INVAL, msg="Using non-zero seqid in OPEN")
示例#14
0
def testServerStateSeqid(t, env):
    """Do multiple OPENs of a file, check that server bumps stateid.seqid

    FLAGS: open all
    CODE: OPEN2
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_READ)
    check(res)
    expect(res, seqid=2)
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid

    # STUB - need to check no delegation return

    res = close_file(sess1, fh, stateid=stateid)
    check(res)
示例#15
0
文件: st_open.py 项目: ffilz/pynfs
def testServerStateSeqid(t, env):
    """Do multiple OPENs of a file, check that server bumps stateid.seqid

    FLAGS: open all
    CODE: OPEN2
    """
    name = env.testname(t)
    sess1 = env.c1.new_client_session(name)
    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
    check(res)
    expect(res, seqid=1)
    res = open_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_READ)
    check(res)
    expect(res, seqid=2)
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid

    # STUB - need to check no delegation return

    res = close_file(sess1, fh, stateid=stateid)
    check(res)