Add startup checks on test servers

This commit is contained in:
lepapareil 2022-12-16 10:51:33 +01:00
parent e67ed69d2a
commit bcf354a94d
No known key found for this signature in database
GPG Key ID: F4F06B068FB00692
7 changed files with 45 additions and 9 deletions

View File

@ -3,7 +3,7 @@ set -Eeuo pipefail
echo "----- install prerequisite packages -----"
pacman -Syy --noconfirm
pacman -Sy --noconfirm bash curl icu base-devel libxml2 python3 glibc
pacman -Sy --noconfirm bash curl icu base-devel libxml2 python3 glibc openbsd-netcat
python3 get-pip.py

View File

@ -3,6 +3,6 @@ set -Eeuo pipefail
# Install packages
pacman -Syy --noconfirm
pacman -Sy --noconfirm bash python3 python-pip icu base-devel libxml2 glibc
pacman -Sy --noconfirm bash python3 python-pip icu base-devel libxml2 glibc openbsd-netcat
python3 -m pip install --upgrade pip --quiet

View File

@ -2,7 +2,7 @@
set -Eeuo pipefail
# Install packages
yum install -y python38 procps gcc libxml2-devel openssl-devel libcurl-devel
yum install -y python38 procps gcc libxml2-devel openssl-devel libcurl-devel nc
alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 0
alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
alternatives --set python3 /usr/bin/python3.8

View File

@ -3,6 +3,6 @@ set -Eeuo pipefail
# Install packages
apt update
apt -y install bash curl sudo libcurl4-openssl-dev libxml2-utils libxml2-dev libssl-dev python3 python3-pip
apt -y install bash curl sudo libcurl4-openssl-dev libxml2-utils libxml2-dev libssl-dev python3 python3-pip netcat
python3 -m pip install --upgrade pip --quiet

View File

@ -2,6 +2,6 @@
set -Eeuo pipefail
echo "----- install prerequisite packages -----"
yum install -y bash procps gcc libxml2-devel openssl-devel libcurl-devel python3-devel python3-pip
yum install -y bash procps gcc libxml2-devel openssl-devel libcurl-devel python3-devel python3-pip nc
python3 -m pip install --upgrade pip --quiet

View File

@ -3,6 +3,6 @@ set -Eeuo pipefail
sudo apt update
# Install libcurl dev so that hurl can be built dynamically with libcurl
sudo apt install bash libcurl4-openssl-dev libxml2-utils
sudo apt install bash libcurl4-openssl-dev libxml2-utils netcat
python3 -m pip install --upgrade pip --quiet

View File

@ -1,11 +1,47 @@
#!/bin/bash
set -Eeuo pipefail
color_green=$(echo -ne "\033[1;32m")
color_red=$(echo -ne "\033[1;31m")
color_reset=$(echo -ne "\033[0m")
function check_listen_port(){
# vars
label="${1:-}"
port="${2:-}"
wait=5
# usage
if [ -z "${label}" ] || [ -z "${port}" ] ; then
echo "${color_red}Usage:${color_reset} check_listen_port {label} {port} {command}"
return 1
fi
sleep "${wait}"
if nc -zv 127.0.0.1 "${port}" ; then
echo "${color_green}${label} listenning${color_reset} on ${port}"
return 0
else
echo "${color_red}${label} not listening${color_reset} on ${port}"
return 1
fi
}
echo "----- install servers prerequisites -----"
pip3 install --requirement bin/requirements-frozen.txt
echo "----- start servers -----"
cd integration
python3 server.py >server.log 2>&1 &
python3 ssl/server.py >server-ssl.log 2>&1 &
mitmdump --listen-host 127.0.0.1 --listen-port 8888 --modify-header "/From-Proxy/Hello" >mitmdump.log 2>&1 &
echo -e "\n------------------ Starting server.py"
(python3 server.py 2>&1 || true) &
check_listen_port "server.py" 8000
echo -e "\n------------------ Starting ssl/server.py"
(python3 ssl/server.py 2>&1 || true) &
check_listen_port "ssl/server.py" 8001
echo -e "\n------------------ Starting mitmdump"
(mitmdump --listen-host 127.0.0.1 --listen-port 8888 --modify-header "/From-Proxy/Hello" 2>&1 ||true) &
check_listen_port "mitmdump" 8888