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

[DPE-2844] New interface indico test and new legacy extensions test #324

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 3 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
jobs:
lint:
name: Lint
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v5.1.2
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v6.1.1

unit-test:
name: Unit test charm
Expand All @@ -45,7 +45,7 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v5.1.2
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v6.1.1
permissions:
actions: write # Needed to manage GitHub Actions cache

Expand Down Expand Up @@ -115,14 +115,8 @@ jobs:
echo Skipping unstable tests
echo "mark_expression=and not unstable" >> "$GITHUB_OUTPUT"
fi
- name: Select test secret usage
id: select-test-secrets
if: ${{ github.event.pull_request.head.repo.full_name != 'canonical/postgresql-k8s-operator' }}
run: |
echo Skipping tests using secrets
echo "mark_secrets=and not uses_secrets" >> "$GITHUB_OUTPUT"
Comment on lines -118 to -123
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New dpw would skip automatically so we no longer need this logic.

- name: Run integration tests
run: tox run -e ${{ matrix.tox-environment }} -- -m 'not ${{ matrix.exclude-mark }} ${{ steps.select-test-secrets.outputs.mark_secrets }} ${{ 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_expression }}' --keep-models
env:
SECRETS_FROM_GITHUB: |
{
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release charm libraries
Expand All @@ -41,14 +41,14 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v5.1.2
uses: canonical/data-platform-workflows/.github/workflows/build_charm_without_cache.yaml@v6.1.1

release:
name: Release charm
needs:
- ci-tests
- build
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v5.1.2
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v6.1.1
with:
channel: 14/edge
artifact-name: ${{ needs.build.outputs.artifact-name }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_issue_to_jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
sync:
name: Sync GitHub issue to Jira
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v5.1.2
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v6.1.1
with:
jira-base-url: https://warthogs.atlassian.net
jira-project-key: DPE
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ optional = true
[tool.poetry.group.integration.dependencies]
lightkube = "^0.14.0"
pytest = "^7.4.3"
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v5.1.2", subdirectory = "python/pytest_plugins/github_secrets"}
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/github_secrets"}
pytest-operator = "^0.29.0"
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v5.1.2", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v5.1.2", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v6.1.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
juju = "^3.2.2"
psycopg2 = {version = "^2.9.9", extras = ["binary"]}
boto3 = "^1.28.70"
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import tarfile
import tempfile
from datetime import datetime
from pathlib import Path
from typing import Dict, Optional, Set, Tuple

import kubernetes as kubernetes
import psycopg2
import requests
import yaml
from kubernetes import config
from kubernetes.client.api import core_v1_api
from kubernetes.stream import stream
Expand All @@ -30,15 +28,14 @@
)

from tests.integration.helpers import (
APPLICATION_NAME,
app_name,
db_connect,
get_password,
get_primary,
get_unit_address,
)

APPLICATION_NAME = "postgresql-test-app"
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
Comment on lines -40 to -41
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have those in the root helpers module

PORT = 5432


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from tenacity import Retrying, stop_after_delay, wait_fixed

from tests.integration.ha_tests.helpers import (
APPLICATION_NAME,
are_writes_increasing,
check_writes,
is_cluster_updated,
start_continuous_writes,
)
from tests.integration.helpers import (
APPLICATION_NAME,
CHARM_SERIES,
app_name,
build_and_deploy,
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from tenacity import Retrying, stop_after_delay, wait_fixed

from tests.integration.ha_tests.helpers import (
APPLICATION_NAME,
METADATA,
are_all_db_processes_down,
are_writes_increasing,
change_patroni_setting,
Expand All @@ -32,7 +30,9 @@
start_continuous_writes,
)
from tests.integration.helpers import (
APPLICATION_NAME,
CHARM_SERIES,
METADATA,
app_name,
build_and_deploy,
db_connect,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from tenacity import Retrying, stop_after_attempt, wait_fixed

from tests.integration.ha_tests.helpers import (
APPLICATION_NAME,
are_writes_increasing,
check_writes,
start_continuous_writes,
)
from tests.integration.helpers import (
APPLICATION_NAME,
DATABASE_APP_NAME,
METADATA,
count_switchovers,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ha_tests/test_upgrade_from_stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from tenacity import Retrying, stop_after_attempt, wait_fixed

from tests.integration.ha_tests.helpers import (
APPLICATION_NAME,
are_writes_increasing,
check_writes,
start_continuous_writes,
)
from tests.integration.helpers import (
APPLICATION_NAME,
DATABASE_APP_NAME,
METADATA,
count_switchovers,
Expand Down
1 change: 1 addition & 0 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
CHARM_SERIES = "jammy"
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
DATABASE_APP_NAME = METADATA["name"]
APPLICATION_NAME = "postgresql-test-app"

charm = None

Expand Down
36 changes: 36 additions & 0 deletions tests/integration/new_relations/test_new_relations.py
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no special behaviour for extensions in the new interface, so just deploying indico and waiting to idle.

Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,39 @@ async def test_invalid_extra_user_roles(ops_test: OpsTest):
raise_on_blocked=False,
timeout=1000,
)


async def test_indico_datatabase(ops_test: OpsTest) -> None:
"""Tests deploying and relating to the Indico charm."""
async with ops_test.fast_forward(fast_interval="30s"):
await ops_test.model.deploy(
"indico",
channel="stable",
application_name="indico",
num_units=1,
)
await ops_test.model.deploy("redis-k8s", channel="stable", application_name="redis-broker")
await ops_test.model.deploy("redis-k8s", channel="stable", application_name="redis-cache")
await asyncio.gather(
ops_test.model.relate("redis-broker", "indico"),
ops_test.model.relate("redis-cache", "indico"),
)

# Wait for model to stabilise
await ops_test.model.wait_for_idle(
apps=["indico"],
status="waiting",
timeout=1000,
)

# Verify that the charm doesn't block when the extensions are enabled.
logger.info("Verifying that the charm doesn't block when the extensions are enabled")
config = {"plugin_pg_trgm_enable": "True", "plugin_unaccent_enable": "True"}
await ops_test.model.applications[DATABASE_APP_NAME].set_config(config)
await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active")
await ops_test.model.relate(DATABASE_APP_NAME, "indico")
await ops_test.model.wait_for_idle(
apps=[DATABASE_APP_NAME, "indico"],
status="active",
timeout=2000,
)
5 changes: 1 addition & 4 deletions tests/integration/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ async def test_none() -> None:
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 @@ -209,8 +208,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:
async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets) -> None:
"""Test that is possible to restore a backup to another PostgreSQL cluster."""
database_app_name = f"new-{DATABASE_APP_NAME}"
await build_and_deploy(ops_test, 1, database_app_name=database_app_name, wait_for_idle=False)
Expand Down Expand Up @@ -282,7 +280,6 @@ 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
Loading