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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 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
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
75 changes: 72 additions & 3 deletions .github/workflows/test-pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,34 @@ 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@35C4n0r check, here also keep-database-1 is getting created: /~https://github.com/keephq/keep/actions/runs/12844511458/job/35817583885#step:12:2243

but until docker exec $(docker ps -qf "name=keep-database") pg_isready -h localhost -U keepuser; do /~https://github.com/keephq/keep/actions/runs/12844511458/job/35817583885#step:13:67 still works

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 2
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!"


# wait to keep backend on port 8080
echo "Waiting for Keep backend to be ready..."
Expand All @@ -118,9 +135,27 @@ jobs:
attempt=$((attempt+1))
sleep 2
done

echo "Keep backend is ready!"

attempt2=0
max_attempts2=10
echo "Hello world: $(attempt2)"
echo "MAX_ATTEMPTS: $(max_attempts2)"
echo $(curl http://localhost:8081/healthcheck)
echo "Waiting for Keep backend (DB AUTH) to be ready..."
until $(curl --output /dev/null --silent --fail http://localhost:8081/healthcheck); do
if [ "$attempt2" -ge "$max_attempts2" ]; 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)))"
attempt2=$((attempt2+1))
sleep 2
done
echo "Keep backend (DB AUTH) is ready!"
# wait to the backend


echo "Waiting for Keep frontend to be ready..."
attempt=0
max_attempts=10
Expand All @@ -134,6 +169,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 +222,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 +236,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
94 changes: 94 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,81 @@ 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_KEY=phc_muk9qE3TfZsX3SZ9XxX52kCGJBclrjhkP9JxAQcm1PZ
- POSTHOG_HOST=https://ingest.keephq.dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove POSTHOG keys from here and set POSTHOG_DISABLED=true

- NEXT_PUBLIC_SENTRY_DSN=https://0d4d59e3105ffe8afa27dcb95a222009@o4505515398922240.ingest.us.sentry.io/4508258058764288
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentry as well, I don't think we need it :)

- PUSHER_HOST=localhost
- PUSHER_PORT=6001
- PUSHER_APP_KEY=keepappkey
- NEXT_PUBLIC_KEEP_VERSION=0.2.9
- 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 +138,20 @@ services:
ports:
- "9090:9090"

grafana:
image: grafana/grafana-enterprise:10.4.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 10.4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno, picked from ./keep/providers/grafana_provider/grafana

user: "472" # Grafana's default user ID
ports:
- "3002:3000"
volumes:
- ./keep/providers/grafana_provider/grafana/provisioning:/etc/grafana/provisioning:ro
- ./keep/providers/grafana_provider/grafana/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: {}
86 changes: 86 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,73 @@ 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:8081
- POSTHOG_KEY=phc_muk9qE3TfZsX3SZ9XxX52kCGJBclrjhkP9JxAQcm1PZ
- POSTHOG_HOST=https://ingest.keephq.dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Posthog key too

- 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 +127,20 @@ services:
ports:
- "9090:9090"

grafana:
image: grafana/grafana-enterprise:10.4.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno, picked from ./keep/providers/grafana_provider/grafana

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with 11.4.0. "Latest" here will bring instability to our tests.

user: "472" # Grafana's default user ID
ports:
- "3002:3000"
volumes:
- ./keep/providers/grafana_provider/grafana/provisioning:/etc/grafana/provisioning:ro
- ./keep/providers/grafana_provider/grafana/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: {}
Loading
Loading