]> Untitled Git - lemmy.git/commitdiff
implement federation test in bash
authorFelix Ableitner <me@nutomic.com>
Thu, 10 Dec 2020 17:03:11 +0000 (18:03 +0100)
committerFelix Ableitner <me@nutomic.com>
Thu, 10 Dec 2020 17:03:11 +0000 (18:03 +0100)
.drone.yml
api_tests/prepare-drone-federation-test.sh [new file with mode: 0755]

index 44569920665a221d7e5d12ade7bafc07067b15c2..997bc104e072ffbc8de3386cdce1d28c17d23fc7 100644 (file)
@@ -79,30 +79,9 @@ steps:
   - name: run federation tests
     image: node:15-alpine3.12
     user: root
-    environment:
-      LEMMY_JWT_SECRET: changeme
-      LEMMY_FEDERATION__ENABLED: true
-      LEMMY_TLS_ENABLED: false
-      LEMMY_SETUP__ADMIN_PASSWORD: lemmy
-      LEMMY_RATE_LIMIT__POST: 99999
-      LEMMY_RATE_LIMIT__REGISTER: 99999
-      LEMMY_CAPTCHA__ENABLED: false
-      RUST_BACKTRACE: 1
-      RUST_LOG: debug
-      LEMMY_HOSTNAME: lemmy-alpha:8541
-      LEMMY_DATABASE_URL: postgres://lemmy:password@postgres_alpha:5432/lemmy
-      LEMMY_FEDERATION__ALLOWED_INSTANCES: lemmy-beta,lemmy-gamma,lemmy-delta,lemmy-epsilon
-      LEMMY_SETUP__ADMIN_USERNAME: lemmy_alpha
-      LEMMY_SETUP__SITE_NAME: lemmy-alpha
-    volumes:
-      - name: dieselcli
-        path: /dieselcli
     commands:
-      - mkdir -p volumes/pictrs_{alpha,beta,gamma,delta,epsilon}
-      - chown -R 991:991 volumes/pictrs_{alpha,beta,gamma,delta,epsilon}
-      - LEMMY_PORT=8541 ./target/debug/lemmy_server &
-      - LEMMY_PORT=8551 ./target/debug/lemmy_server &
       - cd api_tests/
+      - ./prepare-prepare-drone-federation-test.sh
       - yarn
       - yarn api-test
 
@@ -110,8 +89,7 @@ steps:
     image: plugins/docker
     user: root
     commands:
-      # TODO: remove newline, add `latest` (eg `0.9.1,latest`)
-      - git describe > .tags
+      - "$(git describe),latest" > .tags
     when:
       ref:
       - refs/tags/*
diff --git a/api_tests/prepare-drone-federation-test.sh b/api_tests/prepare-drone-federation-test.sh
new file mode 100755 (executable)
index 0000000..d8f66a1
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/bash
+set -e
+
+export LEMMY_JWT_SECRET=changeme
+export LEMMY_FEDERATION__ENABLED=true
+export LEMMY_TLS_ENABLED=false
+export LEMMY_SETUP__ADMIN_PASSWORD=lemmy
+export LEMMY_RATE_LIMIT__POST=99999
+export LEMMY_RATE_LIMIT__REGISTER=99999
+export LEMMY_CAPTCHA__ENABLED=false
+export RUST_BACKTRACE=1
+export RUST_LOG=debug
+
+echo "start alpha"
+LEMMY_HOSTNAME=lemmy-alpha:8541 \
+  LEMMY_PORT=8541 \
+  LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_alpha:5432/lemmy \
+  LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-beta,lemmy-gamma,lemmy-delta,lemmy-epsilon \
+  LEMMY_SETUP__ADMIN_USERNAME=lemmy_alpha \
+  LEMMY_SETUP__SITE_NAME=lemmy-alpha \
+  ../target/debug/lemmy_server &
+
+echo "start beta"
+LEMMY_HOSTNAME=lemmy-beta:8551 \
+  LEMMY_PORT=8551 \
+  LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_beta:5432/lemmy \
+  LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-alpha,lemmy-gamma,lemmy-delta,lemmy-epsilon \
+  LEMMY_SETUP__ADMIN_USERNAME=lemmy_beta \
+  LEMMY_SETUP__SITE_NAME=lemmy-beta \
+  ../target/debug/lemmy_server &
+
+echo "start gamma"
+LEMMY_HOSTNAME=lemmy-gamma:8561 \
+  LEMMY_PORT=8561 \
+  LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_gamma:5432/lemmy \
+  LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-alpha,lemmy-beta,lemmy-delta,lemmy-epsilon \
+  LEMMY_SETUP__ADMIN_USERNAME=lemmy_gamma \
+  LEMMY_SETUP__SITE_NAME=lemmy-gamma \
+  ../target/debug/lemmy_server &
+
+echo "start delta"
+# An instance with only an allowlist for beta
+LEMMY_HOSTNAME=lemmy-delta:8571 \
+  LEMMY_PORT=8571 \
+  LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_delta:5432/lemmy \
+  LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-beta \
+  LEMMY_SETUP__ADMIN_USERNAME=lemmy_delta \
+  LEMMY_SETUP__SITE_NAME=lemmy-delta \
+  ../target/debug/lemmy_server &
+
+echo "start epsilon"
+# An instance who has a blocklist, with lemmy-alpha blocked
+LEMMY_HOSTNAME=lemmy-epsilon:8581 \
+  LEMMY_PORT=8581 \
+  LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_epsilon:5432/lemmy \
+  LEMMY_FEDERATION__BLOCKED_INSTANCES=lemmy-alpha \
+  LEMMY_SETUP__ADMIN_USERNAME=lemmy_epsilon \
+  LEMMY_SETUP__SITE_NAME=lemmy-epsilon \
+  ../target/debug/lemmy_server &
+
+echo "wait for all instances to start"
+while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8541/api/v1/site')" != "200" ]]; do sleep 1; done
+while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8551/api/v1/site')" != "200" ]]; do sleep 1; done
+while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8561/api/v1/site')" != "200" ]]; do sleep 1; done
+while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8571/api/v1/site')" != "200" ]]; do sleep 1; done
+while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8581/api/v1/site')" != "200" ]]; do sleep 1; done