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)]) check(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID]) # An unknown number of lookups will be present for r in res.resarray: if r.resop == OP_OPEN: stateid = r.stateid elif r.resop == OP_GETFH: fh = r.object break # Test passed, now cleanup! res = sess1.compound([op.putfh(fh), op.close(0, stateid)]) check(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 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 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 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 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.setattr(current_stateid, {FATTR4_SIZE: size})]) check(res, NFS4_OK)
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)
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.setattr(current_stateid, {FATTR4_SIZE: size})]) check(res, NFS4_OK)
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 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)
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 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) fh = res.resarray[-2].object stateid = res.resarray[-3].stateid # Test passed, now cleanup! res = sess1.compound([op.putfh(fh), op.close(0, stateid)]) check(res)
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) fh = res.resarray[-2].object stateid = res.resarray[-3].stateid # Test passed, now cleanup! res = sess1.compound([op.putfh(fh), op.close(0, stateid)]) check(res)
def testFlexLayoutStatsSmall(t, env): """Open 20 "small" files and simulate LAYOUTSTATS for them 1) OPEN, LAYOUTGET 2) GETDEVINFO 3) LAYOUTRETURN, CLOSE FLAGS: flex layoutstats CODE: FFLS1 """ lats = [ 93089, 107683, 112340, 113195, 130412, 138390, 140427, 158824, 193078, 201879, 391634, 404757, 2201181, 2232614, 2280089, 2296343, 2341763, 2392984, 3064546, 3070314 ] durs = [ 3387666, 3439506, 3737081, 4448315, 4380523, 4419273, 4419746, 5903420, 5932432, 5932938, 7573082, 11085497, 11125274, 11126513, 13720303, 15990926, 16020425, 16020948, 20181628, 20213871 ] if len(lats) != len(durs): fail("Lats and durs not same") sess = env.c1.new_pnfs_client_session(env.testname(t)) for i in range(len(lats)): open_op = open_create_file_op(sess, env.testname(t) + str(i), open_create=OPEN4_CREATE) res = sess.compound(open_op + [ op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 4196, current_stateid, 0xffff) ]) check(res, NFS4_OK) lo_stateid = res.resarray[-1].logr_stateid fh = res.resarray[-2].object open_stateid = res.resarray[-3].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] stats_hint = opaque.ffl_stats_collect_hint 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(0, 0) wr_io = io_info4(1, 16384) rd_lat = ff_io_latency4(0, 0, 0, 0, 0, nfstime4(0, 0), nfstime4(0, 0)) wr_lat = ff_io_latency4(1, 16384, 1, 16384, 0, nfstime4(0, lats[i]), nfstime4(0, lats[i])) offset = 0 file_length = 16384 dur = durs[i] fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1], rd_lat, wr_lat, nfstime4(0, dur), True) ffio = ff_iostats4(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, fflu) fflr = ff_layoutreturn4([], [ffio]) p = FlexPacker() p.pack_ff_layoutreturn4(fflr) ops = [ op.putfh(fh), op.layoutreturn( False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4( LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, p.get_buffer()))), op.close(0, open_stateid) ] res = sess.compound(ops) check(res)
def testFlexLayoutStatsSmall(t, env): """Open 20 "small" files and simulate LAYOUTSTATS for them 1) OPEN, LAYOUTGET 2) GETDEVINFO 3) LAYOUTRETURN, CLOSE FLAGS: flex layoutstats CODE: FFLS1 """ lats = [93089, 107683, 112340, 113195, 130412, 138390, 140427, 158824, 193078, 201879, 391634, 404757, 2201181, 2232614, 2280089, 2296343, 2341763, 2392984, 3064546, 3070314] durs = [3387666, 3439506, 3737081, 4448315, 4380523, 4419273, 4419746, 5903420, 5932432, 5932938, 7573082, 11085497, 11125274, 11126513, 13720303, 15990926, 16020425, 16020948, 20181628, 20213871] if len(lats) != len(durs): fail("Lats and durs not same") sess = env.c1.new_pnfs_client_session(env.testname(t)) for i in range(len(lats)): open_op = open_create_file_op(sess, env.testname(t) + str(i), open_create=OPEN4_CREATE) res = sess.compound( open_op + [op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0, 0xffffffffffffffff, 4196, current_stateid, 0xffff)]) check(res, NFS4_OK) lo_stateid = res.resarray[-1].logr_stateid fh = res.resarray[-2].object open_stateid = res.resarray[-3].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] stats_hint = opaque.ffl_stats_collect_hint 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(0, 0) wr_io = io_info4(1, 16384) rd_lat = ff_io_latency4(0, 0, 0, 0, 0, nfstime4(0, 0), nfstime4(0, 0)) wr_lat = ff_io_latency4(1, 16384, 1, 16384, 0, nfstime4(0, lats[i]), nfstime4(0, lats[i])) offset = 0 file_length = 16384 dur = durs[i] fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1], rd_lat, wr_lat, nfstime4(0, dur), True) ffio = ff_iostats4(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, fflu) fflr = ff_layoutreturn4([], [ffio]) p = FlexPacker() p.pack_ff_layoutreturn4(fflr) ops = [op.putfh(fh), op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY, layoutreturn4(LAYOUTRETURN4_FILE, layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, p.get_buffer()))), op.close(0, open_stateid)] res = sess.compound(ops) check(res)