From fbe3c3c59cbf04e119c64e1d31f2e99135c3a7b7 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Sun, 31 Mar 2024 22:49:52 +0200 Subject: [PATCH 1/5] 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 + +} From 5a5b461453b1eddcc74e43fcf687634c1e875606 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 01:21:59 +0200 Subject: [PATCH 2/5] correct version to run against --- upgrade/test_pprof_upload.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test_pprof_upload.sh index ad360a6..9a82598 100644 --- a/upgrade/test_pprof_upload.sh +++ b/upgrade/test_pprof_upload.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT function test_upload_profiles() { - FORGEJO_URL="http://0.0.0.0:6060" + FORGEJO_URL="http://${IP}: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") @@ -24,9 +24,9 @@ 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" + log_info "run 8.0-dev" - start 7.0.0 + start 8.0-dev test_upload_profiles stop From 0b216e98515ebf0c6eaa5d990938c87c4baf22ff Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 01:47:56 +0200 Subject: [PATCH 3/5] actually add test to suite --- upgrade/{test_pprof_upload.sh => test-pprof-upload.sh} | 0 upgrade/upgrade.sh | 2 ++ 2 files changed, 2 insertions(+) rename upgrade/{test_pprof_upload.sh => test-pprof-upload.sh} (100%) diff --git a/upgrade/test_pprof_upload.sh b/upgrade/test-pprof-upload.sh similarity index 100% rename from upgrade/test_pprof_upload.sh rename to upgrade/test-pprof-upload.sh diff --git a/upgrade/upgrade.sh b/upgrade/upgrade.sh index 5f69abc..50dc94d 100755 --- a/upgrade/upgrade.sh +++ b/upgrade/upgrade.sh @@ -50,6 +50,7 @@ function test_successful_upgrades() { } source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh +source $UPGRADE_DIR/test-pprof-upload.sh function test_upgrades() { run dependencies @@ -57,4 +58,5 @@ function test_upgrades() { run test_successful_upgrades run test_forgejo_database_v3_upgrades + run test_forgejo_pprof } From c00a5bfc9cf7b3fa72fa573decef88a8e45dc100 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Mon, 1 Apr 2024 18:29:54 +0200 Subject: [PATCH 4/5] download profilecli --- upgrade/test-pprof-upload.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 9a82598..62a2f4d 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -1,10 +1,12 @@ # SPDX-License-Identifier: MIT function test_upload_profiles() { - FORGEJO_URL="http://${IP}:6060" + FORGEJO_URL="http://localhost: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") + curl -fL https://github.com/grafana/pyroscope/releases/download/v1.1.5/profilecli_1.1.5_linux_amd64.tar.gz -o profilecli.tar.gz + tar xzf profilecli.tar.gz for endpoint in "${endpoints[@]}"; do output=$(basename "$endpoint") @@ -27,6 +29,7 @@ function test_forgejo_pprof() { log_info "run 8.0-dev" start 8.0-dev + test_upload_profiles stop From 4a82c559b909f1f831b37fd07392e78fa7f38ea8 Mon Sep 17 00:00:00 2001 From: TheFox0x7 Date: Tue, 2 Apr 2024 20:15:57 +0200 Subject: [PATCH 5/5] run pprof test on test build --- upgrade/test-pprof-upload.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade/test-pprof-upload.sh b/upgrade/test-pprof-upload.sh index 62a2f4d..0fce257 100644 --- a/upgrade/test-pprof-upload.sh +++ b/upgrade/test-pprof-upload.sh @@ -26,9 +26,9 @@ function test_forgejo_pprof() { stop docker run --name test_pyroscope --rm -d -p 4040:4040 docker.io/grafana/pyroscope - log_info "run 8.0-dev" + log_info "run 8.0-test" - start 8.0-dev + start 8.0-test test_upload_profiles stop