hurl/bin/test/test_prerequisites.ps1

47 lines
2.5 KiB
PowerShell
Raw Normal View History

2022-12-28 12:20:27 +03:00
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'
2023-04-05 12:07:50 +03:00
write-host -foregroundcolor Cyan "----- install tests prerequisites -----"
$actual_dir=(Get-Location).Path
2022-09-27 10:04:21 +03:00
$project_root_path=(Resolve-Path -LiteralPath $PSScriptRoot\..\..).path
# install python libs
2023-06-13 12:27:02 +03:00
python3 -m pip install --requirement $project_root_path\bin\requirements-frozen.txt
2022-12-28 12:20:27 +03:00
if ($LASTEXITCODE) { Throw }
# start mock servers
2022-09-27 10:04:21 +03:00
cd $project_root_path\integration
2023-01-20 13:45:49 +03:00
New-Item -ItemType Directory -Force -Path build
2022-12-28 12:20:27 +03:00
2023-04-05 12:07:50 +03:00
python server.py 2>&1 > build\server.log &
2022-12-28 12:20:27 +03:00
if ($LASTEXITCODE) { Throw }
2022-09-27 10:04:21 +03:00
sleep 5
2023-04-05 12:07:50 +03:00
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8000) {write-host -foregroundcolor Green "server is up"} else {write-host -foregroundcolor Red "server is down" ; cat build\server.log ; exit 1}
2022-12-28 12:20:27 +03:00
2023-04-05 12:07:50 +03:00
python ssl/server.py 8001 ssl/server/cert.selfsigned.pem false 2>&1 > build\server-ssl-selfsigned.log &
2022-12-28 12:20:27 +03:00
if ($LASTEXITCODE) { Throw }
2022-09-27 10:04:21 +03:00
sleep 5
2023-04-05 12:07:50 +03:00
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8001) {write-host -foregroundcolor Green "server-ssl-selfsigned up"} else {write-host -foregroundcolor Red "server-ssl-selfsigned is down" ; cat build\server-ssl-selfsigned.log ; exit 1}
2022-12-28 12:20:27 +03:00
2023-04-05 12:07:50 +03:00
python ssl/server.py 8002 ssl/server/cert.pem false 2>&1 > build\server-ssl-signedbyca.log &
2022-12-28 12:20:27 +03:00
if ($LASTEXITCODE) { Throw }
2022-09-27 10:04:21 +03:00
sleep 5
2023-04-05 12:07:50 +03:00
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8002) {write-host -foregroundcolor Green "server-ssl-signedbyca up"} else {write-host -foregroundcolor Red "server-ssl-signedbyca is down" ; cat build\server-ssl-signedbyca.log ; exit 1}
2022-12-11 13:57:19 +03:00
2023-04-05 12:07:50 +03:00
python ssl/server.py 8003 ssl/server/cert.pem true 2>&1 > build\server-ssl-client-authent.log &
2022-12-11 13:57:19 +03:00
if ($LASTEXITCODE) { Throw }
sleep 5
2023-04-05 12:07:50 +03:00
if (netstat -ano | Select-String LISTENING | Select-string 127.0.0.1:8003) {write-host -foregroundcolor Green "server-ssl-client-authent up"} else {write-host -foregroundcolor Red "server-ssl-client-authent is down" ; cat build\server-ssl-client-authent.log ; exit 1}
2023-04-05 12:07:50 +03:00
Get-ChildItem -Force C:\Squid\bin
write-output "cache deny all" "cache_log /dev/null" "access_log /dev/null" "http_access allow all" "http_port 0.0.0.0:3128" "request_header_add From-Proxy Hello" "reply_header_add From-Proxy Hello" > squid.conf
C:\Squid\bin\squid -k kill 2>&1 || true
C:\Squid\bin\squid -d 2 -N -f squid.conf 2>&1 > build\proxy.log &
if ($LASTEXITCODE) { Throw }
sleep 5
2023-04-05 12:07:50 +03:00
if (netstat -ano | Select-String LISTENING | Select-string 0.0.0.0:3128) {write-host -foregroundcolor Green "proxy is up"} else {write-host -foregroundcolor Red "proxy is down" ; cat build\proxy.log ; exit 1}
cd $actual_dir
2022-09-27 10:04:21 +03:00