|
31 | 31 | )
|
32 | 32 | from ops.testing import Harness
|
33 | 33 | from psycopg2 import OperationalError
|
34 |
| -from tenacity import RetryError, wait_fixed |
| 34 | +from tenacity import RetryError |
35 | 35 |
|
36 | 36 | from backups import CANNOT_RESTORE_PITR
|
37 | 37 | from charm import (
|
@@ -2049,59 +2049,6 @@ def test_migration_from_single_secret(harness, scope, is_leader):
|
2049 | 2049 | )
|
2050 | 2050 |
|
2051 | 2051 |
|
2052 |
| -def test_handle_postgresql_restart_need(harness): |
2053 |
| - with ( |
2054 |
| - patch("charms.rolling_ops.v0.rollingops.RollingOpsManager._on_acquire_lock") as _restart, |
2055 |
| - patch("charm.wait_fixed", return_value=wait_fixed(0)), |
2056 |
| - patch("charm.Patroni.reload_patroni_configuration") as _reload_patroni_configuration, |
2057 |
| - patch("charm.PostgresqlOperatorCharm._unit_ip"), |
2058 |
| - patch( |
2059 |
| - "charm.PostgresqlOperatorCharm.is_tls_enabled", new_callable=PropertyMock |
2060 |
| - ) as _is_tls_enabled, |
2061 |
| - patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, |
2062 |
| - ): |
2063 |
| - rel_id = harness.model.get_relation(PEER).id |
2064 |
| - for values in itertools.product( |
2065 |
| - [True, False], [True, False], [True, False], [True, False] |
2066 |
| - ): |
2067 |
| - _reload_patroni_configuration.reset_mock() |
2068 |
| - _restart.reset_mock() |
2069 |
| - with harness.hooks_disabled(): |
2070 |
| - harness.update_relation_data(rel_id, harness.charm.unit.name, {"tls": ""}) |
2071 |
| - harness.update_relation_data( |
2072 |
| - rel_id, |
2073 |
| - harness.charm.unit.name, |
2074 |
| - {"postgresql_restarted": ("True" if values[3] else "")}, |
2075 |
| - ) |
2076 |
| - |
2077 |
| - _is_tls_enabled.return_value = values[0] |
2078 |
| - postgresql_mock.is_tls_enabled.return_value = values[1] |
2079 |
| - postgresql_mock.is_restart_pending = PropertyMock(return_value=values[2]) |
2080 |
| - |
2081 |
| - harness.charm._handle_postgresql_restart_need() |
2082 |
| - _reload_patroni_configuration.assert_called_once() |
2083 |
| - if values[0]: |
2084 |
| - assert "tls" in harness.get_relation_data(rel_id, harness.charm.unit) |
2085 |
| - else: |
2086 |
| - assert "tls" not in harness.get_relation_data(rel_id, harness.charm.unit) |
2087 |
| - |
2088 |
| - if (values[0] != values[1]) or values[2]: |
2089 |
| - assert "postgresql_restarted" not in harness.get_relation_data( |
2090 |
| - rel_id, harness.charm.unit |
2091 |
| - ) |
2092 |
| - _restart.assert_called_once() |
2093 |
| - else: |
2094 |
| - if values[3]: |
2095 |
| - assert "postgresql_restarted" in harness.get_relation_data( |
2096 |
| - rel_id, harness.charm.unit |
2097 |
| - ) |
2098 |
| - else: |
2099 |
| - assert "postgresql_restarted" not in harness.get_relation_data( |
2100 |
| - rel_id, harness.charm.unit |
2101 |
| - ) |
2102 |
| - _restart.assert_not_called() |
2103 |
| - |
2104 |
| - |
2105 | 2052 | def test_on_peer_relation_departed(harness):
|
2106 | 2053 | with (
|
2107 | 2054 | patch(
|
|
0 commit comments