forked from vesoft-inc/nebula
-
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.
Move version info outside of HB (vesoft-inc#344)
#### What type of PR is this? - [ ] bug - [ ] feature - [x] enhancement #### What does this PR do? 1. Move the version info outside the heartbeat 2. Save the version info when establishing the connection to metad server. #### Which issue(s)/PR(s) this PR relates to? vesoft-inc#3055 #### Special notes for your reviewer, ex. impact of this fix, etc: #### Additional context: #### Checklist: - [ ] Documentation affected (Please add the label if documentation needs to be modified.) - [x] Incompatible (If it is incompatible, please describe it and add corresponding label.) - [ ] Need to cherry-pick (If need to cherry-pick to some branches, please label the destination version(s).) - [ ] Performance impacted: Consumes more CPU/Memory #### Release notes: Please confirm whether to reflect in release notes and how to describe: > ` Migrated from vesoft-inc#3378 Co-authored-by: endy.li <[email protected]>
- Loading branch information
1 parent
e376201
commit b7747b5
Showing
10 changed files
with
134 additions
and
31 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
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,75 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "common/base/Base.h" | ||
#include "common/fs/TempDir.h" | ||
#include "meta/processors/admin/HBProcessor.h" | ||
#include "meta/processors/admin/VerifyClientVersionProcessor.h" | ||
#include "meta/processors/parts/ListHostsProcessor.h" | ||
#include "meta/test/TestUtils.h" | ||
|
||
namespace nebula { | ||
namespace meta { | ||
|
||
TEST(VerifyClientVersionTest, VersionTest) { | ||
fs::TempDir rootPath("/tmp/VersionTest.XXXXXX"); | ||
std::unique_ptr<kvstore::KVStore> kv(MockCluster::initMetaKV(rootPath.path())); | ||
{ | ||
auto req = cpp2::VerifyClientVersionReq(); | ||
req.set_version("1.0.1"); | ||
auto* processor = VerifyClientVersionProcessor::instance(kv.get()); | ||
auto f = processor->getFuture(); | ||
processor->process(req); | ||
auto resp = std::move(f).get(); | ||
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CLIENT_SERVER_INCOMPATIBLE, resp.get_code()); | ||
} | ||
{ | ||
for (auto i = 0; i < 5; i++) { | ||
auto req = cpp2::VerifyClientVersionReq(); | ||
req.set_host(HostAddr(std::to_string(i), i)); | ||
auto* processor = VerifyClientVersionProcessor::instance(kv.get()); | ||
auto f = processor->getFuture(); | ||
processor->process(req); | ||
auto resp = std::move(f).get(); | ||
ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); | ||
} | ||
} | ||
{ | ||
const ClusterID kClusterId = 10; | ||
for (auto i = 0; i < 5; i++) { | ||
auto req = cpp2::HBReq(); | ||
req.set_role(cpp2::HostRole::GRAPH); | ||
req.set_host(HostAddr(std::to_string(i), i)); | ||
req.set_cluster_id(kClusterId); | ||
auto* processor = HBProcessor::instance(kv.get(), nullptr, kClusterId); | ||
auto f = processor->getFuture(); | ||
processor->process(req); | ||
auto resp = std::move(f).get(); | ||
ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); | ||
} | ||
} | ||
{ | ||
auto req = cpp2::ListHostsReq(); | ||
req.set_type(cpp2::ListHostType::GRAPH); | ||
auto* processor = ListHostsProcessor::instance(kv.get()); | ||
auto f = processor->getFuture(); | ||
processor->process(req); | ||
auto resp = std::move(f).get(); | ||
ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, resp.get_code()); | ||
ASSERT_EQ(resp.get_hosts().size(), 5); | ||
} | ||
} | ||
|
||
} // namespace meta | ||
} // namespace nebula | ||
|
||
int main(int argc, char** argv) { | ||
testing::InitGoogleTest(&argc, argv); | ||
folly::init(&argc, &argv, true); | ||
google::SetStderrLogging(google::INFO); | ||
return RUN_ALL_TESTS(); | ||
} |