add mq log and add test type in test mod

This commit is contained in:
lnk
2025-05-28 16:09:15 +08:00
parent 8bc9f3c5e8
commit 59ea59f918
11 changed files with 327 additions and 123 deletions

View File

@@ -49,6 +49,7 @@ extern "C" {
#include <iostream>
extern int G_TEST_NUM;
extern int G_TEST_TYPE;
extern void ledger(const char* terminal_id = NULL,QIODevice* outputDevice = NULL);
extern void value_print(const char *variableName, QTcpSocket *clientSocket);
extern int TEST_PORT;
@@ -121,6 +122,7 @@ public:
: QObject(parent),
server(NULL),
TEST_NUM(G_TEST_NUM),
TEST_TYPE(G_TEST_TYPE),
timer(NULL),
historyIndex(-1),
stopViewLog(true),
@@ -208,6 +210,14 @@ public slots:
TEST_NUM = num;
}
/**
* @brief 设置TEST_TYPE
*/
void setTestType(int type) {
QMutexLocker locker(&mutex);
TEST_TYPE = type;
}
void setTestlog(bool flag) {
redirectErrorOutput(flag);
redirectWarnOutput(flag);
@@ -221,13 +231,13 @@ private slots:
*/
void doPeriodicTask() {
QMutexLocker locker(&mutex);
std::cout << "Executing TEST_NUM is " << TEST_NUM << std::endl;
qDebug() << "doPeriodicTask() called. TEST_NUM = " << TEST_NUM;
std::cout << "Executing TEST_NUM is " << TEST_NUM << "Executing TEST_TYPE is " << TEST_TYPE << std::endl;
qDebug() << "doPeriodicTask() called. TEST_NUM = " << TEST_NUM << "Executing TEST_TYPE is " << TEST_TYPE;
if (TEST_NUM != 0) {
qDebug() << "Executing rocketmq_test_300()";
std::cout << "Executing rocketmq_test_300()\n";
rocketmq_test_300(TEST_NUM, g_front_seg_index);
rocketmq_test_300(TEST_NUM, g_front_seg_index,TEST_TYPE);
}
}
@@ -402,6 +412,7 @@ private:
if (cmd == "help") {
QString helpText = "Available commands:\r\n";
helpText += "TEST_NUM=<num> - Set the TEST_NUM\r\n";
helpText += "TEST_TYPE=<num> - Set the TEST_TYPE 0:use ledger,1:use number\r\n";
helpText += "LOG=<bool> - Set the LOG\r\n";
helpText += "telnettest - Set the telnettest\r\n";
helpText += "rc - Execute rocketmq_test_rc\r\n";
@@ -437,13 +448,25 @@ private:
clientSocket->write("Invalid number\r\n");
}
}
else if (cmd.startsWith("TEST_TYPE=")) {
bool ok;
int type = cmd.mid(10).toInt(&ok);
if (ok) {
setTestType(type);
clientSocket->write("\r\x1B[K");
clientSocket->write("TEST_TYPE updated\r\n");
} else {
clientSocket->write("\r\x1B[K");
clientSocket->write("Invalid type\r\n");
}
}
else if (cmd.startsWith("LOG=")) {
bool ok;
bool flag = cmd.mid(4).toInt(&ok);
if (ok) {
setTestlog(flag);
clientSocket->write("\r\x1B[K");
clientSocket->write("TEST_NUM updated\r\n");
clientSocket->write("LOG updated\r\n");
} else {
clientSocket->write("\r\x1B[K");
clientSocket->write("Invalid number\r\n");
@@ -583,6 +606,7 @@ private:
QTcpServer *server;
QTimer *timer;
int TEST_NUM;
int TEST_TYPE;
QMutex mutex;
// 历史命令相关