Skip to content

Commit

Permalink
Conditionally skip backup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Nov 1, 2023
1 parent 24a755d commit 3a38557
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,19 @@ jobs:
echo Skipping unstable tests
echo "mark_expression=and not unstable" >> "$GITHUB_OUTPUT"
fi
- name: Select test secret usage
id: select-test-stability
run: |
if [[ "${{ github.event.pull_request.head.repo.full_name }}" == "canonical/postgresql-k8s-operator" ]]
then
echo Running tests using secrets
echo "mark_secrets=" >> "$GITHUB_OUTPUT"
else
echo Skipping tests using secrets
echo "mark_secrets=and not uses_secrets" >> "$GITHUB_OUTPUT"
fi
- name: Run integration tests
run: tox run -e ${{ matrix.tox-environment }} -- -m 'not ${{ matrix.exclude-mark }} ${{ steps.select-test-stability.outputs.mark_expression }}' --keep-models
run: tox run -e ${{ matrix.tox-environment }} -- -m 'not ${{ matrix.exclude-mark }} ${{ steps.select-test-stability.outputs.mark_secrets }} ${{ steps.select-test-stability.outputs.mark_expression }}' --keep-models
env:
SECRETS_FROM_GITHUB: |
{
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ target-version = ["py38"]

# Linting tools configuration
[tool.ruff]
# preview and explicit preview are enabled for CPY001
preview = true
explicit-preview-rules = true
target-version = "py38"
src = ["src", "."]
line-length = 99
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ async def cloud_configs(ops_test: OpsTest, github_secrets) -> None:
bucket_object.delete()


async def test_none() -> None:
"""Empty test so that the suite will not fail if all tests are skippedi."""
pass


@pytest.mark.uses_secrets
@pytest.mark.abort_on_fail
async def test_backup_and_restore(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> None:
"""Build and deploy two units of PostgreSQL and then test the backup and restore actions."""
Expand Down Expand Up @@ -203,6 +209,7 @@ async def test_backup_and_restore(ops_test: OpsTest, cloud_configs: Tuple[Dict,
await ops_test.model.remove_application(TLS_CERTIFICATES_APP_NAME, block_until_done=True)


@pytest.mark.uses_secrets
async def test_restore_on_new_cluster(ops_test: OpsTest) -> None:
"""Test that is possible to restore a backup to another PostgreSQL cluster."""
database_app_name = f"new-{DATABASE_APP_NAME}"
Expand Down Expand Up @@ -275,6 +282,7 @@ async def test_restore_on_new_cluster(ops_test: OpsTest) -> None:
connection.close()


@pytest.mark.uses_secrets
async def test_invalid_config_and_recovery_after_fixing_it(
ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]
) -> None:
Expand Down

0 comments on commit 3a38557

Please sign in to comment.