-
Notifications
You must be signed in to change notification settings - Fork 20
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
[DPE-5827] Set all nodes to synchronous replicas #784
Open
dragomirp
wants to merge
24
commits into
main
Choose a base branch
from
dpe-5827-all-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f50bb2c
Update patroni configuration
dragomirp 235e19d
Update test assertion
dragomirp 30a7f56
Copy update_synchronous_node_count from VM
dragomirp c6339ce
Add unit test
dragomirp 9bb565e
Set sync node count during upgrade
dragomirp 6e60993
Fix tls test
dragomirp 025bfb2
Switchover primary
dragomirp 0aa9850
Merge branch 'main' into dpe-5827-all-sync
dragomirp f88c956
Add different helper to get leader
dragomirp 39817f6
Add config boilerplate
dragomirp 2d5ab35
Merge branch 'main' into dpe-5827-all-sync
dragomirp 5752281
Merge branch 'dpe-5827-all-sync' into dpe-5827-all-sync-config
dragomirp 43412d1
Use config value when setting sync node count
dragomirp 0b1c289
Escape tuple
dragomirp 707a014
Add policy values
dragomirp 562dad5
Add integration test
dragomirp 048e720
Fix casting
dragomirp 1f65187
Fix test
dragomirp 88541f1
Update to spec
dragomirp 95c80de
Bump retry timout
dragomirp a74eae1
Switch to planned units
dragomirp b3e9684
Merge branch 'main' into dpe-5827-all-sync
dragomirp a5f8f2a
Merge branch 'main' into dpe-5827-all-sync
dragomirp 0a5916b
Fix generator
dragomirp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
import pytest | ||
from pytest_operator.plugin import OpsTest | ||
from tenacity import Retrying, stop_after_attempt, wait_fixed | ||
|
||
from ..helpers import app_name, build_and_deploy | ||
from .helpers import get_cluster_roles | ||
|
||
|
||
@pytest.mark.group(1) | ||
@pytest.mark.abort_on_fail | ||
async def test_build_and_deploy(ops_test: OpsTest) -> None: | ||
"""Build and deploy three unit of PostgreSQL.""" | ||
wait_for_apps = False | ||
# It is possible for users to provide their own cluster for HA testing. Hence, check if there | ||
# is a pre-existing cluster. | ||
if not await app_name(ops_test): | ||
wait_for_apps = True | ||
await build_and_deploy(ops_test, 3, wait_for_idle=False) | ||
|
||
if wait_for_apps: | ||
async with ops_test.fast_forward(): | ||
await ops_test.model.wait_for_idle(status="active", timeout=1000, raise_on_error=False) | ||
|
||
|
||
@pytest.mark.group(1) | ||
async def test_default_all(ops_test: OpsTest) -> None: | ||
app = await app_name(ops_test) | ||
|
||
async with ops_test.fast_forward(): | ||
await ops_test.model.wait_for_idle(apps=[app], status="active", timeout=300) | ||
|
||
for attempt in Retrying(stop=stop_after_attempt(3), wait=wait_fixed(5), reraise=True): | ||
with attempt: | ||
roles = await get_cluster_roles( | ||
ops_test, ops_test.model.applications[app].units[0].name | ||
) | ||
|
||
assert len(roles["primaries"]) == 1 | ||
assert len(roles["sync_standbys"]) == 2 | ||
assert len(roles["replicas"]) == 0 | ||
|
||
|
||
@pytest.mark.group(1) | ||
async def test_majority(ops_test: OpsTest) -> None: | ||
app = await app_name(ops_test) | ||
|
||
await ops_test.model.applications[app].set_config({"synchronous_node_count": "majority"}) | ||
|
||
async with ops_test.fast_forward(): | ||
await ops_test.model.wait_for_idle(apps=[app], status="active") | ||
|
||
for attempt in Retrying(stop=stop_after_attempt(3), wait=wait_fixed(5), reraise=True): | ||
with attempt: | ||
roles = await get_cluster_roles( | ||
ops_test, ops_test.model.applications[app].units[0].name | ||
) | ||
|
||
assert len(roles["primaries"]) == 1 | ||
assert len(roles["sync_standbys"]) == 1 | ||
assert len(roles["replicas"]) == 1 | ||
|
||
|
||
@pytest.mark.group(1) | ||
async def test_constant(ops_test: OpsTest) -> None: | ||
"""Kill primary unit, check reelection.""" | ||
app = await app_name(ops_test) | ||
|
||
await ops_test.model.applications[app].set_config({"synchronous_node_count": "2"}) | ||
|
||
async with ops_test.fast_forward(): | ||
await ops_test.model.wait_for_idle(apps=[app], status="active", timeout=300) | ||
|
||
for attempt in Retrying(stop=stop_after_attempt(3), wait=wait_fixed(5), reraise=True): | ||
with attempt: | ||
roles = await get_cluster_roles( | ||
ops_test, ops_test.model.applications[app].units[0].name | ||
) | ||
|
||
assert len(roles["primaries"]) == 1 | ||
assert len(roles["sync_standbys"]) == 2 | ||
assert len(roles["replicas"]) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sync standby will not change, since all the replicas are sync standbys.