aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
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
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')
-rw-r--r--test/linuxserver/.dockerignore3
-rw-r--r--test/linuxserver/Dockerfile.peer13
-rw-r--r--test/linuxserver/docker-compose.override.yml10
-rwxr-xr-xtest/linuxserver/test.sh34
4 files changed, 49 insertions, 1 deletions
diff --git a/test/linuxserver/.dockerignore b/test/linuxserver/.dockerignore
new file mode 100644
index 0000000..c226288
--- /dev/null
+++ b/test/linuxserver/.dockerignore
@@ -0,0 +1,3 @@
+**
+
+!/example_config/**
diff --git a/test/linuxserver/Dockerfile.peer1 b/test/linuxserver/Dockerfile.peer1
new file mode 100644
index 0000000..d5d2366
--- /dev/null
+++ b/test/linuxserver/Dockerfile.peer1
@@ -0,0 +1,3 @@
+FROM lscr.io/linuxserver/wireguard:latest
+
+COPY ["example_config/peer1/peer1.conf", "/config/wg0.conf"]
diff --git a/test/linuxserver/docker-compose.override.yml b/test/linuxserver/docker-compose.override.yml
index c20f3ad..2eef2c7 100644
--- a/test/linuxserver/docker-compose.override.yml
+++ b/test/linuxserver/docker-compose.override.yml
@@ -1,4 +1,14 @@
# This file is here for the same reason as the root docker-compose.override.yml.
+# In addition, it defines a peer service.
services:
web:
build: ../..
+ peer1:
+ build:
+ context: .
+ dockerfile: Dockerfile.peer1
+ restart: unless-stopped
+ network_mode: host
+ cap_add:
+ - NET_ADMIN
+ - SYS_MODULE
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"
}