Skip to content

Commit

Permalink
try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quentingodeau committed Jan 25, 2024
1 parent ba43e50 commit dbdefc8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 32 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ jobs:
if: ${{ matrix.arch == 'linux_amd64' || matrix.arch == 'linux_amd64_gcc4' }}
run: |
azurite > azurite_log.txt 2>&1 &
./scripts/run_squid.sh 3128 >squid.log 2>&1 &
./scripts/run_squid.sh 3129 auth >squid_auth.log 2>&1 &
./scripts/run_squid.sh --port 3128 --log_dir squid_logs &
./scripts/run_squid.sh --port 3129 --log_dir squid_auth_logs --auth &
sleep 10
./scripts/upload_test_files_to_azurite.sh
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
cat azurite_log.txt
echo "## squid"
cat squid.log
cat squid_logs/*
echo "## squid with auth"
cat squid_auth.log
echo "## squid auth"
cat squid_auth_logs/*
18 changes: 9 additions & 9 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
run: |
brew install squid
npm install -g azurite
./scripts/run_squid.sh 3128 >squid.log 2>&1 &
./scripts/run_squid.sh 3129 auth >squid_auth.log 2>&1 &
./scripts/run_squid.sh --port 3128 --log_dir squid_logs &
./scripts/run_squid.sh --port 3129 --log_dir squid_auth_logs --auth &
azurite > azurite_log.txt 2>&1 &
sleep 10
./scripts/upload_test_files_to_azurite.sh
Expand All @@ -77,11 +77,11 @@ jobs:
if: always() && matrix.osx_build_arch == 'x86_64'
shell: bash
run: |
echo "## azurite"
cat azurite_log.txt

echo "## squid"
cat squid.log
echo "## azurite"
cat azurite_log.txt
echo "## squid"
cat squid_logs/*
echo "## squid with auth"
cat squid_auth.log
echo "## squid with auth"
cat squid_auth_logs/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ __queuestorage__/
__azurite_db_*__.json

# squid
squid_logs
squid_users
squid.pid
squid.pid
squid.conf
squidauth.conf
squid_auth.conf
68 changes: 51 additions & 17 deletions scripts/run_squid.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
#!/bin/bash

if [[ "${1}" == '-h' ]] || [[ "${1}" == '--help' ]]; then
help() {
echo "Usage: ${0} [port] [auth]"
echo " port Port number for squid to lisen to (by default 3128)"
echo " auth Optional string ('auth') to force user basic authentification (autherwise no authentification is required)"
exit 0
fi
}

port='3128'
auth='false'
log_dir="squid_logs"
conf_file="squid.conf"

while [[ $# -gt 0 ]]; do
case "${1}" in
-h|--help)
help
;;
-p|--port)
port="${2}"
shift # past argument
shift # past value
;;
--auth)
auth='true'
conf_file="squid_auth.conf"
shift # past argument
;;
--log_dir)
log_dir="${2}"
shift # past argument
shift # past value
;;
*)
echo "Unknown option ${1}"
exit 1
;;
esac
done

conf_file="squid${2:-}.conf"

echo "http_port 127.0.0.1:${1:-3128}" >"${conf_file}"
echo 'pid_filename ${service_name}.pid' >>"${conf_file}"
mkdir "${log_dir}"

echo '# Send Logs to stdout' >>"${conf_file}"
echo 'logfile_rotate 0' >>"${conf_file}"
echo 'logfile_daemon stdio:/dev/stdout' >>"${conf_file}"
echo 'access_log stdio:/dev/stdout' >>"${conf_file}"
echo 'cache_log stdio:/dev/stdout' >>"${conf_file}"
echo 'cache_store_log stdio:/dev/stdout' >>"${conf_file}"
echo "http_port 127.0.0.1:${port}" >"${conf_file}"
echo 'pid_filename ${service_name}.pid' >>"${conf_file}"

echo 'logfile_rotate 0' >>"${conf_file}"
echo "logfile_daemon ${log_dir}/daemon.log" >>"${conf_file}"
echo "access_log ${log_dir}/access.log" >>"${conf_file}"
echo "cache_log ${log_dir}/cache.log" >>"${conf_file}"
echo "cache_store_log ${log_dir}/cache_store.log" >>"${conf_file}"

if [[ "${2}" == "auth" ]]; then

if [[ "${auth}" == "true" ]]; then
# User 'john' with password 'doe'
echo 'john:$apr1$dalj9e7s$AhqY28Hvl3EcNblNJMiXa0' >squid_users

squid_version="$(squid --version | head -n1 | grep -o 'Version [^ ]*' | cut -d ' ' -f 2)"
if [[ "$(uname)" == "Darwin" ]]; then
squid_version="$(squid --version | head -n1 | grep -o 'Version [^ ]*' | cut -d ' ' -f 2)"
auth_basic_program="/usr/local/Cellar/squid/${squid_version}/libexec/basic_ncsa_auth"
else
auth_basic_program="/usr/lib/squid/basic_ncsa_auth"
if [[ "$(echo ${squid_version} | cut -d '.' -f 1)" == '3' ]]; then
auth_basic_program="/usr/lib/squid3/basic_ncsa_auth"
else
auth_basic_program="/usr/lib/squid/basic_ncsa_auth"
fi
fi

echo '# Add authentification options' >>"${conf_file}"
Expand All @@ -42,6 +78,4 @@ else
echo 'http_access allow localhost' >>"${conf_file}"
fi

cat "${conf_file}"

exec squid -N -f "${conf_file}"
exec squid -N -f "${conf_file}"

0 comments on commit dbdefc8

Please sign in to comment.