From b35f3740ee362cfa823f43d40a4a25a09ceea5fe Mon Sep 17 00:00:00 2001 From: jievince <38901892+jievince@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:42:35 +0800 Subject: [PATCH] fix ci --- .github/workflows/pull_request.yml | 5 +-- src/mclient/MetaClient.cpp | 41 ++++++++++++++++++++----- src/mclient/tests/MetaClientTest.cpp | 19 ++++++++++-- src/sclient/ScanEdgeIter.cpp | 1 + src/sclient/tests/StorageClientTest.cpp | 7 +++-- 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 8b9578a5..2d316a21 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -101,7 +101,7 @@ jobs: centos7) set +e for i in {0..10}; do - wget https://oss-cdn.nebula-graph.com.cn/package/v2-nightly/$(./date.py --day_diff=$i)/nebula-graph-$(./date.py --day_diff=$i)-nightly.el7.x86_64.rpm + wget https://oss-cdn.nebula-graph.com.cn/package/nightly/$(./date.py --day_diff=$i)/nebula-graph-$(./date.py --day_diff=$i)-nightly.el7.x86_64.rpm rpm -ivh nebula-graph-$(./date.py --day_diff=$i)-nightly.el7.x86_64.rpm if [ $? -eq 0 ]; then break; @@ -112,7 +112,7 @@ jobs: ubuntu1804) set +e for i in {0..10}; do - wget https://oss-cdn.nebula-graph.com.cn/package/v2-nightly/$(./date.py --day_diff=$i)/nebula-graph-$(./date.py --day_diff=$i)-nightly.ubuntu1804.amd64.deb + wget https://oss-cdn.nebula-graph.com.cn/package/nightly/$(./date.py --day_diff=$i)/nebula-graph-$(./date.py --day_diff=$i)-nightly.ubuntu1804.amd64.deb dpkg -i nebula-graph-$(./date.py --day_diff=$i)-nightly.ubuntu1804.amd64.deb if [ $? -eq 0 ]; then break; @@ -132,6 +132,7 @@ jobs: echo '127.0.0.1 graphd' >> /etc/hosts echo '127.0.0.1 graphd1' >> /etc/hosts echo '127.0.0.1 graphd2' >> /etc/hosts + echo '127.0.0.1 server' >> /etc/hosts - name: CTest env: ASAN_OPTIONS: fast_unwind_on_malloc=1 diff --git a/src/mclient/MetaClient.cpp b/src/mclient/MetaClient.cpp index 9f6932c4..06f1f1a0 100644 --- a/src/mclient/MetaClient.cpp +++ b/src/mclient/MetaClient.cpp @@ -27,7 +27,16 @@ MetaClient::MetaClient(const std::vector& metaAddrs) { ioExecutor_ = std::make_shared(std::thread::hardware_concurrency()); clientsMan_ = std::make_shared>(false); - loadData(); // load data into cache + bool b = loadData(); // load data into cache + if (!b) { + LOG(INFO) << "load data failed"; + } else { + LOG(INFO) << "load data succecced"; + LOG(INFO) << spaceIndexByName_.size(); + LOG(INFO) << spaceEdgeIndexByName_.size(); + LOG(INFO) << spacePartLeaderMap_.size(); + LOG(INFO) << spacePartsMap_.size(); + } } MetaClient::~MetaClient() = default; @@ -52,22 +61,29 @@ std::pair MetaClient::getEdgeTypeByNameFromCache(GraphSpaceID sp } std::pair> MetaClient::getPartsFromCache(GraphSpaceID spaceId) { + LOG(INFO) << "getPartsFromCache(" << spaceId << ")"; + for (auto kv : spacePartsMap_) { + LOG(INFO) << kv.first << ", "; + for (auto partId : kv.second) { + LOG(INFO) << partId; + } + } auto iter = spacePartsMap_.find(spaceId); - if (iter != spacePartsMap_.end()) { - return {true, iter->second}; + if (iter == spacePartsMap_.end()) { + return {false, {}}; } - return {false, {}}; + return {true, iter->second}; } std::pair MetaClient::getPartLeaderFromCache(GraphSpaceID spaceId, PartitionID partId) { auto iter = spacePartLeaderMap_.find({spaceId, partId}); - if (iter != spacePartLeaderMap_.end()) { - return {true, iter->second}; + if (iter == spacePartLeaderMap_.end()) { + return {false, HostAddr()}; } - return {false, HostAddr()}; + return {true, iter->second}; } bool MetaClient::loadData() { @@ -96,6 +112,7 @@ bool MetaClient::loadData() { } auto& hostItems = hostsRet.second; + LOG(INFO) << "hostItems.size()=" << hostItems.size(); loadLeader(hostItems, spaceIndexByName_); return true; } @@ -148,20 +165,30 @@ std::pair> MetaClient::listEdgeSchemas( void MetaClient::loadLeader(const std::vector& hostItems, const SpaceNameIdMap& spaceIndexByName) { + LOG(INFO) << "loadLeader start"; for (auto& item : hostItems) { + LOG(INFO) << "item.get_leader_parts().size()=" << item.get_leader_parts().size(); + LOG(INFO) << "item.get_all_parts().size()=" << item.get_all_parts().size(); for (auto& spaceEntry : item.get_leader_parts()) { auto spaceName = spaceEntry.first; + LOG(INFO) << "[" << spaceName << "]"; auto iter = spaceIndexByName.find(spaceName); if (iter == spaceIndexByName.end()) { + LOG(INFO) << "dont' find " << spaceName; continue; } auto spaceId = iter->second; + LOG(INFO) << "spaceId:" << spaceId; + LOG(INFO) << "spaceEntry.second.size()" << spaceEntry.second.size(); for (const auto& partId : spaceEntry.second) { + LOG(INFO) << "spaceId: " << spaceId << ", partId: " << partId + << ", host: " << item.get_hostAddr(); spacePartLeaderMap_[{spaceId, partId}] = item.get_hostAddr(); spacePartsMap_[spaceId].emplace_back(partId); } } } + LOG(INFO) << "loadLeader end"; } std::vector MetaClient::toSpaceIdName( diff --git a/src/mclient/tests/MetaClientTest.cpp b/src/mclient/tests/MetaClientTest.cpp index ab1967c4..74458856 100644 --- a/src/mclient/tests/MetaClientTest.cpp +++ b/src/mclient/tests/MetaClientTest.cpp @@ -19,7 +19,7 @@ // Require a nebula server could access -#define kServerHost "127.0.0.1" +#define kServerHost "server" class MetaClientTest : public ClientTest { protected: @@ -36,6 +36,16 @@ class MetaClientTest : public ClientTest { auto result2 = session.execute("CREATE EDGE IF NOT EXISTS like(likeness int)"); ASSERT_EQ(result2.errorCode, nebula::ErrorCode::SUCCEEDED); + + ::sleep(10); + + auto result3 = session.execute( + "INSERT EDGE like(likeness) VALUES '101'->'102':(78), '102'->'103':(99), " + "'103'->'201':(43), '201'->'202':(56), '202'->'203':(-13), '203'->'301':(431), " + "'301'->'302':(457)"); + ASSERT_EQ(result3.errorCode, nebula::ErrorCode::SUCCEEDED); + + ::sleep(10); } static void runOnce(nebula::MetaClient &c) { @@ -58,13 +68,16 @@ class MetaClientTest : public ClientTest { auto ret4 = c.getPartLeaderFromCache(spaceId, 1); ASSERT_TRUE(ret4.first); - EXPECT_EQ(ret4.second, nebula::HostAddr("127.0.0.1", 9779)); + EXPECT_EQ(ret4.second, nebula::HostAddr(kServerHost, 9779)); } }; TEST_F(MetaClientTest, Basic) { - nebula::MetaClient c({kServerHost ":9559"}); + LOG(INFO) << "Prepare data."; prepare(); + + LOG(INFO) << "Run once."; + nebula::MetaClient c({kServerHost ":9559"}); runOnce(c); } diff --git a/src/sclient/ScanEdgeIter.cpp b/src/sclient/ScanEdgeIter.cpp index 7364e246..4e015300 100644 --- a/src/sclient/ScanEdgeIter.cpp +++ b/src/sclient/ScanEdgeIter.cpp @@ -29,6 +29,7 @@ DataSet ScanEdgeIter::next() { auto partCursorMapReq = req_->get_parts(); DCHECK_EQ(partCursorMapReq.size(), 1); partCursorMapReq.begin()->second.set_next_cursor(nextCursor_); + LOG(INFO) << "nextCursor of req: " << partCursorMapReq.begin()->second.get_next_cursor(); req_->set_parts(partCursorMapReq); } auto r = client_->doScanEdge(*req_); diff --git a/src/sclient/tests/StorageClientTest.cpp b/src/sclient/tests/StorageClientTest.cpp index d38183fa..5e3d008c 100644 --- a/src/sclient/tests/StorageClientTest.cpp +++ b/src/sclient/tests/StorageClientTest.cpp @@ -19,7 +19,7 @@ // Require a nebula server could access -#define kServerHost "127.0.0.1" +#define kServerHost "server" class StorageClientTest : public ClientTest { protected: @@ -37,7 +37,7 @@ class StorageClientTest : public ClientTest { auto result2 = session.execute("CREATE EDGE IF NOT EXISTS like(likeness int)"); ASSERT_EQ(result2.errorCode, nebula::ErrorCode::SUCCEEDED); - ::sleep(30); + ::sleep(10); auto result3 = session.execute( "INSERT EDGE like(likeness) VALUES '101'->'102':(78), '102'->'103':(99), " @@ -107,8 +107,9 @@ class StorageClientTest : public ClientTest { }; TEST_F(StorageClientTest, Basic) { - nebula::StorageClient c({kServerHost ":9559"}); + LOG(INFO) << "Prepare data."; prepare(); + nebula::StorageClient c({kServerHost ":9559"}); LOG(INFO) << "Testing run get parts."; runGetParts(c); LOG(INFO) << "Testing run scan edge with part.";