3
3
# See LICENSE file for licensing details.
4
4
import logging
5
5
import os
6
- from asyncio import sleep
7
6
8
7
import pytest as pytest
9
8
from pytest_operator .plugin import OpsTest
12
11
from . import architecture
13
12
from .ha_tests .helpers import (
14
13
change_patroni_setting ,
15
- get_patroni_setting ,
16
14
)
17
15
from .helpers import (
18
16
CHARM_SERIES ,
@@ -111,11 +109,8 @@ async def test_tls_enabled(ops_test: OpsTest) -> None:
111
109
)
112
110
change_primary_start_timeout (ops_test , primary , 0 )
113
111
114
- # Change the loop wait setting to make Patroni wait more time before restarting PostgreSQL.
115
- initial_loop_wait = await get_patroni_setting (ops_test , "loop_wait" , tls = True )
116
- await change_patroni_setting (ops_test , "loop_wait" , 300 , use_random_unit = True , tls = True )
117
-
118
- await sleep (2 * initial_loop_wait )
112
+ # Pause Patroni so it doesn't wipe the custom changes
113
+ await change_patroni_setting (ops_test , "pause" , True , use_random_unit = True , tls = True )
119
114
120
115
for attempt in Retrying (
121
116
stop = stop_after_delay (60 * 5 ), wait = wait_exponential (multiplier = 1 , min = 2 , max = 30 )
@@ -151,10 +146,6 @@ async def test_tls_enabled(ops_test: OpsTest) -> None:
151
146
cursor .execute ("INSERT INTO pgrewindtest SELECT generate_series(1,1000);" )
152
147
connection .close ()
153
148
154
- await change_patroni_setting (
155
- ops_test , "loop_wait" , initial_loop_wait , use_random_unit = True , tls = True
156
- )
157
-
158
149
# Stop the initial primary by killing both Patroni and PostgreSQL OS processes.
159
150
await run_command_on_unit (
160
151
ops_test ,
@@ -179,6 +170,8 @@ async def test_tls_enabled(ops_test: OpsTest) -> None:
179
170
"grep 'connection authorized: user=rewind database=postgres SSL enabled' /var/snap/charmed-postgresql/common/var/log/postgresql/postgresql-*.log" ,
180
171
)
181
172
173
+ await change_patroni_setting (ops_test , "pause" , False , use_random_unit = True , tls = True )
174
+
182
175
# Remove the relation.
183
176
await ops_test .model .applications [DATABASE_APP_NAME ].remove_relation (
184
177
f"{ DATABASE_APP_NAME } :certificates" , f"{ tls_certificates_app_name } :certificates"
0 commit comments