From 52d33d39100eb35ad32a2d8e73cb45973396fc4c Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Tue, 29 Mar 2022 10:01:50 +0800 Subject: [PATCH] [modify] --- tests/test/c/tmqDemo.c | 4 ++-- tests/test/c/tmqSim.c | 32 +++----------------------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/tests/test/c/tmqDemo.c b/tests/test/c/tmqDemo.c index 2618984f51..182d40c96a 100644 --- a/tests/test/c/tmqDemo.c +++ b/tests/test/c/tmqDemo.c @@ -67,7 +67,7 @@ static SConfInfo g_stConfInfo = { "tmqdb", "stb", "./tmqResult.txt", // output_file - "/data2/dnode/data/vnode/vnode2/wal", + "", // /data2/dnode/data/vnode/vnode2/wal", 1, // threads 1, // tables 1, // vgroups @@ -662,7 +662,7 @@ int main(int32_t argc, char *argv[]) { float msgsSpeed = totalMsgs / seconds; - if (0 == g_stConfInfo.simCase) { + if ((0 == g_stConfInfo.simCase) && (strlen(g_stConfInfo.vnodeWalPath))) { walLogSize = getDirectorySize(g_stConfInfo.vnodeWalPath); if (walLogSize <= 0) { printf("%s size incorrect!", g_stConfInfo.vnodeWalPath); diff --git a/tests/test/c/tmqSim.c b/tests/test/c/tmqSim.c index 57fc6eb6f9..81a988e9ae 100644 --- a/tests/test/c/tmqSim.c +++ b/tests/test/c/tmqSim.c @@ -98,7 +98,7 @@ void parseArgument(int32_t argc, char *argv[]) { } } -#if 1 +#if 0 pPrint("%s configDir:%s %s", GREEN, configDir, NC); pPrint("%s dbName:%s %s", GREEN, g_stConfInfo.dbName, NC); pPrint("%s topicString:%s %s", GREEN, g_stConfInfo.topicString, NC); @@ -198,6 +198,8 @@ tmq_t* build_consumer() { TAOS_RES* pRes = taos_query(pConn, sqlStr); if (taos_errno(pRes) != 0) { printf("error in use db, reason:%s\n", taos_errstr(pRes)); + taos_free_result(pRes); + exit(-1); } taos_free_result(pRes); @@ -219,34 +221,6 @@ tmq_list_t* build_topic_list() { return topic_list; } -void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) { - static const int MIN_COMMIT_COUNT = 1000; - - int msg_count = 0; - tmq_resp_err_t err; - - if ((err = tmq_subscribe(tmq, topics))) { - fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(err)); - return; - } - - while (running) { - tmq_message_t* tmqmessage = tmq_consumer_poll(tmq, 1); - if (tmqmessage) { - msg_process(tmqmessage); - tmq_message_destroy(tmqmessage); - - if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0); - } - } - - err = tmq_consumer_close(tmq); - if (err) - fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(err)); - else - fprintf(stderr, "%% Consumer closed\n"); -} - void perf_loop(tmq_t* tmq, tmq_list_t* topics) { tmq_resp_err_t err;