Skip to contentSkip to conversation

pynfs: fix testLeasePeriod sleep with short lease periods

PATCH In review Scott Mayhew 2 participants 2 messages Nov 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pynfs: fix testLeasePeriod sleep with short lease periods

testLeasePeriod() computed its in-lease sleep as min(lease - 10, 1), which goes negative when the server's lease period is less than 10 seconds, causing time.sleep() to raise "ValueError: sleep length must be non-negative". Clamp the sleep to a non-negative value.

---
Note: knfsd doesn't allow the lease time to be less than 10 seconds, but Hammerspace does.

 nfs4.1/server41tests/st_exchange_id.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.1/server41tests/st_exchange_id.py +1 -1
index acb1a93..66053fa 100644
@@ -498,7 +498,7 @@ def testLeasePeriod(t, env):
     # CREATE_SESSION
     chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
     sec = [callback_sec_parms4(0)]
-    time.sleep(min(lease - 10, 1))
+    time.sleep(max(0, min(lease - 10, 1)))
     # Inside lease period, create_session will success.
     res1 = c1.c.compound([op.create_session(c1.clientid, c1.seqid, 0,
                                         chan_attrs, chan_attrs,
Signature · 1 line
2.56.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Scott Mayhew

testLeasePeriod() computed its in-lease sleep as min(lease - 10, 1), which goes negative when the server's lease period is less than 10 seconds, causing time.sleep() to raise "ValueError: sleep length must be non-negative". Clamp the sleep to a non-negative value.

---
Note: knfsd doesn't allow the lease time to be less than 10 seconds, but Hammerspace does.

 nfs4.1/server41tests/st_exchange_id.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nfs4.1/server41tests/st_exchange_id.py +0 -0
index acb1a93..66053fa 100644

nfs4.1/server41tests/st_exchange_id.py def testLeasePeriod(t, env): · line 504

Quoted 8 lines
nfs4.1/server41tests/st_exchange_id.py +1 -1
@@ -498,7 +498,7 @@ def testLeasePeriod(t, env):
     # CREATE_SESSION
     chan_attrs = channel_attrs4(0,8192,8192,8192,128,8,[])
     sec = [callback_sec_parms4(0)]
-    time.sleep(min(lease - 10, 1))
+    time.sleep(max(0, min(lease - 10, 1)))
     # Inside lease period, create_session will success.
     res1 = c1.c.compound([op.create_session(c1.clientid, c1.seqid, 0,
                                         chan_attrs, chan_attrs,