Example #1
0
def testSupported(t, env):
    """Do a simple RECLAIM_COMPLETE

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

    res = sess.compound([op.putrootfh(), op.reclaim_complete(TRUE)])
    check(res)

    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res)
Example #2
0
def testSupported(t, env):
    """Do a simple RECLAIM_COMPLETE

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

    res = sess.compound([op.putrootfh(), op.reclaim_complete(TRUE)])
    check(res)

    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res)
Example #3
0
def testRepTooBig(t, env):
    """If requester sends a request for which the size of the reply
       would exceed ca_maxresponsesize, the replier will return
       NFS4ERR_REP_TOO_BIG

    FLAGS: create_session all
    CODE: CSESS26
    """
    name = env.testname(t)
    c1 = env.c1.new_client(name)
    # create session with a small ca_maxresponsesize
    chan_attrs = channel_attrs4(0,8192,500,8192,128,8,[])
    sess1 = c1.create_session(fore_attrs=chan_attrs)
    sess1.compound([op.reclaim_complete(FALSE)])

    owner = "owner_%s" % name
    path = sess1.c.homedir + [name]
    res = create_file(sess1, owner, path, access=OPEN4_SHARE_ACCESS_BOTH)
    check(res)

    # write some data to file
    fh = res.resarray[-1].object
    stateid = res.resarray[-2].stateid
    res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, "write test data " * 10)])
    check(res)

    # read data rather than ca_maxresponsesize
    res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 500)])
    check(res, NFS4ERR_REP_TOO_BIG)
Example #4
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])
Example #5
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])
Example #6
0
def testDestroyCIDNotOnly(t, env):
    """ destroy a clientid without session with other compound

    FLAGS: destroy_clientid all
    CODE: DESCID7
    """
    res = env.c1.compound([op.destroy_clientid(0), op.reclaim_complete(TRUE)])
    check(res, NFS4ERR_NOT_ONLY_OP)
Example #7
0
def testDoubleRECC(t, env):
    """If RECLAIM_COMPLETE is done a second time, error
       NFS4ERR_COMPLETE_ALREADY will be returned. rfc5661 18.51.4

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

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

    # RECLAIM_COMPLETE again
    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res, NFS4ERR_COMPLETE_ALREADY)
Example #8
0
def testDoubleRECC(t, env):
    """If RECLAIM_COMPLETE is done a second time, error
       NFS4ERR_COMPLETE_ALREADY will be returned. rfc5661 18.51.4

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

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

    # RECLAIM_COMPLETE again
    res = sess.compound([op.reclaim_complete(FALSE)])
    check(res, NFS4ERR_COMPLETE_ALREADY)
Example #9
0
def xtestOpenClientid(t, env):
    """Verify server enforces that open_owner.clientid==0

    See 8.13(draft-10): Such vestigial fields in existing operations
                        should be set by the client to zero
    
    FLAGS: open all
    CODE: OPEN5
    """
    name = env.testname(t)
    c1 = env.c1.new_client("%s_1" % name)
    if c1.clientid == 0:
        # If by coincidence clientid==0, make a new client
        c1 = env.c1.new_client("%s_2" % name)
    sess1 = c1.create_session()
    sess1.compound([op.reclaim_complete(FALSE)])
    res = create_file(sess1, env.testname(t), clientid=c1.clientid)
    check(res, NFS4ERR_INVAL, msg="Using non-zero clientid in open_owner")
Example #10
0
def xtestOpenClientid(t, env):
    """Verify server enforces that open_owner.clientid==0

    See 8.13(draft-10): Such vestigial fields in existing operations
                        should be set by the client to zero
    
    FLAGS: open all
    CODE: OPEN5
    """
    name = env.testname(t)
    c1 = env.c1.new_client("%s_1" % name)
    if c1.clientid == 0:
        # If by coincidence clientid==0, make a new client
        c1 = env.c1.new_client("%s_2" % name)
    sess1 = c1.create_session()
    sess1.compound([op.reclaim_complete(FALSE)])
    res = create_file(sess1, env.testname(t), clientid=c1.clientid)
    check(res, NFS4ERR_INVAL, msg="Using non-zero clientid in open_owner")
Example #11
0
def testWriteDeleg(t, env):
    """Test write delgation handout and return

    FLAGS: open deleg all
    CODE: DELEG2
    """
    recall = threading.Event()
    def pre_hook(arg, env):
        recall.stateid = arg.stateid # NOTE this must be done before set()
        env.notify = recall.set # This is called after compound sent to queue
    def post_hook(arg, env, res):
        return res
    # c1 - OPEN - WRITE
    c1 = env.c1.new_client("%s_1" % env.testname(t))
    c1.cb_pre_hook(OP_CB_RECALL, pre_hook)
    c1.cb_post_hook(OP_CB_RECALL, post_hook)
    sess1 = c1.create_session()
    sess1.compound([op.reclaim_complete(FALSE)])
    res = create_file(sess1, env.testname(t),
                      access=OPEN4_SHARE_ACCESS_BOTH |
                      OPEN4_SHARE_ACCESS_WANT_WRITE_DELEG)
    check(res)
    fh = res.resarray[-1].object
    deleg = res.resarray[-2].delegation
    if deleg.delegation_type == OPEN_DELEGATE_NONE or deleg.delegation_type == OPEN_DELEGATE_NONE_EXT:
        fail("Could not get delegation")
    # c2 - OPEN - READ
    sess2 = env.c1.new_client_session("%s_2" % env.testname(t))
    claim = open_claim4(CLAIM_NULL, env.testname(t))
    owner = open_owner4(0, "My Open Owner 2")
    how = openflag4(OPEN4_NOCREATE)
    open_op = op.open(0, OPEN4_SHARE_ACCESS_READ, OPEN4_SHARE_DENY_NONE,
                      owner, how, claim)
    slot = sess2.compound_async(env.home + [open_op])
    # Wait for recall, and return delegation
    recall.wait() # STUB - deal with timeout
    # Getting here means CB_RECALL reply is in the send queue.
    # Give it a moment to actually be sent
    env.sleep(1)
    res = sess1.compound([op.putfh(fh), op.delegreturn(recall.stateid)])
    check(res)
    # Now get OPEN reply
    res = sess2.listen(slot)
    checklist(res, [NFS4_OK, NFS4ERR_DELAY])
Example #12
0
def testNoDeleg(t, env):
    """Test no delgation handout

    FLAGS: open deleg all
    CODE: DELEG4
    """
    c1 = env.c1.new_client("%s_1" % env.testname(t))
    sess1 = c1.create_session()
    sess1.compound([op.reclaim_complete(FALSE)])
    res = create_file(sess1, env.testname(t),
                      access=OPEN4_SHARE_ACCESS_READ |
                      OPEN4_SHARE_ACCESS_WANT_NO_DELEG)
    check(res)
    fh = res.resarray[-1].object
    deleg = res.resarray[-2].delegation
    if deleg.delegation_type == OPEN_DELEGATE_NONE:
        fail("Got no delegation, expected OPEN_DELEGATE_NONE_EXT")
    if deleg.delegation_type != OPEN_DELEGATE_NONE_EXT:
        fail("Got a delegation (type "+str(deleg.delegation_type)+") despite asking for none")
    if deleg.ond_why != WND4_NOT_WANTED:
        fail("Wrong reason ("+str(deleg.ond_why)+") for giving no delegation")
Example #13
0
def reclaim_complete(sess):
    rc_op = op.reclaim_complete(rca_one_fs=False)
    res = sess.compound([rc_op])
    check(res, msg="reclaim_complete")
Example #14
0
def reclaim_complete(sess):
    rc_op = op.reclaim_complete(rca_one_fs=False)
    res = sess.compound([rc_op])
    check(res, msg="reclaim_complete")
Example #15
0
 def new_client_session(self, name, flags=0, sec=None):
     c = self.new_client(name, flags=flags)
     s = c.create_session(sec=sec)
     s.compound([op.reclaim_complete(FALSE)])
     return s