def rename_obj(sess, oldpath, newpath): olddir = lookup_obj(sess, oldpath[:-1]) newdir = lookup_obj(sess, newpath[:-1]) ops = [op.putfh(olddir), op.savefh()] ops += [op.putfh(newdir)] ops += [op.rename(oldpath[-1], newpath[-1])] return sess.compound(ops)
def testReuseSlotID(t, env): """ If client reuses a slot ID and sequence ID for a completely different request, server MAY treat the request as if it is a retry of what it has already executed. rfc5661 18.46.3 FLAGS: sequence all CODE: SEQ14 """ c = env.c1.new_client(env.testname(t)) # CREATE_SESSION sess1 = c.create_session() name = "%s_1" % env.testname(t) res = create_file(sess1, name) check(res) sid = sess1.sessionid seqid = nfs4lib.inc_u32(sess1.seqid) dir = sess1.c.homedir res = c.c.compound([op.sequence(sid, seqid, 0, 0, TRUE)] + nfs4lib.use_obj(dir) + [op.remove(name)]) check(res) # Reuses slot ID and sequence ID for different request res = c.c.compound([op.sequence(sid, seqid, 0, 0, TRUE)] + nfs4lib.use_obj(dir) + [op.rename(name, "test")]) check(res)
def rename_obj(sess, oldpath, newpath): # Set (sfh) to olddir ops = use_obj(oldpath[:-1]) + [op.savefh()] # Set (cfh) to newdir ops += use_obj(newpath[:-1]) # Call rename ops += [op.rename(oldpath[-1], newpath[-1])] return sess.compound(ops)
def testNoSfh(t, env): """RENAME without (sfh) should return NFS4ERR_NOFILEHANDLE FLAGS: rename emptyfh all CODE: RNM4 """ name = env.testname(t) sess = env.c1.new_client_session(name) ops = env.home + [op.rename(name, name)] res = sess.compound(ops) check(res, NFS4ERR_NOFILEHANDLE, "RENAME with no <sfh>")
def testReplayCache007(t, env): """Send two successful non-idempotent compounds with same seqid and False cache_this FLAGS: sequence all CODE: SEQ10b """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, "%s_1" % env.testname(t)) check(res) ops = env.home + [op.savefh(),\ op.rename("%s_1" % env.testname(t), "%s_2" % env.testname(t))] res1 = sess1.compound(ops, cache_this=False) check(res1, NFS4_OK) res2 = sess1.compound(ops, seq_delta=0, cache_this=False) check(res2, NFS4ERR_RETRY_UNCACHED_REP)
def testReplayCache004(t, env): """Send two unsuccessful non-idempotent compounds with same seqid FLAGS: sequence all CODE: SEQ9d """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() ops = [op.putrootfh(), op.savefh(), op.rename("", "foo")] res1 = sess1.compound(ops, cache_this=True) check(res1, NFS4ERR_INVAL) res2 = sess1.compound(ops, seq_delta=0) check(res2, NFS4ERR_INVAL) res1.tag = res2.tag = "" if not nfs4lib.test_equal(res1, res2): fail("Replay results not equal")
def testReplayCache002(t, env): """Send two successful non-idempotent compounds with same seqid FLAGS: sequence all CODE: SEQ9b """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, "%s_1" % env.testname(t)) check(res) ops = env.home + [op.savefh(),\ op.rename("%s_1" % env.testname(t), "%s_2" % env.testname(t))] res1 = sess1.compound(ops, cache_this=True) check(res1) res2 = sess1.compound(ops, seq_delta=0) check(res2) res1.tag = res2.tag = "" if not nfs4lib.test_equal(res1, res2): fail("Replay results not equal")