@@ -38,107 +38,99 @@ async def test_deploy_charms(ops_test: OpsTest, charm):
38
38
series = CHARM_SERIES ,
39
39
channel = "edge" ,
40
40
),
41
- ops_test .model .deploy (
42
- APPLICATION_APP_NAME ,
43
- application_name = APPLICATION_APP_NAME + "-second" ,
44
- num_units = 1 ,
45
- series = CHARM_SERIES ,
46
- channel = "edge" ,
47
- ),
48
41
ops_test .model .deploy (
49
42
charm ,
50
43
application_name = APP_NAME ,
51
44
num_units = 1 ,
52
45
series = CHARM_SERIES ,
53
46
config = {"profile" : "testing" },
54
47
),
55
- # ops_test.model.deploy(
56
- # MAILMAN3_CORE_APP_NAME,
57
- # application_name=MAILMAN3_CORE_APP_NAME,
58
- # channel="stable",
59
- # series="focal",
60
- # config={"hostname": "example.org"},
61
- # ),
48
+ 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" },
54
+ ),
62
55
)
63
56
64
- await ops_test .model .wait_for_idle (apps = [ APP_NAME , APPLICATION_APP_NAME , APPLICATION_APP_NAME + "-second" ] , status = "active" , timeout = 3000 )
57
+ await ops_test .model .wait_for_idle (apps = APP_NAMES , status = "active" , timeout = 3000 )
65
58
66
59
67
60
@pytest .mark .group (1 )
68
61
async def test_legacy_endpoint_with_multiple_related_endpoints (ops_test : OpsTest ):
69
- # await ops_test.model.relate(MAILMAN3_CORE_APP_NAME, f"{APP_NAME}:{DB_RELATION}")
62
+ await ops_test .model .relate (MAILMAN3_CORE_APP_NAME , f"{ APP_NAME } :{ DB_RELATION } " )
70
63
await ops_test .model .relate (APP_NAME , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } " )
71
- await ops_test .model .relate (APP_NAME , f"{ APPLICATION_APP_NAME } -second:{ FIRST_DATABASE_RELATION } " )
72
64
73
65
app = ops_test .model .applications [APP_NAME ]
74
66
await ops_test .model .block_until (
75
67
lambda : "blocked" in {unit .workload_status for unit in app .units },
76
68
timeout = 1500 ,
77
69
)
78
70
79
- # logger.info(" remove relation with modern endpoints")
80
- # await ops_test.model.applications[APP_NAME].remove_relation(
81
- # f"{APP_NAME}:{DATABASE_RELATION}", f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION}"
82
- # )
83
- # async with ops_test.fast_forward():
84
- # await ops_test.model.wait_for_idle(
85
- # status="active",
86
- # timeout=1500,
87
- # raise_on_error=False,
88
- # )
89
- #
90
- # legacy_interface_connect = await get_legacy_db_connection_str(
91
- # ops_test, MAILMAN3_CORE_APP_NAME, DB_RELATION, remote_unit_name=f"{APP_NAME}/0"
92
- # )
93
- # logger.info(f" check connect to = {legacy_interface_connect}")
94
- # for attempt in Retrying(stop=stop_after_delay(60 * 3), wait=wait_fixed(10)):
95
- # with attempt:
96
- # with psycopg2.connect(legacy_interface_connect) as connection:
97
- # assert connection.status == psycopg2.extensions.STATUS_READY
98
- #
99
- # logger.info(" remove relation mailman3-core")
100
- # async with ops_test.fast_forward():
101
- # await ops_test.model.applications[APP_NAME].remove_relation(
102
- # f"{APP_NAME}:{DB_RELATION}", f"{MAILMAN3_CORE_APP_NAME}:{DB_RELATION}"
103
- # )
104
- # await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000)
105
- # with pytest.raises(psycopg2.OperationalError):
106
- # psycopg2.connect(legacy_interface_connect)
107
- #
108
- #
109
- # async def test_modern_endpoint_with_multiple_related_endpoints(ops_test: OpsTest):
110
- # await ops_test.model.relate(MAILMAN3_CORE_APP_NAME, f"{APP_NAME}:{DB_RELATION}")
111
- # await ops_test.model.relate(APP_NAME, f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION}")
112
- #
113
- # app = ops_test.model.applications[APP_NAME]
114
- # await ops_test.model.block_until(
115
- # lambda: "blocked" in {unit.workload_status for unit in app.units},
116
- # timeout=1500,
117
- # )
118
- #
119
- # logger.info(" remove relation with legacy endpoints")
120
- # await ops_test.model.applications[APP_NAME].remove_relation(
121
- # f"{MAILMAN3_CORE_APP_NAME}:{DB_RELATION}", f"{APP_NAME}:{DB_RELATION}"
122
- # )
123
- # async with ops_test.fast_forward():
124
- # await ops_test.model.wait_for_idle(status="active", timeout=3000, raise_on_error=False)
125
- #
126
- # modern_interface_connect = await build_connection_string(
127
- # ops_test, APPLICATION_APP_NAME, FIRST_DATABASE_RELATION
128
- # )
129
- # logger.info(f" check connect to = {modern_interface_connect}")
130
- # for attempt in Retrying(stop=stop_after_delay(60 * 3), wait=wait_fixed(10)):
131
- # with attempt:
132
- # with psycopg2.connect(modern_interface_connect) as connection:
133
- # assert connection.status == psycopg2.extensions.STATUS_READY
134
- #
135
- # logger.info(f" remove relation {APPLICATION_APP_NAME}")
136
- # async with ops_test.fast_forward():
137
- # await ops_test.model.applications[APP_NAME].remove_relation(
138
- # f"{APP_NAME}:{DATABASE_RELATION}", f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION}"
139
- # )
140
- # await ops_test.model.wait_for_idle(apps=[APP_NAME], status="active", timeout=1000)
141
- # for attempt in Retrying(stop=stop_after_delay(60 * 5), wait=wait_fixed(10)):
142
- # with attempt:
143
- # with pytest.raises(psycopg2.OperationalError):
144
- # psycopg2.connect(modern_interface_connect)
71
+ logger .info (" remove relation with modern endpoints" )
72
+ await ops_test .model .applications [APP_NAME ].remove_relation (
73
+ f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } "
74
+ )
75
+ async with ops_test .fast_forward ():
76
+ await ops_test .model .wait_for_idle (
77
+ status = "active" ,
78
+ timeout = 1500 ,
79
+ raise_on_error = False ,
80
+ )
81
+
82
+ 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"
84
+ )
85
+ logger .info (f" check connect to = { legacy_interface_connect } " )
86
+ for attempt in Retrying (stop = stop_after_delay (60 * 3 ), wait = wait_fixed (10 )):
87
+ with attempt :
88
+ with psycopg2 .connect (legacy_interface_connect ) as connection :
89
+ assert connection .status == psycopg2 .extensions .STATUS_READY
90
+
91
+ logger .info (" remove relation mailman3-core" )
92
+ async with ops_test .fast_forward ():
93
+ await ops_test .model .applications [APP_NAME ].remove_relation (
94
+ f"{ APP_NAME } :{ DB_RELATION } " , f"{ MAILMAN3_CORE_APP_NAME } :{ DB_RELATION } "
95
+ )
96
+ await ops_test .model .wait_for_idle (apps = [APP_NAME ], status = "active" , timeout = 1000 )
97
+ with pytest .raises (psycopg2 .OperationalError ):
98
+ psycopg2 .connect (legacy_interface_connect )
99
+
100
+
101
+ async 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
+
105
+ app = ops_test .model .applications [APP_NAME ]
106
+ await ops_test .model .block_until (
107
+ lambda : "blocked" in {unit .workload_status for unit in app .units },
108
+ timeout = 1500 ,
109
+ )
110
+
111
+ logger .info (" remove relation with legacy endpoints" )
112
+ await ops_test .model .applications [APP_NAME ].remove_relation (
113
+ f"{ MAILMAN3_CORE_APP_NAME } :{ DB_RELATION } " , f"{ APP_NAME } :{ DB_RELATION } "
114
+ )
115
+ async with ops_test .fast_forward ():
116
+ await ops_test .model .wait_for_idle (status = "active" , timeout = 3000 , raise_on_error = False )
117
+
118
+ modern_interface_connect = await build_connection_string (
119
+ ops_test , APPLICATION_APP_NAME , FIRST_DATABASE_RELATION
120
+ )
121
+ logger .info (f" check connect to = { modern_interface_connect } " )
122
+ for attempt in Retrying (stop = stop_after_delay (60 * 3 ), wait = wait_fixed (10 )):
123
+ with attempt :
124
+ with psycopg2 .connect (modern_interface_connect ) as connection :
125
+ assert connection .status == psycopg2 .extensions .STATUS_READY
126
+
127
+ logger .info (f" remove relation { APPLICATION_APP_NAME } " )
128
+ async with ops_test .fast_forward ():
129
+ await ops_test .model .applications [APP_NAME ].remove_relation (
130
+ f"{ APP_NAME } :{ DATABASE_RELATION } " , f"{ APPLICATION_APP_NAME } :{ FIRST_DATABASE_RELATION } "
131
+ )
132
+ await ops_test .model .wait_for_idle (apps = [APP_NAME ], status = "active" , timeout = 1000 )
133
+ for attempt in Retrying (stop = stop_after_delay (60 * 5 ), wait = wait_fixed (10 )):
134
+ with attempt :
135
+ with pytest .raises (psycopg2 .OperationalError ):
136
+ psycopg2 .connect (modern_interface_connect )
0 commit comments