Re: [PATCH] pynfs: add test for read with delegation stateid after close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2025-04-11 at 13:19 +0200, Tigran Mkrtchyan wrote:
> This test checks the independence of delegation stateid from open
> stateid.
> 
> Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@xxxxxxx>
> ---
>  nfs4.1/server41tests/st_delegation.py | 50 ++++++++++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/nfs4.1/server41tests/st_delegation.py b/nfs4.1/server41tests/st_delegation.py
> index f27e852..ea4c073 100644
> --- a/nfs4.1/server41tests/st_delegation.py
> +++ b/nfs4.1/server41tests/st_delegation.py
> @@ -2,7 +2,7 @@ from .st_create_session import create_session
>  from .st_open import open_claim4
>  from xdrdef.nfs4_const import *
>  
> -from .environment import check, fail, create_file, open_file, close_file, do_getattrdict
> +from .environment import check, fail, create_file, open_file, close_file, do_getattrdict, close_file, write_file, read_file
>  from xdrdef.nfs4_type import *
>  import nfs_ops
>  op = nfs_ops.NFS4ops()
> @@ -390,3 +390,51 @@ def testCbGetattrWithChange(t, env):
>      if FATTR4_TIME_DELEG_MODIFY in attrs2:
>          if attrs1[FATTR4_TIME_MODIFY] == attrs2[FATTR4_TIME_DELEG_MODIFY]:
>              fail("Bad modify time: ", attrs1[FATTR4_TIME_MODIFY], " == ", attrs2[FATTR4_TIME_DELEG_MODIFY])
> +
> +def testDelegReadAfterClose(t, env):
> +    """Test read with delegation stateid after close
> +
> +    Create file with some data. Open the file for read, get delegation, close the file.
> +    Tesr that reads with delegation stateid still works.
> +
> +    FLAGS: deleg all
> +    CODE: DELEG26
> +    """
> +    sess1 = env.c1.new_client_session(b"%s_1" % env.testname(t))
> +
> +    name = env.testname(t)
> +    owner = b"owner_%s" % name
> +
> +    # craete file with some data

nit: "create"

> +    res = create_file(sess1, owner)
> +    check(res)
> +
> +    fh = res.resarray[-1].object
> +    stateid = res.resarray[-2].stateid
> +
> +    res = write_file(sess1, fh, b'data', 0, stateid)
> +    check(res)
> +
> +    res = close_file(sess1, fh, stateid=stateid)
> +    check(res)
> +
> +
> +    # open file, get delegation, close the file
> +    access = OPEN4_SHARE_ACCESS_READ | OPEN4_SHARE_ACCESS_WANT_READ_DELEG;
> +    res = open_file(sess1, owner, access = access)
> +    check(res)
> +
> +    fh = res.resarray[-1].object
> +    stateid = res.resarray[-2].stateid
> +    delegstateid = res.resarray[-2].delegation.read.stateid
> +

It might be good to check that you got a delegation here, though the
test will obviously fail either way.
 * 
> +    res = close_file(sess1, fh, stateid=stateid)
> +    check(res)
> +
> +    # Issue READ with delegation sateid

nit: "delegation stateid"

> +    res = read_file(sess1, fh, 0, 10, delegstateid)
> +    check(res)
> +
> +    # cleanup: return delegation
> +    res = sess1.compound([op.putfh(fh), op.delegreturn(delegstateid)])
> +    check(res)

Looks reasonable otherwise.

Reviewed-by: Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux