From ea5d925c50f3eaefd35c4eb22e8388da43a939c8 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 10 Feb 2023 13:00:55 +0800 Subject: [PATCH] fix: alpine support (#19353) * fix: alpine support * fix: ostimer thread_id * fix: taosPrintTrace and tsStreamMax * fix: make_install.sh and dnodes.py for alpine * fix: cmake.platform and cut option for alpine * fix: timer sigev and string convert * fix: test case for alpine * fix: fix test script for alpine * fix: fix test script for alpine * fix: fix taosLogTrace for Alpine * fix: fix taosSort * fix: vnode and mnode compare functions and test cases * fix: sorting algorithms and unit tests * fix: libtaosws.so build error on Alpine * fix: libtaosws.so build error on Alpine --------- Co-authored-by: t_max <1172915550@qq.com> --- cmake/cmake.platform | 15 ++ cmake/taosws_CMakeLists.txt.in | 2 +- include/os/os.h | 4 + include/os/osSysinfo.h | 7 + include/os/osSystem.h | 254 ++++++++++++------ include/os/osThread.h | 6 +- packaging/tools/make_install.sh | 4 +- source/common/src/tglobal.c | 2 + source/dnode/mnode/impl/src/mndVgroup.c | 16 +- source/os/CMakeLists.txt | 4 + source/os/src/osMath.c | 4 +- source/os/src/osMemory.c | 2 +- source/os/src/osString.c | 14 +- source/os/src/osSysinfo.c | 2 +- source/os/src/osTimer.c | 4 +- tests/pytest/util/dnodes.py | 64 +++-- tests/requirements.txt | 4 + tests/script/sh/cfg.sh | 6 +- tests/script/sh/checkAsan.sh | 12 + tests/script/sh/clear.sh | 6 +- tests/script/sh/deploy.sh | 6 +- tests/script/sh/exec-default.sh | 6 +- tests/script/sh/exec-no-random-fail.sh | 6 +- tests/script/sh/exec-random-fail.sh | 6 +- tests/script/sh/exec.sh | 19 +- tests/script/sh/exec_tarbitrator.sh | 6 +- tests/script/sh/mv_old_data.sh | 6 +- tests/script/test.sh | 6 +- tests/script/tsim/dnode/balance3.sim | 14 +- tests/script/tsim/dnode/balancex.sim | 4 +- tests/script/tsim/dnode/drop_dnode_force.sim | 26 +- tests/script/tsim/dnode/vnode_clean.sim | 4 +- tests/script/tsim/scalar/tsConvert.sim | 2 +- tests/system-test/0-others/compatibility.py | 4 + tests/system-test/2-query/irate.py | 2 +- tests/system-test/6-cluster/5dnode1mnode.py | 4 +- tests/system-test/7-tmq/tmq3mnodeSwitch.py | 4 +- ...sFromTsdb1-mutilVg-mutilCtb-funcNFilter.py | 2 +- tests/system-test/pytest.sh | 91 ++++--- tools/CMakeLists.txt | 58 ++-- tools/shell/CMakeLists.txt | 10 +- tools/shell/src/shellArguments.c | 4 + 42 files changed, 452 insertions(+), 270 deletions(-) diff --git a/cmake/cmake.platform b/cmake/cmake.platform index a4bfcaf609..61eb66f675 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -37,6 +37,21 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin SET(TD_LINUX_32 TRUE) ENDIF () + EXECUTE_PROCESS(COMMAND chmod 777 ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh) + EXECUTE_PROCESS(COMMAND readlink /bin/sh OUTPUT_VARIABLE SHELL_LINK) + MESSAGE(STATUS "The shell is: " ${SHELL_LINK}) + + IF (${SHELL_LINK} MATCHES "dash") + EXECUTE_PROCESS(COMMAND ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) + ELSE () + EXECUTE_PROCESS(COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/../packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO) + ENDIF () + MESSAGE(STATUS "The current OS is " ${TD_OS_INFO}) + IF (${TD_OS_INFO} MATCHES "Alpine") + SET(TD_ALPINE TRUE) + ADD_DEFINITIONS("-D_ALPINE") + ENDIF () + ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") SET(TD_DARWIN TRUE) diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in index e79c6b799f..b013d45911 100644 --- a/cmake/taosws_CMakeLists.txt.in +++ b/cmake/taosws_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosws-rs ExternalProject_Add(taosws-rs GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git - GIT_TAG f406d51 + GIT_TAG main SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/include/os/os.h b/include/os/os.h index 809b814491..309a977ff6 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -27,7 +27,11 @@ extern "C" { #if !defined(WINDOWS) #include + +#if !defined(_ALPINE) #include +#endif + #include #include #include diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index dbe4d6801e..a8ccb67bfb 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -60,6 +60,13 @@ void taosSetCoreDump(bool enable); #endif // WINDOWS +#if defined(_ALPINE) + +#define _UTSNAME_LENGTH 65 +#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH + +#endif + typedef struct { char sysname[_UTSNAME_MACHINE_LENGTH]; char nodename[_UTSNAME_MACHINE_LENGTH]; diff --git a/include/os/osSystem.h b/include/os/osSystem.h index 5154c56e4b..ba9f137b40 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -16,6 +16,11 @@ #ifndef _TD_OS_SYSTEM_H_ #define _TD_OS_SYSTEM_H_ +#ifdef _ALPINE +#define UNW_LOCAL_ONLY +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -29,46 +34,124 @@ extern "C" { #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #endif -typedef struct TdCmd* TdCmdPtr; +typedef struct TdCmd *TdCmdPtr; -TdCmdPtr taosOpenCmd(const char* cmd); -int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf); -int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf); -int32_t taosEOFCmd(TdCmdPtr pCmd); -int64_t taosCloseCmd(TdCmdPtr* ppCmd); +TdCmdPtr taosOpenCmd(const char *cmd); -void* taosLoadDll(const char* filename); -void* taosLoadSym(void* handle, char* name); -void taosCloseDll(void* handle); +int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf); + +int64_t taosGetLineCmd(TdCmdPtr pCmd, char **__restrict ptrBuf); + +int32_t taosEOFCmd(TdCmdPtr pCmd); + +int64_t taosCloseCmd(TdCmdPtr *ppCmd); + +void *taosLoadDll(const char *filename); + +void *taosLoadSym(void *handle, char *name); + +void taosCloseDll(void *handle); int32_t taosSetConsoleEcho(bool on); -void taosSetTerminalMode(); + +void taosSetTerminalMode(); + int32_t taosGetOldTerminalMode(); -void taosResetTerminalMode(); + +void taosResetTerminalMode(); #define STACKSIZE 100 -#if !defined(WINDOWS) -#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \ - void* array[STACKSIZE]; \ - int32_t size = backtrace(array, STACKSIZE); \ - char** strings = backtrace_symbols(array, size); \ - int32_t offset = 0; \ - if (strings != NULL) { \ - offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \ - for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ - offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, strings[i]); \ - } \ - } \ - \ - taosMemoryFree(strings); \ -} +#if defined(_ALPINE) +#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \ + { \ + unw_cursor_t cursor; \ + unw_context_t context; \ + \ + unw_getcontext(&context); \ + unw_init_local(&cursor, &context); \ + \ + char *array[STACKSIZE]; \ + int32_t size = 0; \ + int32_t ignores = ignoreNum; \ + int32_t offset = 0; \ + while (unw_step(&cursor) > 0 && size < STACKSIZE) { \ + unw_word_t offset, pc; \ + char fname[64]; \ + unw_get_reg(&cursor, UNW_REG_IP, &pc); \ + fname[0] = '\0'; \ + (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); \ + size += 1; \ + array[size] = (char *)taosMemoryMalloc(sizeof(char) * STACKSIZE + 1); \ + snprintf(array[size], STACKSIZE, "0x%lx : (%s+0x%lx) [0x%lx]\n", (long)pc, fname, (long)offset, (long)pc); \ + } \ + if (ignoreNum < size && size > 0) { \ + offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \ + for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ + offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \ + array[i]); \ + } \ + } \ + for (int i = 0; i < size; i++) { \ + taosMemoryFree(array[i]); \ + } \ + } + +#define taosPrintTrace(flags, level, dflag, ignoreNum) \ + { \ + unw_cursor_t cursor; \ + unw_context_t context; \ + \ + unw_getcontext(&context); \ + unw_init_local(&cursor, &context); \ + \ + char *array[STACKSIZE]; \ + int32_t size = 0; \ + while (unw_step(&cursor) > 0 && size < STACKSIZE) { \ + unw_word_t offset, pc; \ + char fname[64]; \ + unw_get_reg(&cursor, UNW_REG_IP, &pc); \ + fname[0] = '\0'; \ + (void)unw_get_proc_name(&cursor, fname, sizeof(fname), &offset); \ + size += 1; \ + array[size] = (char *)taosMemoryMalloc(sizeof(char) * STACKSIZE + 1); \ + snprintf(array[size], STACKSIZE, "frame:%d, 0x%lx : (%s+0x%lx) [0x%lx]\n", size, (long)pc, fname, (long)offset, \ + (long)pc); \ + } \ + if (ignoreNum < size && size > 0) { \ + taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \ + for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ + taosPrintLog(flags, level, dflag, "frame:%d, %s", (ignoreNum > 0) ? i - ignoreNum : i, array[i]); \ + } \ + } \ + for (int i = 0; i < size; i++) { \ + taosMemoryFree(array[i]); \ + } \ + } + +#elif !defined(WINDOWS) +#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \ + { \ + void *array[STACKSIZE]; \ + int32_t size = backtrace(array, STACKSIZE); \ + char **strings = backtrace_symbols(array, size); \ + int32_t offset = 0; \ + if (strings != NULL) { \ + offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \ + for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ + offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%d, %s\n", (ignoreNum > 0) ? i - ignoreNum : i, \ + strings[i]); \ + } \ + } \ + \ + taosMemoryFree(strings); \ + } #define taosPrintTrace(flags, level, dflag, ignoreNum) \ { \ - void* array[STACKSIZE]; \ - int32_t size = backtrace(array, STACKSIZE); \ - char** strings = backtrace_symbols(array, size); \ + void *array[STACKSIZE]; \ + int32_t size = backtrace(array, STACKSIZE); \ + char **strings = backtrace_symbols(array, size); \ if (strings != NULL) { \ taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \ for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ @@ -80,65 +163,70 @@ void taosResetTerminalMode(); } #else -#include #include +#include -#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \ - unsigned int i; \ - void* stack[STACKSIZE]; \ - unsigned short frames; \ - SYMBOL_INFO* symbol; \ - HANDLE process; \ - int32_t offset = 0; \ - \ - process = GetCurrentProcess(); \ - \ - SymInitialize(process, NULL, TRUE); \ - \ - frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ - symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ - if (symbol != NULL) { \ - symbol->MaxNameLen = 255; \ - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ - \ - if (frames > 0) { \ - offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \ - for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ - SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ - offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \ - } \ - } \ - free(symbol); \ - } \ +#define taosLogTraceToBuf(buf, bufSize, ignoreNum) \ + { \ + unsigned int i; \ + void *stack[STACKSIZE]; \ + unsigned short frames; \ + SYMBOL_INFO *symbol; \ + HANDLE process; \ + int32_t offset = 0; \ + \ + process = GetCurrentProcess(); \ + \ + SymInitialize(process, NULL, TRUE); \ + \ + frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ + symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ + if (symbol != NULL) { \ + symbol->MaxNameLen = 255; \ + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ + \ + if (frames > 0) { \ + offset = \ + snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \ + for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ + SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ + offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", \ + (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \ + } \ + } \ + free(symbol); \ + } \ } -#define taosPrintTrace(flags, level, dflag, ignoreNum) \ +#define taosPrintTrace(flags, level, dflag, ignoreNum) \ { \ - unsigned int i; \ - void* stack[STACKSIZE]; \ - unsigned short frames; \ - SYMBOL_INFO* symbol; \ - HANDLE process; \ - \ - process = GetCurrentProcess(); \ - \ - SymInitialize(process, NULL, TRUE); \ - \ - frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ - symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ - if (symbol != NULL) { \ - symbol->MaxNameLen = 255; \ - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ - \ - if (frames > 0) { \ - taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \ - for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ - SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ - taosPrintLog(flags, level, dflag, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \ - } \ - } \ - free(symbol); \ - } \ + unsigned int i; \ + void *stack[STACKSIZE]; \ + unsigned short frames; \ + SYMBOL_INFO *symbol; \ + HANDLE process; \ + \ + process = GetCurrentProcess(); \ + \ + SymInitialize(process, NULL, TRUE); \ + \ + frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ + symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ + if (symbol != NULL) { \ + symbol->MaxNameLen = 255; \ + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ + \ + if (frames > 0) { \ + taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", \ + (ignoreNum > 0) ? frames - ignoreNum : frames); \ + for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ + SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ + taosPrintLog(flags, level, dflag, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, \ + symbol->Name, symbol->Address); \ + } \ + } \ + free(symbol); \ + } \ } #endif diff --git a/include/os/osThread.h b/include/os/osThread.h index 916d463733..aa0dc066c6 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -22,7 +22,7 @@ extern "C" { #endif -#ifndef WINDOWS +#if !defined(WINDOWS) && !defined(_ALPINE) #ifndef __USE_XOPEN2K #define TD_USE_SPINLOCK_AS_MUTEX typedef pthread_mutex_t pthread_spinlock_t; @@ -100,7 +100,11 @@ typedef pthread_key_t TdThreadKey; #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID + +#if !defined(_ALPINE) #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID +#endif + #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 9034fd85f5..cb99f67e70 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # This file is used to install TAOS time-series database on linux systems. The operating system # is required to use systemd to manage services at boot @@ -340,7 +340,7 @@ function install_lib() { #install_avro lib64 if [ "$osType" != "Darwin" ]; then - ${csudo}ldconfig + ${csudo}ldconfig /etc/ld.so.conf.d fi } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 370a232827..d08110becd 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -351,7 +351,9 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1; if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1; +#if !defined(_ALPINE) if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1; +#endif if (cfgAddInt32(pCfg, "pageSizeKB", tsPageSizeKB, 0, INT64_MAX, 1) != 0) return -1; if (cfgAddInt64(pCfg, "totalMemoryKB", tsTotalMemoryKB, 0, INT64_MAX, 1) != 0) return -1; if (cfgAddString(pCfg, "os sysname", info.sysname, 1) != 0) return -1; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 20be2ee3bb..171916b637 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -528,7 +528,12 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) { return pArray; } -static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { return *dnode1Id >= *dnode2Id ? 1 : 0; } +static int32_t mndCompareDnodeId(int32_t *dnode1Id, int32_t *dnode2Id) { + if (*dnode1Id == *dnode2Id) { + return 0; + } + return *dnode1Id > *dnode2Id ? 1 : -1; +} static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float ratio) { float totalDnodes = pDnode->numOfVnodes + (float)pDnode->numOfOtherNodes * ratio + additionDnodes; @@ -536,9 +541,12 @@ static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float r } static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) { - float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9); - float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9); - return d1Score >= d2Score ? 1 : 0; + float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9); + float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9); + if (d1Score == d2Score) { + return 0; + } + return d1Score > d2Score ? 1 : -1; } void mndSortVnodeGid(SVgObj *pVgroup) { diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt index 2a4fcbcf76..0d75634d14 100644 --- a/source/os/CMakeLists.txt +++ b/source/os/CMakeLists.txt @@ -51,6 +51,10 @@ elseif(TD_DARWIN_64) target_link_libraries( os PUBLIC dl m iconv ) +elseif(TD_ALPINE) + target_link_libraries( + os PUBLIC dl m rt unwind + ) else() target_link_libraries( os PUBLIC dl m rt diff --git a/source/os/src/osMath.c b/source/os/src/osMath.c index 3b42c141df..b466f89a1d 100644 --- a/source/os/src/osMath.c +++ b/source/os/src/osMath.c @@ -16,7 +16,7 @@ #define ALLOW_FORBID_FUNC #define _DEFAULT_SOURCE #include -#include "os.h" +#include "talgo.h" #ifdef WINDOWS void swapStr(char* j, char* J, int width) { @@ -41,7 +41,7 @@ int32_t qsortHelper(const void* p1, const void* p2, const void* param) { void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) { #ifdef _ALPINE void* param = compar; - taosqsort(base, width, sz, param, qsortHelper); + taosqsort(base, sz, width, param, qsortHelper); #else qsort(base, sz, width, compar); #endif diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 3825b8e074..e685cc8351 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -346,7 +346,7 @@ int64_t taosMemorySize(void *ptr) { } void taosMemoryTrim(int32_t size) { -#if defined(WINDOWS) || defined(DARWIN) +#if defined(WINDOWS) || defined(DARWIN) || defined(_ALPINE) // do nothing return; #else diff --git a/source/os/src/osString.c b/source/os/src/osString.c index b9f537ad34..ae4a8a5cad 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -351,7 +351,7 @@ char *taosStrCaseStr(const char *str, const char *pattern) { int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) { int64_t tmp = strtoll(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -363,7 +363,7 @@ int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix) { uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) { uint64_t tmp = strtoull(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -375,7 +375,7 @@ uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix) { int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) { int32_t tmp = strtol(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -387,7 +387,7 @@ int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix) { uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtol(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -399,7 +399,7 @@ uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix) { int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) { int32_t tmp = strtol(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -413,7 +413,7 @@ int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) { uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtoul(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR @@ -437,7 +437,7 @@ int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix) { uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) { uint32_t tmp = strtoul(str, pEnd, radix); -#ifdef DARWIN +#if defined(DARWIN) || defined(_ALPINE) if (errno == EINVAL) errno = 0; #endif #ifdef TD_CHECK_STR_TO_INT_ERROR diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index b5c6edc829..6471dad033 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -124,7 +124,7 @@ static char tsProcIOFile[25] = {0}; static void taosGetProcIOnfos() { tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024; tsOpenMax = sysconf(_SC_OPEN_MAX); - tsStreamMax = sysconf(_SC_STREAM_MAX); + tsStreamMax = TMAX(sysconf(_SC_STREAM_MAX), 0); tsProcId = (pid_t)syscall(SYS_gettid); snprintf(tsProcMemFile, sizeof(tsProcMemFile), "/proc/%d/status", tsProcId); diff --git a/source/os/src/osTimer.c b/source/os/src/osTimer.c index d1c233ea9c..5a57007d17 100644 --- a/source/os/src/osTimer.c +++ b/source/os/src/osTimer.c @@ -99,8 +99,8 @@ static void *taosProcessAlarmSignal(void *tharg) { setThreadName("tmr"); #ifdef _ALPINE - sevent.sigev_notify = SIGEV_THREAD; - sevent.sigev_value.sival_int = syscall(__NR_gettid); + sevent.sigev_notify = SIGEV_THREAD_ID; + sevent.sigev_notify_thread_id = syscall(__NR_gettid); #else sevent.sigev_notify = SIGEV_THREAD_ID; sevent._sigev_un._tid = syscall(__NR_gettid); diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index a1682f47b3..ddb3bfaa26 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -15,6 +15,7 @@ import sys import os import os.path import platform +import distro import subprocess from time import sleep import base64 @@ -22,6 +23,7 @@ import json import copy from fabric2 import Connection from util.log import * +from shutil import which class TDSimClient: @@ -166,9 +168,9 @@ class TDDnode: if value: selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): - self.execPath = os.path.abspath(self.path + "/community/tests/script/sh/exec.sh") + self.execPath = os.path.abspath(self.path + "/community/tests/script/sh/exec.sh") else: - self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh") + self.execPath = os.path.abspath(self.path + "/tests/script/sh/exec.sh") def getDataSize(self): totalSize = 0 @@ -686,7 +688,7 @@ class TDDnodes: if ("community" in selfPath): self.stopDnodesPath = os.path.abspath(self.path + "/community/tests/script/sh/stop_dnodes.sh") self.stopDnodesSigintPath = os.path.abspath(self.path + "/community/tests/script/sh/sigint_stop_dnodes.sh") - else: + else: self.stopDnodesPath = os.path.abspath(self.path + "/tests/script/sh/stop_dnodes.sh") self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh") tdLog.info("run in address sanitizer mode") @@ -765,7 +767,8 @@ class TDDnodes: def stopAll(self): tdLog.info("stop all dnodes, asan:%d" % self.asan) - if self.asan: + distro_id = distro.id() + if self.asan and distro_id != "alpine": tdLog.info("execute script: %s" % self.stopDnodesPath) os.system(self.stopDnodesPath) tdLog.info("execute finished") @@ -777,24 +780,41 @@ class TDDnodes: for i in range(len(self.dnodes)): self.dnodes[i].stop() - psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() - if processID: - cmd = "sudo systemctl stop taosd" - os.system(cmd) - # if os.system(cmd) != 0 : - # tdLog.exit(cmd) - psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs" - processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() - while(processID): - if platform.system().lower() == 'windows': - killCmd = "kill -9 %s > nul 2>&1" % processID - else: - killCmd = "kill -9 %s > /dev/null 2>&1" % processID - os.system(killCmd) - time.sleep(1) - processID = subprocess.check_output( - psCmd, shell=True).decode("utf-8").strip() + + if (distro_id == "alpine"): + print(distro_id) + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + print(processID) + if platform.system().lower() == 'windows': + killCmd = "kill -9 %s > nul 2>&1" % processID + else: + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() + + else: + psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + if processID: + cmd = "sudo systemctl stop taosd" + os.system(cmd) + # if os.system(cmd) != 0 : + # tdLog.exit(cmd) + psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs" + processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() + while(processID): + if platform.system().lower() == 'windows': + killCmd = "kill -9 %s > nul 2>&1" % processID + else: + killCmd = "kill -9 %s > /dev/null 2>&1" % processID + os.system(killCmd) + time.sleep(1) + processID = subprocess.check_output( + psCmd, shell=True).decode("utf-8").strip() if self.killValgrind == 1: psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs" diff --git a/tests/requirements.txt b/tests/requirements.txt index cebe5b9d36..d2edbfb32d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,3 +4,7 @@ fabric2 psutil pandas toml +distro +requests +pexpect +faker \ No newline at end of file diff --git a/tests/script/sh/cfg.sh b/tests/script/sh/cfg.sh index 7d4d747e54..bf58185f62 100755 --- a/tests/script/sh/cfg.sh +++ b/tests/script/sh/cfg.sh @@ -45,11 +45,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/checkAsan.sh b/tests/script/sh/checkAsan.sh index 7225722791..31fe80829f 100755 --- a/tests/script/sh/checkAsan.sh +++ b/tests/script/sh/checkAsan.sh @@ -2,7 +2,19 @@ set +e #set -x +if [[ "$OSTYPE" == "darwin"* ]]; then + TD_OS="Darwin" +else + OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2) + len=$(echo ${#OS}) + len=$((len-2)) + TD_OS=$(echo -ne ${OS:1:${len}} | cut -d" " -f1) +fi +if [[ "$TD_OS" == "Alpine" ]]; then + echo -e "os is Alpine,skip check Asan" + exit 0 +fi unset LD_PRELOAD SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ diff --git a/tests/script/sh/clear.sh b/tests/script/sh/clear.sh index 4ee296cf05..587a33f633 100755 --- a/tests/script/sh/clear.sh +++ b/tests/script/sh/clear.sh @@ -48,11 +48,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 217bd66ef6..7da8da09bf 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -39,11 +39,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/exec-default.sh b/tests/script/sh/exec-default.sh index f648315c67..0a83fa1dc8 100755 --- a/tests/script/sh/exec-default.sh +++ b/tests/script/sh/exec-default.sh @@ -54,11 +54,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/exec-no-random-fail.sh b/tests/script/sh/exec-no-random-fail.sh index e01b18a8e6..b15783afb5 100755 --- a/tests/script/sh/exec-no-random-fail.sh +++ b/tests/script/sh/exec-no-random-fail.sh @@ -54,11 +54,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/exec-random-fail.sh b/tests/script/sh/exec-random-fail.sh index 1f31899e3a..15f2864ca6 100755 --- a/tests/script/sh/exec-random-fail.sh +++ b/tests/script/sh/exec-random-fail.sh @@ -54,11 +54,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index c8cb121b8a..f548a4cc41 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -10,6 +10,14 @@ set +e #set -x +if [[ "$OSTYPE" == "darwin"* ]]; then + TD_OS="Darwin" +else + OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2) + len=$(echo ${#OS}) + len=$((len-2)) + TD_OS=$(echo -ne ${OS:1:${len}} | cut -d" " -f1) +fi unset LD_PRELOAD UNAME_BIN=`which uname` @@ -44,7 +52,10 @@ do ;; esac done - +if [[ "$VALGRIND_OPTION" = "true" ]] && [[ "$TD_OS" == "Alpine" ]]; then + echo alpine skip valgrind + VALGRIND_OPTION="false" +fi SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` @@ -59,11 +70,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/exec_tarbitrator.sh b/tests/script/sh/exec_tarbitrator.sh index e985bd6585..eacf5fd226 100755 --- a/tests/script/sh/exec_tarbitrator.sh +++ b/tests/script/sh/exec_tarbitrator.sh @@ -51,11 +51,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/sh/mv_old_data.sh b/tests/script/sh/mv_old_data.sh index 3f4be6714f..1a6bd22c62 100755 --- a/tests/script/sh/mv_old_data.sh +++ b/tests/script/sh/mv_old_data.sh @@ -20,11 +20,7 @@ fi TAOS_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/test.sh b/tests/script/test.sh index 19180382fd..b10865dd65 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -51,11 +51,7 @@ fi TOP_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` diff --git a/tests/script/tsim/dnode/balance3.sim b/tests/script/tsim/dnode/balance3.sim index 2fb284b466..d0235e096e 100644 --- a/tests/script/tsim/dnode/balance3.sim +++ b/tests/script/tsim/dnode/balance3.sim @@ -130,13 +130,13 @@ print dnode4 openVnodes $data(4)[2] if $data(1)[2] != 1 then return -1 endi -if $data(2)[2] != 1 then +if $data(2)[2] != 2 then return -1 endi if $data(3)[2] != 2 then return -1 endi -if $data(4)[2] != 2 then +if $data(4)[2] != 1 then return -1 endi @@ -216,7 +216,7 @@ endi print ========== step4 sql create database d3 replica 3 vgroups 1 -sql create table d3.t3 (t timestamp, i int) +sql create table d3.t3 (t timestamp, i int) sql insert into d3.t3 values(now+1s, 35) sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+3s, 33) @@ -231,10 +231,10 @@ print dnode5 openVnodes $data(5)[2] if $data(1)[2] != 2 then return -1 endi -if $data(3)[2] != 2 then +if $data(3)[2] != 3 then return -1 endi -if $data(4)[2] != 3 then +if $data(4)[2] != 2 then return -1 endi if $data(5)[2] != 2 then @@ -315,10 +315,10 @@ endi if $data(3)[2] != null then return -1 endi -if $data(4)[2] != 2 then +if $data(4)[2] != 3 then return -1 endi -if $data(5)[2] != 3 then +if $data(5)[2] != 2 then return -1 endi if $data(6)[2] != 2 then diff --git a/tests/script/tsim/dnode/balancex.sim b/tests/script/tsim/dnode/balancex.sim index 0cfc64a954..6f077be521 100644 --- a/tests/script/tsim/dnode/balancex.sim +++ b/tests/script/tsim/dnode/balancex.sim @@ -145,10 +145,10 @@ print dnode2 openVnodes $data(4)[2] if $data(1)[2] != 1 then return -1 endi -if $data(2)[2] != 1 then +if $data(2)[2] != 2 then return -1 endi -if $data(3)[2] != 2 then +if $data(3)[2] != 1 then return -1 endi if $data(4)[2] != 1 then diff --git a/tests/script/tsim/dnode/drop_dnode_force.sim b/tests/script/tsim/dnode/drop_dnode_force.sim index 26e48933be..425e5f48b2 100644 --- a/tests/script/tsim/dnode/drop_dnode_force.sim +++ b/tests/script/tsim/dnode/drop_dnode_force.sim @@ -120,9 +120,9 @@ if $rows != 12 then return -1 endi -print =============== step3: create qnode snode on dnode 2 -sql create qnode on dnode 2 -sql create snode on dnode 2 +print =============== step3: create qnode snode on dnode 3 +sql create qnode on dnode 3 +sql create snode on dnode 3 sql select * from information_schema.ins_qnodes if $rows != 1 then return -1 @@ -136,16 +136,16 @@ print =============== step4: create mnode on dnode 2 sql create mnode on dnode 3 sql create mnode on dnode 2 $x = 0 -step4: +step4: $x = $x + 1 sleep 1000 if $x == 10 then return -1 endi sql select * from information_schema.ins_mnodes -x step4 -print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] -print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] -print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[1][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[1][4] #if $data(1)[2] != leader then # goto step4 #endi @@ -157,7 +157,7 @@ endi #endi print =============== step5: create dnode 5 -system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec.sh -n dnode5 -s start $x = 0 step5: @@ -179,10 +179,10 @@ endi if $data(1)[4] != ready then goto step5 endi -if $data(2)[4] != offline then +if $data(2)[4] != ready then goto step5 endi -if $data(3)[4] != ready then +if $data(3)[4] != offline then goto step5 endi if $data(4)[4] != ready then @@ -192,9 +192,9 @@ if $data(5)[4] != ready then goto step5 endi -print =============== step5a: drop dnode 2 -sql_error drop dnode 2 -sql drop dnode 2 force +print =============== step5a: drop dnode 3 +sql_error drop dnode 3 +sql drop dnode 3 force print select * from information_schema.ins_dnodes; sql select * from information_schema.ins_dnodes; diff --git a/tests/script/tsim/dnode/vnode_clean.sim b/tests/script/tsim/dnode/vnode_clean.sim index ba1d083c68..aead25938e 100644 --- a/tests/script/tsim/dnode/vnode_clean.sim +++ b/tests/script/tsim/dnode/vnode_clean.sim @@ -207,10 +207,10 @@ print dnode2 openVnodes $data(4)[2] if $data(1)[2] != 1 then return -1 endi -if $data(3)[2] != 1 then +if $data(3)[2] != 2 then return -1 endi -if $data(4)[2] != 2 then +if $data(4)[2] != 1 then return -1 endi diff --git a/tests/script/tsim/scalar/tsConvert.sim b/tests/script/tsim/scalar/tsConvert.sim index 75efdb442f..ad8d3b3b93 100644 --- a/tests/script/tsim/scalar/tsConvert.sim +++ b/tests/script/tsim/scalar/tsConvert.sim @@ -13,7 +13,7 @@ sql insert into tb1 values ('2022-07-10 16:31:00', 1, '1'); sql insert into tb1 values ('2022-07-10 16:32:00', 2, '2'); sql insert into tb1 values ('2022-07-10 16:33:00', 3, '3'); sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4'); -sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <=' 2022-11-3 23:59:59' ) t where td >12; +sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <='2022-11-3 23:59:59' ) t where td >12; if $rows != 4 then return -1 endi diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py index 1834432bc9..a5cded7a6b 100644 --- a/tests/system-test/0-others/compatibility.py +++ b/tests/system-test/0-others/compatibility.py @@ -99,6 +99,10 @@ class TDTestCase: def run(self): + distro_id = distro.id() + if distro_id == "alpine": + tdLog.info(f"alpine skip compatibility test") + return True bPath = self.getBuildPath() cPath = self.getCfgPath() dbname = "test" diff --git a/tests/system-test/2-query/irate.py b/tests/system-test/2-query/irate.py index 8aa2b3d420..d976edb49c 100644 --- a/tests/system-test/2-query/irate.py +++ b/tests/system-test/2-query/irate.py @@ -97,7 +97,7 @@ class TDTestCase: tdSql.execute( f'create table {dbname}.ct{i+1} using {dbname}.stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {1*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') - for i in range(9): + for i in range(1,10): tdSql.execute( f"insert into {dbname}.ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) diff --git a/tests/system-test/6-cluster/5dnode1mnode.py b/tests/system-test/6-cluster/5dnode1mnode.py index ce87bced1b..f21fae0d7b 100644 --- a/tests/system-test/6-cluster/5dnode1mnode.py +++ b/tests/system-test/6-cluster/5dnode1mnode.py @@ -145,8 +145,8 @@ class TDTestCase: tdSql.query("show db.alive;") tdSql.checkData(0, 0, 1) - # stop 5 dnode - self.TDDnodes.stoptaosd(5) + # stop 3 dnode + self.TDDnodes.stoptaosd(3) tdSql.checkDataLoop(0, 0, 2, "show cluster alive;", 20, 0.5) tdSql.query("show db.alive;") diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py index abe8ed2945..cdcdadbcbb 100644 --- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -236,8 +236,8 @@ class TDTestCase: tdDnodes[0].starttaosd() self.check3mnode() - tdLog.info("3. stop dnode 1") - tdDnodes[1].stoptaosd() + tdLog.info("3. stop dnode 2") + tdDnodes[2].stoptaosd() time.sleep(10) self.check3mnode1off() diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py index 95ce03e653..37946d0c22 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py @@ -192,7 +192,7 @@ class TDTestCase: topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 - keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:300, auto.offset.reset:earliest' + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:100, auto.offset.reset:earliest' tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) tdLog.info("start consume processor 0") diff --git a/tests/system-test/pytest.sh b/tests/system-test/pytest.sh index 68d49f5d06..792cab98f7 100755 --- a/tests/system-test/pytest.sh +++ b/tests/system-test/pytest.sh @@ -8,15 +8,23 @@ set +e #set -x +if [[ "$OSTYPE" == "darwin"* ]]; then + TD_OS="Darwin" +else + OS=$(cat /etc/*-release | grep "^NAME=" | cut -d= -f2) + len=$(echo ${#OS}) + len=$((len - 2)) + TD_OS=$(echo -ne ${OS:1:${len}} | cut -d" " -f1) +fi -UNAME_BIN=`which uname` -OS_TYPE=`$UNAME_BIN` +UNAME_BIN=$(which uname) +OS_TYPE=$($UNAME_BIN) cd . # Get responsible directories -CODE_DIR=`dirname $0` -CODE_DIR=`pwd` +CODE_DIR=$(dirname $0) +CODE_DIR=$(pwd) IN_TDINTERNAL="community" if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then @@ -25,19 +33,15 @@ else cd ../../ fi -TOP_DIR=`pwd` -TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` +TOP_DIR=$(pwd) +TAOSD_DIR=$(find . -name "taosd" | grep bin | head -n1) -if [[ "$OS_TYPE" != "Darwin" ]]; then - cut_opt="--field=" -else - cut_opt="-f " -fi +cut_opt="-f " if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` + BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2,3) else - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` + BIN_DIR=$(find . -name "taosd" | grep bin | head -n1 | cut -d '/' ${cut_opt}2) fi declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR @@ -66,35 +70,38 @@ ulimit -c unlimited #sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e echo "ExcuteCmd:" $* -AsanFile=$ASAN_DIR/psim.info -echo "AsanFile:" $AsanFile -unset LD_PRELOAD -#export LD_PRELOAD=libasan.so.5 -export LD_PRELOAD=`gcc -print-file-name=libasan.so` -echo "Preload AsanSo:" $? - -$* -a 2> $AsanFile - -unset LD_PRELOAD -for ((i=1;i<=20;i++)) -do - AsanFileLen=`cat $AsanFile | wc -l` - echo "AsanFileLen:" $AsanFileLen - if [ $AsanFileLen -gt 10 ]; then - break - fi - sleep 1 -done - -AsanFileSuccessLen=`grep -w successfully $AsanFile | wc -l` -echo "AsanFileSuccessLen:" $AsanFileSuccessLen - -if [ $AsanFileSuccessLen -gt 0 ]; then - echo "Execute script successfully and check asan" - $CODE_DIR/../script/sh/checkAsan.sh +if [[ "$TD_OS" == "Alpine" ]]; then + $* else - echo "Execute script failure" - exit 1 -fi + AsanFile=$ASAN_DIR/psim.info + echo "AsanFile:" $AsanFile + unset LD_PRELOAD + #export LD_PRELOAD=libasan.so.5 + export LD_PRELOAD=$(gcc -print-file-name=libasan.so) + echo "Preload AsanSo:" $? + + $* -a 2>$AsanFile + + unset LD_PRELOAD + for ((i = 1; i <= 20; i++)); do + AsanFileLen=$(cat $AsanFile | wc -l) + echo "AsanFileLen:" $AsanFileLen + if [ $AsanFileLen -gt 10 ]; then + break + fi + sleep 1 + done + + AsanFileSuccessLen=$(grep -w successfully $AsanFile | wc -l) + echo "AsanFileSuccessLen:" $AsanFileSuccessLen + + if [ $AsanFileSuccessLen -gt 0 ]; then + echo "Execute script successfully and check asan" + $CODE_DIR/../script/sh/checkAsan.sh + else + echo "Execute script failure" + exit 1 + fi +fi diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d61d25602b..1461a7b373 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,25 +7,45 @@ IF (TD_WEBSOCKET) SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}") ENDIF () MESSAGE("${Green} use libtaos-ws${ColourReset}") - - include(ExternalProject) - ExternalProject_Add(taosws-rs - PREFIX "taosws-rs" - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs - BUILD_ALWAYS off - DEPENDS taos - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" - PATCH_COMMAND - COMMAND git clean -f -d - BUILD_COMMAND - COMMAND cargo update - COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored - INSTALL_COMMAND - COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib - COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include - COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include - ) + IF (TD_ALPINE) + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS off + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo update + COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features native-tls + INSTALL_COMMAND + COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) + ELSE() + include(ExternalProject) + ExternalProject_Add(taosws-rs + PREFIX "taosws-rs" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs + BUILD_ALWAYS off + DEPENDS taos + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" + PATCH_COMMAND + COMMAND git clean -f -d + BUILD_COMMAND + COMMAND cargo update + COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored + INSTALL_COMMAND + COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include + COMMAND cmake -E copy target/release/taosws.h ${CMAKE_BINARY_DIR}/build/include + ) + ENDIF () ENDIF () IF (TD_TAOS_TOOLS) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 342d6410d2..600e33feab 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -30,15 +30,23 @@ IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging) ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) +IF (TD_LINUX AND TD_ALPINE) + SET(LINK_ARGP "/usr/lib/libargp.a") +ELSE () + SET(LINK_ARGP "") +ENDIF () + if(TD_WINDOWS) target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET}) else() - target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC}) + target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC} ${LINK_ARGP}) endif () + target_link_libraries( shell PRIVATE os common transport util ) + target_include_directories( shell PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index d899249b97..0612c2f455 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -97,7 +97,11 @@ void shellPrintHelp() { #ifdef LINUX #include +#ifdef _ALPINE +#include +#else #include +#endif const char *argp_program_version = version; const char *argp_program_bug_address = cusEmail;