Skip to content

Commit

Permalink
Add group markers
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Oct 30, 2023
1 parent 9b056f4 commit 960a699
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 3 deletions.
8 changes: 5 additions & 3 deletions poetry.lock

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

4 changes: 4 additions & 0 deletions tests/integration/ha_tests/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from tests.integration.helpers import CHARM_SERIES, db_connect, scale_application


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy three unit of PostgreSQL."""
Expand Down Expand Up @@ -51,6 +52,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.wait_for_idle(status="active", timeout=1000)


@pytest.mark.group(1)
async def test_reelection(ops_test: OpsTest, continuous_writes, primary_start_timeout) -> None:
"""Kill primary unit, check reelection."""
app = await app_name(ops_test)
Expand Down Expand Up @@ -88,6 +90,7 @@ async def test_reelection(ops_test: OpsTest, continuous_writes, primary_start_ti
await check_writes(ops_test)


@pytest.mark.group(1)
async def test_consistency(ops_test: OpsTest, continuous_writes) -> None:
"""Write to primary, read data from secondaries (check consistency)."""
# Locate primary unit.
Expand All @@ -104,6 +107,7 @@ async def test_consistency(ops_test: OpsTest, continuous_writes) -> None:
await check_writes(ops_test)


@pytest.mark.group(1)
async def test_no_data_replicated_between_clusters(ops_test: OpsTest, continuous_writes) -> None:
"""Check that writes in one cluster are not replicated to another cluster."""
# Locate primary unit.
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/ha_tests/test_restore_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
charm = None


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy two PostgreSQL clusters."""
Expand Down Expand Up @@ -66,6 +67,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.destroy_unit(second_primary)


@pytest.mark.group(1)
async def test_cluster_restore(ops_test):
"""Recreates the cluster from storage volumes."""
# Write some data.
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
DB_PROCESSES = [POSTGRESQL_PROCESS, PATRONI_PROCESS]


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy three unit of PostgreSQL."""
Expand Down Expand Up @@ -93,6 +94,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
await ops_test.model.wait_for_idle(status="active", timeout=1000)


@pytest.mark.group(1)
async def test_storage_re_use(ops_test, continuous_writes):
"""Verifies that database units with attached storage correctly repurpose storage.
Expand Down Expand Up @@ -139,6 +141,7 @@ async def test_storage_re_use(ops_test, continuous_writes):
), "new instance not up to date."


@pytest.mark.group(1)
@pytest.mark.parametrize("process", DB_PROCESSES)
async def test_kill_db_process(
ops_test: OpsTest, process: str, continuous_writes, primary_start_timeout
Expand Down Expand Up @@ -166,6 +169,7 @@ async def test_kill_db_process(
await is_cluster_updated(ops_test, primary_name)


@pytest.mark.group(1)
@pytest.mark.parametrize("process", DB_PROCESSES)
async def test_freeze_db_process(
ops_test: OpsTest, process: str, continuous_writes, primary_start_timeout
Expand Down Expand Up @@ -203,6 +207,7 @@ async def test_freeze_db_process(
await is_cluster_updated(ops_test, primary_name)


@pytest.mark.group(1)
@pytest.mark.parametrize("process", DB_PROCESSES)
async def test_restart_db_process(
ops_test: OpsTest, process: str, continuous_writes, primary_start_timeout
Expand Down Expand Up @@ -230,6 +235,7 @@ async def test_restart_db_process(
await is_cluster_updated(ops_test, primary_name)


@pytest.mark.group(1)
@pytest.mark.parametrize("process", DB_PROCESSES)
@pytest.mark.parametrize("signal", ["SIGTERM", "SIGKILL"])
async def test_full_cluster_restart(
Expand Down Expand Up @@ -299,6 +305,7 @@ async def test_full_cluster_restart(
await check_writes(ops_test)


@pytest.mark.group(1)
@pytest.mark.unstable
async def test_forceful_restart_without_data_and_transaction_logs(
ops_test: OpsTest,
Expand Down Expand Up @@ -374,6 +381,7 @@ async def test_forceful_restart_without_data_and_transaction_logs(
await is_cluster_updated(ops_test, primary_name)


@pytest.mark.group(1)
@pytest.mark.unstable
async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_timeout):
"""Completely cut and restore network."""
Expand Down Expand Up @@ -458,6 +466,7 @@ async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_t
await is_cluster_updated(ops_test, primary_name)


@pytest.mark.group(1)
@pytest.mark.unstable
async def test_network_cut_without_ip_change(
ops_test: OpsTest, continuous_writes, primary_start_timeout
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/ha_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
TIMEOUT = 5 * 60


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_deploy_latest(ops_test: OpsTest) -> None:
"""Simple test to ensure that the PostgreSQL and application charms get deployed."""
Expand All @@ -52,6 +53,7 @@ async def test_deploy_latest(ops_test: OpsTest) -> None:
assert len(ops_test.model.applications[DATABASE_APP_NAME].units) == 3


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_pre_upgrade_check(ops_test: OpsTest) -> None:
"""Test that the pre-upgrade-check action runs successfully."""
Expand All @@ -64,6 +66,7 @@ async def test_pre_upgrade_check(ops_test: OpsTest) -> None:
await action.wait()


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_upgrade_from_edge(ops_test: OpsTest, continuous_writes) -> None:
# Start an application that continuously writes data to the database.
Expand Down Expand Up @@ -113,6 +116,7 @@ async def test_upgrade_from_edge(ops_test: OpsTest, continuous_writes) -> None:
) <= 2, "Number of switchovers is greater than 2"


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_fail_and_rollback(ops_test, continuous_writes) -> None:
# Start an application that continuously writes data to the database.
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/ha_tests/test_upgrade_from_stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
TIMEOUT = 5 * 60


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_deploy_stable(ops_test: OpsTest) -> None:
"""Simple test to ensure that the PostgreSQL and application charms get deployed."""
Expand Down Expand Up @@ -75,6 +76,7 @@ async def test_deploy_stable(ops_test: OpsTest) -> None:
assert len(ops_test.model.applications[DATABASE_APP_NAME].units) == 3


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_pre_upgrade_check(ops_test: OpsTest) -> None:
"""Test that the pre-upgrade-check action runs successfully."""
Expand All @@ -92,6 +94,7 @@ async def test_pre_upgrade_check(ops_test: OpsTest) -> None:
await action.wait()


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_upgrade_from_stable(ops_test: OpsTest):
"""Test updating from stable channel."""
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/new_relations/test_new_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_deploy_charms(ops_test: OpsTest, charm):
"""Deploy both charms (application and database) to use in the tests."""
Expand Down Expand Up @@ -68,6 +69,7 @@ async def test_deploy_charms(ops_test: OpsTest, charm):
await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", timeout=3000)


@pytest.mark.group(1)
async def test_no_read_only_endpoint_in_standalone_cluster(ops_test: OpsTest):
"""Test that there is no read-only endpoint in a standalone cluster."""
async with ops_test.fast_forward():
Expand Down Expand Up @@ -114,6 +116,7 @@ async def test_no_read_only_endpoint_in_standalone_cluster(ops_test: OpsTest):
)


@pytest.mark.group(1)
async def test_read_only_endpoint_in_scaled_up_cluster(ops_test: OpsTest):
"""Test that there is read-only endpoint in a scaled up cluster."""
async with ops_test.fast_forward():
Expand All @@ -131,6 +134,7 @@ async def test_read_only_endpoint_in_scaled_up_cluster(ops_test: OpsTest):
)


@pytest.mark.group(1)
async def test_database_relation_with_charm_libraries(ops_test: OpsTest):
"""Test basic functionality of database relation interface."""
# Get the connection string to connect to the database using the read/write endpoint.
Expand Down Expand Up @@ -178,6 +182,7 @@ async def test_database_relation_with_charm_libraries(ops_test: OpsTest):
cursor.execute("DROP TABLE test;")


@pytest.mark.group(1)
async def test_user_with_extra_roles(ops_test: OpsTest):
"""Test superuser actions and the request for more permissions."""
# Get the connection string to connect to the database.
Expand All @@ -198,6 +203,7 @@ async def test_user_with_extra_roles(ops_test: OpsTest):
connection.close()


@pytest.mark.group(1)
async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: OpsTest):
"""Test that two different application connect to the database with different credentials."""
# Set some variables to use in this test.
Expand Down Expand Up @@ -250,6 +256,7 @@ async def test_two_applications_doesnt_share_the_same_relation_data(ops_test: Op
psycopg2.connect(connection_string)


@pytest.mark.group(1)
async def test_an_application_can_connect_to_multiple_database_clusters(ops_test: OpsTest):
"""Test that an application can connect to different clusters of the same database."""
# Relate the application with both database clusters
Expand Down Expand Up @@ -280,6 +287,7 @@ async def test_an_application_can_connect_to_multiple_database_clusters(ops_test
assert application_connection_string != another_application_connection_string


@pytest.mark.group(1)
async def test_an_application_can_connect_to_multiple_aliased_database_clusters(ops_test: OpsTest):
"""Test that an application can connect to different clusters of the same database."""
# Relate the application with both database clusters
Expand Down Expand Up @@ -313,6 +321,7 @@ async def test_an_application_can_connect_to_multiple_aliased_database_clusters(
assert application_connection_string != another_application_connection_string


@pytest.mark.group(1)
async def test_an_application_can_request_multiple_databases(ops_test: OpsTest):
"""Test that an application can request additional databases using the same interface."""
# Relate the charms using another relation and wait for them exchanging some connection data.
Expand All @@ -333,6 +342,7 @@ async def test_an_application_can_request_multiple_databases(ops_test: OpsTest):
assert first_database_connection_string != second_database_connection_string


@pytest.mark.group(1)
async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest):
"""Test that relation data, like connection data, is updated correctly when scaling."""
# Retrieve the list of current database unit names.
Expand Down Expand Up @@ -399,6 +409,7 @@ async def test_relation_data_is_updated_correctly_when_scaling(ops_test: OpsTest
psycopg2.connect(primary_connection_string)


@pytest.mark.group(1)
async def test_relation_with_no_database_name(ops_test: OpsTest):
"""Test that a relation with no database name doesn't block the charm."""
async with ops_test.fast_forward():
Expand All @@ -415,6 +426,7 @@ async def test_relation_with_no_database_name(ops_test: OpsTest):
await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", raise_on_blocked=True)


@pytest.mark.group(1)
async def test_admin_role(ops_test: OpsTest):
"""Test that the admin role gives access to all the databases."""
all_app_names = [DATA_INTEGRATOR_APP_NAME]
Expand Down Expand Up @@ -499,6 +511,7 @@ async def test_admin_role(ops_test: OpsTest):
connection.close()


@pytest.mark.group(1)
async def test_invalid_extra_user_roles(ops_test: OpsTest):
async with ops_test.fast_forward():
# Remove the relation between the database and the first data integrator.
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async def cloud_configs(ops_test: OpsTest, github_secrets) -> None:
bucket_object.delete()


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_backup(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 @@ -216,6 +217,7 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
await ops_test.model.remove_application(TLS_CERTIFICATES_APP_NAME, block_until_done=True)


@pytest.mark.group(1)
async def test_restore_on_new_cluster(ops_test: OpsTest) -> None:
"""Test that is possible to restore a backup to another PostgreSQL cluster."""
charm = await ops_test.build_charm(".")
Expand Down Expand Up @@ -293,6 +295,7 @@ async def test_restore_on_new_cluster(ops_test: OpsTest) -> None:
connection.close()


@pytest.mark.group(1)
async def test_invalid_config_and_recovery_after_fixing_it(
ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]
) -> None:
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
UNIT_IDS = [0, 1, 2]


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
@pytest.mark.skip_if_deployed
async def test_deploy(ops_test: OpsTest, charm: str):
Expand All @@ -55,6 +56,7 @@ async def test_deploy(ops_test: OpsTest, charm: str):
assert ops_test.model.applications[DATABASE_APP_NAME].units[0].workload_status == "active"


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
@pytest.mark.parametrize("unit_id", UNIT_IDS)
async def test_database_is_up(ops_test: OpsTest, unit_id: int):
Expand All @@ -65,6 +67,7 @@ async def test_database_is_up(ops_test: OpsTest, unit_id: int):
assert result.status_code == 200


@pytest.mark.group(1)
@pytest.mark.parametrize("unit_id", UNIT_IDS)
async def test_exporter_is_up(ops_test: OpsTest, unit_id: int):
# Query Patroni REST API and check the status that indicates
Expand All @@ -77,6 +80,7 @@ async def test_exporter_is_up(ops_test: OpsTest, unit_id: int):
), "Scrape error in postgresql_prometheus_exporter"


@pytest.mark.group(1)
@pytest.mark.parametrize("unit_id", UNIT_IDS)
async def test_settings_are_correct(ops_test: OpsTest, unit_id: int):
# Connect to the PostgreSQL instance.
Expand Down Expand Up @@ -162,6 +166,7 @@ async def test_settings_are_correct(ops_test: OpsTest, unit_id: int):
assert unit.data["port-ranges"][0]["protocol"] == "tcp"


@pytest.mark.group(1)
async def test_postgresql_parameters_change(ops_test: OpsTest) -> None:
"""Test that's possible to change PostgreSQL parameters."""
await ops_test.model.applications[DATABASE_APP_NAME].set_config(
Expand Down Expand Up @@ -198,6 +203,7 @@ async def test_postgresql_parameters_change(ops_test: OpsTest) -> None:
assert settings["lc_monetary"] == "en_GB.utf8"


@pytest.mark.group(1)
async def test_scale_down_and_up(ops_test: OpsTest):
"""Test data is replicated to new units after a scale up."""
# Ensure the initial number of units in the application.
Expand Down Expand Up @@ -279,6 +285,7 @@ async def test_scale_down_and_up(ops_test: OpsTest):
await scale_application(ops_test, DATABASE_APP_NAME, initial_scale)


@pytest.mark.group(1)
async def test_persist_data_through_primary_deletion(ops_test: OpsTest):
"""Test data persists through a primary deletion."""
# Set a composite application name in order to test in more than one series at the same time.
Expand Down
Loading

0 comments on commit 960a699

Please sign in to comment.