test: fix tmq test case

This commit is contained in:
Liu Jicong 2022-04-13 16:07:38 +08:00
parent 1a13affb13
commit 79bc579779
1 changed files with 109 additions and 117 deletions

View File

@ -13,17 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// clang-format off
#include <assert.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
#include "taos.h"
#include "taoserror.h"
@ -81,7 +79,6 @@ static void printHelp() {
}
void parseArgument(int32_t argc, char* argv[]) {
memset(&g_stConfInfo, 0, sizeof(SConfInfo));
g_stConfInfo.showMsgFlag = 0;
g_stConfInfo.consumeDelay = 8000;
@ -128,23 +125,20 @@ void splitStr(char **arr, char *str, const char *del) {
}
}
void ltrim(char *str)
{
if (str == NULL || *str == '\0')
{
void ltrim(char* str) {
if (str == NULL || *str == '\0') {
return;
}
int len = 0;
char* p = str;
while (*p != '\0' && isspace(*p))
{
++p; ++len;
while (*p != '\0' && isspace(*p)) {
++p;
++len;
}
memmove(str, p, strlen(str) - len + 1);
// return str;
}
void parseInputString() {
// printf("topicString: %s\n", g_stConfInfo.topicString);
// printf("keyString: %s\n\n", g_stConfInfo.keyString);
@ -173,7 +167,8 @@ void parseInputString() {
char* ret = strchr(pstr, ch);
memcpy(g_stConfInfo.key[g_stConfInfo.numOfKey], pstr, ret - pstr);
strcpy(g_stConfInfo.value[g_stConfInfo.numOfKey], ret + 1);
//printf("key: %s, value: %s\n", g_stConfInfo.key[g_stConfInfo.numOfKey], g_stConfInfo.value[g_stConfInfo.numOfKey]);
// printf("key: %s, value: %s\n", g_stConfInfo.key[g_stConfInfo.numOfKey],
// g_stConfInfo.value[g_stConfInfo.numOfKey]);
g_stConfInfo.numOfKey++;
}
@ -181,11 +176,9 @@ void parseInputString() {
}
}
static int running = 1;
/*static void msg_process(tmq_message_t* message) { tmqShowMsg(message); }*/
int queryDB(TAOS* taos, char* command) {
TAOS_RES* pRes = taos_query(taos, command);
int code = taos_errno(pRes);
@ -269,7 +262,6 @@ void loop_consume(tmq_t* tmq) {
printf("{consume success: %d, %d}", totalMsgs, totalRows);
}
void parallel_consume(tmq_t* tmq) {
tmq_resp_err_t err;
@ -277,7 +269,7 @@ void parallel_consume(tmq_t* tmq) {
int32_t totalRows = 0;
int32_t skipLogNum = 0;
while (running) {
tmq_message_t* tmqMsg = tmq_consumer_poll(tmq, g_stConfInfo.consumeDelay * 1000);
TAOS_RES* tmqMsg = tmq_consumer_poll(tmq, g_stConfInfo.consumeDelay * 1000);
if (tmqMsg) {
totalMsgs++;
@ -288,9 +280,9 @@ void parallel_consume(tmq_t* tmq) {
}
#endif
skipLogNum += tmqGetSkipLogNum(tmqMsg);
/*skipLogNum += tmqGetSkipLogNum(tmqMsg);*/
if (0 != g_stConfInfo.showMsgFlag) {
msg_process(tmqMsg);
/*msg_process(tmqMsg);*/
}
tmq_message_destroy(tmqMsg);