Skip to content

Commit

Permalink
test again
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Nov 26, 2021
1 parent d1ed559 commit 9503f68
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/nebula/sclient/StorageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class StorageClient {
bool onlyLatestVersion = false,
bool enableReadFromFollower = true); // plato needed

MetaClient* getMetaClient() { return mClient_.get(); }

private:
std::pair<bool, storage::cpp2::ScanEdgeResponse> doScanEdge(
const storage::cpp2::ScanEdgeRequest& req);
Expand Down
28 changes: 27 additions & 1 deletion src/sclient/tests/StorageClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,34 @@ class StorageClientTest : public ClientTest {
"'103'->'201':(43), '201'->'202':(56), '202'->'203':(-13), '203'->'301':(431), "
"'301'->'302':(457)");
ASSERT_EQ(result3.errorCode, nebula::ErrorCode::SUCCEEDED)
<< (result2.errorMsg ? *result2.errorMsg : "");
<< (result3.errorMsg ? *result3.errorMsg : "");

::sleep(10);
}

static void runOnce(nebula::MetaClient &c) {
auto ret = c.getSpaceIdByNameFromCache("storage_client_test");
ASSERT_TRUE(ret.first);
nebula::GraphSpaceID spaceId = ret.second;
LOG(INFO) << "spaceId of nba: " << spaceId;
EXPECT_GT(spaceId, 0);

auto ret2 = c.getEdgeTypeByNameFromCache(spaceId, "like");
ASSERT_TRUE(ret2.first);
nebula::EdgeType edgeType = ret2.second;
LOG(INFO) << "edgeType of like: " << edgeType;
EXPECT_GT(edgeType, 0);

auto ret3 = c.getPartsFromCache(spaceId);
ASSERT_TRUE(ret3.first);
auto parts = ret3.second;
EXPECT_EQ(parts, (std::vector<nebula::PartitionID>{1}));

auto ret4 = c.getPartLeaderFromCache(spaceId, 1);
ASSERT_TRUE(ret4.first);
EXPECT_EQ(ret4.second, nebula::HostAddr(kServerHost, 9779));
}

static void runGetParts(nebula::StorageClient &c) {
auto parts = c.getParts("storage_client_test");
EXPECT_EQ(parts, (std::vector<nebula::PartitionID>{1}));
Expand Down Expand Up @@ -113,6 +136,9 @@ TEST_F(StorageClientTest, Basic) {
LOG(INFO) << "Prepare data.";
prepare();
nebula::StorageClient c({kServerHost ":9559"});
auto* m = c.getMetaClient();
LOG(INFO) << "Testing run once of meta client";
runOnce(*m);
LOG(INFO) << "Testing run get parts.";
runGetParts(c);
LOG(INFO) << "Testing run scan edge with part.";
Expand Down

0 comments on commit 9503f68

Please sign in to comment.