Skip to content

Commit bee2522

Browse files
committed
Improve integration test retry and backoff
1 parent a33c03b commit bee2522

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

test/chisel2.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ def auth_and_issue(domains, chall_type="dns-01", email=None, cert_output=None, c
142142
else:
143143
raise Exception("invalid challenge type %s" % chall_type)
144144

145-
# Retry up to twice upon badNonce errors
146-
for n in range(2):
145+
# Make up to three attempts, retrying on badNonce errors
146+
for n in range(3):
147+
time.sleep(0.2 * n) # No sleep before the first attempt, then backoff
147148
try:
148149
order = client.poll_and_finalize(order)
149150
if cert_output is not None:
150151
with open(cert_output, "w") as f:
151152
f.write(order.fullchain_pem)
152153
except messages.Error as e:
153154
if e.typ == "urn:ietf:params:acme:error:badNonce":
154-
time.sleep(0.01)
155155
continue
156156
else:
157157
break
@@ -242,15 +242,8 @@ def expect_problem(problem_type, func):
242242
if len(domains) == 0:
243243
print(__doc__)
244244
sys.exit(0)
245-
# Retry up to twice upon badNonce errors
246-
for n in range(2):
247-
try:
248-
auth_and_issue(domains)
249-
except messages.Error as e:
250-
if e.typ == "urn:ietf:params:acme:error:badNonce":
251-
time.sleep(0.01)
252-
continue
253-
print(e)
254-
sys.exit(1)
255-
else:
256-
break
245+
try:
246+
auth_and_issue(domains)
247+
except messages.Error as e:
248+
print(e)
249+
sys.exit(1)

0 commit comments

Comments
 (0)