Skip to content

Commit

Permalink
WIP migrating to DPE int tests for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Feb 9, 2024
1 parent cfa3ade commit 24774cf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 67 deletions.
75 changes: 16 additions & 59 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,67 +72,24 @@ jobs:
integration-test:
strategy:
fail-fast: false
matrix:
tox-environments:
- charm-integration
- ha-integration
- relation-integration
- legacy-integration
- tls-integration
- backup-integration
- metric-integration
- sharding-integration
- sharding-relation-integration
- sharding-race-conditions-integration
- sharding-mongos-integration
name: ${{ matrix.tox-environments }}
name: Integration test charm
needs:
- lint
- unit-test
- lib-check
- build
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup operator environment
# TODO: Replace with custom image on self-hosted runner
uses: charmed-kubernetes/actions-operator@main
with:
provider: lxd
juju-channel: 3.1/stable
- name: Download packed charm(s)
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact-name }}
- name: Free disk space
run: |
echo "Free disk space before cleanup"
df -T
# free space in the runner
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Free disk space after cleanup"
df -T
- name: Select tests
id: select-tests
run: |
if [ "${{ github.event_name }}" == "schedule" ]
then
echo Running unstable and stable tests
echo "mark_expression=" >> $GITHUB_OUTPUT
else
echo Skipping unstable tests
echo "mark_expression=not unstable" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: tox run -e ${{ matrix.tox-environments }} -- -m '${{ steps.select-tests.outputs.mark_expression }}'
env:
CI_PACKED_CHARMS: ${{ needs.build.outputs.charms }}
AWS_ACCESS_KEY: ${{ matrix.tox-environments != 'backup-integration' || secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ matrix.tox-environments != 'backup-integration' || secrets.AWS_SECRET_KEY }}
GCP_ACCESS_KEY: ${{ matrix.tox-environments != 'backup-integration' || secrets.GCP_ACCESS_KEY }}
GCP_SECRET_KEY: ${{ matrix.tox-environments != 'backup-integration' || secrets.GCP_SECRET_KEY }}
uses: canonical/data-platform-workflows/.github/workflows/[email protected]
with:
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
cloud: lxd
juju-agent-version: 3.1.6
permissions:
contents: write # Needed for Allure Report beta
secrets:
integration-test: |
{
"AWS_ACCESS_KEY": "${{ secrets.AWS_ACCESS_KEY }}",
"AWS_SECRET_KEY": "${{ secrets.AWS_SECRET_KEY }}",
"GCP_ACCESS_KEY": "${{ secrets.GCP_ACCESS_KEY }}",
"GCP_SECRET_KEY": "${{ secrets.GCP_SECRET_KEY }}",
}
10 changes: 6 additions & 4 deletions tests/integration/backup_tests/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def test_blocked_incorrect_creds(ops_test: OpsTest) -> None:


@pytest.mark.abort_on_fail
async def test_blocked_incorrect_conf(ops_test: OpsTest) -> None:
async def test_blocked_incorrect_conf(ops_test: OpsTest, github_secrets) -> None:
"""Verifies that the charm goes into blocked status when s3 config options are incorrect."""
db_app_name = await get_app_name(ops_test)

Expand Down Expand Up @@ -131,7 +131,7 @@ async def test_ready_correct_conf(ops_test: OpsTest) -> None:


@pytest.mark.abort_on_fail
async def test_create_and_list_backups(ops_test: OpsTest) -> None:
async def test_create_and_list_backups(ops_test: OpsTest, github_secrets) -> None:
db_app_name = await get_app_name(ops_test)
leader_unit = await helpers.get_leader_unit(ops_test, db_app_name=db_app_name)
await helpers.set_credentials(ops_test, cloud="AWS")
Expand Down Expand Up @@ -162,7 +162,7 @@ async def test_create_and_list_backups(ops_test: OpsTest) -> None:


@pytest.mark.abort_on_fail
async def test_multi_backup(ops_test: OpsTest, continuous_writes_to_db) -> None:
async def test_multi_backup(ops_test: OpsTest, continuous_writes_to_db, github_secrets) -> None:
"""With writes in the DB test creating a backup while another one is running.
Note that before creating the second backup we change the bucket and change the s3 storage
Expand Down Expand Up @@ -302,7 +302,9 @@ async def test_restore(ops_test: OpsTest, add_writes_to_db) -> None:


@pytest.mark.parametrize("cloud_provider", ["AWS", "GCP"])
async def test_restore_new_cluster(ops_test: OpsTest, add_writes_to_db, cloud_provider):
async def test_restore_new_cluster(
ops_test: OpsTest, add_writes_to_db, cloud_provider, github_secrets
):
# configure test for the cloud provider
db_app_name = await get_app_name(ops_test)
await helpers.set_credentials(ops_test, cloud=cloud_provider)
Expand Down
17 changes: 13 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ description = Run charm integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -88,6 +89,7 @@ description = Run high availability integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -104,6 +106,7 @@ description = Run new relation integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -120,6 +123,7 @@ description = Run legacy relation integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -136,6 +140,7 @@ description = Run tls integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -153,10 +158,8 @@ description = Run backup integration tests
pass_env =
{[testenv]pass_env}
CI
AWS_ACCESS_KEY
AWS_SECRET_KEY
GCP_ACCESS_KEY
GCP_SECRET_KEY
GITHUB_OUTPUT
SECRETS_FROM_GITHUB
deps =
pytest
juju==3.2.0.1
Expand All @@ -173,6 +176,7 @@ description = Run metrics integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -189,6 +193,7 @@ description = Run sharding integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -205,6 +210,7 @@ description = Run sharding integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -221,6 +227,7 @@ description = Run sharding race condition tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -237,6 +244,7 @@ description = Run sharding mongos tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUT
deps =
pytest
juju==3.2.0.1
Expand All @@ -254,6 +262,7 @@ description = Run all integration tests
pass_env =
{[testenv]pass_env}
CI
GITHUB_OUTPUTd
deps =
pytest
juju==3.2.0.1
Expand Down

0 comments on commit 24774cf

Please sign in to comment.