• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / taos-tools / 12929200663

23 Jan 2025 12:30PM UTC coverage: 74.953% (-0.3%) from 75.249%
12929200663

Pull #839

github

web-flow
Merge 5b5d1f387 into 84c50c54f
Pull Request #839: FIX mixed query mode no need calc thread

388 of 548 new or added lines in 4 files covered. (70.8%)

243 existing lines in 9 files now uncovered.

12434 of 16589 relevant lines covered (74.95%)

321013.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.02
/src/benchMain.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the MIT license as published by the Free Software
6
 * Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12

13
#include <bench.h>
14
#include "benchLog.h"
15
#include <benchCsv.h>
16
#include <toolsdef.h>
17

18
SArguments*    g_arguments;
19
SQueryMetaInfo g_queryInfo;
20
STmqMetaInfo   g_tmqInfo;
21
bool           g_fail = false;
22
uint64_t       g_memoryUsage = 0;
23
tools_cJSON*   root;
24

25
#define CLIENT_INFO_LEN   20
26
static char     g_client_info[CLIENT_INFO_LEN] = {0};
27

28
int32_t         g_majorVersionOfClient = 0;
29
// set flag if command passed, see ARG_OPT_ ???
30
uint64_t        g_argFlag = 0;
31

32
#ifdef LINUX
33
void benchQueryInterruptHandler(int32_t signum, void* sigingo, void* context) {
1✔
34
    infoPrint("%s", "Receive SIGINT or other signal, quit benchmark\n");
1✔
35
    sem_post(&g_arguments->cancelSem);
1✔
36
}
1✔
37

38
void* benchCancelHandler(void* arg) {
180✔
39
    if (bsem_wait(&g_arguments->cancelSem) != 0) {
180✔
40
        toolsMsleep(10);
×
41
    }
42

43
    g_arguments->terminate = true;
1✔
44
    toolsMsleep(10);
1✔
45

46
    return NULL;
1✔
47
}
48
#endif
49

50
void checkArgumentValid() {
175✔
51
     // check prepared_rand valid
52
    if(g_arguments->prepared_rand < g_arguments->reqPerReq) {
175✔
53
        infoPrint("prepared_rand(%"PRIu64") < num_of_records_per_req(%d), so set num_of_records_per_req = prepared_rand\n", 
3✔
54
                   g_arguments->prepared_rand, g_arguments->reqPerReq);
55
        g_arguments->reqPerReq = g_arguments->prepared_rand;
3✔
56
    }
57

58
    if(g_arguments->host == NULL) {
175✔
59
        g_arguments->host = DEFAULT_HOST;
84✔
60
    }
61

62
    if (isRest(g_arguments->iface)) {
175✔
63
        if (0 != convertServAddr(g_arguments->iface,
9✔
64
                                 false,
65
                                 1)) {
66
            errorPrint("%s", "Failed to convert server address\n");
×
67
            return;
×
68
        }
69
        encodeAuthBase64();
9✔
70
        g_arguments->rest_server_ver_major =
9✔
71
            getServerVersionRest(g_arguments->port);
9✔
72
    }
73

74
}
75

76
int main(int argc, char* argv[]) {
180✔
77
    int ret = 0;
180✔
78

79
    // log
80
    initLog();
180✔
81
    initArgument();
180✔
82
    srand(time(NULL)%1000000);
180✔
83

84
    snprintf(g_client_info, CLIENT_INFO_LEN, "%s", taos_get_client_info());
180✔
85
    g_majorVersionOfClient = atoi(g_client_info);
180✔
86
    debugPrint("Client info: %s, major version: %d\n",
180✔
87
            g_client_info,
88
            g_majorVersionOfClient);
89

90
#ifdef LINUX
91
    if (sem_init(&g_arguments->cancelSem, 0, 0) != 0) {
180✔
92
        errorPrint("%s", "failed to create cancel semaphore\n");
×
93
        exit(EXIT_FAILURE);
×
94
    }
95
    pthread_t spid = {0};
180✔
96
    pthread_create(&spid, NULL, benchCancelHandler, NULL);
180✔
97

98
    benchSetSignal(SIGINT, benchQueryInterruptHandler);
180✔
99

100
#endif
101
    if (benchParseArgs(argc, argv)) {
180✔
102
        exitLog();
×
103
        return -1;
×
104
    }
105
#ifdef WEBSOCKET
106
    if (g_arguments->debug_print) {
176✔
107
        ws_enable_log("info");
2✔
108
    }
109

110
    if (g_arguments->dsn != NULL) {
176✔
111
        g_arguments->websocket = true;
1✔
112
        infoPrint("set websocket true from dsn not empty. dsn=%s\n", g_arguments->dsn);
1✔
113
    } else {
114
        char * dsn = getenv("TDENGINE_CLOUD_DSN");
175✔
115
        if (dsn != NULL && strlen(dsn) > 3) {
175✔
116
            g_arguments->dsn = dsn;
1✔
117
            g_arguments->websocket = true;
1✔
118
            infoPrint("set websocket true from getenv TDENGINE_CLOUD_DSN=%s\n", g_arguments->dsn);
1✔
119
        } else {
120
            g_arguments->dsn = false;
174✔
121
        }
122
    }
123
#endif
124
    if (g_arguments->metaFile) {
176✔
125
        g_arguments->totalChildTables = 0;
91✔
126
        if (readJsonConfig(g_arguments->metaFile)) {
91✔
127
            errorPrint("failed to readJsonConfig %s\n", g_arguments->metaFile);
1✔
128
            exitLog();
1✔
129
            return -1;
1✔
130
        }
131
    } else {
132
        modifyArgument();
85✔
133
    }
134

135
    if(g_arguments->output_file[0] == 0) {
175✔
136
        infoPrint("%s","result_file is empty, ignore output.");
×
137
        g_arguments->fpOfInsertResult = NULL;
×
138
    } else {
139
        g_arguments->fpOfInsertResult = fopen(g_arguments->output_file, "a");
175✔
140
        if (NULL == g_arguments->fpOfInsertResult) {
175✔
141
            errorPrint("failed to open %s for save result\n",
×
142
                    g_arguments->output_file);
143
        }
144
    }
145

146
    infoPrint("client version: %s\n", taos_get_client_info());
175✔
147
    checkArgumentValid();
175✔
148

149
    if (g_arguments->test_mode == INSERT_TEST) {
175✔
150
        if (insertTestProcess()) {
158✔
151
            errorPrint("%s", "insert test process failed\n");
8✔
152
            ret = -1;
8✔
153
        }
154
    } else if (g_arguments->test_mode == CSVFILE_TEST) {
17✔
155
        if (csvTestProcess()) {
1✔
156
            errorPrint("%s", "query test process failed\n");
×
157
            ret = -1;
×
158
        }
159
    } else if (g_arguments->test_mode == QUERY_TEST) {
16✔
160
        if (queryTestProcess()) {
12✔
UNCOV
161
            errorPrint("%s", "query test process failed\n");
×
UNCOV
162
            ret = -1;
×
163
        }
164
    } else if (g_arguments->test_mode == SUBSCRIBE_TEST) {
4✔
165
        if (subscribeTestProcess()) {
4✔
166
            errorPrint("%s", "sub test process failed\n");
×
167
            ret = -1;
×
168
        }
169
    }
170

171
    if ((ret == 0) && g_arguments->aggr_func) {
175✔
172
        queryAggrFunc();
6✔
173
    }
174
    postFreeResource();
175✔
175

176
#ifdef LINUX
177
    pthread_cancel(spid);
175✔
178
    pthread_join(spid, NULL);
175✔
179
#endif
180

181
    exitLog();
175✔
182
    return ret;
175✔
183
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc