From 8dc5d9c716c60a277c66e0963a0c0ebcad48aa49 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 16 Oct 2023 18:01:04 +0800 Subject: [PATCH 1/8] fix: modify logic --- inc/bench.h | 11 +++++- src/benchData.c | 86 ++++++++++++++++++++++++++++++++++---------- src/benchJsonOpt.c | 88 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 155 insertions(+), 30 deletions(-) diff --git a/inc/bench.h b/inc/bench.h index 74f4e226..9318e450 100644 --- a/inc/bench.h +++ b/inc/bench.h @@ -561,8 +561,12 @@ typedef struct SChildField { #define FUNTYPE_NONE 0 #define FUNTYPE_SIN 1 #define FUNTYPE_COS 2 +#define FUNTYPE_COUNT 3 +#define FUNTYPE_SAW 4 +#define FUNTYPE_SQUARE 5 +#define FUNTYPE_TRI 6 -#define FUNTYPE_CNT 2 +#define FUNTYPE_CNT 7 typedef struct SField { uint8_t type; @@ -581,6 +585,11 @@ typedef struct SField { int32_t addend; int32_t random; + int32_t period; + int32_t offset; + int32_t step; + + bool sma; } Field; diff --git a/src/benchData.c b/src/benchData.c index a196ada3..f52a121a 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -42,22 +42,72 @@ const char* locations_sml[] = { #include "benchLocations.h" #endif +int32_t funCount(int32_t min, int32_t max, int32_t step, int32_t loop) { + int32_t range = abs(max - min); + int32_t maxCnt = range / step; + int32_t val = min + (loop % maxCnt) * step ; + + return val; +} + +int32_t funSaw(int32_t min, int32_t max, int32_t period, int32_t loop) { + int32_t range = abs(max - min); + int32_t step = range / period; + int32_t val = min + (loop % period) * step ; + return val; +} + +int32_t funSquare(int32_t min, int32_t max, int32_t period, int32_t loop) { + int32_t change = (loop/period) % 2; + if (change) + return min; + else + return max; +} + +int32_t funTriAngle(int32_t min, int32_t max, int32_t period, int32_t loop) { + int32_t range = abs(max - min); + int32_t change = (loop/period) % 2; + int32_t step = range / period; + int32_t cnt = 0; + if(change) + cnt = loop % period; + else + cnt = period - 1 - loop % period; + + return min + cnt * step; +} + + // calc expression value like 10*sin(x) + 100 -float calc_expr_value(Field *field, int32_t angle) { +float calc_expr_value(Field *field, int32_t angle, int32_t loop) { float radian = ATOR(angle); float funVal = 0; + if (field->funType == FUNTYPE_SIN) funVal = sin(radian); else if (field->funType == FUNTYPE_COS) funVal = cos(radian); - - float val = field->multiple * funVal + field->addend; - if (field->random >0) { + else if (field->funType == FUNTYPE_COUNT) + funVal = (float)funCount(field->min, field->max, field->step, loop); + else if (field->funType == FUNTYPE_SAW) + funVal = (float)funSaw(field->min, field->max, field->period, loop + field->offset ); + else if (field->funType == FUNTYPE_SQUARE) + funVal = (float)funSquare(field->min, field->max, field->period, loop + field->offset); + else if (field->funType == FUNTYPE_TRI) + funVal = (float)funTriAngle(field->min, field->max, field->period, loop + field->offset); + + if(field->multiple != 0) + funVal *= field->multiple; + + if ( field->addend !=0 && field->random > 0 ) { float rate = taosRandom() % field->random; - val += field->addend * (rate/100); + funVal += field->addend * (rate/100); + } else if(field->addend !=0 ) { + funVal += field->addend; } - return val; + return funVal; } @@ -387,11 +437,11 @@ static int tmpStr(char *tmp, int iface, Field *field, int i) { return 0; } -FORCE_INLINE double tmpDoubleImpl(Field *field, int32_t angle) { +FORCE_INLINE double tmpDoubleImpl(Field *field, int32_t angle, int32_t loop) { double doubleTmp = (double)(field->min); if(field->funType != FUNTYPE_NONE) { - doubleTmp = calc_expr_value(field, angle); + doubleTmp = calc_expr_value(field, angle, loop); } else if (field->max != field->min) { doubleTmp += ((taosRandom() % (field->max - field->min)) + @@ -463,10 +513,10 @@ FORCE_INLINE uint16_t tmpUint16(Field *field) { return usmallintTmp; } -FORCE_INLINE int64_t tmpInt64Impl(Field *field, int32_t angle) { +FORCE_INLINE int64_t tmpInt64Impl(Field *field, int32_t angle, int32_t loop) { int64_t bigintTmp = field->min; if(field->funType != FUNTYPE_NONE) { - bigintTmp = calc_expr_value(field, angle); + bigintTmp = calc_expr_value(field, angle, loop); } else if (field->min != field->max) { bigintTmp += (taosRandom() % (field->max - field->min)); } @@ -486,10 +536,10 @@ FORCE_INLINE float tmpFloat(Field *field) { return floatTmp; } -static float tmpFloatImpl(Field *field, int i, int32_t angle) { +static float tmpFloatImpl(Field *field, int i, int32_t angle, int32_t loop) { float floatTmp = (float)field->min; if(field->funType != FUNTYPE_NONE) { - floatTmp = calc_expr_value(field, angle); + floatTmp = calc_expr_value(field, angle, loop); } else { if (field->max != field->min) { floatTmp += ((taosRandom() % @@ -511,11 +561,11 @@ static float tmpFloatI(Field *field, int i) { return tmpFloatImpl(field, i, 0); } -static int tmpInt32Impl(Field *field, int i, int angle) { +static int tmpInt32Impl(Field *field, int i, int angle, int32_t loop) { int intTmp; if (field->funType != FUNTYPE_NONE) { // calc from function - intTmp = calc_expr_value(field, angle); + intTmp = calc_expr_value(field, angle, loop); } else if ((g_arguments->demo_mode) && (i == 0)) { unsigned int tmpRand = taosRandom(); intTmp = tmpRand % 10 + 1; @@ -660,13 +710,13 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf, break; } case TSDB_DATA_TYPE_INT: { - int32_t intTmp = tmpInt32Impl(field, i, angle); + int32_t intTmp = tmpInt32Impl(field, i, angle, k); n = snprintf(sampleDataBuf + pos, bufLen - pos, "%d,", intTmp); break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t bigintTmp = tmpInt64Impl(field, angle); + int64_t bigintTmp = tmpInt64Impl(field, angle, k); n = snprintf(sampleDataBuf + pos, bufLen - pos, "%"PRId64",", bigintTmp); break; @@ -685,13 +735,13 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf, break; } case TSDB_DATA_TYPE_FLOAT: { - float floatTmp = tmpFloatImpl(field, i, angle); + float floatTmp = tmpFloatImpl(field, i, angle, k); n = snprintf(sampleDataBuf + pos, bufLen - pos, "%f,", floatTmp); break; } case TSDB_DATA_TYPE_DOUBLE: { - double double_ = tmpDoubleImpl(field, angle); + double double_ = tmpDoubleImpl(field, angle, k); n = snprintf(sampleDataBuf + pos, bufLen - pos, "%f,", double_); break; diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 535d960b..6dcf7012 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -17,16 +17,67 @@ extern char g_configDir[MAX_PATH_LEN]; char funsName [FUNTYPE_CNT] [32] = { "sin(", - "cos(" + "cos(", + "count(", + "saw(", + "square(", + "tri(", }; -uint8_t parseFuns(char* funValue, float* multiple, int32_t* addend, int32_t* random) { +bool parseFunArgs(char* value, uint8_t funType, int32_t* min ,int32_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { + char* buf = strdup(value); + char* p[4] = {NULL}; + int i = 0; + // find ")" fun end brance + char* end = strstr(buf,")"); + if(end) { + *end = 0; + } + + // find first + char* token = strtok(buf, ","); + if(token == NULL) { + free(buf); + return false; + } + p[i++] = token; + + // find others + while(token = strtok(NULL, ",") && i < 4) { + p[i++] = token; + } + + if(i != 4) { + // must 4 params + free(buf); + return false; + } + + // parse fun + if(funType == FUNTYPE_COUNT) { + *min = atoi(p[1]); + *max = atoi(p[2]); + *step = atoi(p[3]); + *offset = atoi(p[4]); + } else { + *min = atoi(p[1]); + *max = atoi(p[2]); + *period = atoi(p[3]); + *offset = atoi(p[4]); + } + + free(buf) + return true; +} + +uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, + int32_t* min ,int32_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { // check valid - if (funValue == NULL || multiple == NULL || addend == NULL) { + if (expr == NULL || multiple == NULL || addend == NULL) { return FUNTYPE_NONE; } - size_t len = strlen(funValue); + size_t len = strlen(expr); if(len > 100) { return FUNTYPE_NONE; } @@ -34,9 +85,10 @@ uint8_t parseFuns(char* funValue, float* multiple, int32_t* addend, int32_t* ran //parse format 10*sin(x) + 100 * random(5) char value[128]; size_t n = 0; + // remove blank for (size_t i = 0; i < len; i++) { - if (funValue[i] != ' ') { - value[n++] = funValue[i]; + if (expr[i] != ' ') { + value[n++] = expr[i]; } } // set end @@ -44,10 +96,13 @@ uint8_t parseFuns(char* funValue, float* multiple, int32_t* addend, int32_t* ran // multiple char* key1 = strstr(value, "*"); - if(key1 == NULL) return FUNTYPE_NONE; - *key1 = 0; - * multiple = atof(value); - key1 += 1; + if(key1) { + *key1 = 0; + *multiple = atof(value); + key1 += 1; + } else { + key1 = value; + } // funType uint8_t funType = FUNTYPE_NONE; @@ -57,6 +112,10 @@ uint8_t parseFuns(char* funValue, float* multiple, int32_t* addend, int32_t* ran if(key2) { funType = i + 1; key2 += strlen(funsName[i]); + if(!parseFunArgs(key2, funType, min, max, step, period, offset)){ + return FUNTYPE_NONE; + } + break; } } @@ -110,6 +169,10 @@ static int getColumnAndTagTypeFromInsertJsonFile( float multiple = 0; int32_t addend = 0; int32_t random = 0; + int32_t step = 0; + int32_t period = 0; + int32_t offset = 0; + tools_cJSON *column = tools_cJSON_GetArrayItem(columnsObj, k); if (!tools_cJSON_IsObject(column)) { @@ -152,7 +215,7 @@ static int getColumnAndTagTypeFromInsertJsonFile( // fun tools_cJSON *fun = tools_cJSON_GetObjectItem(column, "fun"); if (tools_cJSON_IsString(fun)) { - funType = parseFuns(fun->valuestring, &multiple, &addend, &random); + funType = parseFuns(fun->valuestring, &multiple, &addend, &random, &min, &max, &step, &period, &offset); } tools_cJSON *dataValues = tools_cJSON_GetObjectItem(column, "values"); @@ -196,6 +259,9 @@ static int getColumnAndTagTypeFromInsertJsonFile( col->multiple = multiple; col->addend = addend; col->random = random; + col->step = step; + col->period = period; + col->offset = offset; if (customName) { if (n >= 1) { From 2d06a006b78630241009101867edd6e5f5f4d36f Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Tue, 17 Oct 2023 16:41:30 +0800 Subject: [PATCH 2/8] feat: submit count saw square tri funtion --- example/insertFuns.json | 84 +++++++++++++++++++++++++++++++++++++++++ example/insertNow.json | 28 +++++++------- inc/bench.h | 1 + src/benchData.c | 53 ++++++++++++++++++++------ src/benchInsert.c | 8 +++- src/benchJsonOpt.c | 52 ++++++++++++++----------- 6 files changed, 177 insertions(+), 49 deletions(-) create mode 100644 example/insertFuns.json diff --git a/example/insertFuns.json b/example/insertFuns.json new file mode 100644 index 00000000..f5b0f8c0 --- /dev/null +++ b/example/insertFuns.json @@ -0,0 +1,84 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "connection_pool_size": 8, + "thread_count": 5, + "create_table_thread_count": 7, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 2000, + "prepared_rand": 10000, + "chinese": "no", + "escape_character": "yes", + "databases": [ + { + "dbinfo": { + "name": "dmeters", + "drop": "yes", + "vgroups": 4, + "duration": "5d", + "keep": "30d", + "pages": 512, + "minrows":5000, + "maxrows":10000, + "stt_trigger":1, + "wal_retention_period": 1, + "wal_retention_size": 10, + "cachemodel": "'both'", + "precision": "ms" + }, + "super_tables": [ + { + "name": "meters", + "child_table_exists": "no", + "childtable_count": 100000, + "childtable_prefix": "d", + "auto_create_table": "no", + "batch_create_tbl_num": 5, + "data_source": "rand", + "insert_mode": "taosc", + "non_stop_mode": "no", + "line_protocol": "line", + "insert_rows": 900000000000000, + "interlace_rows": 1, + "insert_interval": 1000, + "start_timestamp": "now", + "sample_format": "csv", + "sample_file": "./sample.csv", + "use_sample_ts": "no", + "tags_file": "", + "columns": [ + { "type": "FLOAT", "name": "current", "fun": "3*sin(x)+10*random(2)"}, + { "type": "INT", "name": "voltage", "fun": "40*sin(x)+200*random(10)"}, + { "type": "FLOAT", "name": "phase", "fun": "1*sin(x)+1*random(3)"}, + { "type": "INT", "name": "c1", "fun": "count(0,100,1,0)"}, + { "type": "INT", "name": "c2", "fun": "saw(-100,100,20,0)"}, + { "type": "INT", "name": "c3", "fun": "square(0,60,20,10)"}, + { "type": "INT", "name": "c4", "fun": "tri(-20,100,30,10)"} + ], + "tags": [ + { + "type": "TINYINT", + "name": "groupid", + "max": 10, + "min": 1 + }, + { + "name": "location", + "type": "BINARY", + "len": 16, + "values": ["San Francisco", "Los Angles", "San Diego", + "San Jose", "Palo Alto", "Campbell", "Mountain View", + "Sunnyvale", "Santa Clara", "Cupertino"] + } + ] + } + ] + } + ] +} diff --git a/example/insertNow.json b/example/insertNow.json index 8032654d..f5b0f8c0 100644 --- a/example/insertNow.json +++ b/example/insertNow.json @@ -18,17 +18,17 @@ "databases": [ { "dbinfo": { - "name": "smart", + "name": "dmeters", "drop": "yes", "vgroups": 4, - "duration": "10d", - "keep": "100d", + "duration": "5d", + "keep": "30d", "pages": 512, "minrows":5000, "maxrows":10000, "stt_trigger":1, - "wal_retention_period": 10, - "wal_retention_size": 100, + "wal_retention_period": 1, + "wal_retention_size": 10, "cachemodel": "'both'", "precision": "ms" }, @@ -36,7 +36,7 @@ { "name": "meters", "child_table_exists": "no", - "childtable_count": 10000, + "childtable_count": 100000, "childtable_prefix": "d", "auto_create_table": "no", "batch_create_tbl_num": 5, @@ -53,15 +53,13 @@ "use_sample_ts": "no", "tags_file": "", "columns": [ - { - "type": "FLOAT", - "name": "current", - "count": 1, - "max": 12, - "min": 8 - }, - { "type": "INT", "name": "voltage", "max": 225, "min": 215 }, - { "type": "FLOAT", "name": "phase", "max": 1, "min": 0 } + { "type": "FLOAT", "name": "current", "fun": "3*sin(x)+10*random(2)"}, + { "type": "INT", "name": "voltage", "fun": "40*sin(x)+200*random(10)"}, + { "type": "FLOAT", "name": "phase", "fun": "1*sin(x)+1*random(3)"}, + { "type": "INT", "name": "c1", "fun": "count(0,100,1,0)"}, + { "type": "INT", "name": "c2", "fun": "saw(-100,100,20,0)"}, + { "type": "INT", "name": "c3", "fun": "square(0,60,20,10)"}, + { "type": "INT", "name": "c4", "fun": "tri(-20,100,30,10)"} ], "tags": [ { diff --git a/inc/bench.h b/inc/bench.h index 9318e450..05614a8d 100644 --- a/inc/bench.h +++ b/inc/bench.h @@ -966,6 +966,7 @@ typedef struct SThreadInfo_S { char **sml_tags_json_array; char **sml_json_value_array; uint64_t start_time; + uint64_t pos; // point for sampleDataBuff uint64_t max_sql_len; FILE *fp; char filePath[MAX_PATH_LEN]; diff --git a/src/benchData.c b/src/benchData.c index f52a121a..1796e25b 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -71,16 +71,16 @@ int32_t funTriAngle(int32_t min, int32_t max, int32_t period, int32_t loop) { int32_t step = range / period; int32_t cnt = 0; if(change) - cnt = loop % period; + cnt = period - loop % period; else - cnt = period - 1 - loop % period; + cnt = loop % period; return min + cnt * step; } // calc expression value like 10*sin(x) + 100 -float calc_expr_value(Field *field, int32_t angle, int32_t loop) { +float funValueFloat(Field *field, int32_t angle, int32_t loop) { float radian = ATOR(angle); float funVal = 0; @@ -110,6 +110,37 @@ float calc_expr_value(Field *field, int32_t angle, int32_t loop) { return funVal; } +// calc expression value like 10*sin(x) + 100 +int32_t funValueInt32(Field *field, int32_t angle, int32_t loop) { + float radian = ATOR(angle); + int32_t funVal = 0; + + if (field->funType == FUNTYPE_SIN) + funVal = (int32_t)sin(radian); + else if (field->funType == FUNTYPE_COS) + funVal = (int32_t)cos(radian); + else if (field->funType == FUNTYPE_COUNT) + funVal = funCount(field->min, field->max, field->step, loop); + else if (field->funType == FUNTYPE_SAW) + funVal = funSaw(field->min, field->max, field->period, loop + field->offset ); + else if (field->funType == FUNTYPE_SQUARE) + funVal = funSquare(field->min, field->max, field->period, loop + field->offset); + else if (field->funType == FUNTYPE_TRI) + funVal = funTriAngle(field->min, field->max, field->period, loop + field->offset); + + if(field->multiple != 0) + funVal *= field->multiple; + + if ( field->addend !=0 && field->random > 0 ) { + float rate = taosRandom() % field->random; + funVal += field->addend * (rate/100); + } else if(field->addend !=0 ) { + funVal += field->addend; + } + + return funVal; +} + static int usc2utf8(char *p, int unic) { int ret = 0; @@ -441,7 +472,7 @@ FORCE_INLINE double tmpDoubleImpl(Field *field, int32_t angle, int32_t loop) { double doubleTmp = (double)(field->min); if(field->funType != FUNTYPE_NONE) { - doubleTmp = calc_expr_value(field, angle, loop); + doubleTmp = funValueFloat(field, angle, loop); } else if (field->max != field->min) { doubleTmp += ((taosRandom() % (field->max - field->min)) + @@ -451,7 +482,7 @@ FORCE_INLINE double tmpDoubleImpl(Field *field, int32_t angle, int32_t loop) { } FORCE_INLINE double tmpDouble(Field *field) { - return tmpDoubleImpl(field, 0); + return tmpDoubleImpl(field, 0, 0); } @@ -516,7 +547,7 @@ FORCE_INLINE uint16_t tmpUint16(Field *field) { FORCE_INLINE int64_t tmpInt64Impl(Field *field, int32_t angle, int32_t loop) { int64_t bigintTmp = field->min; if(field->funType != FUNTYPE_NONE) { - bigintTmp = calc_expr_value(field, angle, loop); + bigintTmp = funValueInt32(field, angle, loop); } else if (field->min != field->max) { bigintTmp += (taosRandom() % (field->max - field->min)); } @@ -524,7 +555,7 @@ FORCE_INLINE int64_t tmpInt64Impl(Field *field, int32_t angle, int32_t loop) { } FORCE_INLINE int64_t tmpInt64(Field *field) { - return tmpInt64Impl(field, 0); + return tmpInt64Impl(field, 0, 0); } FORCE_INLINE float tmpFloat(Field *field) { @@ -539,7 +570,7 @@ FORCE_INLINE float tmpFloat(Field *field) { static float tmpFloatImpl(Field *field, int i, int32_t angle, int32_t loop) { float floatTmp = (float)field->min; if(field->funType != FUNTYPE_NONE) { - floatTmp = calc_expr_value(field, angle, loop); + floatTmp = funValueFloat(field, angle, loop); } else { if (field->max != field->min) { floatTmp += ((taosRandom() % @@ -558,14 +589,14 @@ static float tmpFloatImpl(Field *field, int i, int32_t angle, int32_t loop) { } static float tmpFloatI(Field *field, int i) { - return tmpFloatImpl(field, i, 0); + return tmpFloatImpl(field, i, 0, 0); } static int tmpInt32Impl(Field *field, int i, int angle, int32_t loop) { int intTmp; if (field->funType != FUNTYPE_NONE) { // calc from function - intTmp = calc_expr_value(field, angle, loop); + intTmp = funValueInt32(field, angle, loop); } else if ((g_arguments->demo_mode) && (i == 0)) { unsigned int tmpRand = taosRandom(); intTmp = tmpRand % 10 + 1; @@ -587,7 +618,7 @@ static int tmpInt32Impl(Field *field, int i, int angle, int32_t loop) { } static int tmpInt32(Field *field, int i) { - return tmpInt32Impl(field, i, 0); + return tmpInt32Impl(field, i, 0, 0); } static int tmpJson(char *sampleDataBuf, diff --git a/src/benchInsert.c b/src/benchInsert.c index 06440d30..6b66ff64 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -1449,7 +1449,6 @@ static void *syncWriteInterlace(void *sarg) { int64_t insertRows = stbInfo->insertRows; int32_t interlaceRows = stbInfo->interlaceRows; - int64_t pos = 0; uint32_t batchPerTblTimes = g_arguments->reqPerReq / interlaceRows; uint64_t lastPrintTime = toolsGetTimestampMs(); uint64_t lastTotalInsertRows = 0; @@ -1469,6 +1468,7 @@ static void *syncWriteInterlace(void *sarg) { goto free_of_interlace; } int64_t timestamp = pThreadInfo->start_time; + int64_t pos = pThreadInfo->pos; SChildTable *childTbl = stbInfo->childTblArray[tableSeq]; char * tableName = stbInfo->childTblArray[tableSeq]->name; @@ -1555,6 +1555,7 @@ static void *syncWriteInterlace(void *sarg) { } generated++; pos++; + //printf(" interlace pos=%" PRId64 " j=%" PRId64" timestamp=%"PRId64" tableName=%s tableSeq=%"PRIu64" \n", pos, j, timestamp, tableName, tableSeq); if (pos >= g_arguments->prepared_rand) { pos = 0; } @@ -1646,12 +1647,16 @@ static void *syncWriteInterlace(void *sarg) { break; } } + + // move to next table in one batch tableSeq++; tmp_total_insert_rows += interlaceRows; if (tableSeq > pThreadInfo->end_table_to) { + // one tables loop timestamp and pos add tableSeq = pThreadInfo->start_table_from; pThreadInfo->start_time += interlaceRows * stbInfo->timestamp_step; + pThreadInfo->pos += interlaceRows; if (!stbInfo->non_stop) { insertRows -= interlaceRows; } @@ -2934,6 +2939,7 @@ static int startMultiThreadInsertData(SDataBase* database, pThreadInfo->dbInfo = database; pThreadInfo->stbInfo = stbInfo; pThreadInfo->start_time = stbInfo->startTimestamp; + pThreadInfo->pos = 0; pThreadInfo->totalInsertRows = 0; pThreadInfo->samplePos = 0; #ifdef TD_VER_COMPATIBLE_3_0_0_0 diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 6dcf7012..6cd5e31e 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -24,54 +24,55 @@ char funsName [FUNTYPE_CNT] [32] = { "tri(", }; -bool parseFunArgs(char* value, uint8_t funType, int32_t* min ,int32_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { +int32_t parseFunArgs(char* value, uint8_t funType, int64_t* min ,int64_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { char* buf = strdup(value); char* p[4] = {NULL}; - int i = 0; + int32_t i = 0; // find ")" fun end brance char* end = strstr(buf,")"); if(end) { *end = 0; } + int32_t argsLen = strlen(buf) + 1; // find first char* token = strtok(buf, ","); if(token == NULL) { free(buf); - return false; + return 0; } p[i++] = token; // find others - while(token = strtok(NULL, ",") && i < 4) { + while((token = strtok(NULL, ",")) && i < 4) { p[i++] = token; } if(i != 4) { // must 4 params free(buf); - return false; + return 0; } // parse fun if(funType == FUNTYPE_COUNT) { - *min = atoi(p[1]); - *max = atoi(p[2]); - *step = atoi(p[3]); - *offset = atoi(p[4]); + *min = atoi(p[0]); + *max = atoi(p[1]); + *step = atoi(p[2]); + *offset = atoi(p[3]); } else { - *min = atoi(p[1]); - *max = atoi(p[2]); - *period = atoi(p[3]); - *offset = atoi(p[4]); + *min = atoi(p[0]); + *max = atoi(p[1]); + *period = atoi(p[2]); + *offset = atoi(p[3]); } - free(buf) - return true; + free(buf); + return argsLen; } uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, - int32_t* min ,int32_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { + int64_t* min ,int64_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { // check valid if (expr == NULL || multiple == NULL || addend == NULL) { return FUNTYPE_NONE; @@ -112,9 +113,11 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, if(key2) { funType = i + 1; key2 += strlen(funsName[i]); - if(!parseFunArgs(key2, funType, min, max, step, period, offset)){ + int32_t argsLen = parseFunArgs(key2, funType, min, max, step, period, offset); + if(len <= 0){ return FUNTYPE_NONE; } + key2 += argsLen; break; } @@ -125,17 +128,22 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, char* key3 = strstr(key2, "+"); if(key3) { *addend = atoi(key3 + 1); + key3 += 1; } else { key3 = strstr(key2, "-"); - if(key3) + if(key3) { *addend = atoi(key3 + 1) * -1; + key3 += 1; + } } - key3 += 1; + // random - char* key4 = strstr(key3, "*random("); - if(key4) { - *random = atoi(key4 + 8); + if(key3) { + char* key4 = strstr(key3, "*random("); + if(key4) { + *random = atoi(key4 + 8); + } } return funType; From 27cf8f4d17f0f2bfe2619ca4b9595cc529f99603 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sat, 21 Oct 2023 21:55:53 +0800 Subject: [PATCH 3/8] fix: add base and fix pos --- inc/bench.h | 3 ++- src/benchData.c | 3 +++ src/benchInsert.c | 5 +++-- src/benchJsonOpt.c | 48 ++++++++++++++++++++++++++++++++++++---------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/inc/bench.h b/inc/bench.h index 05614a8d..50180bf5 100644 --- a/inc/bench.h +++ b/inc/bench.h @@ -582,7 +582,8 @@ typedef struct SField { // fun uint8_t funType; float multiple; - int32_t addend; + float addend; + float base; int32_t random; int32_t period; diff --git a/src/benchData.c b/src/benchData.c index 1796e25b..310ce0d3 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -107,6 +107,7 @@ float funValueFloat(Field *field, int32_t angle, int32_t loop) { funVal += field->addend; } + funVal += field->base; return funVal; } @@ -138,6 +139,8 @@ int32_t funValueInt32(Field *field, int32_t angle, int32_t loop) { funVal += field->addend; } + funVal += field->base; + return funVal; } diff --git a/src/benchInsert.c b/src/benchInsert.c index 6b66ff64..b5ee71a7 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -1656,7 +1656,8 @@ static void *syncWriteInterlace(void *sarg) { tableSeq = pThreadInfo->start_table_from; pThreadInfo->start_time += interlaceRows * stbInfo->timestamp_step; - pThreadInfo->pos += interlaceRows; + // save + pThreadInfo->pos = pos; if (!stbInfo->non_stop) { insertRows -= interlaceRows; } @@ -2229,7 +2230,7 @@ void *syncWriteProgressive(void *sarg) { switch (stbInfo->iface) { case TAOSC_IFACE: case REST_IFACE: - generated = prepareProgressDataSql( + generated = b( pThreadInfo, childTbl, tableSeq, diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 6cd5e31e..5ef10f63 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -71,10 +71,10 @@ int32_t parseFunArgs(char* value, uint8_t funType, int64_t* min ,int64_t* max, i return argsLen; } -uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, +uint8_t parseFuns(char* expr, float* multiple, float* addend, float* base, int32_t* random, int64_t* min ,int64_t* max, int32_t* step ,int32_t* period ,int32_t* offset) { // check valid - if (expr == NULL || multiple == NULL || addend == NULL) { + if (expr == NULL || multiple == NULL || addend == NULL || base == NULL) { return FUNTYPE_NONE; } @@ -98,9 +98,22 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, // multiple char* key1 = strstr(value, "*"); if(key1) { - *key1 = 0; - *multiple = atof(value); - key1 += 1; + // excpet tri(-20,40,20,5)+20+50*random(12) + bool found = true; + char* p1 = strstr(value+1, "+"); + char* p2 = strstr(value+1, "-"); + if(p1 && key1 > p1 ) + found = false; + if(p2 && key1 > p2 ) + found = false; + + if(found) { + *key1 = 0; + *multiple = atof(value); + key1 += 1; + } else { + key1 = value; + } } else { key1 = value; } @@ -108,7 +121,7 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, // funType uint8_t funType = FUNTYPE_NONE; char* key2 = NULL; - for(int i=0; i < FUNTYPE_CNT; i++) { + for (int i = 0; i < FUNTYPE_CNT - 1; i++) { key2 = strstr(key1, funsName[i]); if(key2) { funType = i + 1; @@ -127,12 +140,12 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, char* key3 = strstr(key2, "+"); if(key3) { - *addend = atoi(key3 + 1); + *addend = atof(key3 + 1); key3 += 1; } else { key3 = strstr(key2, "-"); if(key3) { - *addend = atoi(key3 + 1) * -1; + *addend = atof(key3 + 1) * -1; key3 += 1; } } @@ -143,6 +156,19 @@ uint8_t parseFuns(char* expr, float* multiple, int32_t* addend, int32_t* random, char* key4 = strstr(key3, "*random("); if(key4) { *random = atoi(key4 + 8); + key3 += 9; + } + } + + // base + if(key3) { + char* key5 = strstr(key3, "+"); + if(key5){ + *base = atof(key5+1); + } else { + key5 = strstr(key3, "-"); + if(key5) + *base = atof(key5+1) * -1; } } @@ -175,7 +201,8 @@ static int getColumnAndTagTypeFromInsertJsonFile( // fun type uint8_t funType = FUNTYPE_NONE; float multiple = 0; - int32_t addend = 0; + float addend = 0; + float base = 0; int32_t random = 0; int32_t step = 0; int32_t period = 0; @@ -223,7 +250,7 @@ static int getColumnAndTagTypeFromInsertJsonFile( // fun tools_cJSON *fun = tools_cJSON_GetObjectItem(column, "fun"); if (tools_cJSON_IsString(fun)) { - funType = parseFuns(fun->valuestring, &multiple, &addend, &random, &min, &max, &step, &period, &offset); + funType = parseFuns(fun->valuestring, &multiple, &addend, &base, &random, &min, &max, &step, &period, &offset); } tools_cJSON *dataValues = tools_cJSON_GetObjectItem(column, "values"); @@ -266,6 +293,7 @@ static int getColumnAndTagTypeFromInsertJsonFile( col->funType = funType; col->multiple = multiple; col->addend = addend; + col->base = base; col->random = random; col->step = step; col->period = period; From 1641f72c39deeaa07c47ffc9796005a139f18e88 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 22 Oct 2023 13:59:07 +0800 Subject: [PATCH 4/8] fix: add partialColFrom --- inc/bench.h | 1 + src/benchData.c | 23 ++++++++++++++++++----- src/benchInsert.c | 2 +- src/benchInsertMix.c | 15 ++++++++++++--- src/benchJsonOpt.c | 7 +++++++ 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/inc/bench.h b/inc/bench.h index 50180bf5..077044ca 100644 --- a/inc/bench.h +++ b/inc/bench.h @@ -700,6 +700,7 @@ typedef struct SSuperTable_S { char sampleFile[MAX_FILE_NAME_LEN]; char tagsFile[MAX_FILE_NAME_LEN]; uint32_t partialColNum; + uint32_t partialColFrom; char *partialColNameBuf; BArray *cols; BArray *tags; diff --git a/src/benchData.c b/src/benchData.c index 310ce0d3..e07b685b 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -1598,9 +1598,17 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { if (stbInfo->partialColNum != 0 && ((stbInfo->iface == TAOSC_IFACE || stbInfo->iface == REST_IFACE))) { - if (stbInfo->partialColNum > stbInfo->cols->size) { - stbInfo->partialColNum = stbInfo->cols->size; - } else { + // check valid + if(stbInfo->partialColFrom >= stbInfo->cols->size) { + stbInfo->partialColFrom = 0; + infoPrint("stbInfo->partialColFrom(%d) is large than stbInfo->cols->size(%d) \n ",stbInfo->partialColFrom,stbInfo->cols->size); + } + + if (stbInfo->partialColFrom + stbInfo->partialColNum > stbInfo->cols->size) { + stbInfo->partialColNum = stbInfo->cols->size - stbInfo->partialColFrom ; + } + + if(stbInfo->partialColNum < stbInfo->cols->size) stbInfo->partialColNameBuf = benchCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN, true); int pos = 0; @@ -1614,7 +1622,7 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { } else { pos += n; } - for (int i = 0; i < stbInfo->partialColNum; ++i) { + for (int i = stbInfo->partialColFrom; i < stbInfo->partialColNum; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); n = snprintf(stbInfo->partialColNameBuf+pos, TSDB_MAX_ALLOWED_SQL_LEN - pos, @@ -1626,8 +1634,13 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { pos += n; } } - for (int i = 0; i < stbInfo->partialColNum; ++i) { + + // first part set noen + for (int i = 0; i < =stbInfo->partialColFrom; ++i) { + Field * col = benchArrayGet(stbInfo->cols, i); + col->none = true; } + // last part set none for (int i = stbInfo->partialColNum; i < stbInfo->cols->size; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); col->none = true; diff --git a/src/benchInsert.c b/src/benchInsert.c index b5ee71a7..76ac89ad 100644 --- a/src/benchInsert.c +++ b/src/benchInsert.c @@ -2230,7 +2230,7 @@ void *syncWriteProgressive(void *sarg) { switch (stbInfo->iface) { case TAOSC_IFACE: case REST_IFACE: - generated = b( + generated = prepareProgressDataSql( pThreadInfo, childTbl, tableSeq, diff --git a/src/benchInsertMix.c b/src/benchInsertMix.c index 55d74dd3..e06829d6 100644 --- a/src/benchInsertMix.c +++ b/src/benchInsertMix.c @@ -219,10 +219,19 @@ uint32_t genInsertPreSql(threadInfo* info, SDataBase* db, SSuperTable* stb, char // new mix rule int32_t max = stb->cols->size > MAX_BATCOLS ? MAX_BATCOLS : stb->cols->size; - info->nBatCols = RD(max) + 1; - // random select cnt elements from max - randomFillCols(info->batCols, max, info->nBatCols); + if(stb->partialColNum > 0 && stb->partialColNum < MAX_BATCOLS) { + info->nBatCols = stb->partialColNum; + int j = 0; + for (int i = stb->partialColFrom; i < stb->partialColFrom + stb->partialColNum; i++) { + info->batCols[j++] = i; + } + } else { + info->nBatCols = RD(max) + 1; + // random select cnt elements from max + randomFillCols(info->batCols, max, info->nBatCols); + } + char * colNames = genBatColsNames(info, stb); len = snprintf(pstr, TSDB_MAX_ALLOWED_SQL_LEN, "%s %s.%s (%s) VALUES ", STR_INSERT_INTO, db->dbName, tableName, colNames); free(colNames); diff --git a/src/benchJsonOpt.c b/src/benchJsonOpt.c index 5ef10f63..8f046b74 100644 --- a/src/benchJsonOpt.c +++ b/src/benchJsonOpt.c @@ -676,6 +676,7 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) { superTable->insert_interval = g_arguments->insert_interval; superTable->max_sql_len = TSDB_MAX_ALLOWED_SQL_LEN; superTable->partialColNum = 0; + superTable->partialColFrom = 0; superTable->comment = NULL; superTable->delay = -1; superTable->file_factor = -1; @@ -1087,6 +1088,12 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) { superTable->partialColNum = pPartialColNum->valueint; } + tools_cJSON *pPartialColFrom = + tools_cJSON_GetObjectItem(stbInfo, "partial_col_from"); + if (tools_cJSON_IsNumber(pPartialColFrom)) { + superTable->partialColFrom = pPartialColFrom->valueint; + } + if (g_arguments->taosc_version == 3) { tools_cJSON *delay = tools_cJSON_GetObjectItem(stbInfo, "delay"); if (tools_cJSON_IsNumber(delay)) { From 98d65ce9013698b5363a4751bb0dc68748e62dff Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 22 Oct 2023 14:39:30 +0800 Subject: [PATCH 5/8] fix: build error --- src/benchData.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/benchData.c b/src/benchData.c index e07b685b..bc069812 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -1601,14 +1601,14 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { // check valid if(stbInfo->partialColFrom >= stbInfo->cols->size) { stbInfo->partialColFrom = 0; - infoPrint("stbInfo->partialColFrom(%d) is large than stbInfo->cols->size(%d) \n ",stbInfo->partialColFrom,stbInfo->cols->size); + infoPrint("stbInfo->partialColFrom(%d) is large than stbInfo->cols->size(%"PRIu64") \n ",stbInfo->partialColFrom,stbInfo->cols->size); } if (stbInfo->partialColFrom + stbInfo->partialColNum > stbInfo->cols->size) { stbInfo->partialColNum = stbInfo->cols->size - stbInfo->partialColFrom ; } - if(stbInfo->partialColNum < stbInfo->cols->size) + if(stbInfo->partialColNum < stbInfo->cols->size) { stbInfo->partialColNameBuf = benchCalloc(1, TSDB_MAX_ALLOWED_SQL_LEN, true); int pos = 0; @@ -1622,7 +1622,7 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { } else { pos += n; } - for (int i = stbInfo->partialColFrom; i < stbInfo->partialColNum; ++i) { + for (int i = stbInfo->partialColFrom; i < stbInfo->partialColFrom + stbInfo->partialColNum; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); n = snprintf(stbInfo->partialColNameBuf+pos, TSDB_MAX_ALLOWED_SQL_LEN - pos, @@ -1636,12 +1636,12 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { } // first part set noen - for (int i = 0; i < =stbInfo->partialColFrom; ++i) { + for (uint32_t i = 0; i <= stbInfo->partialColFrom; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); col->none = true; } // last part set none - for (int i = stbInfo->partialColNum; i < stbInfo->cols->size; ++i) { + for (uint32_t i = stbInfo->partialColFrom + stbInfo->partialColNum; i < stbInfo->cols->size; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); col->none = true; } From ee3206300572157498b8fad8c7f4e98675d5853a Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 22 Oct 2023 14:55:07 +0800 Subject: [PATCH 6/8] fix: partialColFrom ok --- example/insertFuns.json | 11 ++++++----- src/benchData.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/example/insertFuns.json b/example/insertFuns.json index f5b0f8c0..d9dfe7ca 100644 --- a/example/insertFuns.json +++ b/example/insertFuns.json @@ -47,6 +47,8 @@ "insert_rows": 900000000000000, "interlace_rows": 1, "insert_interval": 1000, + "partial_col_num": 2, + "partial_col_from": 3, "start_timestamp": "now", "sample_format": "csv", "sample_file": "./sample.csv", @@ -56,11 +58,10 @@ { "type": "FLOAT", "name": "current", "fun": "3*sin(x)+10*random(2)"}, { "type": "INT", "name": "voltage", "fun": "40*sin(x)+200*random(10)"}, { "type": "FLOAT", "name": "phase", "fun": "1*sin(x)+1*random(3)"}, - { "type": "INT", "name": "c1", "fun": "count(0,100,1,0)"}, - { "type": "INT", "name": "c2", "fun": "saw(-100,100,20,0)"}, - { "type": "INT", "name": "c3", "fun": "square(0,60,20,10)"}, - { "type": "INT", "name": "c4", "fun": "tri(-20,100,30,10)"} - ], + { "type": "INT", "name": "c1", "fun": "count(0,100,1,0) + 100"}, + { "type": "INT", "name": "c2", "fun": "saw(-100,100,20,0) + 1000"}, + { "type": "float", "name": "c3", "fun": "square(0,50,10,3)+20+ 80"}, + { "type": "INT", "name": "c4", "fun": "tri(-20,40,20,5)+50*random(12)+ 10000"} ], "tags": [ { "type": "TINYINT", diff --git a/src/benchData.c b/src/benchData.c index bc069812..664ea985 100644 --- a/src/benchData.c +++ b/src/benchData.c @@ -1636,7 +1636,7 @@ int prepareSampleData(SDataBase* database, SSuperTable* stbInfo) { } // first part set noen - for (uint32_t i = 0; i <= stbInfo->partialColFrom; ++i) { + for (uint32_t i = 0; i < stbInfo->partialColFrom; ++i) { Field * col = benchArrayGet(stbInfo->cols, i); col->none = true; } From 7800246fd61fd7037291beac1b6e2b3c9a94208e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sun, 22 Oct 2023 15:00:32 +0800 Subject: [PATCH 7/8] feat: partialColFrom and new function completed --- example/insertFuns.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/insertFuns.json b/example/insertFuns.json index d9dfe7ca..024abbab 100644 --- a/example/insertFuns.json +++ b/example/insertFuns.json @@ -60,8 +60,8 @@ { "type": "FLOAT", "name": "phase", "fun": "1*sin(x)+1*random(3)"}, { "type": "INT", "name": "c1", "fun": "count(0,100,1,0) + 100"}, { "type": "INT", "name": "c2", "fun": "saw(-100,100,20,0) + 1000"}, - { "type": "float", "name": "c3", "fun": "square(0,50,10,3)+20+ 80"}, - { "type": "INT", "name": "c4", "fun": "tri(-20,40,20,5)+50*random(12)+ 10000"} ], + { "type": "float", "name": "c3", "fun": "square(0,50,10,3)+20+ 80"}, + { "type": "INT", "name": "c4", "fun": "tri(-20,40,20,5)+50*random(12)+ 10000"} ], "tags": [ { "type": "TINYINT", From 09e24972085abc61fb7b54eaec568deeca930280 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 23 Oct 2023 14:23:00 +0800 Subject: [PATCH 8/8] fix: remove no support platform --- .github/workflows/2.x-aarch64.yml | 2 +- .github/workflows/3.0-alpine.yml | 123 ------------ .github/workflows/3.0-archlinux-release.yml | 206 -------------------- .github/workflows/3.0-non-x64.yml | 4 +- 4 files changed, 2 insertions(+), 333 deletions(-) delete mode 100644 .github/workflows/3.0-alpine.yml delete mode 100644 .github/workflows/3.0-archlinux-release.yml diff --git a/.github/workflows/2.x-aarch64.yml b/.github/workflows/2.x-aarch64.yml index eaae6533..6aa9feca 100644 --- a/.github/workflows/2.x-aarch64.yml +++ b/.github/workflows/2.x-aarch64.yml @@ -140,7 +140,7 @@ jobs: distro: ubuntu22.04 run: | apt update -y > /dev/null - apt install git cmake build-essential libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config -y > /dev/null + apt install git cmake build-essential libexpat1-dev libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config -y > /dev/null cd TDengine mkdir debug ||: diff --git a/.github/workflows/3.0-alpine.yml b/.github/workflows/3.0-alpine.yml deleted file mode 100644 index 77101f60..00000000 --- a/.github/workflows/3.0-alpine.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: Alpine (3.0 alpine) - -on: - schedule: - - cron: "10 16 * * *" - push: - branches: - - develop - - 3.0 - - main - pull_request: - branches: - - develop - - 3.0 - - main - -env: - TOOLS_BUILD_TYPE: Release - PR_NUMBER: ${{ github.event.number }} - -jobs: - check-changed: - runs-on: ubuntu-latest - outputs: - changedflag: ${{ steps.changedflag.outputs.changedflag }} - steps: - - name: Step that prints name of pull request's base branch - run: | - echo "Pull request's base branch is: ${BASE_BRANCH}" - echo "Pull request's branch is: ${GITHUB_REF##*/}" - echo "Pull request's head ref is: ${GITHUB_HEAD_REF}" - env: - BASE_BRANCH: ${{ github.base_ref }} - if: github.event_name == 'pull_request' - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v23.2 - - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" - done - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v23.2 - with: - files: | - src/* - inc/* - deps/CMakeLists.txt - .github/workflows/3.0-alpine.yml - - - name: Run step if any of the listed files above change - id: changedflag - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - echo "One or more files listed above has changed." > ~/changed.log - echo "::set-output name=changedflag::true" - - build: - runs-on: ubuntu-latest - needs: check-changed - - steps: - - name: Step that prints name of pull request's base branch - run: | - echo ${{needs.check-changed.outputs.changedflag}} - echo "Pull request's base branch is: ${BASE_BRANCH}" - echo "Pull request's branch is: ${GITHUB_REF##*/}" - echo "Pull request's head ref is: ${GITHUB_HEAD_REF}" - env: - BASE_BRANCH: ${{ github.base_ref }} - if: github.event_name == 'pull_request' - - - name: setup Alpine - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - uses: jirutka/setup-alpine@v1 - - - - name: Run script inside Alpine chroot as root - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - run: | - cat /etc/alpine-release - apk add argp-standalone bash curl cmake gcc g++ git go procps lsof make valgrind linux-headers libunwind libunwind-dev tzdata wget jansson-dev snappy-dev xz-dev zlib-dev - shell: alpine.sh --root {0} - - - name: Build & Install TDengine - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - shell: alpine.sh --root {0} - run: | - git clone --branch ${{ github.event.pull_request.base.ref }} --depth 1 https://github.com/taosdata/TDengine > /dev/null || exit 1 - cd TDengine && mkdir debug && cd debug && cmake .. -DBUILD_TOOLS=true -DTOOLS_BUILD_TYPE=${{env.TOOLS_BUILD_TYPE}} -DBUILD_HTTP=false && make -j2 && make install - if [[ ! -f /usr/local/taos/bin/taosd ]] || [[ ! -f /usr/local/taos/bin/taos ]] - then - echo "TDengien build failure" - exit 1 - fi - - if [[ ! -f /usr/local/taos/bin/taosdump ]] || [[ ! -f /usr/local/taos/bin/taosBenchmark ]] - then - echo "taos-tools build failure" - exit 1 - fi - diff --git a/.github/workflows/3.0-archlinux-release.yml b/.github/workflows/3.0-archlinux-release.yml deleted file mode 100644 index 9b31a57e..00000000 --- a/.github/workflows/3.0-archlinux-release.yml +++ /dev/null @@ -1,206 +0,0 @@ -name: Arch Linux (3.0 release build) - -on: - schedule: - - cron: "10 16 * * *" - push: - branches: - - develop - - 3.0 - - main - pull_request: - branches: - - develop - - 3.0 - - main - -env: - TOOLS_BUILD_TYPE: Release - PR_NUMBER: ${{ github.event.number }} - -jobs: - check-changed: - runs-on: ubuntu-latest - outputs: - output1: ${{ steps.step1.outputs.test }} - output2: ${{ steps.step2.outputs.test }} - changedflag: ${{ steps.changedflag.outputs.changedflag }} - steps: - - name: Step that prints name of pull request's base branch - run: | - echo "Pull request's base branch is: ${BASE_BRANCH}" - echo "Pull request's branch is: ${GITHUB_REF##*/}" - echo "Pull request's head ref is: ${GITHUB_HEAD_REF}" - env: - BASE_BRANCH: ${{ github.base_ref }} - if: github.event_name == 'pull_request' - - - name: checkout taos-tools - uses: actions/checkout@v3 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v23.2 - - - name: List all changed files - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - echo "$file was changed" - done - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v23.2 - with: - files: | - src/* - inc/* - deps/CMakeLists.txt - .github/workflows/3.0-archlinux-release.yml - - - name: Run step if any of the listed files above change - id: changedflag - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - echo "One or more files listed above has changed." > ~/changed.log - echo "::set-output name=changedflag::true" - - build: - runs-on: ubuntu-latest - needs: check-changed - container: docker.io/archlinux:latest - - steps: - - name: Step that prints name of pull request's base branch - run: | - echo ${{needs.check-changed.outputs.changedflag}} - echo "Pull request's base branch is: ${BASE_BRANCH}" - echo "Pull request's branch is: ${GITHUB_REF##*/}" - echo "Pull request's head ref is: ${GITHUB_HEAD_REF}" - env: - BASE_BRANCH: ${{ github.base_ref }} - if: github.event_name == 'pull_request' - - - name: install packages for build - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - run: | - pacman -Syu --noconfirm > /dev/null - pacman -Sy git --noconfirm > /dev/null - - - name: Checkout TDengine - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - uses: actions/checkout@v2 - with: - submodules: recursive - repository: 'taosdata/TDengine' - path: 'TDengine' - ref: ${{ github.event.pull_request.base.ref }} - - - name: Change time zone - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - run: | - echo "disable timezone changing" - #timedatectl set-timezone Asia/Shanghai - #date - - - name: Set up Go - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - uses: actions/setup-go@v3 - with: - go-version: 1.17 - - - name: Set up Rust - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - - uses: actions/cache@v3 - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - id: cache-rust - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: ${{ runner.os }}-cargo-${{ steps.setup-rust.outputs.rustc_hash }} - - - name: first build TDengine 3.0 - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - run: | - pacman -Sy --noconfirm gcc make cmake gcc-libs gflags pkg-config python3 python-pip snappy zlib > /dev/null - gcc --version - python3 -m pip install --upgrade pip > /dev/null 2>&1 - cd TDengine && mkdir debug && cd debug && cmake .. -DBUILD_HTTP=false -DWEBSOCKET=true && make -j2 > /dev/null && make install > /dev/null - if [[ ! -f /usr/local/taos/bin/taosd ]] || [[ ! -f /usr/local/taos/bin/taosadapter ]] - then - echo "TDengine build failure" - exit 1 - fi - - - name: checkout taos-tools - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - uses: actions/checkout@v3 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Checkout taos-tools to PR number - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - run: | - git config --global --add safe.directory /__w/taos-tools/taos-tools - git fetch origin +refs/pull/${{env.PR_NUMBER}}/merge - git checkout -qf FETCH_HEAD - - - name: build taos-tools - if: | - (needs.check-changed.outputs.changedflag == 'true' - && github.event_name == 'pull_request') - || github.event_name == 'push' - || github.event_name == 'schedule' - run: | - mkdir debug ||: - cd debug - cmake .. -DTOOLS_BUILD_TYPE=${{env.TOOLS_BUILD_TYPE}} -DWEBSOCKET=true > /dev/null - make -j8 > /dev/null && make install > /dev/null - if [[ ! -f /usr/local/taos/bin/taosdump ]] || [[ ! -f /usr/local/taos/bin/taosBenchmark ]] - then - echo "taos-tools build failure" - exit 1 - fi diff --git a/.github/workflows/3.0-non-x64.yml b/.github/workflows/3.0-non-x64.yml index 6ba0881a..4893e6a7 100644 --- a/.github/workflows/3.0-non-x64.yml +++ b/.github/workflows/3.0-non-x64.yml @@ -9,12 +9,10 @@ on: # Triggers the workflow on push or pull request events but only for the develop branch push: branches: - - develop - 3.0 - main pull_request: branches: - - develop - 3.0 - main @@ -140,7 +138,7 @@ jobs: run: | echo "Install packages on ${{ steps.setup.outputs.uname }}" apt update -y > /dev/null - apt install -y cmake build-essential git libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config libssl-dev > /dev/null + apt install -y cmake libexpat1-dev build-essential git libjansson-dev libsnappy-dev liblzma-dev libz-dev zlib1g pkg-config libssl-dev > /dev/null apt install libgflags2.2 libgflags-dev -y > /dev/null echo "clone TDengine ${{ github.event.pull_request.base.ref }} on ${{ steps.setup.outputs.uname }}"