Beispiel #1
0
def testLeasePeriod(t, env):
    """Any unconfirmed record that is not confirmed within
       a lease period SHOULD be removed.

    FLAGS: exchange_id all
    CODE: EID9
    """
    c1 = env.c1.new_client("%s_1" % env.testname(t))
    c2 = env.c1.new_client("%s_2" % env.testname(t))

    # Get server's lease time
    c3 = env.c1.new_client("%s_3" % env.testname(t))
    sess = c3.create_session()
    lease = _getleasetime(sess)

    # CREATE_SESSION
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    time.sleep(min(lease - 10, 1))
    # Inside lease period, create_session will success.
    res1 = c1.c.compound([op.create_session(c1.clientid, c1.seqid, 0,
                                        chan_attrs, chan_attrs,
                                        123, [])], None)
    check(res1)

    time.sleep(lease + 10)
    # After lease period, create_session will get error NFS4ERR_STALE_CLIENTID
    res2 = c2.c.compound([op.create_session(c2.clientid, c2.seqid, 0,
                                        chan_attrs, chan_attrs,
                                        123, [])], None)
    check(res2, NFS4ERR_STALE_CLIENTID)
def testLeasePeriod(t, env):
    """Any unconfirmed record that is not confirmed within
       a lease period SHOULD be removed.

    FLAGS: exchange_id all
    CODE: EID9
    """
    c1 = env.c1.new_client("%s_1" % env.testname(t))
    c2 = env.c1.new_client("%s_2" % env.testname(t))

    # Get server's lease time
    c3 = env.c1.new_client("%s_3" % env.testname(t))
    sess = c3.create_session()
    lease = _getleasetime(sess)

    # CREATE_SESSION
    chan_attrs = channel_attrs4(0, 8192, 8192, 8192, 128, 8, [])
    sec = [callback_sec_parms4(0)]
    time.sleep(min(lease - 10, 1))
    # Inside lease period, create_session will success.
    res1 = c1.c.compound([
        op.create_session(c1.clientid, c1.seqid, 0, chan_attrs, chan_attrs,
                          123, sec)
    ], None)
    check(res1)

    time.sleep(lease + 10)
    # After lease period, create_session will get error NFS4ERR_STALE_CLIENTID
    res2 = c2.c.compound([
        op.create_session(c2.clientid, c2.seqid, 0, chan_attrs, chan_attrs,
                          123, sec)
    ], None)
    check(res2, NFS4ERR_STALE_CLIENTID)
Beispiel #3
0
def create_session(c, clientid, sequenceid, cred=None, flags=0):
    """Send a simple CREATE_SESSION"""
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    res = c.compound([op.create_session(clientid, sequenceid, flags,
                                        chan_attrs, chan_attrs,
                                        123, [])], cred)
    return res
Beispiel #4
0
 def create_session(self,
                    flags=CREATE_SESSION4_FLAG_CONN_BACK_CHAN,
                    fore_attrs=None, back_attrs=None, sec=None, prog=None):
     max_retries = 10
     delay_time = 1
     chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
     if fore_attrs is None:
         fore_attrs = chan_attrs
     if back_attrs is None:
         back_attrs = chan_attrs
     if sec is None:
         sec= [callback_sec_parms4(0)]
     if prog is None:
         prog = self.c.prog
     for item in xrange(max_retries):
         res = self.c.compound([op.create_session(self.clientid, self.seqid,
                                              flags,
                                              fore_attrs, back_attrs,
                                              prog, sec)],
                           self.cred)
         if res.status != NFS4ERR_DELAY:
             break
         time.sleep(delay_time)
     nfs4lib.check(res)
     return self._add_session(res.resarray[0])
Beispiel #5
0
def create_session(c, cred=None, flags=0):
    """Send a simple CREATE_SESSION"""
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    sec = [callback_sec_parms4(0)]
    res = c.c.compound([op.create_session(c.clientid, c.seqid, flags,
                                        chan_attrs, chan_attrs,
                                        123, sec)], cred)
    return res
Beispiel #6
0
def create_session(c, cred=None, flags=0):
    """Send a simple CREATE_SESSION"""
    chan_attrs = channel_attrs4(0, 8192, 8192, 8192, 128, 8, [])
    sec = [callback_sec_parms4(0)]
    res = c.c.compound([
        op.create_session(c.clientid, c.seqid, flags, chan_attrs, chan_attrs,
                          123, sec)
    ], cred)
    return res
Beispiel #7
0
def testNotOnlyOp(t, env):
    """Check for NFS4ERR_NOT_ONLY_OP

    FLAGS: create_session all
    CODE: CSESS23
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION with PUT_ROOTFH
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    res = c.c.compound([op.create_session(c.clientid, c.seqid, 0,
                                        chan_attrs, chan_attrs,
                                        123, []), op.putrootfh()], None)
    check(res, NFS4ERR_NOT_ONLY_OP)
Beispiel #8
0
def testTooSmallMaxRS(t, env):
    """If client selects a value for ca_maxresponsesize such that
       a replier on a channel could never send a response,
       server SHOULD return NFS4ERR_TOOSMALL

    FLAGS: create_session all
    CODE: CSESS25
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION with too small ca_maxresponsesize
    chan_attrs = channel_attrs4(0,8192,0,8192,128,8,[])
    res = c.c.compound([op.create_session(c.clientid, c.seqid, 0,
                                        chan_attrs, chan_attrs,
                                        123, [])], None)
    check(res, NFS4ERR_TOOSMALL)
Beispiel #9
0
def testSupported2(t, env):
    """Do a CREATE_SESSION after a SEQUENCE (for same client)

    FLAGS: create_session all
    CODE: CSESS2
    """
    c1 = env.c1.new_client(env.testname(t))
    sess1 = c1.create_session()
    # Create second session
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    cs_op = op.create_session(c1.clientid, c1.seqid, 0,
                              chan_attrs, chan_attrs, c1.c.prog, [])
    res = sess1.compound([cs_op])
    check(res)
    sess2 = c1._add_session(res.resarray[-1])
    # Now make sure sess2 works
    res = sess2.compound([op.putrootfh()])
    check(res)
Beispiel #10
0
def testSupported2(t, env):
    """Do a CREATE_SESSION after a SEQUENCE (for same client)

    FLAGS: create_session all
    CODE: CSESS2
    """
    c1 = env.c1.new_client(env.testname(t))
    sess1 = c1.create_session()
    # Create second session
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    cs_op = op.create_session(c1.clientid, c1.seqid, 0,
                              chan_attrs, chan_attrs, c1.c.prog, [])
    res = sess1.compound([cs_op])
    check(res)
    sess2 = c1._add_session(res.resarray[-1])
    # Now make sure sess2 works
    res = sess2.compound([op.putrootfh()])
    check(res)
Beispiel #11
0
def testRepTooBigToCache(t, env):
    """If requester sends a request for which the size of the reply
       would exceed ca_maxresponsesize_cached, the replier will return
       NFS4ERR_REP_TOO_BIG_TO_CACHE

    FLAGS: create_session all
    CODE: CSESS27
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION with a small ca_maxresponsesize_cached
    chan_attrs = channel_attrs4(0,8192,8192,10,128,8,[])
    res = c.c.compound([op.create_session(c.clientid, c.seqid, 0,
                                        chan_attrs, chan_attrs,
                                        123, [])], None)
    check(res)

    # SEQUENCE with cache this
    sid = res.resarray[0].csr_sessionid
    res = c.c.compound([op.sequence(sid, 1, 0, 0, True)])
    check(res, NFS4ERR_REP_TOO_BIG_TO_CACHE)
Beispiel #12
0
def testSupported2b(t, env):
    """Do a CREATE_SESSION after a SEQUENCE (for different client)

    FLAGS: create_session all
    CODE: CSESS2b
    """
    c1 = env.c1.new_client("%s_1" % env.testname(t))
    c2 = env.c1.new_client("%s_2" % env.testname(t))
    sess1 = c1.create_session()
    # Create second session
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    sec = [callback_sec_parms4(0)]
    cs_op = op.create_session(c2.clientid, c2.seqid, 0,
                              chan_attrs, chan_attrs, c2.c.prog, sec)
    res = sess1.compound([cs_op])
    check(res)
    sess2 = c2._add_session(res.resarray[-1])
    # Now make sure sess2 works
    res = sess2.compound([op.putrootfh()])
    check(res)
Beispiel #13
0
def testRdmaArray2(t, env):
    """Test length 2 rdma arrays

    FLAGS: create_session all
    CODE: CSESS19
    """
    c = env.c1.new_client(env.testname(t))
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[13, 57])
    ops = [op.create_session(c.clientid, c.seqid, 0,
                             chan_attrs, chan_attrs,
                             c.c.prog, [])]
    c = c.c
    xid = c.compound_async(ops, checks=False)
    try:
        res = c.listen(xid)
        print res
    except RPCAcceptError, e:
        if e.stat == GARBAGE_ARGS:
            # Legitimate return
            return
        else:
            raise
Beispiel #14
0
def testReplay1b(t, env):
    """Replay a successful SEQUENCE:CREATE_SESSION without a preceeding SEQUENCE

    FLAGS: create_session all
    CODE: CSESS5b
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION
    sess1 = c.create_session()
    # another CREATE_SESSION with SEQUENCE from first session
    c.seqid = 2
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    cs_op = op.create_session(c.clientid, c.seqid, 0,
                              chan_attrs, chan_attrs, c.c.prog, [])
    res1 = sess1.compound([cs_op])
    check(res1)
    # REPLAY second CREATE_SESSION without SEQUENCE
    res2 = create_session(c.c, c.clientid, c.seqid)
    check(res2)
    # Test results are equal (ignoring tags)
    res1.tag = res2.tag = ""
    if not nfs4lib.test_equal(res1, res2):
        fail("Replay results not equal")
Beispiel #15
0
def testReplay1b(t, env):
    """Replay a successful SEQUENCE:CREATE_SESSION without a preceeding SEQUENCE

    FLAGS: create_session all
    CODE: CSESS5b
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION
    sess1 = c.create_session()
    # another CREATE_SESSION with SEQUENCE from first session
    c.seqid = 2
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    cs_op = op.create_session(c.clientid, c.seqid, 0,
                              chan_attrs, chan_attrs, c.c.prog, [])
    res1 = sess1.compound([cs_op])
    check(res1)
    # REPLAY second CREATE_SESSION without SEQUENCE
    res2 = create_session(c.c, c.clientid, c.seqid)
    check(res2)
    # Test results are equal (ignoring tags)
    res1.tag = res2.tag = ""
    if not nfs4lib.test_equal(res1, res2):
        fail("Replay results not equal")
Beispiel #16
0
def testReplay1a(t, env):
    """Replay a successful CREATE_SESSION with a SEQUENCE from a different session

    FLAGS: create_session all
    CODE: CSESS5a
    """
    c = env.c1.new_client(env.testname(t))
    # CREATE_SESSION
    sess1 = c.create_session()
    # another CREATE_SESSION
    c.seqid = 2
    chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
    sec = [callback_sec_parms4(0)]
    res1 = create_session(c.c, c.clientid, c.seqid)
    check(res1)
    # REPLAY first CREATE_SESSION with SEQUENCE from 2nd session
    cs_op = op.create_session(c.clientid, c.seqid, 0,
                              chan_attrs, chan_attrs, c.c.prog, sec)
    res2 = sess1.compound([cs_op])
    check(res2)
    # Test results are equal (ignoring tags)
    res1.tag = res2.tag = ""
    if not nfs4lib.test_equal(res1, res2):
        fail("Replay results not equal")
Beispiel #17
0
 def _create_session(self,
                    flags=CREATE_SESSION4_FLAG_CONN_BACK_CHAN,
                    fore_attrs=None, back_attrs=None, sec=None,
                    prog=None,
                    max_retries=1, delay_time=1):
     chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
     if fore_attrs is None:
         fore_attrs = chan_attrs
     if back_attrs is None:
         back_attrs = chan_attrs
     if sec is None:
         sec= [callback_sec_parms4(0)]
     if prog is None:
         prog = self.c.prog
     for item in xrange(max_retries):
         res = self.c.compound([op.create_session(self.clientid, self.seqid,
                                              flags,
                                              fore_attrs, back_attrs,
                                              prog, sec)],
                           self.cred)
         if res.status != NFS4ERR_DELAY:
             break
         time.sleep(delay_time)
     return res;