Skip to content

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Oct 7, 2025

  • Port async & upgrade tests from Mysql
  • Fix endpoint update in replicated cluster
  • Fix standby leader switch in pre-refresh-check

Checklist

  • I have cleaned any remaining cloud resources from my accounts.
  • I have added or updated any relevant documentation.

@dragomirp dragomirp added the not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes label Oct 7, 2025
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.83%. Comparing base (d86803f) to head (cbe61f1).

Files with missing lines Patch % Lines
src/charm.py 46.15% 6 Missing and 1 partial ⚠️
src/cluster.py 37.50% 4 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (66.83%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           16/edge    #1206      +/-   ##
===========================================
- Coverage    66.94%   66.83%   -0.11%     
===========================================
  Files           17       17              
  Lines         4347     4360      +13     
  Branches       671      675       +4     
===========================================
+ Hits          2910     2914       +4     
- Misses        1242     1249       +7     
- Partials       195      197       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 98cb060 to 85ae99f Compare October 7, 2025 11:14
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 85ae99f to 76fe647 Compare October 7, 2025 11:26
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch 2 times, most recently from eff6861 to 744dd63 Compare October 7, 2025 14:28
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 744dd63 to 1eb046e Compare October 7, 2025 15:10
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 9fa9066 to c35a605 Compare October 8, 2025 13:01
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 8eaec8a to 731f8b9 Compare October 8, 2025 15:43
import subprocess
from collections.abc import Callable

import jubilant
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using regular jubilant, since PG 16 doesn't need juju 2 support.

Comment on lines +120 to +124
logging.info("checking the number of switchovers")
final_number_of_switchovers = count_switchovers(juju, DB_APP_NAME)
assert (final_number_of_switchovers - initial_number_of_switchovers) <= 2, (
"Number of switchovers is greater than 2"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mysql checks that the DB primary is moved to the Juju leader. We checked for number of switchovers.

@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 908f94e to 0d7bc5f Compare October 15, 2025 02:39
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 93ad21d to be9df49 Compare October 15, 2025 14:48
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from 105a1f5 to c9f5501 Compare October 15, 2025 22:20
@dragomirp dragomirp force-pushed the dpe-8426-port-tests branch from fda46d2 to 239f7f3 Compare October 16, 2025 00:38
Comment on lines +2366 to +2368
base_patch = {}
if primary_endpoint := self.async_replication.get_primary_cluster_endpoint():
base_patch["standby_cluster"] = {"host": primary_endpoint}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standby cluster is DCS value, so not updated by just changing the config. Should I also add this to the async relation changed hook?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strict opinion here. Up to Marcelo.

with attempt:
current_primary = self.get_primary()
current_primary = (
self.get_primary() if not async_cluster else self.get_standby_leader()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the async cluster we have a standby leader.

Comment on lines +167 to +170
for attempt in Retrying(stop=stop_after_attempt(2), wait=wait_fixed(1), reraise=True):
with attempt:
if not self._charm._patroni.are_all_members_ready():
raise charm_refresh.PrecheckFailed("PostgreSQL is not running on 1+ units")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When moving the standby leader, the status becomes stopped for a bit, so the action will fail if the standby leader is not already the lowest unit.

Comment on lines +868 to +870
if current_primary == candidate:
logger.info("Candidate and leader are the same")
return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got conflicts in the standby cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frankenstein between the existing Postgresql test and the one in Mysql.

@pytest.fixture(scope="module")
def first_model(juju: Juju, request: pytest.FixtureRequest) -> Generator:
"""Creates and return the first model."""
yield juju.model
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails to cleanup when running locally on a Jubilant temp model.



@pytest.fixture()
def first_model_continuous_writes(first_model: str) -> Generator:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how pytest resolves fixtures, so used a different name than the one in conftest.

Comment on lines +121 to +128
model_2.deploy(
charm=DB_TEST_APP_NAME,
app=DB_TEST_APP_2,
base="ubuntu@22.04",
channel="latest/edge",
num_units=1,
constraints=constraints,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PGB can't switch over between cluster, so using two test apps like in the previous test.

Comment on lines +282 to +283
for attempt in Retrying(stop=stop_after_attempt(10), wait=wait_fixed(3), reraise=True):
with attempt:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are waiting for the config to be patched and events to fire, for the replication to resume.



def get_db_max_written_values(
first_model: str, second_model: str, test_model: str, test_app: str
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to know which of the models the test app is running in, to stop it.

)
model_2 = Juju(model=second_model)
model_2.deploy(
charm=charm,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-refresh check will be ran on the old code, so it will fail on edge (leader vs. standby leader).

@dragomirp dragomirp marked this pull request as ready for review October 16, 2025 02:00
@dragomirp dragomirp requested review from a team, marceloneppel and taurus-forever and removed request for a team October 16, 2025 02:00
Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. This is massive!

Comment on lines +2366 to +2368
base_patch = {}
if primary_endpoint := self.async_replication.get_primary_cluster_endpoint():
base_patch["standby_cluster"] = {"host": primary_endpoint}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a strict opinion here. Up to Marcelo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Libraries: Out of sync not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants