forked from patroni/patroni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement kubernetes.bootstrap_labels
Allow to define labels that will be assigned to a postgres pod when in 'initializing new cluster', 'running custom bootstrap script' or 'creating replica' state
- Loading branch information
Showing
10 changed files
with
112 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Feature: bootstrap labels | ||
Check that user-configurable bootstrap labels are set and removed with state change | ||
|
||
Scenario: check label for cluster bootstrap protection | ||
When I start postgres-0 | ||
Then postgres-0 is a leader after 10 seconds | ||
When I start postgres-1 in a cluster batman1 as a long-running clone of postgres-0 | ||
Then "members/postgres-1" key in DCS has state=running custom bootstrap script after 20 seconds | ||
And postgres-1 is labeled with "foo" | ||
And postgres-1 is a leader of batman1 after 20 seconds | ||
|
||
Scenario: check label for replica bootstrap protection | ||
When I do a backup of postgres-1 | ||
And I start postgres-2 in cluster batman1 using long-running backup_restore | ||
Then "members/postgres-2" key in DCS has state=creating replica after 20 seconds | ||
And postgres-2 is labeled with "foo" | ||
|
||
Scenario: check label is removed | ||
Given "members/postgres-1" key in DCS has state=running after 2 seconds | ||
And "members/postgres-2" key in DCS has state=running after 20 seconds | ||
Then postgres-1 is not labeled with "foo" | ||
And postgres-2 is not labeled with "foo" |
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,29 @@ | ||
import time | ||
|
||
from behave import step, then | ||
|
||
@step('I start {name:name} in a cluster {cluster_name:w} as a long-running clone of {name2:name}') | ||
def start_cluster_clone(context, name, cluster_name, name2): | ||
context.pctl.clone(name2, cluster_name, name, True) | ||
|
||
@step('I start {name:name} in cluster {cluster_name:w} using long-running backup_restore') | ||
def start_patroni(context, name, cluster_name): | ||
return context.pctl.start(name, custom_config={ | ||
"scope": cluster_name, | ||
"postgresql": { | ||
'create_replica_methods': ['backup_restore'], | ||
"backup_restore": context.pctl.backup_restore_config(long_running=True), | ||
'authentication': { | ||
'superuser': {'password': 'patroni1'}, | ||
'replication': {'password': 'rep-pass1'} | ||
} | ||
} | ||
}, max_wait_limit=-1) | ||
|
||
@then('{name:name} is labeled with "{label:w}"') | ||
def pod_labeled(context, name, label): | ||
assert label in context.dcs_ctl.pod_labels(name), f'pod {name} is not labeled with {label}' | ||
|
||
@then('{name:name} is not labeled with "{label:w}"') | ||
def pod_not_labeled(context, name, label): | ||
assert label not in context.dcs_ctl.pod_labels(name), f'pod {name} is still labeled with {label}' |
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