add test fun
This commit is contained in:
@@ -299,6 +299,7 @@ extern bool normalOutputEnabled;
|
||||
"Available commands:\r\n"
|
||||
"G_TEST_NUM=<num> - Set the G_TEST_NUM\r\n"
|
||||
"G_TEST_TYPE=<num> - Set the G_TEST_TYPE 0:use ledger,1:use number\r\n"
|
||||
"TESTLEDGER <processNo>,<start>,<count> - Batch send UD ledger updates (e.g. TESTLEDGER 3,1,50)\r\n"
|
||||
"LOG=<bool> - Set the LOG\r\n"
|
||||
"MAX=<int> - Set the MAX_ITEMS\r\n"
|
||||
"dir - Execute rocketmq_test_getdir\r\n"
|
||||
@@ -315,6 +316,43 @@ extern bool normalOutputEnabled;
|
||||
"exit - Exit the shell\r\n"
|
||||
"help - Show this help message\r\n";
|
||||
sendStr(clientFD, "\r\x1B[K" + helpText);
|
||||
} else if (cmd.find("TESTLEDGER") == 0) {
|
||||
// 支持:TESTLEDGER 3,1,50(中间允许空格)
|
||||
size_t pos = cmd.find(' ');
|
||||
if (pos == std::string::npos || pos + 1 >= cmd.size()) {
|
||||
sendStr(clientFD, "\r\x1B[KUsage: TESTLEDGER <processNo>,<start>,<count>\r\n");
|
||||
} else {
|
||||
std::string args = cmd.substr(pos + 1);
|
||||
|
||||
// 去掉可能的空格
|
||||
for (size_t i = 0; i < args.size(); ) {
|
||||
if (args[i] == ' ' || args[i] == '\t' || args[i] == '\r' || args[i] == '\n')
|
||||
args.erase(i, 1);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
// 解析三个整数
|
||||
int processNo = 0, start = 0, count = 0;
|
||||
size_t c1 = args.find(',');
|
||||
size_t c2 = (c1 == std::string::npos) ? std::string::npos : args.find(',', c1 + 1);
|
||||
|
||||
if (c1 == std::string::npos || c2 == std::string::npos) {
|
||||
sendStr(clientFD, "\r\x1B[KUsage: TESTLEDGER <processNo>,<start>,<count> (e.g. TESTLEDGER 3,1,50)\r\n");
|
||||
} else {
|
||||
processNo = std::atoi(args.substr(0, c1).c_str());
|
||||
start = std::atoi(args.substr(c1 + 1, c2 - (c1 + 1)).c_str());
|
||||
count = std::atoi(args.substr(c2 + 1).c_str());
|
||||
|
||||
if (processNo <= 0 || start <= 0 || count <= 0) {
|
||||
sendStr(clientFD, "\r\x1B[KInvalid args. Need >0. Example: TESTLEDGER 3,1,50\r\n");
|
||||
} else {
|
||||
// 调用批量发送(每条间隔1秒的逻辑在函数内部)
|
||||
rocketmq_test_ud_batch(m_front, processNo, start, count);
|
||||
sendStr(clientFD, "\r\x1B[KExecuted TESTLEDGER batch send\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (cmd.find("viewlog") == 0) {
|
||||
showinshellflag = true;
|
||||
handleViewLogCommand(cmd, clientFD);
|
||||
|
||||
Reference in New Issue
Block a user