Skip to content

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Sep 21, 2022

Issue

  • Jira issues: DPE-535 and DPE-537
  • The PostgreSQL charm should self heal the workload when the DB process is killed.

Solution

  • Add a test that kills the DB processes (from Patroni and from PostgreSQL) and later check that the workload recovers itself from that situation.

Context

  • We can run the test on an existing cluster passing the model name when running the integration tests (the PostgreSQL application from an existing cluster is retrieved through the app_name helper function).
  • The master_start_timeout fixture runs the continuous writes test charm that was merged on Add continuous writes test charm #36 and now is used to ensure the database is healthy after each shakedown test.
  • The master_start_timeout fixture is used to speed up the fail-over process when the DB process is killed in the former primary.

Testing

  • The test was added on tests/integration/ha_tests/test_self_healing.py. It tests the charm in a very similar way the Charmed MongoDB Operator is tested.
  • Both Patroni and PostgreSQL OS process are killed, one at a time.

Release Notes

  • Add kill db process test.

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2022

Codecov Report

Merging #35 (5aaf4bc) into main (ceeba02) will increase coverage by 0.20%.
The diff coverage is 61.39%.

@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
+ Coverage   60.11%   60.32%   +0.20%     
==========================================
  Files           6        6              
  Lines         692      809     +117     
  Branches      103      119      +16     
==========================================
+ Hits          416      488      +72     
- Misses        256      293      +37     
- Partials       20       28       +8     
Impacted Files Coverage Δ
src/cluster.py 55.94% <55.17%> (+1.46%) ⬆️
src/charm.py 53.25% <60.33%> (+1.08%) ⬆️
src/constants.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@marceloneppel marceloneppel changed the base branch from main to continuous-writes-test-charm September 29, 2022 11:28
Base automatically changed from continuous-writes-test-charm to main September 30, 2022 14:13
- name: Run integration tests
run: tox -e db-admin-relation-integration

integration-test-ha-self-healing-rotation:
Copy link
Contributor

Choose a reason for hiding this comment

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

In the release pipeline you could call the CI with the following code:

# release.yaml
jobs:
  test/ci/whatever you want to call this part:
    uses: ./.github/workflows/ci.yaml
# ci.yaml
on:
  workflow_call:

This way, you only have to write these test runs out once.

Copy link
Member Author

Choose a reason for hiding this comment

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

Amazing suggestion! I updated that on 5aaf4bc.

# Deploy the continuous writes application charm if it wasn't already deployed.
async with ops_test.fast_forward():
if await app_name(ops_test, APPLICATION_NAME) is None:
charm = await ops_test.build_charm("tests/integration/ha_tests/application-charm")
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps these test application-charms could be renamed to be more descriptive? not essential for this PR though.

Copy link
Member Author

@marceloneppel marceloneppel Oct 4, 2022

Choose a reason for hiding this comment

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

Good suggestion! I created a ticket for that on Jira.

@marceloneppel marceloneppel merged commit bd13f3f into main Oct 4, 2022
@marceloneppel marceloneppel deleted the kill-db-process-test branch October 4, 2022 16:47
BON4 pushed a commit to BON4/postgresql-operator that referenced this pull request Apr 23, 2024
* Add kill db process test

* Change timeout

* Ignore PyCharm folder and LXD profile file

* Add continuous writes test charm

* Improve workflow files
github-actions bot added a commit to canonical/test-runners-2-github-x64-postgresql-operator that referenced this pull request May 20, 2024
github-actions bot added a commit to canonical/test-runners-2-is-x64-postgresql-operator that referenced this pull request May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants