@@ -92,11 +92,8 @@ async def cloud_configs(ops_test: OpsTest, github_secrets) -> None:
92
92
93
93
@pytest .mark .group (1 )
94
94
@pytest .mark .abort_on_fail
95
- async def test_backup (ops_test : OpsTest , cloud_configs : Tuple [Dict , Dict ]) -> None :
95
+ async def test_backup (ops_test : OpsTest , cloud_configs : Tuple [Dict , Dict ], charm ) -> None :
96
96
"""Build and deploy two units of PostgreSQL and then test the backup and restore actions."""
97
- # Build the PostgreSQL charm.
98
- charm = await ops_test .build_charm ("." )
99
-
100
97
# Deploy S3 Integrator and TLS Certificates Operator.
101
98
await ops_test .model .deploy (S3_INTEGRATOR_APP_NAME )
102
99
await ops_test .model .deploy (TLS_CERTIFICATES_APP_NAME , config = TLS_CONFIG , channel = TLS_CHANNEL )
@@ -126,7 +123,7 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
126
123
await action .wait ()
127
124
async with ops_test .fast_forward (fast_interval = "60s" ):
128
125
await ops_test .model .wait_for_idle (
129
- apps = [database_app_name , S3_INTEGRATOR_APP_NAME ], status = "active" , timeout = 1200
126
+ apps = [database_app_name , S3_INTEGRATOR_APP_NAME ], status = "active" , timeout = 1500
130
127
)
131
128
132
129
primary = await get_primary (ops_test , f"{ database_app_name } /0" )
@@ -279,14 +276,14 @@ async def test_backup(ops_test: OpsTest, cloud_configs: Tuple[Dict, Dict]) -> No
279
276
280
277
# Remove the database app.
281
278
await ops_test .model .remove_application (database_app_name , block_until_done = True )
279
+
282
280
# Remove the TLS operator.
283
281
await ops_test .model .remove_application (TLS_CERTIFICATES_APP_NAME , block_until_done = True )
284
282
285
283
286
284
@pytest .mark .group (1 )
287
- async def test_restore_on_new_cluster (ops_test : OpsTest , github_secrets ) -> None :
285
+ async def test_restore_on_new_cluster (ops_test : OpsTest , github_secrets , charm ) -> None :
288
286
"""Test that is possible to restore a backup to another PostgreSQL cluster."""
289
- charm = await ops_test .build_charm ("." )
290
287
previous_database_app_name = f"{ DATABASE_APP_NAME } -gcp"
291
288
database_app_name = f"new-{ DATABASE_APP_NAME } "
292
289
await ops_test .model .deploy (charm , application_name = previous_database_app_name )
@@ -355,12 +352,9 @@ async def test_restore_on_new_cluster(ops_test: OpsTest, github_secrets) -> None
355
352
356
353
# Wait for the restore to complete.
357
354
async with ops_test .fast_forward ():
358
- await wait_for_idle_on_blocked (
359
- ops_test ,
360
- database_app_name ,
361
- 0 ,
362
- S3_INTEGRATOR_APP_NAME ,
363
- ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE ,
355
+ unit = ops_test .model .units .get (f"{ database_app_name } /0" )
356
+ await ops_test .model .block_until (
357
+ lambda : unit .workload_status_message == ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE
364
358
)
365
359
366
360
# Check that the backup was correctly restored by having only the first created table.
@@ -402,12 +396,9 @@ async def test_invalid_config_and_recovery_after_fixing_it(
402
396
)
403
397
await action .wait ()
404
398
logger .info ("waiting for the database charm to become blocked" )
405
- await wait_for_idle_on_blocked (
406
- ops_test ,
407
- database_app_name ,
408
- 0 ,
409
- S3_INTEGRATOR_APP_NAME ,
410
- FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE ,
399
+ unit = ops_test .model .units .get (f"{ database_app_name } /0" )
400
+ await ops_test .model .block_until (
401
+ lambda : unit .workload_status_message == FAILED_TO_ACCESS_CREATE_BUCKET_ERROR_MESSAGE
411
402
)
412
403
413
404
# Provide valid backup configurations, but from another cluster repository.
@@ -421,12 +412,9 @@ async def test_invalid_config_and_recovery_after_fixing_it(
421
412
)
422
413
await action .wait ()
423
414
logger .info ("waiting for the database charm to become blocked" )
424
- await wait_for_idle_on_blocked (
425
- ops_test ,
426
- database_app_name ,
427
- 0 ,
428
- S3_INTEGRATOR_APP_NAME ,
429
- ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE ,
415
+ unit = ops_test .model .units .get (f"{ database_app_name } /0" )
416
+ await ops_test .model .block_until (
417
+ lambda : unit .workload_status_message == ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE
430
418
)
431
419
432
420
# Provide valid backup configurations, with another path in the S3 bucket.
0 commit comments