Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor typo in access of ServiceSpec object #520

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def check_service_connectivity(self) -> bool:
return False

endpoints_to_connect = [self.read_write_endpoints]
if self.read_only_endpoints or service.spec.name != ServiceType("false").name:
if self.read_only_endpoints or service.spec.type != ServiceType("false").name:
endpoints_to_connect.append(self.read_only_endpoints)

for endpoints in endpoints_to_connect:
Expand Down
20 changes: 15 additions & 5 deletions tests/integration/test_expose_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def confirm_cluster_ip_endpoints(ops_test: OpsTest) -> None:
), "URIs is unexpected"


async def confirm_endpoint_connectivity(ops_test: OpsTest) -> None:
async def confirm_endpoint_connectivity(ops_test: OpsTest) -> str:
"""Helper to confirm endpoint connectivity."""
for attempt in tenacity.Retrying(
reraise=True,
Expand All @@ -85,6 +85,8 @@ async def confirm_endpoint_connectivity(ops_test: OpsTest) -> None:
cursor.execute("SELECT 1;")
assert cursor.fetchone()[0] == 1, "Unable to execute query"

return endpoints


@pytest.mark.group(1)
@pytest.mark.abort_on_fail
Expand Down Expand Up @@ -151,7 +153,7 @@ async def test_expose_external(ops_test) -> None:
timeout=SLOW_TIMEOUT,
)

await confirm_endpoint_connectivity(ops_test)
nodeport_endpoints = await confirm_endpoint_connectivity(ops_test)

logger.info("Testing endpoint when expose-external=loadbalancer")
await pgbouncer_application.set_config({"expose-external": "loadbalancer"})
Expand All @@ -161,7 +163,11 @@ async def test_expose_external(ops_test) -> None:
timeout=SLOW_TIMEOUT,
)

await confirm_endpoint_connectivity(ops_test)
load_balancer_endpoints = await confirm_endpoint_connectivity(ops_test)

assert nodeport_endpoints != load_balancer_endpoints, (
"Endpoints did not change for expose-external=loadbalancer"
)


@pytest.mark.group(1)
Expand Down Expand Up @@ -208,7 +214,7 @@ async def test_expose_external_with_tls(ops_test: OpsTest) -> None:
timeout=SLOW_TIMEOUT,
)

await confirm_endpoint_connectivity(ops_test)
nodeport_endpoints = await confirm_endpoint_connectivity(ops_test)

logger.info("Testing endpoint when expose-external=loadbalancer")
await pgbouncer_application.set_config({"expose-external": "loadbalancer"})
Expand All @@ -218,4 +224,8 @@ async def test_expose_external_with_tls(ops_test: OpsTest) -> None:
timeout=SLOW_TIMEOUT,
)

await confirm_endpoint_connectivity(ops_test)
load_balancer_endpoints = await confirm_endpoint_connectivity(ops_test)

assert nodeport_endpoints != load_balancer_endpoints, (
"Endpoints did not change for expose-external=loadbalancer"
)
Loading