Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable zone commands #3776

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/common/meta/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ using RemoteListeners =
std::unordered_map<GraphSpaceID,
std::unordered_map<PartitionID, std::vector<RemoteListenerInfo>>>;


} // namespace meta
} // namespace nebula

Expand Down
21 changes: 12 additions & 9 deletions src/graph/validator/AdminValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Status CreateSpaceValidator::validateImpl() {
auto status = Status::OK();
spaceDesc_.space_name_ref() = std::move(*(sentence->spaceName()));
if (sentence->zoneNames()) {
spaceDesc_.zone_names_ref() = sentence->zoneNames()->zoneNames();
return Status::SemanticError("Create space with zone is unsupported");
}

StatusOr<std::string> retStatusOr;
std::string result;
auto *charsetInfo = qctx_->getCharsetInfo();
Expand Down Expand Up @@ -323,10 +324,6 @@ Status ShowListenerValidator::toPlan() {
}

Status AddHostsValidator::validateImpl() {
return Status::OK();
}

Status AddHostsValidator::toPlan() {
auto sentence = static_cast<AddHostsSentence *>(sentence_);
auto hosts = sentence->hosts()->hosts();
if (hosts.empty()) {
Expand All @@ -337,18 +334,19 @@ Status AddHostsValidator::toPlan() {
if (it != hosts.end()) {
return Status::SemanticError("Host have duplicated");
}
return Status::OK();
}

Status AddHostsValidator::toPlan() {
auto sentence = static_cast<AddHostsSentence *>(sentence_);
auto hosts = sentence->hosts()->hosts();
auto *addHost = AddHosts::make(qctx_, nullptr, hosts);
root_ = addHost;
tail_ = root_;
return Status::OK();
}

Status DropHostsValidator::validateImpl() {
return Status::OK();
}

Status DropHostsValidator::toPlan() {
auto sentence = static_cast<DropHostsSentence *>(sentence_);
auto hosts = sentence->hosts()->hosts();
if (hosts.empty()) {
Expand All @@ -359,7 +357,12 @@ Status DropHostsValidator::toPlan() {
if (it != hosts.end()) {
return Status::SemanticError("Host have duplicated");
}
return Status::OK();
}

Status DropHostsValidator::toPlan() {
auto sentence = static_cast<DropHostsSentence *>(sentence_);
auto hosts = sentence->hosts()->hosts();
auto *dropHost = DropHosts::make(qctx_, nullptr, hosts);
root_ = dropHost;
tail_ = root_;
Expand Down
12 changes: 6 additions & 6 deletions src/graph/validator/MaintainValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ Status ShowEdgeIndexStatusValidator::toPlan() {
}

Status MergeZoneValidator::validateImpl() {
return Status::OK();
return Status::SemanticError("Merge zone is unsupported");
}

Status MergeZoneValidator::toPlan() {
Expand All @@ -509,7 +509,7 @@ Status MergeZoneValidator::toPlan() {
}

Status RenameZoneValidator::validateImpl() {
return Status::OK();
return Status::SemanticError("Rename zone is unsupported");
}

Status RenameZoneValidator::toPlan() {
Expand All @@ -534,7 +534,7 @@ Status DropZoneValidator::toPlan() {
}

Status DivideZoneValidator::validateImpl() {
return Status::OK();
return Status::SemanticError("Divide zone is unsupported");
}

Status DivideZoneValidator::toPlan() {
Expand All @@ -558,11 +558,11 @@ Status DescribeZoneValidator::toPlan() {
return Status::OK();
}

Status ListZonesValidator::validateImpl() {
return Status::OK();
Status ShowZonesValidator::validateImpl() {
return Status::SemanticError("Show zones is unsupported");
}

Status ListZonesValidator::toPlan() {
Status ShowZonesValidator::toPlan() {
auto *doNode = ListZones::make(qctx_, nullptr);
root_ = doNode;
tail_ = root_;
Expand Down
4 changes: 2 additions & 2 deletions src/graph/validator/MaintainValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ class DescribeZoneValidator final : public Validator {
Status toPlan() override;
};

class ListZonesValidator final : public Validator {
class ShowZonesValidator final : public Validator {
public:
ListZonesValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) {
ShowZonesValidator(Sentence* sentence, QueryContext* context) : Validator(sentence, context) {
setNoSpaceRequired();
}

Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/Validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ std::unique_ptr<Validator> Validator::makeValidator(Sentence* sentence, QueryCon
case Sentence::Kind::kDescribeZone:
return std::make_unique<DescribeZoneValidator>(sentence, context);
case Sentence::Kind::kListZones:
return std::make_unique<ListZonesValidator>(sentence, context);
return std::make_unique<ShowZonesValidator>(sentence, context);
case Sentence::Kind::kAddHostsIntoZone:
return std::make_unique<AddHostsIntoZoneValidator>(sentence, context);
case Sentence::Kind::kAddListener:
Expand Down
8 changes: 0 additions & 8 deletions src/parser/AdminSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ std::string ShowCollationSentence::toString() const {
return std::string("SHOW COLLATION");
}

std::string ShowGroupsSentence::toString() const {
return std::string("SHOW GROUPS");
}

std::string ShowZonesSentence::toString() const {
return std::string("SHOW ZONES");
}

std::string SpaceOptItem::toString() const {
switch (optType_) {
case OptionType::PARTITION_NUM:
Expand Down
16 changes: 0 additions & 16 deletions src/parser/AdminSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,6 @@ class ShowCollationSentence final : public Sentence {
std::string toString() const override;
};

class ShowGroupsSentence final : public Sentence {
public:
ShowGroupsSentence() {
kind_ = Kind::kShowGroups;
}
std::string toString() const override;
};

class ShowZonesSentence final : public Sentence {
public:
ShowZonesSentence() {
kind_ = Kind::kShowZones;
}
std::string toString() const override;
};

class SpaceOptItem final {
public:
using Value = boost::variant<int64_t, std::string, meta::cpp2::ColumnTypeDef>;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/MaintainSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ std::string DescribeZoneSentence::toString() const {
return folly::stringPrintf("DESCRIBE ZONE \"%s\"", zoneName_.get()->c_str());
}

std::string ListZonesSentence::toString() const {
std::string ShowZonesSentence::toString() const {
return folly::stringPrintf("SHOW ZONES");
}

Expand Down
4 changes: 2 additions & 2 deletions src/parser/MaintainSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@ class DescribeZoneSentence : public Sentence {
std::unique_ptr<std::string> zoneName_;
};

class ListZonesSentence : public Sentence {
class ShowZonesSentence : public Sentence {
public:
ListZonesSentence() {
ShowZonesSentence() {
kind_ = Kind::kListZones;
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -3421,7 +3421,7 @@ show_sentence
$$ = new ShowCollationSentence();
}
| KW_SHOW KW_ZONES {
$$ = new ListZonesSentence();
$$ = new ShowZonesSentence();
}
| KW_SHOW KW_STATS {
$$ = new ShowStatsSentence();
Expand Down
58 changes: 29 additions & 29 deletions tests/admin/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def test_space(self):
self.check_resp_succeeded(resp)

# check result
resp = self.client.execute('DESC SPACE space_with_default_options')
expect_result = [['space_with_default_options', 100, 1, 'utf8', 'utf8_bin',
'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# resp = self.client.execute('DESC SPACE space_with_default_options')
# expect_result = [['space_with_default_options', 100, 1, 'utf8', 'utf8_bin',
# 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# drop space
resp = self.client.execute('DROP SPACE space_with_default_options')
Expand All @@ -42,26 +42,26 @@ def test_space(self):
# desc space
resp = self.client.execute('DESC SPACE default_space')
self.check_resp_succeeded(resp)
expect_result = [['default_space', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)',
False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['default_space', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)',
# False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# show create space
# TODO(shylock) need meta cache to permission checking
time.sleep(self.delay)
resp = self.client.execute('SHOW CREATE SPACE default_space')
self.check_resp_succeeded(resp)

create_space_str_result = 'CREATE SPACE `default_space` (partition_num = 9, '\
'replica_factor = 1, '\
'charset = utf8, '\
'collate = utf8_bin, '\
'vid_type = FIXED_STRING(8), '\
'atomic_edge = false) '\
'ON default_zone'
# create_space_str_result = 'CREATE SPACE `default_space` (partition_num = 9, '\
# 'replica_factor = 1, '\
# 'charset = utf8, '\
# 'collate = utf8_bin, '\
# 'vid_type = FIXED_STRING(8), '\
# 'atomic_edge = false) '\
# 'ON default_zone'

expect_result = [['default_space', create_space_str_result]]
self.check_result(resp, expect_result)
# expect_result = [['default_space', create_space_str_result]]
# self.check_result(resp, expect_result)

# check result from show create
resp = self.client.execute('DROP SPACE default_space')
Expand Down Expand Up @@ -92,8 +92,8 @@ def test_charset_collate(self):

resp = self.client.execute('DESC SPACE space_charset_collate')
self.check_resp_succeeded(resp)
expect_result = [['space_charset_collate', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_charset_collate', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# drop space
resp = self.client.execute('DROP SPACE space_charset_collate')
Expand All @@ -105,8 +105,8 @@ def test_charset_collate(self):

resp = self.client.execute('DESC SPACE space_charset')
self.check_resp_succeeded(resp)
expect_result = [['space_charset', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_charset', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# drop space
resp = self.client.execute('DROP SPACE space_charset')
Expand All @@ -118,8 +118,8 @@ def test_charset_collate(self):

resp = self.client.execute('DESC SPACE space_collate')
self.check_resp_succeeded(resp)
expect_result = [['space_collate', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_collate', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# drop space
resp = self.client.execute('DROP SPACE space_collate')
Expand Down Expand Up @@ -155,9 +155,9 @@ def test_charset_collate(self):

resp = self.client.execute('DESC SPACE space_capital')
self.check_resp_succeeded(resp)
expect_result = [['space_capital', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)',
False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_capital', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(8)',
# False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# drop space
resp = self.client.execute('DROP SPACE space_capital')
Expand Down Expand Up @@ -208,8 +208,8 @@ def test_create_space_with_string_vid(self):

resp = self.client.execute('DESC SPACE space_string_vid')
self.check_resp_succeeded(resp)
expect_result = [['space_string_vid', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(30)', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_string_vid', 9, 1, 'utf8', 'utf8_bin', 'FIXED_STRING(30)', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# clean up
resp = self.client.execute('DROP SPACE space_string_vid')
Expand All @@ -223,8 +223,8 @@ def test_create_space_with_int_vid(self):

resp = self.client.execute('DESC SPACE space_int_vid')
self.check_resp_succeeded(resp)
expect_result = [['space_int_vid', 9, 1, 'utf8', 'utf8_bin', 'INT64', False, 'default_zone', T_EMPTY]]
self.check_result(resp, expect_result, {0})
# expect_result = [['space_int_vid', 9, 1, 'utf8', 'utf8_bin', 'INT64', False, 'default_zone', T_EMPTY]]
# self.check_result(resp, expect_result, {0})

# clean up
resp = self.client.execute('DROP SPACE space_int_vid')
Expand Down
2 changes: 1 addition & 1 deletion tests/common/nebula_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def start(self):
for storaged in self.storaged_processes
]
)
cmd = "ADD HOSTS {} INTO NEW ZONE \"default_zone\"".format(hosts)
cmd = "ADD HOSTS {}".format(hosts)
print("add hosts cmd is {}".format(cmd))
resp = client.execute(cmd)
assert resp.is_succeeded(), resp.error_msg()
Expand Down
30 changes: 0 additions & 30 deletions tests/maintain/test_zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,3 @@
class TestZone(NebulaTestSuite):
def test_zone(self):
pass
# resp = self.client.execute('SHOW HOSTS')
# self.check_resp_succeeded(resp)
# assert not resp.is_empty()
# storage_port = resp.row_values(0)[1].as_int()

# # Get Zone
# resp = self.client.execute('DESC ZONE default_zone_127.0.0.1_' + str(storage_port))
# self.check_resp_succeeded(resp)

# resp = self.client.execute('DESCRIBE ZONE zone_0')
# self.check_resp_succeeded(resp)

# # Get Zone which is not exist
# resp = self.client.execute('DESC ZONE zone_not_exist')
# self.check_resp_failed(resp)

# resp = self.client.execute('DESCRIBE ZONE zone_not_exist')
# self.check_resp_failed(resp)

# # SHOW Zones
# resp = self.client.execute('SHOW ZONES')
# self.check_resp_succeeded(resp)

# # Drop Zone
# resp = self.client.execute('DROP ZONE zone_0')
# self.check_resp_succeeded(resp)

# # Drop Zone which is not exist
# resp = self.client.execute('DROP ZONE zone_0')
# self.check_resp_failed(resp)
4 changes: 2 additions & 2 deletions tests/tck/features/admin/Hosts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Feature: Admin hosts
"""
CREATE SPACE space_without_vid_type(partition_num=9, replica_factor=3) on "default_zone";
"""
Then a SemanticError should be raised at runtime: space vid_type must be specified explicitly
Then a SemanticError should be raised at runtime: Create space with zone is unsupported
When executing query:
"""
CREATE SPACE space_without_vid_type on "default_zone";
"""
Then a SemanticError should be raised at runtime: space vid_type must be specified explicitly
Then a SemanticError should be raised at runtime: Create space with zone is unsupported
When executing query:
"""
CREATE SPACE space_specify_vid_type(partition_num=9, replica_factor=1, vid_type=FIXED_STRING(8));
Expand Down
Loading