Skip to content

Commit

Permalink
add a branch in the debug super-endpoint to remove profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Jun 7, 2024
1 parent ffd6913 commit 7251762
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ProfileEndpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,22 @@ function handle_task_backtraces(stage_path = nothing)
return HTTP.Response(200, backtrace_file)
end

###
### Profile removal
###

function handle_profile_removal(stage_path = nothing)
if stage_path !== nothing
# Remove all files in the stage path
for file in readdir(stage_path)
if isfile(joinpath(stage_path, file))
rm(joinpath(stage_path, file))
end
end
end
return HTTP.Response(200, "All profiles removed")
end

###
### Debug super-endpoint
###
Expand Down Expand Up @@ -358,6 +374,8 @@ function debug_profile_endpoint_with_stage_path(stage_path = nothing)
)
elseif profile_type == "task_backtraces"
return handle_task_backtraces(stage_path)
elseif profile_type == "remove_all_profiles"
return handle_profile_removal(stage_path)
else
return HTTP.Response(400, "Unknown profile_type: $profile_type")
end
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ const url = "http://127.0.0.1:$port"
@test isfile(fname)
end
end

@testset "Debug endpoint profile removal" begin
headers = ["Content-Type" => "application/json"]
payload = JSON3.write(Dict("profile_type" => "remove_all_profiles"))
req = HTTP.post("$url/debug_engine", headers, payload)
@test req.status == 200
end
end

@testset "Heap snapshot $query" for query in ("", "?all_one=true")
Expand Down

0 comments on commit 7251762

Please sign in to comment.