Skip to content

Commit

Permalink
fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
darionyaphet committed Nov 24, 2021
1 parent 49f1257 commit ae4ec35
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 253 deletions.
22 changes: 0 additions & 22 deletions src/meta/test/GroupZoneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,28 +275,6 @@ TEST(GroupAndZoneTest, GroupAndZoneTest) {
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_KEY_NOT_FOUND, resp.get_code());
}
// Drop host from zone
{
cpp2::DropHostFromZoneReq req;
req.set_zone_name("zone_0");
HostAddr node{"12", 12};
req.set_node(std::move(node));
auto* processor = DropHostFromZoneProcessor::instance(kv.get());
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_CONFLICT, resp.get_code());
}
{
cpp2::DropSpaceReq req;
req.set_space_name("space");
req.set_if_exists(false);
auto* processor = DropSpaceProcessor::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());
}
{
cpp2::DropHostFromZoneReq req;
req.set_zone_name("zone_0");
Expand Down
39 changes: 0 additions & 39 deletions src/meta/test/MetaClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,45 +410,6 @@ TEST(MetaClientTest, SpaceWithGroupTest) {
ret = client->createSpace(spaceDesc, true).get();
ASSERT_TRUE(ret.ok()) << ret.status();
}
// Create Space on group_0, replica factor is equal with zone size
{
meta::cpp2::SpaceDesc spaceDesc;
spaceDesc.set_space_name("space_on_group_0_3");
spaceDesc.set_partition_num(9);
spaceDesc.set_replica_factor(3);
spaceDesc.set_group_name("group_0");
auto ret = client->createSpace(spaceDesc).get();
ASSERT_TRUE(ret.ok()) << ret.status();

ret = client->createSpace(spaceDesc, true).get();
ASSERT_TRUE(ret.ok()) << ret.status();
}
// Create Space on group_0, replica factor is less than zone size
{
meta::cpp2::SpaceDesc spaceDesc;
spaceDesc.set_space_name("space_on_group_0_1");
spaceDesc.set_partition_num(9);
spaceDesc.set_replica_factor(1);
spaceDesc.set_group_name("group_0");
auto ret = client->createSpace(spaceDesc).get();
ASSERT_TRUE(ret.ok()) << ret.status();

ret = client->createSpace(spaceDesc, true).get();
ASSERT_TRUE(ret.ok()) << ret.status();
}
// Create Space on a group which is not exist
{
meta::cpp2::SpaceDesc spaceDesc;
spaceDesc.set_space_name("space_on_group_not_exist");
spaceDesc.set_partition_num(9);
spaceDesc.set_replica_factor(4);
spaceDesc.set_group_name("group_not_exist");
auto ret = client->createSpace(spaceDesc).get();
ASSERT_FALSE(ret.ok()) << ret.status();

ret = client->createSpace(spaceDesc, true).get();
ASSERT_FALSE(ret.ok()) << ret.status();
}
} // namespace nebula

TEST(MetaClientTest, TagTest) {
Expand Down
157 changes: 0 additions & 157 deletions src/meta/test/ProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,163 +463,6 @@ TEST(ProcessorTest, SpaceTest) {
}
}

TEST(ProcessorTest, SpaceWithGroupTest) {
fs::TempDir rootPath("/tmp/SpaceWithGroupTest.XXXXXX");
std::unique_ptr<kvstore::KVStore> kv(MockCluster::initMetaKV(rootPath.path()));
std::vector<HostAddr> addresses;
for (int32_t i = 0; i <= 10; i++) {
addresses.emplace_back(std::to_string(i), i);
}
TestUtils::createSomeHosts(kv.get(), std::move(addresses));

// Add Zones
{{std::vector<HostAddr> nodes;
for (int32_t i = 0; i < 2; i++) {
nodes.emplace_back(std::to_string(i), i);
}
cpp2::AddZoneReq req;
req.set_zone_name("zone_0");
req.set_nodes(std::move(nodes));
auto* processor = AddZoneProcessor::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());
}
{
std::vector<HostAddr> nodes;
for (int32_t i = 2; i < 4; i++) {
nodes.emplace_back(std::to_string(i), i);
}
cpp2::AddZoneReq req;
req.set_zone_name("zone_1");
req.set_nodes(std::move(nodes));
auto* processor = AddZoneProcessor::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());
}
{
std::vector<HostAddr> nodes;
for (int32_t i = 4; i < 6; i++) {
nodes.emplace_back(std::to_string(i), i);
}
cpp2::AddZoneReq req;
req.set_zone_name("zone_2");
req.set_nodes(std::move(nodes));
auto* processor = AddZoneProcessor::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());
}
{
std::vector<HostAddr> nodes;
for (int32_t i = 6; i < 8; i++) {
nodes.emplace_back(std::to_string(i), i);
}
cpp2::AddZoneReq req;
req.set_zone_name("zone_3");
req.set_nodes(std::move(nodes));
auto* processor = AddZoneProcessor::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());
}
{
std::vector<HostAddr> nodes;
for (int32_t i = 8; i < 10; i++) {
nodes.emplace_back(std::to_string(i), i);
}
cpp2::AddZoneReq req;
req.set_zone_name("zone_4");
req.set_nodes(std::move(nodes));
auto* processor = AddZoneProcessor::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());
}
} // namespace meta
// List Zones
{
cpp2::ListZonesReq req;
auto* processor = ListZonesProcessor::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(5, resp.get_zones().size());
ASSERT_EQ("zone_0", resp.get_zones()[0].get_zone_name());
ASSERT_EQ("zone_1", resp.get_zones()[1].get_zone_name());
ASSERT_EQ("zone_2", resp.get_zones()[2].get_zone_name());
ASSERT_EQ("zone_3", resp.get_zones()[3].get_zone_name());
ASSERT_EQ("zone_4", resp.get_zones()[4].get_zone_name());
}

// Create Space without Group
{
cpp2::SpaceDesc properties;
properties.set_space_name("default_space");
properties.set_partition_num(9);
properties.set_replica_factor(3);
cpp2::CreateSpaceReq req;
req.set_properties(std::move(properties));
auto* processor = CreateSpaceProcessor::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());
}
// Create Space on group_0, replica factor is equal with zone size
{
cpp2::SpaceDesc properties;
properties.set_space_name("space_on_group_0_3");
properties.set_partition_num(9);
properties.set_replica_factor(3);
properties.set_group_name("group_0");
cpp2::CreateSpaceReq req;
req.set_properties(std::move(properties));
auto* processor = CreateSpaceProcessor::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());
}
// Create Space on group_0, replica factor is less than zone size
{
cpp2::SpaceDesc properties;
properties.set_space_name("space_on_group_0_1");
properties.set_partition_num(9);
properties.set_replica_factor(1);
properties.set_group_name("group_0");
cpp2::CreateSpaceReq req;
req.set_properties(std::move(properties));
auto* processor = CreateSpaceProcessor::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());
}
// Create Space on a group which is not exist
{
cpp2::SpaceDesc properties;
properties.set_space_name("space_on_group_not_exist");
properties.set_partition_num(9);
properties.set_replica_factor(4);
properties.set_group_name("group_not_exist");
cpp2::CreateSpaceReq req;
req.set_properties(std::move(properties));
auto* processor = CreateSpaceProcessor::instance(kv.get());
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(nebula::cpp2::ErrorCode::E_GROUP_NOT_FOUND, resp.get_code());
}
} // namespace nebula

TEST(ProcessorTest, CreateTagTest) {
fs::TempDir rootPath("/tmp/CreateTagTest.XXXXXX");
auto kv = MockCluster::initMetaKV(rootPath.path());
Expand Down
35 changes: 0 additions & 35 deletions src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2710,11 +2710,6 @@ TEST_F(ParserTest, MatchListSubscriptRange) {
}

TEST_F(ParserTest, Zone) {
{
std::string query = "SHOW GROUPS";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "SHOW ZONES";
auto result = parse(query);
Expand Down Expand Up @@ -2750,36 +2745,6 @@ TEST_F(ParserTest, Zone) {
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD GROUP group_0 zone_0,zone_1,zone_2";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "ADD ZONE zone_3 INTO GROUP group_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DROP ZONE zone_3 FROM GROUP group_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESC GROUP group_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DESCRIBE GROUP group_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
{
std::string query = "DROP GROUP group_0";
auto result = parse(query);
ASSERT_TRUE(result.ok()) << result.status();
}
}

TEST_F(ParserTest, FullText) {
Expand Down

0 comments on commit ae4ec35

Please sign in to comment.