Skip to content

Commit

Permalink
Add version for show hosts (#3702)
Browse files Browse the repository at this point in the history
* version

* tck

* pytest

* pytest

Co-authored-by: cpw <[email protected]>
  • Loading branch information
2 people authored and Sophie-Xie committed Jan 22, 2022
1 parent db7a5a3 commit 8352799
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
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

0 comments on commit 8352799

Please sign in to comment.