8
8
from pytest_operator .plugin import OpsTest
9
9
from tenacity import Retrying , stop_after_attempt , stop_after_delay , wait_exponential
10
10
11
- from . import markers
12
11
from .helpers import (
13
12
CHARM_SERIES ,
14
13
DATABASE_APP_NAME ,
24
23
restart_machine ,
25
24
run_command_on_unit ,
26
25
)
26
+ from .juju_ import juju_major_version
27
27
28
28
logger = logging .getLogger (__name__ )
29
29
30
30
APP_NAME = METADATA ["name" ]
31
- SELF_SIGNED_CERTIFICATES_APP_NAME = "self-signed-certificates"
32
- TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
31
+ if juju_major_version < 3 :
32
+ TLS_CERTIFICATES_APP_NAME = "tls-certificates-operator"
33
+ TLS_CHANNEL = "legacy/stable"
34
+ TLS_CONFIG = {"generate-self-signed-certificates" : "true" , "ca-common-name" : "Test CA" }
35
+ else :
36
+ TLS_CERTIFICATES_APP_NAME = "self-signed-certificates"
37
+ TLS_CHANNEL = "latest/stable"
38
+ TLS_CONFIG = {"ca-common-name" : "Test CA" }
33
39
34
40
35
41
@pytest .mark .runner (["self-hosted" , "linux" , "X64" , "jammy" , "large" ])
@@ -56,9 +62,8 @@ async def test_tls_enabled(ops_test: OpsTest) -> None:
56
62
"""Test that TLS is enabled when relating to the TLS Certificates Operator."""
57
63
async with ops_test .fast_forward ():
58
64
# Deploy TLS Certificates operator.
59
- config = {"generate-self-signed-certificates" : "true" , "ca-common-name" : "Test CA" }
60
65
await ops_test .model .deploy (
61
- TLS_CERTIFICATES_APP_NAME , config = config , channel = "legacy/stable"
66
+ TLS_CERTIFICATES_APP_NAME , config = TLS_CONFIG , channel = TLS_CHANNEL
62
67
)
63
68
64
69
# Relate it to the PostgreSQL to enable TLS.
@@ -206,20 +211,3 @@ async def test_restart_machine(ops_test: OpsTest) -> None:
206
211
assert await check_tls (ops_test , "postgresql/0" , enabled = True )
207
212
logger .info (f"checking TLS on Patroni API from { unit_name } " )
208
213
assert await check_tls_patroni_api (ops_test , "postgresql/0" , enabled = True )
209
-
210
-
211
- @markers .juju3
212
- @pytest .mark .group (1 )
213
- async def test_relation_with_self_signed_certificates_operator (ops_test : OpsTest ) -> None :
214
- """Test the relation with the Self Signed Certificates operator."""
215
- async with ops_test .fast_forward (fast_interval = "60s" ):
216
- # Deploy Self Signed Certificates operator.
217
- await ops_test .model .deploy (SELF_SIGNED_CERTIFICATES_APP_NAME )
218
- # Relate it to the PostgreSQL to enable TLS.
219
- await ops_test .model .relate (DATABASE_APP_NAME , SELF_SIGNED_CERTIFICATES_APP_NAME )
220
- await ops_test .model .wait_for_idle (status = "active" , timeout = 1500 )
221
-
222
- # Wait for all units enabling TLS.
223
- for unit in ops_test .model .applications [DATABASE_APP_NAME ].units :
224
- assert await check_tls (ops_test , unit .name , enabled = True )
225
- assert await check_tls_patroni_api (ops_test , unit .name , enabled = True )
0 commit comments