1616logger = logging .getLogger (__name__ )
1717
1818APP_NAME = METADATA ["name" ]
19- MAILMAN3_CORE_APP_NAME = "mailman3-core"
19+ # MAILMAN3_CORE_APP_NAME = "mailman3-core"
2020DB_RELATION = "db"
2121DATABASE_RELATION = "database"
2222FIRST_DATABASE_RELATION = "first-database"
23- APP_NAMES = [APP_NAME , APPLICATION_APP_NAME , MAILMAN3_CORE_APP_NAME ]
23+ DATABASE_APP_NAME = "database-app"
24+ DB_APP_NAME = "db-app"
25+ APP_NAMES = [APP_NAME , DATABASE_APP_NAME , DB_APP_NAME ]
2426
2527
2628@pytest .mark .group (1 )
@@ -33,7 +35,7 @@ async def test_deploy_charms(ops_test: OpsTest, charm):
3335 await asyncio .gather (
3436 ops_test .model .deploy (
3537 APPLICATION_APP_NAME ,
36- application_name = APPLICATION_APP_NAME ,
38+ application_name = DATABASE_APP_NAME ,
3739 num_units = 1 ,
3840 series = CHARM_SERIES ,
3941 channel = "edge" ,
@@ -43,14 +45,14 @@ async def test_deploy_charms(ops_test: OpsTest, charm):
4345 application_name = APP_NAME ,
4446 num_units = 1 ,
4547 series = CHARM_SERIES ,
46- config = {"profile" : "testing" },
48+ config = {"profile" : "testing" , "plugin_unaccent_enable" : "True" , "plugin_pg_trgm_enable" : "True" },
4749 ),
4850 ops_test .model .deploy (
49- MAILMAN3_CORE_APP_NAME ,
50- application_name = MAILMAN3_CORE_APP_NAME ,
51- channel = "stable" ,
52- series = "focal" ,
53- config = { "hostname" : "example.org" } ,
51+ APPLICATION_APP_NAME ,
52+ application_name = DB_APP_NAME ,
53+ num_units = 1 ,
54+ series = CHARM_SERIES ,
55+ channel = "edge" ,
5456 ),
5557 )
5658
@@ -59,8 +61,8 @@ async def test_deploy_charms(ops_test: OpsTest, charm):
5961
6062@pytest .mark .group (1 )
6163async def test_legacy_endpoint_with_multiple_related_endpoints (ops_test : OpsTest ):
62- await ops_test .model .relate (MAILMAN3_CORE_APP_NAME , f"{ APP_NAME } :{ DB_RELATION } " )
63- await ops_test .model .relate (APP_NAME , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } " )
64+ await ops_test .model .relate (f" { DB_APP_NAME } : { DB_RELATION } " , f"{ APP_NAME } :{ DB_RELATION } " )
65+ await ops_test .model .relate (APP_NAME , f"{ DATABASE_APP_NAME } :{ FIRST_DATABASE_RELATION } " )
6466
6567 app = ops_test .model .applications [APP_NAME ]
6668 await ops_test .model .block_until (
@@ -70,7 +72,7 @@ async def test_legacy_endpoint_with_multiple_related_endpoints(ops_test: OpsTest
7072
7173 logger .info (" remove relation with modern endpoints" )
7274 await ops_test .model .applications [APP_NAME ].remove_relation (
73- f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } "
75+ f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ DATABASE_APP_NAME } :{ FIRST_DATABASE_RELATION } "
7476 )
7577 async with ops_test .fast_forward ():
7678 await ops_test .model .wait_for_idle (
@@ -80,27 +82,27 @@ async def test_legacy_endpoint_with_multiple_related_endpoints(ops_test: OpsTest
8082 )
8183
8284 legacy_interface_connect = await get_legacy_db_connection_str (
83- ops_test , MAILMAN3_CORE_APP_NAME , DB_RELATION , remote_unit_name = f"{ APP_NAME } /0"
85+ ops_test , DB_APP_NAME , DB_RELATION , remote_unit_name = f"{ APP_NAME } /0"
8486 )
8587 logger .info (f" check connect to = { legacy_interface_connect } " )
8688 for attempt in Retrying (stop = stop_after_delay (60 * 3 ), wait = wait_fixed (10 )):
8789 with attempt :
8890 with psycopg2 .connect (legacy_interface_connect ) as connection :
8991 assert connection .status == psycopg2 .extensions .STATUS_READY
9092
91- logger .info (" remove relation mailman3-core " )
93+ logger .info (f " remove relation { DB_APP_NAME } : { DB_RELATION } " )
9294 async with ops_test .fast_forward ():
9395 await ops_test .model .applications [APP_NAME ].remove_relation (
94- f"{ APP_NAME } :{ DB_RELATION } " , f"{ MAILMAN3_CORE_APP_NAME } :{ DB_RELATION } "
96+ f"{ APP_NAME } :{ DB_RELATION } " , f"{ DB_APP_NAME } :{ DB_RELATION } "
9597 )
9698 await ops_test .model .wait_for_idle (apps = [APP_NAME ], status = "active" , timeout = 1000 )
9799 with pytest .raises (psycopg2 .OperationalError ):
98100 psycopg2 .connect (legacy_interface_connect )
99101
100102
101103async def test_modern_endpoint_with_multiple_related_endpoints (ops_test : OpsTest ):
102- await ops_test .model .relate (MAILMAN3_CORE_APP_NAME , f"{ APP_NAME } :{ DB_RELATION } " )
103- await ops_test .model .relate (APP_NAME , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } " )
104+ await ops_test .model .relate (f" { DB_APP_NAME } : { DB_RELATION } " , f"{ APP_NAME } :{ DB_RELATION } " )
105+ await ops_test .model .relate (APP_NAME , f"{ DATABASE_APP_NAME } :{ FIRST_DATABASE_RELATION } " )
104106
105107 app = ops_test .model .applications [APP_NAME ]
106108 await ops_test .model .block_until (
@@ -110,24 +112,24 @@ async def test_modern_endpoint_with_multiple_related_endpoints(ops_test: OpsTest
110112
111113 logger .info (" remove relation with legacy endpoints" )
112114 await ops_test .model .applications [APP_NAME ].remove_relation (
113- f"{ MAILMAN3_CORE_APP_NAME } :{ DB_RELATION } " , f"{ APP_NAME } :{ DB_RELATION } "
115+ f"{ DB_APP_NAME } :{ DB_RELATION } " , f"{ APP_NAME } :{ DB_RELATION } "
114116 )
115117 async with ops_test .fast_forward ():
116118 await ops_test .model .wait_for_idle (status = "active" , timeout = 3000 , raise_on_error = False )
117119
118120 modern_interface_connect = await build_connection_string (
119- ops_test , APPLICATION_APP_NAME , FIRST_DATABASE_RELATION
121+ ops_test , DATABASE_APP_NAME , FIRST_DATABASE_RELATION
120122 )
121- logger .info (f" check connect to = { modern_interface_connect } " )
123+ logger .info (f"check connect to = { modern_interface_connect } " )
122124 for attempt in Retrying (stop = stop_after_delay (60 * 3 ), wait = wait_fixed (10 )):
123125 with attempt :
124126 with psycopg2 .connect (modern_interface_connect ) as connection :
125127 assert connection .status == psycopg2 .extensions .STATUS_READY
126128
127- logger .info (f" remove relation { APPLICATION_APP_NAME } " )
129+ logger .info (f"remove relation { DATABASE_APP_NAME } : { FIRST_DATABASE_RELATION } " )
128130 async with ops_test .fast_forward ():
129131 await ops_test .model .applications [APP_NAME ].remove_relation (
130- f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } "
132+ f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ DATABASE_APP_NAME } :{ FIRST_DATABASE_RELATION } "
131133 )
132134 await ops_test .model .wait_for_idle (apps = [APP_NAME ], status = "active" , timeout = 1000 )
133135 for attempt in Retrying (stop = stop_after_delay (60 * 5 ), wait = wait_fixed (10 )):
0 commit comments