162 lines
3.2 KiB
C++
162 lines
3.2 KiB
C++
/*
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
*
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "parTestUtil.h"
|
|
|
|
using namespace std;
|
|
|
|
namespace ParserTest {
|
|
|
|
class ParserShowToUseTest : public ParserDdlTest {};
|
|
|
|
// todo SHOW accounts
|
|
// todo SHOW apps
|
|
// todo SHOW connections
|
|
// todo SHOW create database
|
|
// todo SHOW create stable
|
|
// todo SHOW create table
|
|
|
|
TEST_F(ParserShowToUseTest, showDatabases) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW databases");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showDnodes) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW dnodes");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showFunctions) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW functions");
|
|
}
|
|
|
|
// todo SHOW licence
|
|
|
|
TEST_F(ParserShowToUseTest, showIndexes) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW indexes from t1");
|
|
|
|
run("SHOW indexes from t1 from test");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showMnodes) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW mnodes");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showModules) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW modules");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showQnodes) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW qnodes");
|
|
}
|
|
|
|
// todo SHOW queries
|
|
// todo SHOW scores
|
|
|
|
TEST_F(ParserShowToUseTest, showStables) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW stables");
|
|
|
|
run("SHOW test.stables");
|
|
|
|
run("SHOW stables like 'c%'");
|
|
|
|
run("SHOW test.stables like 'c%'");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showStreams) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW streams");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showTransactions) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW TRANSACTIONS");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, showTables) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW tables");
|
|
|
|
run("SHOW test.tables");
|
|
|
|
run("SHOW tables like 'c%'");
|
|
|
|
run("SHOW test.tables like 'c%'");
|
|
}
|
|
|
|
// todo SHOW topics
|
|
|
|
TEST_F(ParserShowToUseTest, showUsers) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW users");
|
|
}
|
|
|
|
// todo SHOW variables
|
|
|
|
TEST_F(ParserShowToUseTest, showVgroups) {
|
|
useDb("root", "test");
|
|
|
|
run("SHOW vgroups");
|
|
|
|
run("SHOW test.vgroups");
|
|
}
|
|
|
|
// todo SHOW vnodes
|
|
|
|
TEST_F(ParserShowToUseTest, splitVgroup) {
|
|
useDb("root", "test");
|
|
|
|
SSplitVgroupReq expect = {0};
|
|
|
|
auto setSplitVgroupReqFunc = [&](int32_t vgId) { expect.vgId = vgId; };
|
|
|
|
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
|
|
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SPLIT_VGROUP_STMT);
|
|
ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_SPLIT_VGROUP);
|
|
SSplitVgroupReq req = {0};
|
|
ASSERT_EQ(tDeserializeSSplitVgroupReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS);
|
|
ASSERT_EQ(req.vgId, expect.vgId);
|
|
});
|
|
|
|
setSplitVgroupReqFunc(15);
|
|
run("SPLIT VGROUP 15");
|
|
}
|
|
|
|
TEST_F(ParserShowToUseTest, useDatabase) {
|
|
useDb("root", "test");
|
|
|
|
run("use wxy_db");
|
|
}
|
|
|
|
} // namespace ParserTest
|