From cddf9a6a85998434716657c3352e0c6c71d19dc5 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 17 Feb 2021 11:12:20 -0500 Subject: [PATCH] Trying to fix tests, try 1 --- api_tests/prepare-drone-federation-test.sh | 44 ++++--------- crates/utils/src/settings.rs | 12 ++-- docker/dev/Dockerfile | 1 - docker/federation/docker-compose.yml | 75 +++------------------- docker/prod/Dockerfile | 1 - docker/prod/Dockerfile.arm | 1 - 6 files changed, 28 insertions(+), 106 deletions(-) diff --git a/api_tests/prepare-drone-federation-test.sh b/api_tests/prepare-drone-federation-test.sh index de9b7b844..32eb75136 100755 --- a/api_tests/prepare-drone-federation-test.sh +++ b/api_tests/prepare-drone-federation-test.sh @@ -1,13 +1,6 @@ #!/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 LEMMY_TEST_SEND_SYNC=1 export RUST_BACKTRACE=1 @@ -35,52 +28,39 @@ fi killall lemmy_server || true +echo "$PWD" + echo "start alpha" LEMMY_HOSTNAME=lemmy-alpha:8541 \ - LEMMY_PORT=8541 \ + LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_alpha.hjson \ LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_alpha" \ - 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/lemmy_server >/dev/null 2>&1 & + target/lemmy_server >/tmp/lemmy_alpha.out 2>&1 & echo "start beta" LEMMY_HOSTNAME=lemmy-beta:8551 \ - LEMMY_PORT=8551 \ + LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_beta.hjson \ LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_beta" \ - 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/lemmy_server >/dev/null 2>&1 & + target/lemmy_server >/tmp/lemmy_beta.out 2>&1 & echo "start gamma" LEMMY_HOSTNAME=lemmy-gamma:8561 \ - LEMMY_PORT=8561 \ + LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_gamma.hjson \ LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_gamma" \ - 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/lemmy_server >/dev/null 2>&1 & + target/lemmy_server >/tmp/lemmy_gamma.out 2>&1 & echo "start delta" # An instance with only an allowlist for beta LEMMY_HOSTNAME=lemmy-delta:8571 \ - LEMMY_PORT=8571 \ + LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_delta.hjson \ LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_delta" \ - LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-beta \ - LEMMY_SETUP__ADMIN_USERNAME=lemmy_delta \ - LEMMY_SETUP__SITE_NAME=lemmy-delta \ - target/lemmy_server >/dev/null 2>&1 & + target/lemmy_server >/tmp/lemmy_delta.out 2>&1 & echo "start epsilon" # An instance who has a blocklist, with lemmy-alpha blocked LEMMY_HOSTNAME=lemmy-epsilon:8581 \ - LEMMY_PORT=8581 \ + LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_epsilon.hjson \ LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_epsilon" \ - LEMMY_FEDERATION__BLOCKED_INSTANCES=lemmy-alpha \ - LEMMY_SETUP__ADMIN_USERNAME=lemmy_epsilon \ - LEMMY_SETUP__SITE_NAME=lemmy-epsilon \ - target/lemmy_server >/dev/null 2>&1 & + target/lemmy_server >/tmp/lemmy_epsilon.out 2>&1 & echo "wait for all instances to start" while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8541/api/v2/site')" != "200" ]]; do sleep 1; done diff --git a/crates/utils/src/settings.rs b/crates/utils/src/settings.rs index 6400264fd..0a6859f9b 100644 --- a/crates/utils/src/settings.rs +++ b/crates/utils/src/settings.rs @@ -135,16 +135,16 @@ impl Default for DatabaseConfig { #[derive(Debug, Deserialize, Clone)] pub struct FederationConfig { pub enabled: bool, - pub allowed_instances: String, - pub blocked_instances: String, + pub allowed_instances: Option, + pub blocked_instances: Option, } impl Default for FederationConfig { fn default() -> Self { Self { enabled: false, - allowed_instances: "".into(), - blocked_instances: "".into(), + allowed_instances: Some("".into()), + blocked_instances: Some("".into()), } } } @@ -201,11 +201,11 @@ impl Settings { .to_owned() .unwrap_or_default() .allowed_instances + .unwrap_or_default() .split(',') .map(|d| d.trim().to_string()) .collect(); - // The defaults.hjson config always returns a [""] allowed_instances.retain(|d| !d.eq("")); allowed_instances } @@ -216,11 +216,11 @@ impl Settings { .to_owned() .unwrap_or_default() .blocked_instances + .unwrap_or_default() .split(',') .map(|d| d.trim().to_string()) .collect(); - // The defaults.hjson config always returns a [""] blocked_instances.retain(|d| !d.eq("")); blocked_instances } diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index a2712f9f2..d56a1fdcf 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -56,7 +56,6 @@ RUN addgroup -g 1000 lemmy RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy # Copy resources -COPY --chown=lemmy:lemmy config/defaults.hjson /config/defaults.hjson COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy RUN chown lemmy:lemmy /app/lemmy diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 72e6c5cec..ed662e441 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -38,20 +38,9 @@ services: - lemmy-alpha lemmy-alpha: image: lemmy-federation:latest + volumes: + - ./lemmy_alpha.hjson:/config/config.hjson environment: - - LEMMY_HOSTNAME=lemmy-alpha:8541 - - LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_alpha:5432/lemmy - - LEMMY_JWT_SECRET=changeme - - LEMMY_FEDERATION__ENABLED=true - - LEMMY_TLS_ENABLED=false - - LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-beta,lemmy-gamma,lemmy-delta,lemmy-epsilon - - LEMMY_PORT=8541 - - LEMMY_SETUP__ADMIN_USERNAME=lemmy_alpha - - LEMMY_SETUP__ADMIN_PASSWORD=lemmy - - LEMMY_SETUP__SITE_NAME=lemmy-alpha - - LEMMY_RATE_LIMIT__POST=99999 - - LEMMY_RATE_LIMIT__REGISTER=99999 - - LEMMY_CAPTCHA__ENABLED=false - LEMMY_TEST_SEND_SYNC=1 - RUST_BACKTRACE=1 - RUST_LOG=debug @@ -78,20 +67,9 @@ services: - lemmy-beta lemmy-beta: image: lemmy-federation:latest + volumes: + - ./lemmy_beta.hjson:/config/config.hjson environment: - - LEMMY_HOSTNAME=lemmy-beta:8551 - - LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_beta:5432/lemmy - - LEMMY_JWT_SECRET=changeme - - LEMMY_FEDERATION__ENABLED=true - - LEMMY_TLS_ENABLED=false - - LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-alpha,lemmy-gamma,lemmy-delta,lemmy-epsilon - - LEMMY_PORT=8551 - - LEMMY_SETUP__ADMIN_USERNAME=lemmy_beta - - LEMMY_SETUP__ADMIN_PASSWORD=lemmy - - LEMMY_SETUP__SITE_NAME=lemmy-beta - - LEMMY_RATE_LIMIT__POST=99999 - - LEMMY_RATE_LIMIT__REGISTER=99999 - - LEMMY_CAPTCHA__ENABLED=false - LEMMY_TEST_SEND_SYNC=1 - RUST_BACKTRACE=1 - RUST_LOG=debug @@ -118,20 +96,9 @@ services: - lemmy-gamma lemmy-gamma: image: lemmy-federation:latest + volumes: + - ./lemmy_gamma.hjson:/config/config.hjson environment: - - LEMMY_HOSTNAME=lemmy-gamma:8561 - - LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_gamma:5432/lemmy - - LEMMY_JWT_SECRET=changeme - - LEMMY_FEDERATION__ENABLED=true - - LEMMY_TLS_ENABLED=false - - LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-alpha,lemmy-beta,lemmy-delta,lemmy-epsilon - - LEMMY_PORT=8561 - - LEMMY_SETUP__ADMIN_USERNAME=lemmy_gamma - - LEMMY_SETUP__ADMIN_PASSWORD=lemmy - - LEMMY_SETUP__SITE_NAME=lemmy-gamma - - LEMMY_RATE_LIMIT__POST=99999 - - LEMMY_RATE_LIMIT__REGISTER=99999 - - LEMMY_CAPTCHA__ENABLED=false - LEMMY_TEST_SEND_SYNC=1 - RUST_BACKTRACE=1 - RUST_LOG=debug @@ -159,20 +126,9 @@ services: - lemmy-delta lemmy-delta: image: lemmy-federation:latest + volumes: + - ./lemmy_delta.hjson:/config/config.hjson environment: - - LEMMY_HOSTNAME=lemmy-delta:8571 - - LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_delta:5432/lemmy - - LEMMY_JWT_SECRET=changeme - - LEMMY_FEDERATION__ENABLED=true - - LEMMY_TLS_ENABLED=false - - LEMMY_FEDERATION__ALLOWED_INSTANCES=lemmy-beta - - LEMMY_PORT=8571 - - LEMMY_SETUP__ADMIN_USERNAME=lemmy_delta - - LEMMY_SETUP__ADMIN_PASSWORD=lemmy - - LEMMY_SETUP__SITE_NAME=lemmy-delta - - LEMMY_RATE_LIMIT__POST=99999 - - LEMMY_RATE_LIMIT__REGISTER=99999 - - LEMMY_CAPTCHA__ENABLED=false - LEMMY_TEST_SEND_SYNC=1 - RUST_BACKTRACE=1 - RUST_LOG=debug @@ -200,20 +156,9 @@ services: - lemmy-epsilon lemmy-epsilon: image: lemmy-federation:latest + volumes: + - ./lemmy_epsilon.hjson:/config/config.hjson environment: - - LEMMY_HOSTNAME=lemmy-epsilon:8581 - - LEMMY_DATABASE_URL=postgres://lemmy:password@postgres_epsilon:5432/lemmy - - LEMMY_JWT_SECRET=changeme - - LEMMY_FEDERATION__ENABLED=true - - LEMMY_TLS_ENABLED=false - - LEMMY_FEDERATION__BLOCKED_INSTANCES=lemmy-alpha - - LEMMY_PORT=8581 - - LEMMY_SETUP__ADMIN_USERNAME=lemmy_epsilon - - LEMMY_SETUP__ADMIN_PASSWORD=lemmy - - LEMMY_SETUP__SITE_NAME=lemmy-epsilon - - LEMMY_RATE_LIMIT__POST=99999 - - LEMMY_RATE_LIMIT__REGISTER=99999 - - LEMMY_CAPTCHA__ENABLED=false - LEMMY_TEST_SEND_SYNC=1 - RUST_BACKTRACE=1 - RUST_LOG=debug diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 8f307bf60..c4f0358d1 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -56,7 +56,6 @@ RUN addgroup -g 1000 lemmy RUN adduser -D -s /bin/sh -u 1000 -G lemmy lemmy # Copy resources -COPY --chown=lemmy:lemmy config/defaults.hjson /config/defaults.hjson COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy RUN chown lemmy:lemmy /app/lemmy diff --git a/docker/prod/Dockerfile.arm b/docker/prod/Dockerfile.arm index bcf590034..a6e698f0d 100644 --- a/docker/prod/Dockerfile.arm +++ b/docker/prod/Dockerfile.arm @@ -31,7 +31,6 @@ RUN addgroup --gid 1000 lemmy RUN adduser --no-create-home --shell /bin/sh --uid 1000 --gid 1000 lemmy # Copy resources -COPY --chown=lemmy:lemmy config/defaults.hjson /config/defaults.hjson COPY --chown=lemmy:lemmy --from=builder /app/lemmy_server /app/lemmy RUN chown lemmy:lemmy /app/lemmy