Skip to content
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

Add version for show hosts #3702

Merged
merged 6 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/graph/executor/admin/ShowHostsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
"Status",
"Leader count",
"Leader distribution",
"Partition distribution"});
"Partition distribution",
"Version"});

std::map<std::string, int64_t> leaderPartsCount;
std::map<std::string, int64_t> allPartsCount;
Expand Down Expand Up @@ -82,6 +83,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
r.emplace_back(leaderCount);
r.emplace_back(leaders.str());
r.emplace_back(parts.str());
r.emplace_back(host.version_ref().has_value() ? Value(*host.version_ref()) : Value());
v.emplace_back(std::move(r));
} // row loop
{
Expand Down Expand Up @@ -148,7 +150,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
LOG(ERROR) << resp.status();
return resp.status();
}
auto value = std::move(resp).value();
auto value = std::forward<decltype(resp)>(resp).value();
if (type == meta::cpp2::ListHostType::ALLOC) {
return finish(makeTraditionalResult(value));
}
Expand Down
6 changes: 4 additions & 2 deletions tests/admin/test_show_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def test_show_hosts(self):
'Status',
'Leader count',
'Leader distribution',
'Partition distribution']
'Partition distribution',
'Version']
expected_result_format = [[re.compile(r'\S+'),
re.compile(r'\d+'),
re.compile(r'ONLINE|OFFLINE'),
re.compile(r'\d+'),
re.compile(r'No valid partition|(\S+:\d+, )*\S+:\d+'),
re.compile(r'No valid partition|(\S+:\d+, )*\S+:\d+')]]
re.compile(r'No valid partition|(\S+:\d+, )*\S+:\d+'),
re.compile(r'(^$)|(v\d+\.\d+\.\d+)')]]
resp = self.execute(query)
self.check_resp_succeeded(resp)
self.check_column_names(resp, expected_column_names)
Expand Down
4 changes: 2 additions & 2 deletions tests/tck/features/admin/Hosts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Feature: Admin hosts
SHOW HOSTS;
"""
Then the result should contain:
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
| /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ |
| Host | Port | Status | Leader count | Leader distribution | Partition distribution | Version |
| /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ |
When executing query:
"""
SHOW HOSTS GRAPH;
Expand Down
4 changes: 2 additions & 2 deletions tests/tck/features/parser/Example.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Feature: Feature examples
SHOW HOSTS
"""
Then the result should contain:
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
| /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ |
| Host | Port | Status | Leader count | Leader distribution | Partition distribution | Version |
| /\w+/ | /\d+/ | "ONLINE" | /\d+/ | /.*/ | /.*/ | /.*/ |
When executing query:
"""
SHOW HOSTS
Expand Down