Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add e2e tests #3054

Merged
merged 53 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e64a456
feat: add e2e tests
35C4n0r Jan 18, 2025
c7a8b86
feat: gitpod --> localhost
35C4n0r Jan 18, 2025
24b49dc
feat: multiple name instances
35C4n0r Jan 18, 2025
3c3014f
chore: minor fix
35C4n0r Jan 18, 2025
4df2cc2
chore: minor fix
35C4n0r Jan 19, 2025
305a59b
chore: minor fix
35C4n0r Jan 19, 2025
fc19afd
chore: minor fix
35C4n0r Jan 19, 2025
b0f4b97
chore: minor fix
35C4n0r Jan 19, 2025
66a01b2
chore: minor fix
35C4n0r Jan 19, 2025
56b32db
chore: minor fix
35C4n0r Jan 19, 2025
7623917
chore: minor fix
35C4n0r Jan 19, 2025
6b01805
chore: fix prom test
35C4n0r Jan 19, 2025
b02ca96
Merge branch 'main' into feat-e2e-tests
talboren Jan 19, 2025
6e21f22
Merge branch 'main' into feat-e2e-tests
35C4n0r Jan 19, 2025
461742e
chore: minor fixes
35C4n0r Jan 19, 2025
3b7d1f4
Merge remote-tracking branch 'origin/feat-e2e-tests' into feat-e2e-tests
35C4n0r Jan 19, 2025
2b3db30
chore: minor fixes
35C4n0r Jan 19, 2025
3b35ba1
Merge branch 'main' into feat-e2e-tests
Matvey-Kuk Jan 19, 2025
bb82f50
chore: minor fixes
35C4n0r Jan 19, 2025
58e44ea
chore: minor fixes
35C4n0r Jan 19, 2025
d3ae308
chore: minor fixes
35C4n0r Jan 19, 2025
2a3bf9a
chore: minor fixes
35C4n0r Jan 19, 2025
59bc901
chore: minor fixes
35C4n0r Jan 19, 2025
755350a
Merge branch 'main' into feat-e2e-tests
35C4n0r Jan 19, 2025
bd40c23
chore: minor fixes
35C4n0r Jan 20, 2025
73b8cde
Merge remote-tracking branch 'origin/feat-e2e-tests' into feat-e2e-tests
35C4n0r Jan 20, 2025
a13d273
chore: minor fixes
35C4n0r Jan 20, 2025
2d23bf3
chore: minor fixes
35C4n0r Jan 20, 2025
c8da2c1
chore: review comments
35C4n0r Jan 24, 2025
3eee547
test: change order
35C4n0r Jan 24, 2025
7087fa1
Merge branch 'main' into feat-e2e-tests
shahargl Jan 24, 2025
bc59f89
test: change order
35C4n0r Jan 24, 2025
803f50f
Merge branch 'main' into feat-e2e-tests
35C4n0r Jan 25, 2025
cb1c6c8
feat: grafana latest
35C4n0r Jan 25, 2025
35230f0
Merge remote-tracking branch 'origin/feat-e2e-tests' into feat-e2e-tests
35C4n0r Jan 25, 2025
03d16a3
Merge branch 'main' into feat-e2e-tests
Matvey-Kuk Jan 27, 2025
c11686c
feat: delete providers test
35C4n0r Jan 31, 2025
05a801c
fix: remove gitpod urls
35C4n0r Jan 31, 2025
94c2786
Merge branch 'main' into feat-e2e-tests
35C4n0r Jan 31, 2025
b5d2d32
fix: add timeout
35C4n0r Jan 31, 2025
5347fbb
Update test_end_to_end.py
35C4n0r Jan 31, 2025
163de09
fix: failed tests
35C4n0r Jan 31, 2025
79ca01e
fix: revert original and new ini
35C4n0r Jan 31, 2025
bd76ad1
Merge branch 'main' into feat-e2e-tests
talboren Jan 31, 2025
2acaf98
fix: update mysql
35C4n0r Jan 31, 2025
f37b413
Merge remote-tracking branch 'refs/remotes/origin/feat-e2e-tests' int…
35C4n0r Jan 31, 2025
61625f9
re: run
35C4n0r Jan 31, 2025
681b6b6
chore: try fix
35C4n0r Jan 31, 2025
afb4c01
fix: remove links
35C4n0r Jan 31, 2025
0f86c73
chore: increase waiting time
35C4n0r Jan 31, 2025
ce118eb
Merge remote-tracking branch 'origin/feat-e2e-tests' into feat-e2e-tests
35C4n0r Jan 31, 2025
b61457c
Merge branch 'main' into feat-e2e-tests
talboren Feb 1, 2025
b616e03
Merge branch 'main' into feat-e2e-tests
talboren Feb 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 71 additions & 5 deletions .github/workflows/test-pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,49 @@ jobs:
- name: Wait for database to be ready
run: |
# Add commands to wait for the database to be ready
echo "Waiting for Database to be ready..."
if [ "${{ matrix.db_type }}" == "mysql" ]; then
until docker exec $(docker ps -qf "name=keep-database") mysqladmin ping -h "localhost" --silent; do
until docker exec $(docker ps -qf "name=keep-database-1") mysqladmin ping -h "localhost" --silent; do
35C4n0r marked this conversation as resolved.
Show resolved Hide resolved
echo "Waiting for MySQL to be ready..."
sleep 2
done
elif [ "${{ matrix.db_type }}" == "postgres" ]; then
until docker exec $(docker ps -qf "name=keep-database") pg_isready -h localhost -U keepuser; do
until docker exec $(docker ps -qf "name=keep-database-1") pg_isready -h localhost -U keepuser; do
echo "Waiting for Postgres to be ready..."
sleep 2
done
fi
echo "Database is ready!"

echo "Waiting for Database (DB AUTH) to be ready..."
if [ "${{ matrix.db_type }}" == "mysql" ]; then
until docker exec $(docker ps -qf "name=keep-database-db-auth-1") mysqladmin ping -h "localhost" --silent; do
echo "Waiting for MySQL (DB AUTH) to be ready..."
sleep 3
done
elif [ "${{ matrix.db_type }}" == "postgres" ]; then
until docker exec $(docker ps -qf "name=keep-database-db-auth-1") pg_isready -h localhost -U keepuser; do
echo "Waiting for Postgres (DB AUTH) to be ready..."
sleep 2
done
fi
echo "Database (DB AUTH) is ready!"

attempt=0
max_attempts=10
echo "Waiting for Keep backend (DB AUTH) to be ready..."
until $(curl --output /dev/null --silent --fail http://localhost:8081/healthcheck); do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting... Sometimes Keep can't start because of double-headed migrations, use: 'alembic -c keep/alembic.ini history' to investigate, or check artifacts."
exit 1
fi
echo "Waiting for Keep backend (DB AUTH) to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 4
done
echo "Keep backend (DB AUTH) is ready!"
# wait to the backend


# wait to keep backend on port 8080
echo "Waiting for Keep backend to be ready..."
Expand All @@ -116,11 +148,11 @@ jobs:
fi
echo "Waiting for Keep backend to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 2
sleep 4
done

echo "Keep backend is ready!"
# wait to the backend


echo "Waiting for Keep frontend to be ready..."
attempt=0
max_attempts=10
Expand All @@ -134,6 +166,36 @@ jobs:
attempt=$((attempt+1))
sleep 2
done
echo "Keep frontend is ready"

echo "Waiting for Keep frontend (DB AUTH) to be ready..."
attempt=0
max_attempts=10
until $(curl --output /dev/null --silent --fail http://localhost:3001/); do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting..."
exit 1
fi
echo "Waiting for Keep frontend (DB AUTH) to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 2
done
echo "Keep frontend (DB AUTH) is ready"


echo "Waiting for Grafana to be ready..."
attempt=0
max_attempts=10
until $(curl --output /dev/null --silent --fail http://localhost:3002/api/health); do
if [ "$attempt" -ge "$max_attempts" ]; then
echo "Max attempts reached, exiting... "
exit 1
fi
echo "Waiting for Grafana to be ready... (Attempt: $((attempt+1)))"
attempt=$((attempt+1))
sleep 2
done
echo "Grafana is ready..."

# create the state directory
# mkdir -p ./state && chown -R root:root ./state && chmod -R 777 ./state
Expand All @@ -157,6 +219,8 @@ jobs:
run: |
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-backend > backend_logs-${{ matrix.db_type }}.txt
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-frontend > frontend_logs-${{ matrix.db_type }}.txt
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-backend-db-auth > backend_logs-${{ matrix.db_type }}-db-auth.txt
docker compose --project-directory . -f tests/e2e_tests/docker-compose-e2e-${{ matrix.db_type }}.yml logs keep-frontend-db-auth > frontend_logs-${{ matrix.db_type }}-db-auth.txt
continue-on-error: true

- name: Upload test artifacts on failure
Expand All @@ -169,6 +233,8 @@ jobs:
playwright_dump_*.png
backend_logs-${{ matrix.db_type }}.txt
frontend_logs-${{ matrix.db_type }}.txt
backend_logs-${{ matrix.db_type }}-db-auth.txt
frontend_logs-${{ matrix.db_type }}-db-auth.txt
continue-on-error: true

- name: Tear down environment
Expand Down
88 changes: 88 additions & 0 deletions tests/e2e_tests/docker-compose-e2e-mysql.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
services:
## Keep Services with NO_AUTH
# Database Service
keep-database:
image: mysql:latest
environment:
Expand All @@ -14,6 +16,7 @@ services:
timeout: 5s
retries: 5

# Frontend Services
keep-frontend:
extends:
file: docker-compose.common.yml
Expand All @@ -28,6 +31,7 @@ services:
- FRIGADE_DISABLED=true
- SENTRY_DISABLED=true

# Backend Services
keep-backend:
extends:
file: docker-compose.common.yml
Expand All @@ -46,6 +50,75 @@ services:
keep-database:
condition: service_healthy


## Keep Services with DB
# Database Service (5433)
keep-database-db-auth:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD=keep
- MYSQL_DATABASE=keep
volumes:
- mysql-data:/var/lib/mysql-auth-db
ports:
- "3307:3306"
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h localhost"]
interval: 10s
timeout: 5s
retries: 5

# Frontend Services (3001)
keep-frontend-db-auth:
build:
context: ./keep-ui/
dockerfile: ../docker/Dockerfile.ui
ports:
- "3001:3000"
environment:
- NEXTAUTH_SECRET=secret
- NEXTAUTH_URL=http://localhost:3001
- NEXT_PUBLIC_API_URL=http://localhost:8081
- POSTHOG_DISABLED=true
- AUTH_TYPE=DB
- API_URL=http://keep-backend-db-auth:8080
- POSTHOG_DISABLED=true
- FRIGADE_DISABLED=true
- SENTRY_DISABLED=true

# Backend Services (8081)
keep-backend-db-auth:
build:
context: .
dockerfile: docker/Dockerfile.api
ports:
- "8081:8080"
environment:
- PORT=8080
- SECRET_MANAGER_TYPE=FILE
- SECRET_MANAGER_DIRECTORY=/state
- OPENAI_API_KEY=$OPENAI_API_KEY
- PUSHER_APP_ID=1
- PUSHER_APP_KEY=keepappkey
- PUSHER_APP_SECRET=keepappsecret
- PUSHER_HOST=keep-websocket-server
- PUSHER_PORT=6001
- USE_NGROK=false
- AUTH_TYPE=DB
- DATABASE_CONNECTION_STRING=mysql+pymysql://root:keep@keep-database-db-auth:3306/keep
- POSTHOG_DISABLED=true
- FRIGADE_DISABLED=true
- SECRET_MANAGER_DIRECTORY=/app
- SQLALCHEMY_WARN_20=1
- KEEP_JWT_SECRET=verysecretkey
- KEEP_DEFAULT_USERNAME=keep
- KEEP_DEFAULT_PASSWORD=keep
depends_on:
keep-database-db-auth:
condition: service_healthy


# Other Services (Common)
keep-websocket-server:
extends:
file: docker-compose.common.yml
Expand All @@ -59,5 +132,20 @@ services:
ports:
- "9090:9090"

grafana:
image: grafana/grafana-enterprise:11.4.0
user: "472" # Grafana's default user ID
ports:
- "3002:3000"
volumes:
- ./keep/providers/grafana_provider/grafana/provisioning:/etc/grafana/provisioning:ro
- ./tests/e2e_tests/grafana.ini:/etc/grafana/grafana.ini:ro
- grafana-storage:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
depends_on:
- prometheus-server-for-test-target

volumes:
mysql-data:
grafana-storage: {}
83 changes: 83 additions & 0 deletions tests/e2e_tests/docker-compose-e2e-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
services:
## Keep Services with NO_AUTH
# Database Service
keep-database:
image: postgres:13
environment:
Expand All @@ -12,6 +14,7 @@ services:
- ./postgres-custom.conf:/etc/postgresql/conf.d/custom.conf
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

# Frontend Services
keep-frontend:
extends:
file: docker-compose.common.yml
Expand All @@ -26,6 +29,7 @@ services:
- FRIGADE_DISABLED=true
- SENTRY_DISABLED=true

# Backend Services
keep-backend:
extends:
file: docker-compose.common.yml
Expand All @@ -43,6 +47,70 @@ services:
depends_on:
- keep-database

## Keep Services with DB
# Database Service (5433)
keep-database-db-auth:
image: postgres:13
environment:
POSTGRES_USER: keepuser
POSTGRES_PASSWORD: keeppassword
POSTGRES_DB: keepdb
ports:
- "5433:5432"
volumes:
- postgres-data:/var/lib/postgresql-auth-db/data
- ./postgres-custom.conf:/etc/postgresql-auth-db/conf.d/custom.conf
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

# Frontend Services (3001)
keep-frontend-db-auth:
build:
context: ./keep-ui/
dockerfile: ../docker/Dockerfile.ui
ports:
- "3001:3000"
environment:
- NEXTAUTH_SECRET=secret
- NEXTAUTH_URL=http://localhost:3001
- NEXT_PUBLIC_API_URL=http://localhost:8080
- POSTHOG_DISABLED=true
- AUTH_TYPE=DB
- API_URL=http://keep-backend-db-auth:8080
- POSTHOG_DISABLED=true
- FRIGADE_DISABLED=true
- SENTRY_DISABLED=true

# Backend Services (8081)
keep-backend-db-auth:
build:
context: .
dockerfile: docker/Dockerfile.api
ports:
- "8081:8080"
environment:
- PORT=8080
- SECRET_MANAGER_TYPE=FILE
- SECRET_MANAGER_DIRECTORY=/state
- OPENAI_API_KEY=$OPENAI_API_KEY
- PUSHER_APP_ID=1
- PUSHER_APP_KEY=keepappkey
- PUSHER_APP_SECRET=keepappsecret
- PUSHER_HOST=keep-websocket-server
- PUSHER_PORT=6001
- USE_NGROK=false
- AUTH_TYPE=DB
- DATABASE_CONNECTION_STRING=postgresql+psycopg2://keepuser:keeppassword@keep-database-db-auth:5432/keepdb
- POSTHOG_DISABLED=true
- FRIGADE_DISABLED=true
- SECRET_MANAGER_DIRECTORY=/app
- SQLALCHEMY_WARN_20=1
- KEEP_JWT_SECRET=verysecretkey
- KEEP_DEFAULT_USERNAME=keep
- KEEP_DEFAULT_PASSWORD=keep
depends_on:
- keep-database-db-auth

# Other Services (Common)
keep-websocket-server:
extends:
file: docker-compose.common.yml
Expand All @@ -56,5 +124,20 @@ services:
ports:
- "9090:9090"

grafana:
image: grafana/grafana-enterprise:11.4.0
user: "472" # Grafana's default user ID
ports:
- "3002:3000"
volumes:
- ./keep/providers/grafana_provider/grafana/provisioning:/etc/grafana/provisioning:ro
- ./tests/e2e_tests/grafana.ini:/etc/grafana/grafana.ini:ro
- grafana-storage:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
depends_on:
- prometheus-server-for-test-target

volumes:
postgres-data:
grafana-storage: {}
9 changes: 9 additions & 0 deletions tests/e2e_tests/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[unified_alerting]
enabled = true

[database]
wal = true
url = sqlite3:///var/lib/grafana/grafana.db?_busy_timeout=500

[service_accounts]
enabled = true
Loading
Loading