public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Calum Mackay <calum.mackay@oracle.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] pynfs: add courteous server tests
Date: Fri, 19 Feb 2021 16:51:04 -0500	[thread overview]
Message-ID: <YDAyyOS6SM0wEgWd@pick.fieldses.org> (raw)
In-Reply-To: <20210219212447.15549-1-calum.mackay@oracle.com>

On Fri, Feb 19, 2021 at 09:24:47PM +0000, Calum Mackay wrote:
> Add a first test that simply locks, sleeps for twice the lease period,
> then unlocks.
> 
> Signed-off-by: Calum Mackay <calum.mackay@oracle.com>
> ---
> 
> I plan to add some more tests shortly, but will send what I have now,
> in case it's useful for the upcoming BAT. This first test has been tried
> against Solaris & Linux (discourteous) servers.

Looks good to me.  Thanks!

--b.

> 
>  nfs4.1/server41tests/__init__.py    |  1 +
>  nfs4.1/server41tests/st_courtesy.py | 47 +++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+)
>  create mode 100644 nfs4.1/server41tests/st_courtesy.py
> 
> diff --git a/nfs4.1/server41tests/__init__.py b/nfs4.1/server41tests/__init__.py
> index a4d7ee65fb5e..ebb4e8847151 100644
> --- a/nfs4.1/server41tests/__init__.py
> +++ b/nfs4.1/server41tests/__init__.py
> @@ -25,4 +25,5 @@ __all__ = ["st_exchange_id.py", # draft 21
>             "st_sparse.py",
>             "st_flex.py",
>             "st_xattr.py",
> +           "st_courtesy.py",
>             ]
> diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py
> new file mode 100644
> index 000000000000..5e13dad44a01
> --- /dev/null
> +++ b/nfs4.1/server41tests/st_courtesy.py
> @@ -0,0 +1,47 @@
> +from .st_create_session import create_session
> +from xdrdef.nfs4_const import *
> +
> +from .environment import check, fail, create_file, open_file, close_file
> +from .environment import open_create_file_op, use_obj
> +from xdrdef.nfs4_type import open_owner4, openflag4, createhow4, open_claim4
> +from xdrdef.nfs4_type import creatverfattr, fattr4, stateid4, locker4, lock_owner4
> +from xdrdef.nfs4_type import open_to_lock_owner4
> +import nfs_ops
> +op = nfs_ops.NFS4ops()
> +import threading
> +
> +
> +def _getleasetime(sess):
> +    res = sess.compound([op.putrootfh(), op.getattr(1 << FATTR4_LEASE_TIME)])
> +    return res.resarray[-1].obj_attributes[FATTR4_LEASE_TIME]
> +
> +def testLockSleepLockU(t, env):
> +    """test server courtesy by having LOCK and LOCKU
> +       in separate compounds, separated by a sleep of twice the lease period
> +
> +    FLAGS: courteous
> +    CODE: COUR1
> +    """
> +    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, b"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) ]
> +    res = sess1.compound([op.putfh(fh)] + lock_ops)
> +    check(res, NFS4_OK)
> +
> +    lease_time = _getleasetime(sess1)
> +    env.sleep(lease_time * 2, "twice the lease period")
> +
> +    lock_stateid = res.resarray[-1].lock_stateid
> +    lock_ops = [ op.locku(WRITE_LT, 0, lock_stateid, 0, NFS4_UINT64_MAX) ]
> +    res = sess1.compound([op.putfh(fh)] + lock_ops)
> +    check(res, NFS4_OK, warnlist = [NFS4ERR_BADSESSION])
> +
> +    res = close_file(sess1, fh, stateid=stateid)
> +    check(res)
> -- 
> 2.18.4
> 


      reply	other threads:[~2021-02-19 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-19 21:24 [PATCH] pynfs: add courteous server tests Calum Mackay
2021-02-19 21:51 ` J. Bruce Fields [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YDAyyOS6SM0wEgWd@pick.fieldses.org \
    --to=bfields@redhat.com \
    --cc=calum.mackay@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox