-
Notifications
You must be signed in to change notification settings - Fork 7
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
Move zookeeper.py in chadmin #70
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Feature: keeper-monitoring tool | ||
|
||
Background: | ||
Given default configuration | ||
And a working s3 | ||
And a working zookeeper | ||
And a working clickhouse on clickhouse01 | ||
|
||
|
||
Scenario: Cleanup all hosts | ||
When we execute chadmin create zk nodes on zookeeper01 | ||
""" | ||
/test/write_sli_part/shard1/replicas/host1.net | ||
/test/write_sli_part/shard1/replicas/host2.net | ||
/test/read_sli_part/shard1/replicas/host1.net | ||
/test/read_sli_part/shard1/replicas/host2.net | ||
/test/write_sli_part/shard1/log | ||
""" | ||
And we do hosts cleanup on zookeeper01 with fqdn host1.net,host2.net and zk root /test | ||
|
||
Then the list of children on zookeeper01 for zk node /test/write_sli_part are empty | ||
And the list of children on zookeeper01 for zk node /test/read_sli_part are empty | ||
|
||
Scenario: Cleanup single host | ||
When we execute chadmin create zk nodes on zookeeper01 | ||
""" | ||
/test/write_sli_part/shard1/replicas/host1.net | ||
/test/write_sli_part/shard1/replicas/host2.net | ||
/test/read_sli_part/shard1/replicas/host1.net | ||
/test/read_sli_part/shard1/replicas/host2.net | ||
/test/write_sli_part/shard1/log | ||
""" | ||
And we do hosts cleanup on zookeeper01 with fqdn host1.net and zk root /test | ||
|
||
|
||
Then the list of children on zookeeper01 for zk node /test/write_sli_part/shard1/replicas/ are equal to | ||
""" | ||
/test/write_sli_part/shard1/replicas/host2.net | ||
""" | ||
And the list of children on zookeeper01 for zk node /test/read_sli_part/shard1/replicas/ are equal to | ||
""" | ||
/test/read_sli_part/shard1/replicas/host2.net | ||
""" |
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,35 @@ | ||
import logging | ||
|
||
|
||
class Chadmin: | ||
def __init__(self, container): | ||
self._container = container | ||
|
||
def exec_cmd(self, cmd): | ||
ch_admin_cmd = f"chadmin {cmd}" | ||
logging.debug("chadmin command:", ch_admin_cmd) | ||
result = self._container.exec_run(["bash", "-c", ch_admin_cmd], user="root") | ||
return result | ||
|
||
def create_zk_node(self, zk_node, no_ch_config=True, recursive=True): | ||
cmd = "zookeeper {use_config} create {make_parents} {node}".format( | ||
use_config="--no-ch-config" if no_ch_config else "", | ||
make_parents="--make-parents" if recursive else "", | ||
node=zk_node, | ||
) | ||
return self.exec_cmd(cmd) | ||
|
||
def zk_list(self, zk_node, no_ch_config=True): | ||
cmd = "zookeeper {use_config} list {node}".format( | ||
use_config="--no-ch-config" if no_ch_config else "", | ||
node=zk_node, | ||
) | ||
return self.exec_cmd(cmd) | ||
|
||
def zk_cleanup(self, fqdn, zk_root, no_ch_config=True): | ||
cmd = "zookeeper {use_config} --chroot {root} cleanup-removed-hosts-metadata {hosts}".format( | ||
use_config="--no-ch-config" if no_ch_config else "", | ||
root=zk_root, | ||
hosts=fqdn, | ||
) | ||
return self.exec_cmd(cmd) |
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,40 @@ | ||
""" | ||
Steps for interacting with chadmin. | ||
""" | ||
|
||
from behave import then, when | ||
from hamcrest import assert_that, equal_to | ||
from modules.chadmin import Chadmin | ||
from modules.docker import get_container | ||
|
||
|
||
@when("we execute chadmin create zk nodes on {node:w}") | ||
def step_create_(context, node): | ||
container = get_container(context, node) | ||
nodes = context.text.strip().split("\n") | ||
chadmin = Chadmin(container) | ||
|
||
for node in nodes: | ||
result = chadmin.create_zk_node(node) | ||
assert result.exit_code == 0, f" output:\n {result.output.decode().strip()}" | ||
|
||
|
||
@when("we do hosts cleanup on {node} with fqdn {fqdn} and zk root {zk_root}") | ||
def step_host_cleanup(context, node, fqdn, zk_root): | ||
container = get_container(context, node) | ||
result = Chadmin(container).zk_cleanup(fqdn, zk_root) | ||
assert result.exit_code == 0, f" output:\n {result.output.decode().strip()}" | ||
|
||
|
||
@then("the list of children on {node:w} for zk node {zk_node} are equal to") | ||
def step_childen_list(context, node, zk_node): | ||
container = get_container(context, node) | ||
result = Chadmin(container).zk_list(zk_node) | ||
assert_that(result.output.decode(), equal_to(context.text + "\n")) | ||
|
||
|
||
@then("the list of children on {node:w} for zk node {zk_node} are empty") | ||
def step_childen_list_empty(context, node, zk_node): | ||
container = get_container(context, node) | ||
result = Chadmin(container).zk_list(zk_node) | ||
assert_that(result.output.decode(), equal_to("\n")) |
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.
Looks like a copy-paste error.