Skip to content

Commit

Permalink
Merge pull request #853 from AppFlowy-IO/stateless
Browse files Browse the repository at this point in the history
Stateless collab group
  • Loading branch information
Horusiath authored Dec 27, 2024
2 parents c804912 + 4550cae commit 48e038b
Show file tree
Hide file tree
Showing 75 changed files with 3,044 additions and 824 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
matrix:
include:
- test_service: "appflowy_cloud"
test_cmd: "--workspace --exclude appflowy-history --exclude appflowy-ai-client --features ai-test-enabled"
test_cmd: "--workspace --exclude appflowy-ai-client --features ai-test-enabled"
- test_service: "appflowy_worker"
test_cmd: "-p appflowy-worker"
- test_service: "admin_frontend"
Expand Down Expand Up @@ -130,7 +130,7 @@ jobs:
- name: Run Tests
run: |
echo "Running tests for ${{ matrix.test_service }} with flags: ${{ matrix.test_cmd }}"
RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test ${{ matrix.test_cmd }}
RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test ${{ matrix.test_cmd }} -- --skip stress_test
- name: Server Logs
if: failure()
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/push_latest_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ jobs:
if: always()
run: docker logout


appflowy_worker_image:
runs-on: ubuntu-22.04
env:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/stress_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: AppFlowy-Cloud Stress Test

on: [ pull_request ]

concurrency:
group: stress-test-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: false

env:
POSTGRES_HOST: localhost
REDIS_HOST: localhost
MINIO_HOST: localhost
SQLX_OFFLINE: true
RUST_TOOLCHAIN: "1.78"

jobs:
test:
name: Collab Stress Tests
runs-on: self-hosted-appflowy3

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Copy and Rename deploy.env to .env
run: cp deploy.env .env

- name: Replace Values in .env
run: |
sed -i '' 's|RUST_LOG=.*|RUST_LOG=debug|' .env
sed -i '' 's|API_EXTERNAL_URL=.*|API_EXTERNAL_URL=http://localhost:9999|' .env
sed -i '' 's|APPFLOWY_GOTRUE_BASE_URL=.*|APPFLOWY_GOTRUE_BASE_URL=http://localhost:9999|' .env
shell: bash

- name: Start Docker Compose Services
run: |
docker compose -f docker-compose-stress-test.yml up -d
docker ps -a
- name: Install Prerequisites
run: |
brew install protobuf
- name: Run Server and Test
run: |
cargo run --package xtask -- --stress-test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ http.workspace = true
indexer.workspace = true

[dev-dependencies]
flate2 = "1.0"
once_cell = "1.19.0"
tempfile = "3.9.0"
assert-json-diff = "2.0.2"
Expand Down Expand Up @@ -214,7 +215,6 @@ members = [
"libs/appflowy-ai-client",
"libs/client-api-entity",
# services
#"services/appflowy-history",
"services/appflowy-collaborate",
"services/appflowy-worker",
# xtask
Expand Down Expand Up @@ -283,6 +283,7 @@ sanitize-filename = "0.5.0"
base64 = "0.22"
md5 = "0.7.0"
pin-project = "1.1.5"
arc-swap = { version = "1.7" }
validator = "0.19"
zstd = { version = "0.13.2", features = [] }
chrono = { version = "0.4.39", features = [
Expand Down
11 changes: 8 additions & 3 deletions deploy.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# PostgreSQL Settings
POSTGRES_HOST=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changepassword
POSTGRES_PASSWORD=password
POSTGRES_PORT=5432
POSTGRES_DB=postgres

Expand All @@ -15,6 +15,10 @@ SUPABASE_PASSWORD=root
REDIS_HOST=redis
REDIS_PORT=6379

# Minio Host
MINIO_HOST=minio
MINIO_PORT=9000

# AppFlowy Cloud
## URL that connects to the gotrue docker container
APPFLOWY_GOTRUE_BASE_URL=http://gotrue:9999
Expand Down Expand Up @@ -69,11 +73,12 @@ GOTRUE_DISABLE_SIGNUP=false
# If you are using a different domain, you need to change the redirect_uri in the OAuth2 configuration
# Make sure that this domain is accessible to the user
# Make sure no endswith /
# Replace with your host name instead of localhost
API_EXTERNAL_URL=http://your-host

# In docker environment, `postgres` is the hostname of the postgres service
# GoTrue connect to postgres using this url
GOTRUE_DATABASE_URL=postgres://supabase_auth_admin:${SUPABASE_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
GOTRUE_DATABASE_URL=postgres://supabase_auth_admin:${SUPABASE_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}

# Refer to this for details: https://github.com/AppFlowy-IO/AppFlowy-Cloud/blob/main/doc/AUTHENTICATION.md
# Google OAuth2
Expand Down Expand Up @@ -105,7 +110,7 @@ APPFLOWY_S3_CREATE_BUCKET=true
# By default, Minio is used as the default file storage which uses host's file system.
# Keep this as true if you are using other S3 compatible storage provider other than AWS.
APPFLOWY_S3_USE_MINIO=true
APPFLOWY_S3_MINIO_URL=http://minio:9000 # change this if you are using a different address for minio
APPFLOWY_S3_MINIO_URL=http://${MINIO_HOST}:${MINIO_PORT} # change this if you are using a different address for minio
APPFLOWY_S3_ACCESS_KEY=minioadmin
APPFLOWY_S3_SECRET_KEY=minioadmin
APPFLOWY_S3_BUCKET=appflowy
Expand Down
97 changes: 97 additions & 0 deletions docker-compose-stress-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
services:
nginx:
restart: on-failure
image: nginx
ports:
- 80:80 # Disable this if you are using TLS
- 443:443
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/ssl/certificate.crt:/etc/nginx/ssl/certificate.crt
- ./nginx/ssl/private_key.key:/etc/nginx/ssl/private_key.key
minio:
restart: on-failure
image: minio/minio
ports:
- 9000:9000
- 9001:9001
environment:
- MINIO_BROWSER_REDIRECT_URL=http://localhost:9001
command: server /data --console-address ":9001"

postgres:
restart: on-failure
image: pgvector/pgvector:pg16
environment:
- POSTGRES_USER=${POSTGRES_USER:-postgres}
- POSTGRES_DB=${POSTGRES_DB:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
- POSTGRES_HOST=${POSTGRES_HOST:-postgres}
- SUPABASE_USER=${SUPABASE_USER:-supabase_auth_admin}
- SUPABASE_PASSWORD=${SUPABASE_PASSWORD:-root}
ports:
- 5432:5432
volumes:
- ./migrations/before:/docker-entrypoint-initdb.d
# comment out the following line if you want to persist data when restarting docker
#- postgres_data:/var/lib/postgresql/data

redis:
restart: on-failure
image: redis
ports:
- 6379:6379

gotrue:
restart: on-failure
image: supabase/gotrue:v2.159.1
depends_on:
- postgres
environment:
# Gotrue config: https://github.com/supabase/gotrue/blob/master/example.env
- GOTRUE_SITE_URL=appflowy-flutter:// # redirected to AppFlowy application
- URI_ALLOW_LIST=* # adjust restrict if necessary
- GOTRUE_JWT_SECRET=${GOTRUE_JWT_SECRET} # authentication secret
- GOTRUE_JWT_EXP=${GOTRUE_JWT_EXP}
- GOTRUE_DB_DRIVER=postgres
- API_EXTERNAL_URL=${API_EXTERNAL_URL}
- DATABASE_URL=${GOTRUE_DATABASE_URL}
- PORT=9999
- GOTRUE_MAILER_URLPATHS_CONFIRMATION=/verify
- GOTRUE_SMTP_HOST=${GOTRUE_SMTP_HOST} # e.g. smtp.gmail.com
- GOTRUE_SMTP_PORT=${GOTRUE_SMTP_PORT} # e.g. 465
- GOTRUE_SMTP_USER=${GOTRUE_SMTP_USER} # email sender, e.g. [email protected]
- GOTRUE_SMTP_PASS=${GOTRUE_SMTP_PASS} # email password
- GOTRUE_SMTP_ADMIN_EMAIL=${GOTRUE_SMTP_ADMIN_EMAIL} # email with admin privileges e.g. [email protected]
- GOTRUE_SMTP_MAX_FREQUENCY=${GOTRUE_SMTP_MAX_FREQUENCY:-1ns} # set to 1ns for running tests
- GOTRUE_RATE_LIMIT_EMAIL_SENT=${GOTRUE_RATE_LIMIT_EMAIL_SENT:-100} # number of email sendable per minute
- GOTRUE_MAILER_AUTOCONFIRM=${GOTRUE_MAILER_AUTOCONFIRM:-false} # change this to true to skip email confirmation
# Google OAuth config
- GOTRUE_EXTERNAL_GOOGLE_ENABLED=${GOTRUE_EXTERNAL_GOOGLE_ENABLED}
- GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID=${GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID}
- GOTRUE_EXTERNAL_GOOGLE_SECRET=${GOTRUE_EXTERNAL_GOOGLE_SECRET}
- GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI=${GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI}
# Apple OAuth config
- GOTRUE_EXTERNAL_APPLE_ENABLED=${GOTRUE_EXTERNAL_APPLE_ENABLED}
- GOTRUE_EXTERNAL_APPLE_CLIENT_ID=${GOTRUE_EXTERNAL_APPLE_CLIENT_ID}
- GOTRUE_EXTERNAL_APPLE_SECRET=${GOTRUE_EXTERNAL_APPLE_SECRET}
- GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=${GOTRUE_EXTERNAL_APPLE_REDIRECT_URI}
# GITHUB OAuth config
- GOTRUE_EXTERNAL_GITHUB_ENABLED=${GOTRUE_EXTERNAL_GITHUB_ENABLED}
- GOTRUE_EXTERNAL_GITHUB_CLIENT_ID=${GOTRUE_EXTERNAL_GITHUB_CLIENT_ID}
- GOTRUE_EXTERNAL_GITHUB_SECRET=${GOTRUE_EXTERNAL_GITHUB_SECRET}
- GOTRUE_EXTERNAL_GITHUB_REDIRECT_URI=${GOTRUE_EXTERNAL_GITHUB_REDIRECT_URI}
# Discord OAuth config
- GOTRUE_EXTERNAL_DISCORD_ENABLED=${GOTRUE_EXTERNAL_DISCORD_ENABLED}
- GOTRUE_EXTERNAL_DISCORD_CLIENT_ID=${GOTRUE_EXTERNAL_DISCORD_CLIENT_ID}
- GOTRUE_EXTERNAL_DISCORD_SECRET=${GOTRUE_EXTERNAL_DISCORD_SECRET}
- GOTRUE_EXTERNAL_DISCORD_REDIRECT_URI=${GOTRUE_EXTERNAL_DISCORD_REDIRECT_URI}
# Prometheus Metrics
- GOTRUE_METRICS_ENABLED=true
- GOTRUE_METRICS_EXPORTER=prometheus
- GOTRUE_MAILER_TEMPLATES_CONFIRMATION=${GOTRUE_MAILER_TEMPLATES_CONFIRMATION}
ports:
- 9999:9999

volumes:
postgres_data:
Loading

0 comments on commit 48e038b

Please sign in to comment.