def testLockWriteLocku(t, env): """test current state id processing by having LOCK, WRITE and LOCKU in a single compound FLAGS: currentstateid all CODE: CSID4 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t)) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid data = "write test data" open_to_lock_owner = open_to_lock_owner4(0, stateid, 0, lock_owner4(0, "lock1")) lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True) lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner), op.write(current_stateid, 5, FILE_SYNC4, data), op.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX), op.close(0, stateid) ] res = sess1.compound([op.putfh(fh)] + lock_ops) check(res, NFS4_OK)
def close_file(self, mds_fh): """close the given file""" seqid=0 #FIXME: seqid must be !=0 fh, stateid = self.filehandles[mds_fh] ops = [op.putfh(fh)] + [op.close(seqid, stateid)] res = self.execute(ops) # ignoring return del self.filehandles[mds_fh]
def close_file(self, mds_fh): """close the given file""" seqid = 0 #FIXME: seqid must be !=0 fh, stateid = self.filehandles[mds_fh] ops = [op.putfh(fh)] + [op.close(seqid, stateid)] res = self.execute(ops) # ignoring return del self.filehandles[mds_fh]
def close_file(sess, fh, stateid, seqid=0): """close the given file""" if fh is None: ops = [] else: ops = [op.putfh(fh)] ops += [op.close(seqid, stateid)] res = sess.compound(ops) return res
def testOpenPutrootfhClose(t, env): """test current state id processing by having OPEN, PUTROOTFH and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID5 """ sess1 = env.c1.new_client_session(env.testname(t)) open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound(open_op + [op.putrootfh(), op.close(0, current_stateid)]) checklist(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
def testOpenAndClose(t, env): """test current state id processing by having OPEN and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID1 """ sess1 = env.c1.new_client_session(env.testname(t)) open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound(open_op + [op.close(0, current_stateid)]) check(res, NFS4_OK)
def testOpenFreestateidClose(t, env): """test current state id processing by having OPEN, FREE_STATEID and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID9 """ sess1 = env.c1.new_client_session(env.testname(t)) open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound(open_op + [op.free_stateid(current_stateid), op.close(0, current_stateid)]) check(res, NFS4ERR_LOCKS_HELD)
def testOpenWriteClose(t, env): """test current state id processing by having OPEN, WRITE and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID3 """ sess1 = env.c1.new_client_session(env.testname(t)) data = "write test data" open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound(open_op + [op.write(current_stateid, 5, FILE_SYNC4, data), op.close(0, current_stateid)]) check(res, NFS4_OK)
def testOpenLookupClose(t, env): """test current state id processing by having OPEN, LOOKUP and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID5 """ sess1 = env.c1.new_client_session(env.testname(t)) fname = env.testname(t) open_op = open_create_file_op(sess1, fname, open_create=OPEN4_CREATE) lookup_op = env.home + [op.lookup(fname)] res = sess1.compound(open_op + lookup_op + [op.close(0, current_stateid)]) checklist(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
def testCloseNoStateid(t, env): """test current state id processing by having CLOSE without operation which provides stateid FLAGS: currentstateid all CODE: CSID6 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t)) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid res = sess1.compound([op.putfh(fh), op.close(0, current_stateid)]) checklist(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
def testOpenPutrootfhClose(t, env): """test current state id processing by having OPEN, PUTROOTFH and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID5 """ sess1 = env.c1.new_client_session(env.testname(t)) open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound( open_op + [op.putrootfh(), op.close(0, current_stateid)]) checklist(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
def testOpenSaveFHLookupRestoreFHClose(t, env): """test current state id processing by having OPEN, SAVEFH, LOOKUP, RESTOREFH and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID10 """ sess1 = env.c1.new_client_session(env.testname(t)) fname = env.testname(t) open_op = open_create_file_op(sess1, fname, open_create=OPEN4_CREATE) lookup_op = env.home res = sess1.compound(lookup_op + [op.getfh()]) check(res) fh = res.resarray[-1].object res = sess1.compound(open_op + [op.savefh(), op.putfh(fh), op.restorefh(), op.close(0, current_stateid)]) check(res)
def testOpenFreestateidClose(t, env): """test current state id processing by having OPEN, FREE_STATEID and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID9 """ sess1 = env.c1.new_client_session(env.testname(t)) open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound( open_op + [op.free_stateid(current_stateid), op.close(0, current_stateid)]) check(res, NFS4ERR_LOCKS_HELD)
def testOpenWriteClose(t, env): """test current state id processing by having OPEN, WRITE and CLOSE in a single compound FLAGS: currentstateid all CODE: CSID3 """ sess1 = env.c1.new_client_session(env.testname(t)) data = "write test data" open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE) res = sess1.compound(open_op + [ op.write(current_stateid, 5, FILE_SYNC4, data), op.close(0, current_stateid) ]) check(res, NFS4_OK)
def testLockWriteLocku(t, env): """test current state id processing by having LOCK, WRITE and LOCKU in a single compound FLAGS: currentstateid all CODE: CSID4 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t)) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid data = "write test data" open_to_lock_owner = open_to_lock_owner4( 0, stateid, 0, lock_owner4(0, "lock1")) lock_owner = locker4(open_owner=open_to_lock_owner, new_lock_owner=True) lock_ops = [ op.lock(WRITE_LT, False, 0, NFS4_UINT64_MAX, lock_owner), op.write(current_stateid, 5, FILE_SYNC4, data), op.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX), op.close(0, stateid)] res = sess1.compound([op.putfh(fh)] + lock_ops) check(res, NFS4_OK)