-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 (#3378)
* feat - remove version from heartbeat * style - remove unused header * add test cases * add test case * remove version_ from HostInfo * style Co-authored-by: Sophie <[email protected]>
- Loading branch information
1 parent
dd06a53
commit 5194726
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(); | ||
} |