Compare commits

...

3 Commits

Author SHA1 Message Date
pablodanswer
8a5fdeebd8 fix 2024-12-01 16:42:26 -08:00
pablodanswer
2fc78e3fe8 fix multi tenant tests failing silently 2024-12-01 16:41:21 -08:00
pablodanswer
c74cacccfc add bones for proper cloud integration testing 2024-12-01 16:31:17 -08:00
3 changed files with 132 additions and 14 deletions

View File

@@ -0,0 +1,116 @@
name: Integration Tests
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
integration-tests:
runs-on: ubuntu-latest
env:
IMAGE_TAG: "latest"
steps:
- name: Checkout Data Plane Repository
uses: actions/checkout@v4
with:
path: data-plane
- name: Checkout Control Plane Repository
uses: actions/checkout@v4
with:
repository: danswer/control-plane-repo
path: control-plane
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Start Data Plane Services
working-directory: data-plane/deployment/docker_compose
env:
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: |
# Set any additional environment variables as needed
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \
AUTH_TYPE=basic \
REQUIRE_EMAIL_VERIFICATION=false \
DISABLE_TELEMETRY=true \
MULTI_TENANT=true \
IMAGE_TAG=${IMAGE_TAG} \
docker-compose -f docker-compose.dev.yml -p danswer-stack up -d
- name: Start Control Plane Services
working-directory: control-plane/deployment
env:
IMAGE_TAG: ${{ env.IMAGE_TAG }}
run: |
# Set any additional environment variables as needed
IMAGE_TAG=${IMAGE_TAG} \
docker-compose up -d
- name: Wait for Data Plane Services to be Ready
run: |
echo "Waiting for Data Plane API server..."
until curl -s http://localhost:8080/health; do
sleep 5
done
echo "Data Plane API server is ready."
- name: Wait for Control Plane Services to be Ready
run: |
echo "Waiting for Control Plane API server..."
until curl -s http://localhost:8082/health; do
sleep 5
done
echo "Control Plane API server is ready."
- name: Run Integration Tests from Data Plane Backend
working-directory: data-plane/backend
run: |
# Install dependencies if needed
pip install -r requirements.txt
# Run the integration tests
pytest tests/integration
- name: Collect Data Plane Docker Logs
if: always()
run: |
cd data-plane/deployment/docker_compose
docker-compose -f docker-compose.dev.yml -p danswer-stack logs > $GITHUB_WORKSPACE/data-plane-docker-compose.log
- name: Collect Control Plane Docker Logs
if: always()
run: |
cd control-plane/deployment
docker-compose logs > $GITHUB_WORKSPACE/control-plane-docker-compose.log
- name: Upload Logs
if: always()
uses: actions/upload-artifact@v3
with:
name: docker-logs
path: |
$GITHUB_WORKSPACE/data-plane-docker-compose.log
$GITHUB_WORKSPACE/control-plane-docker-compose.log
- name: Tear Down Data Plane Services
if: always()
working-directory: data-plane/deployment/docker_compose
run: |
docker-compose -f docker-compose.dev.yml -p danswer-stack down -v
- name: Tear Down Control Plane Services
if: always()
working-directory: control-plane/deployment
run: |
docker-compose down -v

View File

@@ -8,7 +8,7 @@ on:
pull_request:
branches:
- main
- 'release/**'
- "release/**"
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -16,11 +16,12 @@ env:
CONFLUENCE_TEST_SPACE_URL: ${{ secrets.CONFLUENCE_TEST_SPACE_URL }}
CONFLUENCE_USER_NAME: ${{ secrets.CONFLUENCE_USER_NAME }}
CONFLUENCE_ACCESS_TOKEN: ${{ secrets.CONFLUENCE_ACCESS_TOKEN }}
jobs:
integration-tests:
# See https://runs-on.com/runners/linux/
runs-on: [runs-on,runner=8cpu-linux-x64,ram=16,"run-id=${{ github.run_id }}"]
runs-on:
[runs-on, runner=8cpu-linux-x64, ram=16, "run-id=${{ github.run_id }}"]
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -36,9 +37,9 @@ jobs:
# tag every docker image with "test" so that we can spin up the correct set
# of images during testing
# We don't need to build the Web Docker image since it's not yet used
# in the integration tests. We have a separate action to verify that it builds
# in the integration tests. We have a separate action to verify that it builds
# successfully.
- name: Pull Web Docker image
run: |
@@ -50,7 +51,7 @@ jobs:
# https://runs-on.com/caching/s3-cache-for-github-actions/
# https://runs-on.com/caching/docker/
# https://github.com/moby/buildkit#s3-cache-experimental
# images are built and run locally for testing purposes. Not pushed.
- name: Build Backend Docker image
uses: ./.github/actions/custom-build-and-push
@@ -75,7 +76,7 @@ jobs:
load: true
cache-from: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
cache-to: type=s3,prefix=cache/${{ github.repository }}/integration-tests/model-server/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max
- name: Build integration test Docker image
uses: ./.github/actions/custom-build-and-push
with:
@@ -121,25 +122,25 @@ jobs:
-e MULTI_TENANT=true \
danswer/danswer-integration:test \
/app/tests/integration/multitenant_tests
continue-on-error: true
id: run_multitenant_tests
- name: Check multi-tenant test results
run: |
if [ ${{ steps.run_tests.outcome }} == 'failure' ]; then
if [ ${{ steps.run_multitenant_tests.outcome }} == 'failure' ]; then
echo "Integration tests failed. Exiting with error."
exit 1
else
echo "All integration tests passed successfully."
fi
fi
- name: Stop multi-tenant Docker containers
run: |
cd deployment/docker_compose
docker compose -f docker-compose.dev.yml -p danswer-stack down -v
- name: Start Docker containers
- name: Start Docker containers
run: |
cd deployment/docker_compose
ENABLE_PAID_ENTERPRISE_EDITION_FEATURES=true \
@@ -153,12 +154,12 @@ jobs:
- name: Wait for service to be ready
run: |
echo "Starting wait-for-service script..."
docker logs -f danswer-stack-api_server-1 &
start_time=$(date +%s)
timeout=300 # 5 minutes in seconds
while true; do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
@@ -229,7 +230,7 @@ jobs:
run: |
cd deployment/docker_compose
docker compose -f docker-compose.dev.yml -p danswer-stack down -v
- name: Upload logs
if: success() || failure()
uses: actions/upload-artifact@v4

View File

@@ -222,6 +222,7 @@ def reset_vespa_multitenant() -> None:
"""Wipe all data from the Vespa index for all tenants."""
for tenant_id in get_all_tenant_ids():
print(f"Resetting Vespa for tenant {tenant_id}")
with get_session_with_tenant(tenant_id=tenant_id) as db_session:
# swap to the correct default model for each tenant
check_index_swap(db_session)