def testSupported2(t, env): """Check OPEN delegation handling FLAGS: open all CODE: OPEN200 """ # c1 - OPEN - READ with delegation c1 = env.c1.new_client("%s_1" % env.testname(t)) sess1 = c1.create_session() res = create_file(sess1, env.testname(t), access=OPEN4_SHARE_ACCESS_READ | OPEN4_SHARE_ACCESS_WANT_READ_DELEG) check(res) # STUB Should check delegation was granted fh1 = res.resarray[-1].object stateid1 = res.resarray[-2].stateid # c2 - OPEN - WRITE c2 = env.c1.new_client("%s_2" % env.testname(t)) sess2 = c2.create_session() owner = open_owner4(0, "My Open Owner 2") claim = open_claim4(CLAIM_NULL, env.testname(t)) how = openflag4(OPEN4_NOCREATE) open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, owner, how, claim) res = sess2.compound(env.home + [open_op]) # STUB - since we are not handling callback, deleg_return never gets done print res check(res) fh2 = res.resarray[-1].object stateid2 = res.resarray[-2].stateid res = close_file(sess1, fh1, stateid=stateid1) check(res) res = close_file(sess2, fh2, stateid=stateid2) check(res)
def testReadWrite(t, env): """Do a simple READ and WRITE FLAGS: open all CODE: OPEN400 """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() owner = open_owner4(0, "My Open Owner") how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE: 0})) claim = open_claim4(CLAIM_NULL, env.testname(t)) open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, owner, how, claim) fh_op = op.putrootfh() res = sess1.compound([fh_op, open_op, op.getfh()]) # OPEN print res check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid stateid.seqid = 0 res = sess1.compound( [op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, "write test data")]) print res check(res) res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) print res check(res) res = close_file(sess1, fh, stateid=stateid) check(res)
def testLayout(t, env): """Verify layout handling FLAGS: layout all CODE: LAYOUT1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) blocksize = get_blocksize(sess, use_obj(env.opts.path)) # Open the file owner = "owner for %s" % env.testname(t) # openres = open_file(sess, owner, env.opts.path + ["simple_extent"]) openres = open_file(sess, owner, env.opts.path + ["hole_between_extents"]) check(openres) # Get a layout fh = openres.resarray[-1].object stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_READ, 0, 0xffffffff, 4 * blocksize, 0xffff) ] res = sess.compound(ops) check(res) res = close_file(sess1, fh, stateid=stateid) check(res)
def testDeadlock(t, env): """Trigger deadlock bug FLAGS: debug all CODE: DEBUG1 """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() owner = open_owner4(0, "My Open Owner") how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE: 0})) claim = open_claim4(CLAIM_NULL, env.testname(t)) open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, owner, how, claim) res = sess1.compound(env.home + [open_op, op.getfh()]) # OPEN fh = res.resarray[-1].object stateid = res.resarray[-2].stateid #### def ops(i): return [ op.putfh(fh), op.write(stateid, i * 1000, UNSTABLE4, chr(97 + i) * 100), op.getattr(42950721818L) ] xids = [sess1.compound_async(ops(i), slot=i) for i in range(4)] for xid in xids: res = sess1.listen(xid) check(res) print res res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexLayoutReturnFile(t, env): """ Return a file's layout FLAGS: flex DEPEND: FFGLO1 CODE: FFLOR1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 4196, open_stateid, 0xffff)] res = sess.compound(ops) check(res) # Return layout layout_stateid = res.resarray[-1].logr_stateid ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, layout_stateid, "")))] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testOPENClaimFH(t, env): """OPEN file with claim_type is CLAIM_FH FLAGS: open all CODE: OPEN7 """ 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 = close_file(sess1, fh, stateid=stateid) check(res) claim = open_claim4(CLAIM_FH) how = openflag4(OPEN4_NOCREATE) oowner = open_owner4(0, "My Open Owner 2") open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH, OPEN4_SHARE_DENY_NONE, oowner, how, claim) res = sess1.compound([op.putfh(fh), open_op]) check(res) stateid = res.resarray[-1].stateid stateid.seqid = 0 data = "write test data" res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) check(res) res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) check(res) if not res.resarray[-1].eof: fail("EOF not set on read") desired = "\0"*5 + data if res.resarray[-1].data != desired: fail("Expected %r, got %r" % (desired, res.resarray[-1].data))
def testAnonReadWrite(t, env): """Do a simple READ and WRITE using anonymous stateid FLAGS: open all CODE: OPEN31 """ sess1 = env.c1.new_client_session(env.testname(t)) owner = open_owner4(0, "My Open Owner") res = create_file(sess1, env.testname(t)) check(res) expect(res, seqid=1) fh = res.resarray[-1].object data = "write test data" stateid = res.resarray[-2].stateid res = close_file(sess1, fh, stateid=stateid) check(res) res = sess1.compound([op.putfh(fh), op.write(nfs4lib.state00, 5, FILE_SYNC4, data)]) check(res) res = sess1.compound([op.putfh(fh), op.read(nfs4lib.state00, 0, 1000)]) check(res) if not res.resarray[-1].eof: fail("EOF not set on read") desired = "\0"*5 + data if res.resarray[-1].data != desired: fail("Expected %r, got %r" % (desired, res.resarray[-1].data))
def testReadWrite(t, env): """Do a simple READ and WRITE FLAGS: open all CODE: OPEN400 """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() owner = open_owner4(0, "My Open Owner") how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) claim = open_claim4(CLAIM_NULL, env.testname(t)) open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH , OPEN4_SHARE_DENY_NONE, owner, how, claim) fh_op = op.putrootfh() res = sess1.compound([fh_op, open_op, op.getfh()]) # OPEN print res check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid stateid.seqid = 0 res = sess1.compound([op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, "write test data")]) print res check(res) res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) print res check(res) res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexLayoutOldSeqid(t, env): """Check that we do not get NFS4ERR_OLD_STATEID if we send two LAYOUTGETS in a row without bumping the seqid FLAGS: flex CODE: FFLOOS """ seqid_next = 1 sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, open_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, seqid_next) seqid_next += 1 # Get the first with the lo_stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid2 = res.resarray[-1].logr_stateid check_seqid(lo_stateid2, seqid_next) seqid_next += 1 # Get the second with the original lo_stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid3 = res.resarray[-1].logr_stateid check_seqid(lo_stateid3, seqid_next) seqid_next += 1 ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexGetLayout(t, env): """Verify layout handling FLAGS: flex CODE: FFGLO1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 4196, open_stateid, 0xffff) ] res = sess.compound(ops) check(res) # Parse opaque for layout in res.resarray[-1].logr_layout: if layout.loc_type == LAYOUT4_FLEX_FILES: p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexLayoutStress(t, env): """Alternate LAYOUTIOMODE4_RW/LAYOUTIOMODE4_READ layout segments in the file FLAGS: flex CODE: FFLG2 """ seqid_next = 1 sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid for i in range(1000): ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ if i%2 else LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, seqid_next) seqid_next += 1 ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testLockLockU(t, env): """test current state id processing by having LOCK and LOCKU in a single compound FLAGS: currentstateid all CODE: CSID2 """ 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 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.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX) ] res = sess1.compound([op.putfh(fh)] + lock_ops) check(res, NFS4_OK) res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexGetLayout(t, env): """Verify layout handling FLAGS: flex CODE: FFGLO1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 4196, open_stateid, 0xffff)] res = sess.compound(ops) check(res) # Parse opaque for layout in res.resarray[-1].logr_layout: if layout.loc_type == LAYOUT4_FLEX_FILES: p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() res = close_file(sess, fh, stateid=open_stateid) check(res)
def testReadWrite(t, env): """Do a simple READ and WRITE FLAGS: open all CODE: OPEN30 """ sess1 = env.c1.new_client_session(env.testname(t)) owner = open_owner4(0, "My Open Owner") res = create_file(sess1, env.testname(t)) check(res) expect(res, seqid=1) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid stateid.seqid = 0 data = "write test data" res = sess1.compound( [op.putfh(fh), op.write(stateid, 5, FILE_SYNC4, data)]) check(res) res = sess1.compound([op.putfh(fh), op.read(stateid, 0, 1000)]) check(res) if not res.resarray[-1].eof: fail("EOF not set on read") desired = "\0" * 5 + data if res.resarray[-1].data != desired: fail("Expected %r, got %r" % (desired, res.resarray[-1].data)) res = close_file(sess1, fh, stateid=stateid) check(res)
def testDeadlock(t, env): """Trigger deadlock bug FLAGS: debug all CODE: DEBUG1 """ c1 = env.c1.new_client(env.testname(t)) sess1 = c1.create_session() owner = open_owner4(0, "My Open Owner") how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) claim = open_claim4(CLAIM_NULL, env.testname(t)) open_op = op.open(0, OPEN4_SHARE_ACCESS_BOTH , OPEN4_SHARE_DENY_NONE, owner, how, claim) res = sess1.compound(env.home + [open_op, op.getfh()]) # OPEN fh = res.resarray[-1].object stateid = res.resarray[-2].stateid #### def ops(i): return [op.putfh(fh), op.write(stateid, i*1000, UNSTABLE4, chr(97+i)*100), op.getattr(42950721818L) ] xids = [sess1.compound_async(ops(i), slot=i) for i in range(4)] for xid in xids: res = sess1.listen(xid) check(res) print res res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexGetDevInfo(t, env): """Get the device info FLAGS: flex CODE: FFGDI1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] deviceid = ds.ffds_deviceid ops = [ op.putfh(fh), op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0) ] res = sess.compound(ops) check(res) ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, ""))) ] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testCloseWithZeroSeqid(t, env): """OPEN followed by CLOSE with stateid.seq = 0 FLAGS: open all CODE: OPEN8 """ 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 stateid.seqid = 0 res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexGetDevInfo(t, env): """Get the device info FLAGS: flex CODE: FFGDI1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] deviceid = ds.ffds_deviceid ops = [op.putfh(fh), op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)] res = sess.compound(ops) check(res) ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testOpenSetattr(t, env): """test current state id processing by having OPEN and SETATTR in a single compound FLAGS: currentstateid all CODE: CSID8 """ size = 8 sess = env.c1.new_pnfs_client_session(env.testname(t)) open_op = open_create_file_op(sess, env.testname(t), open_create=OPEN4_CREATE) res = sess.compound(open_op + [op.getfh(), op.setattr(current_stateid, {FATTR4_SIZE: size})]) check(res, NFS4_OK) fh = res.resarray[-3].object stateid = res.resarray[-4].stateid res = close_file(sess, fh, stateid=stateid) check(res)
def testOpenLayoutGet(t, env): """test current state id processing by having OPEN and LAYOUTGET in a single compound FLAGS: currentstateid pnfs CODE: CSID7 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) open_op = open_create_file_op(sess, env.testname(t), open_create=OPEN4_CREATE) res = sess.compound( open_op + [op.layoutget(False, LAYOUT4_NFSV4_1_FILES, LAYOUTIOMODE4_RW, 0, 8192, 8192, current_stateid, 0xFFFF)] ) check(res, NFS4_OK) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid res = close_file(sess, fh, stateid=stateid) check(res)
def testStateid1(t, env): """Check for proper sequence handling in layout stateids. FLAGS: flex CODE: FFST1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 8192, 8192, open_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid # From draft23 12.5.2 "The first successful LAYOUTGET processed by # the server using a non-layout stateid as an argument MUST have the # "seqid" field of the layout stateid in the response set to one." check_seqid(lo_stateid, 1) for i in range(6): # Get subsequent layouts ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, (i + 1) * 8192, 8192, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid # From draft23 12.5.3 "After the layout stateid is established, # the server increments by one the value of the "seqid" in each # subsequent LAYOUTGET and LAYOUTRETURN response, check_seqid(lo_stateid, i + 2) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexLayoutStress(t, env): """Alternate LAYOUTIOMODE4_RW/LAYOUTIOMODE4_READ layout segments in the file FLAGS: flex CODE: FFLG2 """ seqid_next = 1 sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid for i in range(1000): ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ if i % 2 else LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, seqid_next) seqid_next += 1 ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, ""))) ] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testOpenLayoutGet(t, env): """test current state id processing by having OPEN and LAYOUTGET in a single compound FLAGS: currentstateid pnfs CODE: CSID7 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) open_op = open_create_file_op(sess, env.testname(t), open_create=OPEN4_CREATE) res = sess.compound(open_op + [ op.layoutget(False, LAYOUT4_NFSV4_1_FILES, LAYOUTIOMODE4_RW, 0, 8192, 8192, current_stateid, 0xffff) ]) check(res, NFS4_OK) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid res = close_file(sess, fh, stateid=stateid) check(res)
def testEXCLUSIVE4AtNameAttribute(t, env): """If the file does exist,but the stored verifier does not match, then an error of NFS4ERR_EXIST is returned from server. rfc5661 18.16.3 FLAGS: open all CODE: OPEN6 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier = "Justtest") check(res, NFS4ERR_EXIST) res = close_file(sess1, fh, stateid=stateid) check(res)
def testStateid1(t, env): """Check for proper sequence handling in layout stateids. FLAGS: flex CODE: FFST1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 8192, 8192, open_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid # From draft23 12.5.2 "The first successful LAYOUTGET processed by # the server using a non-layout stateid as an argument MUST have the # "seqid" field of the layout stateid in the response set to one." check_seqid(lo_stateid, 1) for i in range(6): # Get subsequent layouts ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, (i+1)*8192, 8192, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid # From draft23 12.5.3 "After the layout stateid is established, # the server increments by one the value of the "seqid" in each # subsequent LAYOUTGET and LAYOUTRETURN response, check_seqid(lo_stateid, i + 2) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testSupported(t, env): """Do a simple OPEN create FLAGS: open all CODE: OPEN1 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t)) check(res) # See 8.1.3.1 of draft-10: # the server MUST provide an "seqid" value starting at one... expect(res, seqid=1) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid # STUB - need to check open_res.delegation.delegation_type # see draft-10 line 19445 # QUESTION - what does "If the server supports the new _WANT_ flags" mean? # will the server return INVAL? NOTSUPP? or just silently ignore? res = close_file(sess1, fh, stateid=stateid) check(res)
def testOpenSetattr(t, env): """test current state id processing by having OPEN and SETATTR in a single compound FLAGS: currentstateid all CODE: CSID8 """ size = 8 sess = env.c1.new_pnfs_client_session(env.testname(t)) open_op = open_create_file_op(sess, env.testname(t), open_create=OPEN4_CREATE) res = sess.compound( open_op + [op.getfh(), op.setattr(current_stateid, {FATTR4_SIZE: size})]) check(res, NFS4_OK) fh = res.resarray[-3].object stateid = res.resarray[-4].stateid res = close_file(sess, fh, stateid=stateid) check(res)
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)
def testEXCLUSIVE4AtNameAttribute(t, env): """If the file does exist,but the stored verifier does not match, then an error of NFS4ERR_EXIST is returned from server. rfc5661 18.16.3 FLAGS: open all CODE: OPEN6 """ sess1 = env.c1.new_client_session(env.testname(t)) res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1) check(res) fh = res.resarray[-1].object stateid = res.resarray[-2].stateid res = create_file(sess1, env.testname(t), mode=EXCLUSIVE4_1, verifier="Justtest") check(res, NFS4ERR_EXIST) res = close_file(sess1, fh, stateid=stateid) check(res)
def testLayout(t, env): """Verify layout handling FLAGS: layout all CODE: LAYOUT1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) blocksize = get_blocksize(sess, use_obj(env.opts.path)) # Open the file owner = "owner for %s" % env.testname(t) # openres = open_file(sess, owner, env.opts.path + ["simple_extent"]) openres = open_file(sess, owner, env.opts.path + ["hole_between_extents"]) check(openres) # Get a layout fh = openres.resarray[-1].object stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_BLOCK_VOLUME, LAYOUTIOMODE4_READ, 0, 0xffffffff, 4*blocksize, 0xffff)] res = sess.compound(ops) check(res) res = close_file(sess1, fh, stateid=stateid) check(res)
def testFlexLayoutReturnFile(t, env): """ Return a file's layout FLAGS: flex DEPEND: FFGLO1 CODE: FFLOR1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 4196, open_stateid, 0xffff) ] res = sess.compound(ops) check(res) # Return layout layout_stateid = res.resarray[-1].logr_stateid ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, layout_stateid, ""))) ] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testLockLockU(t, env): """test current state id processing by having LOCK and LOCKU in a single compound FLAGS: currentstateid all CODE: CSID2 """ 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 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.locku(WRITE_LT, 0, current_stateid, 0, NFS4_UINT64_MAX), ] res = sess1.compound([op.putfh(fh)] + lock_ops) check(res, NFS4_OK) res = close_file(sess1, fh, stateid=stateid) check(res)
def _LayoutStats(t, env, stats): '''Loop over the provided layoutstats, sending them on in time ''' sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() stats_hint = opaque.ffl_stats_collect_hint # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] deviceid = ds.ffds_deviceid ops = [ op.putfh(fh), op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0) ] res = sess.compound(ops) check(res) gda = res.resarray[-1].gdir_device_addr p = FlexUnpacker(gda.da_addr_body) da = p.unpack_ff_device_addr4() p.done() rd_io = io_info4() wr_io = io_info4() rd_lat = ff_io_latency4() wr_lat = ff_io_latency4() for s in stats: dur = get_nfstime(s[1]) # Did not capture these in the gathered traces offset = 0 file_length = 0xffffffffffffffff rd_io.ii_count = 0 rd_io.ii_bytes = 0 wr_io.ii_count = 0 wr_io.ii_bytes = 0 rd_lat.ffil_ops_requested = s[5] rd_lat.ffil_bytes_requested = s[4] rd_lat.ffil_ops_completed = s[6] rd_lat.ffil_bytes_completed = s[2] rd_lat.ffil_bytes_not_delivered = s[3] rd_lat.ffil_total_busy_time = get_nfstime(s[7]) rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8]) wr_lat.ffil_ops_requested = s[12] wr_lat.ffil_bytes_requested = s[11] wr_lat.ffil_ops_completed = s[13] wr_lat.ffil_bytes_completed = s[9] wr_lat.ffil_bytes_not_delivered = s[10] wr_lat.ffil_total_busy_time = get_nfstime(s[14]) wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15]) sleeper = s[0] env.sleep(sleeper) fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1], rd_lat, wr_lat, dur, True) p = FlexPacker() p.pack_ff_layoutupdate4(fflu) lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer()) ops = [ op.putfh(fh), op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, lu4) ] res = sess.compound(ops) check(res) ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, ""))) ] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexLayoutOldSeqid(t, env): """Check that we do not get NFS4ERR_OLD_STATEID if we send two LAYOUTGETS in a row without bumping the seqid FLAGS: flex CODE: FFLOOS """ seqid_next = 1 sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, open_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, seqid_next) seqid_next += 1 # Get the first with the lo_stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid2 = res.resarray[-1].logr_stateid check_seqid(lo_stateid2, seqid_next) seqid_next += 1 # Get the second with the original lo_stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid3 = res.resarray[-1].logr_stateid check_seqid(lo_stateid3, seqid_next) seqid_next += 1 ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, ""))) ] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexLayoutTestAccess(t, env): """Get both a LAYOUTIOMODE4_RW and LAYOUTIOMODE4_READ segment making sure that they have the same gid, but a different uid. FLAGS: flex CODE: FFLA1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, open_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] uid_rw = ds.ffds_user gid_rw = ds.ffds_group ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 2) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] uid_rd = ds.ffds_user gid_rd = ds.ffds_group if uid_rw == uid_rd: fail("Expected uid_rd != %i, got %i" % (uid_rd, uid_rw)) if gid_rw != gid_rd: fail("Expected gid_rd == %i, got %i" % (gid_rd, gid_rw)) res = close_file(sess, fh, stateid=open_stateid) check(res)
def _LayoutStats(t, env, stats): '''Loop over the provided layoutstats, sending them on in time ''' sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid lo_stateid = open_stateid ops = [op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() stats_hint = opaque.ffl_stats_collect_hint # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] deviceid = ds.ffds_deviceid ops = [op.putfh(fh), op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)] res = sess.compound(ops) check(res) gda = res.resarray[-1].gdir_device_addr p = FlexUnpacker(gda.da_addr_body) da = p.unpack_ff_device_addr4() p.done() rd_io = io_info4() wr_io = io_info4() rd_lat = ff_io_latency4() wr_lat = ff_io_latency4() for s in stats: dur = get_nfstime(s[1]) # Did not capture these in the gathered traces offset = 0 file_length = 0xffffffffffffffff rd_io.ii_count = 0 rd_io.ii_bytes = 0 wr_io.ii_count = 0 wr_io.ii_bytes = 0 rd_lat.ffil_ops_requested = s[5] rd_lat.ffil_bytes_requested = s[4] rd_lat.ffil_ops_completed = s[6] rd_lat.ffil_bytes_completed = s[2] rd_lat.ffil_bytes_not_delivered = s[3] rd_lat.ffil_total_busy_time = get_nfstime(s[7]) rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8]) wr_lat.ffil_ops_requested = s[12] wr_lat.ffil_bytes_requested = s[11] wr_lat.ffil_ops_completed = s[13] wr_lat.ffil_bytes_completed = s[9] wr_lat.ffil_bytes_not_delivered = s[10] wr_lat.ffil_total_busy_time = get_nfstime(s[14]) wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15]) sleeper = s[0] env.sleep(sleeper) fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1], rd_lat, wr_lat, dur, True) p = FlexPacker() p.pack_ff_layoutupdate4(fflu) lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer()) ops = [op.putfh(fh), op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, lu4)] res = sess.compound(ops) check(res) ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))] res = sess.compound(ops) check(res) res = close_file(sess, fh, stateid=open_stateid) check(res)
def testFlexLayoutTestAccess(t, env): """Get both a LAYOUTIOMODE4_RW and LAYOUTIOMODE4_READ segment making sure that they have the same gid, but a different uid. FLAGS: flex CODE: FFLA1 """ sess = env.c1.new_pnfs_client_session(env.testname(t)) # Create the file res = create_file(sess, env.testname(t)) check(res) # Get layout 1 fh = res.resarray[-1].object open_stateid = res.resarray[-2].stateid ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 8192, open_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 1) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] uid_rw = ds.ffds_user gid_rw = ds.ffds_group ops = [ op.putfh(fh), op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_READ, 0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff) ] res = sess.compound(ops) check(res) lo_stateid = res.resarray[-1].logr_stateid check_seqid(lo_stateid, 2) layout = res.resarray[-1].logr_layout[-1] p = FlexUnpacker(layout.loc_body) opaque = p.unpack_ff_layout4() p.done() # Assume one mirror/storage device ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1] uid_rd = ds.ffds_user gid_rd = ds.ffds_group if uid_rw == uid_rd: fail("Expected uid_rd != %i, got %i" % (uid_rd, uid_rw)) if gid_rw != gid_rd: fail("Expected gid_rd == %i, got %i" % (gid_rd, gid_rw)) res = close_file(sess, fh, stateid=open_stateid) check(res)