aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/linuxserver/test.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-03-12 22:21:29 +0100
committerEgor Tensin <Egor.Tensin@gmail.com>2023-03-12 22:21:29 +0100
commit5bb6ca3371771301a013d4bfa83fd5ee931fd1b2 (patch)
tree75df2009d5ae719379f257d179ed680f7985a80c /test/linuxserver/test.sh
parenttest/linuxserver: don't do catch-all AllowedIPs (diff)
downloadwg-api-web-5bb6ca3371771301a013d4bfa83fd5ee931fd1b2.tar.gz
wg-api-web-5bb6ca3371771301a013d4bfa83fd5ee931fd1b2.zip
test/linuxserver: add a peer service
Diffstat (limited to 'test/linuxserver/test.sh')
-rwxr-xr-xtest/linuxserver/test.sh34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/linuxserver/test.sh b/test/linuxserver/test.sh
index d043ce1..83d6a8c 100755
--- a/test/linuxserver/test.sh
+++ b/test/linuxserver/test.sh
@@ -7,6 +7,19 @@ script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
script_dir="$( cd -- "$script_dir" && pwd )"
readonly script_dir
+script_dir_ownership="$( stat -c '%u:%g' -- "$script_dir" )"
+readonly script_dir_ownership
+
+readonly server=10.13.13.1
+
+fix_permissions() {
+ chown -R -- "$script_dir_ownership" "$script_dir/example_config"
+}
+
+docker_build() {
+ docker-compose build --force-rm --progress plain --pull "$@"
+}
+
build_services() {
echo ------------------------------------------------------------------
echo Pull third-party images
@@ -16,7 +29,12 @@ build_services() {
echo ------------------------------------------------------------------
echo Build wg-api-web
echo ------------------------------------------------------------------
- docker-compose build --force-rm --progress plain --pull web
+ docker_build web
+
+ echo ------------------------------------------------------------------
+ echo Build peer1
+ echo ------------------------------------------------------------------
+ docker_build peer1
echo ------------------------------------------------------------------
echo docker-compose up
@@ -24,19 +42,33 @@ build_services() {
docker-compose up -d
}
+ping_server() {
+ echo ------------------------------------------------------------------
+ echo Pinging the server
+ echo ------------------------------------------------------------------
+ ping -c 5 -W 3 "$server"
+}
+
cleanup() {
echo ------------------------------------------------------------------
echo Cleaning up
echo ------------------------------------------------------------------
docker-compose down -v --remove-orphans
+ fix_permissions
}
main() {
cd -- "$script_dir"
trap cleanup EXIT
+ fix_permissions
+ if ping_server; then
+ echo "Should've failed to ping the server!" >&2
+ exit 1
+ fi
build_services
sleep 3
+ ping_server
"$script_dir/../check_web.sh"
}