|
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 (
|
@@ -2039,59 +2039,6 @@ def test_migration_from_single_secret(harness, scope, is_leader):
|
2039 | 2039 | )
|
2040 | 2040 |
|
2041 | 2041 |
|
2042 |
| -def test_handle_postgresql_restart_need(harness): |
2043 |
| - with ( |
2044 |
| - patch("charms.rolling_ops.v0.rollingops.RollingOpsManager._on_acquire_lock") as _restart, |
2045 |
| - patch("charm.wait_fixed", return_value=wait_fixed(0)), |
2046 |
| - patch("charm.Patroni.reload_patroni_configuration") as _reload_patroni_configuration, |
2047 |
| - patch("charm.PostgresqlOperatorCharm._unit_ip"), |
2048 |
| - patch( |
2049 |
| - "charm.PostgresqlOperatorCharm.is_tls_enabled", new_callable=PropertyMock |
2050 |
| - ) as _is_tls_enabled, |
2051 |
| - patch.object(PostgresqlOperatorCharm, "postgresql", Mock()) as postgresql_mock, |
2052 |
| - ): |
2053 |
| - rel_id = harness.model.get_relation(PEER).id |
2054 |
| - for values in itertools.product( |
2055 |
| - [True, False], [True, False], [True, False], [True, False] |
2056 |
| - ): |
2057 |
| - _reload_patroni_configuration.reset_mock() |
2058 |
| - _restart.reset_mock() |
2059 |
| - with harness.hooks_disabled(): |
2060 |
| - harness.update_relation_data(rel_id, harness.charm.unit.name, {"tls": ""}) |
2061 |
| - harness.update_relation_data( |
2062 |
| - rel_id, |
2063 |
| - harness.charm.unit.name, |
2064 |
| - {"postgresql_restarted": ("True" if values[3] else "")}, |
2065 |
| - ) |
2066 |
| - |
2067 |
| - _is_tls_enabled.return_value = values[0] |
2068 |
| - postgresql_mock.is_tls_enabled.return_value = values[1] |
2069 |
| - postgresql_mock.is_restart_pending = PropertyMock(return_value=values[2]) |
2070 |
| - |
2071 |
| - harness.charm._handle_postgresql_restart_need() |
2072 |
| - _reload_patroni_configuration.assert_called_once() |
2073 |
| - if values[0]: |
2074 |
| - assert "tls" in harness.get_relation_data(rel_id, harness.charm.unit) |
2075 |
| - else: |
2076 |
| - assert "tls" not in harness.get_relation_data(rel_id, harness.charm.unit) |
2077 |
| - |
2078 |
| - if (values[0] != values[1]) or values[2]: |
2079 |
| - assert "postgresql_restarted" not in harness.get_relation_data( |
2080 |
| - rel_id, harness.charm.unit |
2081 |
| - ) |
2082 |
| - _restart.assert_called_once() |
2083 |
| - else: |
2084 |
| - if values[3]: |
2085 |
| - assert "postgresql_restarted" in harness.get_relation_data( |
2086 |
| - rel_id, harness.charm.unit |
2087 |
| - ) |
2088 |
| - else: |
2089 |
| - assert "postgresql_restarted" not in harness.get_relation_data( |
2090 |
| - rel_id, harness.charm.unit |
2091 |
| - ) |
2092 |
| - _restart.assert_not_called() |
2093 |
| - |
2094 |
| - |
2095 | 2042 | def test_on_peer_relation_departed(harness):
|
2096 | 2043 | with (
|
2097 | 2044 | patch(
|
|
0 commit comments