mirror of
https://github.com/getsentry/self-hosted.git
synced 2025-12-08 19:46:14 +00:00
Since we download JS SDKs in a for loop which invokes a separate docker container for each `curl` run, we seem to be triggering some sort of a DoS protection. And rightfully so as the old method causes TCP and TLS churn although we advertise we support HTTP/1.1 and HTTP/2. This patch does a few things: 1. Uses `curl`s globbing support to download all files in one go, maxing TCP and TLS reuse. This should fix the DoS protection 2. Uses `curl`'s `--compress` option to make things even more efficient 3. Uses `curl`'s `--create-dirs` to save 1 docker container run per version for creating the directory 4. Removes the `-I` `HEAD` checks in favor of a `-f` fail option combined with `|| true` which makes curl fail and not write the output on a non-200 response while still allowing the script to succeed 5. To make sure the above approach works, it adds a file size test, requiring all downloaded files to be larger than 1kB
33 lines
1.0 KiB
Bash
Executable File
33 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source _unit-test/_test_setup.sh
|
|
source install/dc-detect-version.sh
|
|
$dcb --force-rm web
|
|
|
|
export SETUP_JS_SDK_ASSETS=1
|
|
|
|
source install/setup-js-sdk-assets.sh
|
|
|
|
sdk_files=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx ls -lah /var/www/js-sdk/)
|
|
sdk_tree=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx tree /var/www/js-sdk/ | tail -n 1)
|
|
non_empty_file_count=$(docker compose run --no-deps --rm -v "sentry-nginx-www:/var/www" nginx find /var/www/js-sdk/ -type f -size +1k | wc -l)
|
|
|
|
# `sdk_files` should contains 5 lines, '4.*', '5.*', '6.*', `7.*` and `8.*`
|
|
echo $sdk_files
|
|
total_directories=$(echo "$sdk_files" | grep -c '[45678]\.[0-9]*\.[0-9]*$')
|
|
echo $total_directories
|
|
test "5" == "$total_directories"
|
|
echo "Pass"
|
|
|
|
# `sdk_tree` should output "5 directories, 17 files"
|
|
echo "$sdk_tree"
|
|
test "5 directories, 17 files" == "$(echo "$sdk_tree")"
|
|
echo "Pass"
|
|
|
|
# Files should all be >1k (ensure they are not empty)
|
|
echo "Testing file sizes"
|
|
test "17" == "$non_empty_file_count"
|
|
echo "Pass"
|
|
|
|
report_success
|