From fbe3c3c59cbf04e119c64e1d31f2e99135c3a7b7 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 31 Mar 2024 22:49:52 +0200 Subject: [PATCH] add pprof test --- upgrade/default-app.ini | 1 + upgrade/test_pprof_upload.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 upgrade/test_pprof_upload.sh diff --git a/upgrade/default-app.ini b/upgrade/default-app.ini index 518504c..6eadb37 100644 --- a/upgrade/default-app.ini +++ b/upgrade/default-app.ini @@ -7,6 +7,7 @@ DOMAIN = ${IP} HTTP_PORT = 3000 SSH_LISTEN_PORT = 2222 LFS_START_SERVER = true +ENABLE_PPROF = true [queue] TYPE = immediate diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test_pprof_upload.sh new file mode 100644 index 0000000..ad360a6 --- /dev/null +++ b/upgrade/test_pprof_upload.sh @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: MIT + +function test_upload_profiles() { + FORGEJO_URL="http://0.0.0.0:6060" + PROFILECLI_URL="http://0.0.0.0:4040" + + endpoints=("/debug/pprof/allocs" "/debug/pprof/block" "/debug/pprof/goroutine" "/debug/pprof/mutex" "/debug/pprof/profile?seconds=5") + + for endpoint in "${endpoints[@]}"; do + output=$(basename "$endpoint") + if [[ $endpoint == *"/profile"* ]]; then + output="profile" + fi + output="${output}.pprof" + # Download the content and save it to a file + curl -s "${FORGEJO_URL}${endpoint}" -o "${output}" + ./profilecli upload ${output} --url=${PROFILECLI_URL} + + rm ${output} + done +} + +function test_forgejo_pprof() { + stop + docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope + + log_info "run 7.0.0" + + start 7.0.0 + test_upload_profiles + stop + + docker stop test_pyroscope + +}