ci: move tests to bash scripts (#3648)

This improves maintenance because we can now use a regular matrix for
the integration tests and one can locally use tools like shellcheck or a
`bash-lsp` during development.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
Thomas Eizinger
2024-02-15 00:55:28 +11:00
committed by GitHub
parent 354ee3cb02
commit e47c1766bf
8 changed files with 137 additions and 105 deletions

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
source "./scripts/tests/lib.sh"
client_ping_gateway
docker compose stop api relay # Stop portal & relay
sleep 5 # Wait for client to disconnect
client_ping_gateway

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
source "./scripts/tests/lib.sh"
client_ping_gateway
docker compose stop api # Stop portal
sleep 5 # Wait for client to disconnect
client_ping_gateway

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
source "./scripts/tests/lib.sh"
client_ping_gateway
docker compose restart api # Restart portal
sleep 5 # Wait for client to reconnect
client_ping_gateway

15
scripts/tests/lib.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
function install_iptables_drop_rules() {
sudo iptables -I FORWARD 1 -s 172.28.0.100 -d 172.28.0.105 -j DROP
sudo iptables -I FORWARD 1 -s 172.28.0.105 -d 172.28.0.100 -j DROP
}
function remove_iptables_drop_rules() {
sudo iptables -D FORWARD -s 172.28.0.100 -d 172.28.0.105 -j DROP
sudo iptables -D FORWARD -s 172.28.0.105 -d 172.28.0.100 -j DROP
}
function client_ping_gateway() {
docker compose exec -it client timeout 60 sh -c 'until ping -W 1 -c 10 172.20.0.100 &>/dev/null; do true; done'
}

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
source "./scripts/tests/lib.sh"
install_iptables_drop_rules
trap remove_iptables_drop_rules EXIT # Cleanup after us
client_ping_gateway
docker compose stop api # Stop portal
sleep 5 # Wait for client to disconnect
client_ping_gateway

View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
source "./scripts/tests/lib.sh"
install_iptables_drop_rules
trap remove_iptables_drop_rules EXIT # Cleanup after us
client_ping_gateway
docker compose restart api # Restart portal
sleep 5 # Wait for client to reconnect
client_ping_gateway