mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
tests: reload cases that hold on slow runners
The downloads spanning a reload asked httpsrv for 64 KB blocks 60 ms apart, meant as two seconds; but httpsrv sends at most 8 KB a block, so they took 245 waits, some 15 seconds, and on the CI runners, whose timers stretch, more than the 20 the cases waited. They now ask for 400 KB in 8 KB blocks 40 ms apart, two seconds indeed, and are waited for up to a minute. The UDP part of the takeover case slept 1.5 s after the reload adding its udppm and then counted every datagram unanswered as lost; it now asks until the service answers first, and wants more than 20 datagrams through the reloads rather than 100, what a slow runner can send. That none is lost is the check. On a failure, run.py prints every log line with a result code other than 0, not only the last lines, so the reason a connection ended is shown wherever it was logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
67a73a4132
commit
6428c4423f
4 files changed
+49
-20
No files matched your search
+22
-3
@@ -115,7 +115,25 @@ def run(t):
|
||||
uconf = conf + f"\n udppm {udp} 127.0.0.1 {echo_port}\n"
|
||||
t.write_config("takeover", uconf)
|
||||
t.http(f"http://127.0.0.1:{adm}/R")
|
||||
time.sleep(1.5)
|
||||
# a UDP service has no listening socket to wait for, so ask until it
|
||||
# answers rather than racing it
|
||||
def udp_answers(deadline):
|
||||
probe = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
probe.settimeout(0.3)
|
||||
try:
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
probe.sendto(b"ping", ("127.0.0.1", udp))
|
||||
probe.recvfrom(2048)
|
||||
return True
|
||||
except OSError:
|
||||
pass
|
||||
return False
|
||||
finally:
|
||||
probe.close()
|
||||
|
||||
t.ok("the UDP service added by a reload answers") if udp_answers(time.time() + 10) else \
|
||||
t.fail("the UDP service added by a reload answers", "a reply", "none in 10 seconds")
|
||||
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
client.settimeout(1)
|
||||
@@ -141,8 +159,9 @@ def run(t):
|
||||
time.sleep(0.02)
|
||||
client.close()
|
||||
echo.close()
|
||||
t.ok(f"a UDP session sends through three reloads ({sent} datagrams)") if sent > 100 else \
|
||||
t.fail("a UDP session sends through three reloads", "more than 100", sent)
|
||||
# how many depends on the runner's speed; that none is lost is the point
|
||||
t.ok(f"a UDP session sends through three reloads ({sent} datagrams)") if sent > 20 else \
|
||||
t.fail("a UDP session sends through three reloads", "more than 20", sent)
|
||||
t.eq(0, lost, "and every datagram comes back, the socket handed over")
|
||||
t.contains(server.output(), f"{udp} 0.0.0.0:0 0 0 0 Accepting connections, taken over",
|
||||
"the UDP service takes the socket over")
|
||||
|
||||
Reference in new issue
Block a user