Skip to content

Commit 0051612

Browse files
committed
Probe HTTP 1252 with Reseau timer shutdown fix
1 parent b6c88d9 commit 0051612

1 file changed

Lines changed: 36 additions & 11 deletions

File tree

.github/workflows/http-1252-loopback-probe.yml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ jobs:
4747
Pkg.activate(".")
4848
Pkg.add([
4949
Pkg.PackageSpec(name="HTTP", version="2.0.0"),
50-
Pkg.PackageSpec(name="Reseau", version="1.1.4"),
5150
Pkg.PackageSpec(name="Preferences"),
5251
])
52+
Pkg.add(Pkg.PackageSpec(url="https://github.com/JuliaServices/Reseau.jl", rev="codex/shutdown-wakes-timers"))
5353
5454
using Preferences
5555
set_preferences!("HTTP", "precompile_workload" => false; force=true)
@@ -65,6 +65,8 @@ jobs:
6565
println("Threads.nthreads()=", Threads.nthreads())
6666
Pkg.status(["HTTP", "Reseau"])
6767
68+
const HTTP_PROBE_FAILURES = String[]
69+
6870
deadline_ns(seconds) = Int64(time_ns()) + Int64(round(Int, seconds * 1.0e9))
6971
7072
function wait_task_done!(task::Task, label::AbstractString, seconds::Real)
@@ -131,8 +133,9 @@ jobs:
131133
return nothing
132134
end
133135
134-
function http_probe(label::AbstractString; protocol::Symbol=:auto, pause::Bool=false)
135-
println("BEGIN http_probe label=", label, " protocol=", protocol, " pause=", pause)
136+
function http_probe(label::AbstractString; protocol::Symbol=:auto, pause::Bool=false, request_timeout::Real=4.0, allow_failure::Bool=false)
137+
println("BEGIN http_probe label=", label, " protocol=", protocol, " pause=", pause,
138+
" request_timeout=", request_timeout, " allow_failure=", allow_failure)
136139
hits = Threads.Atomic{Int}(0)
137140
server = HTTP.serve!("127.0.0.1", 0; listenany=true) do req
138141
Threads.atomic_add!(hits, 1)
@@ -149,9 +152,9 @@ jobs:
149152
"GET",
150153
"http://$(addr)/ping";
151154
connect_timeout=2.0,
152-
request_timeout=4.0,
153-
response_header_timeout=4.0,
154-
read_idle_timeout=4.0,
155+
request_timeout=request_timeout,
156+
response_header_timeout=request_timeout,
157+
read_idle_timeout=request_timeout,
155158
retry=false,
156159
protocol=protocol,
157160
)
@@ -169,7 +172,12 @@ jobs:
169172
" failed=", istaskfailed(server.serve_task))
170173
showerror(stdout, err, catch_backtrace())
171174
println()
172-
rethrow()
175+
if allow_failure
176+
push!(HTTP_PROBE_FAILURES, String(label))
177+
return nothing
178+
else
179+
rethrow()
180+
end
173181
finally
174182
close_http_server!(server, label)
175183
end
@@ -178,11 +186,13 @@ jobs:
178186
end
179187
180188
raw_tcp_probe()
181-
http_probe("auto-immediate"; protocol=:auto)
182-
http_probe("h1-immediate"; protocol=:h1)
183-
http_probe("h1-paused"; protocol=:h1, pause=true)
189+
http_probe("auto-cold-4"; protocol=:auto, request_timeout=4.0, allow_failure=true)
190+
http_probe("auto-cold-10"; protocol=:auto, request_timeout=10.0)
191+
http_probe("h1-after-cold"; protocol=:h1, request_timeout=4.0)
192+
http_probe("h1-paused"; protocol=:h1, pause=true, request_timeout=4.0)
184193
185194
IOPoll.shutdown!()
195+
println("allowed HTTP probe failures=", HTTP_PROBE_FAILURES)
186196
println("loopback probes complete")
187197
JL
188198
julia --project=. loopback_probe.jl
@@ -222,8 +232,23 @@ jobs:
222232
using Pkg
223233
Pkg.add([
224234
Pkg.PackageSpec(name="HTTP", version="2.0.0"),
225-
Pkg.PackageSpec(name="Reseau", version="1.1.4"),
226235
])
236+
Pkg.add(Pkg.PackageSpec(url="https://github.com/JuliaServices/Reseau.jl", rev="codex/shutdown-wakes-timers"))
227237
Pkg.status(["HTTP", "Reseau"])
228238
'
229239
julia --project=. -e 'using Pkg; Pkg.precompile()'
240+
julia --project=. -e '
241+
using HTTP
242+
server = HTTP.serve!("127.0.0.1", 0; listenany=true) do req
243+
return HTTP.Response(200, "pong")
244+
end
245+
try
246+
addr = HTTP.server_addr(server)
247+
response = HTTP.get("http://$(addr)/ping"; connect_timeout=2.0, request_timeout=4.0, response_header_timeout=4.0, read_idle_timeout=4.0, retry=false)
248+
@assert response.status == 200
249+
@assert String(response.body) == "pong"
250+
println("post-precompile loopback ok")
251+
finally
252+
HTTP.forceclose(server)
253+
end
254+
'

0 commit comments

Comments
 (0)