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>
This commit is contained in:
Shuduo Sang 2023-02-10 13:00:55 +08:00 committed by GitHub
parent 703c4066eb
commit ea5d925c50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 452 additions and 270 deletions

View File

@ -37,6 +37,21 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin
SET(TD_LINUX_32 TRUE) SET(TD_LINUX_32 TRUE)
ENDIF () 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") ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(TD_DARWIN TRUE) SET(TD_DARWIN TRUE)

View File

@ -2,7 +2,7 @@
# taosws-rs # taosws-rs
ExternalProject_Add(taosws-rs ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
GIT_TAG f406d51 GIT_TAG main
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs" SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR "" BINARY_DIR ""
#BUILD_IN_SOURCE TRUE #BUILD_IN_SOURCE TRUE

View File

@ -27,7 +27,11 @@ extern "C" {
#if !defined(WINDOWS) #if !defined(WINDOWS)
#include <dirent.h> #include <dirent.h>
#if !defined(_ALPINE)
#include <execinfo.h> #include <execinfo.h>
#endif
#include <libgen.h> #include <libgen.h>
#include <sched.h> #include <sched.h>
#include <unistd.h> #include <unistd.h>

View File

@ -60,6 +60,13 @@ void taosSetCoreDump(bool enable);
#endif // WINDOWS #endif // WINDOWS
#if defined(_ALPINE)
#define _UTSNAME_LENGTH 65
#define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
#endif
typedef struct { typedef struct {
char sysname[_UTSNAME_MACHINE_LENGTH]; char sysname[_UTSNAME_MACHINE_LENGTH];
char nodename[_UTSNAME_MACHINE_LENGTH]; char nodename[_UTSNAME_MACHINE_LENGTH];

View File

@ -16,6 +16,11 @@
#ifndef _TD_OS_SYSTEM_H_ #ifndef _TD_OS_SYSTEM_H_
#define _TD_OS_SYSTEM_H_ #define _TD_OS_SYSTEM_H_
#ifdef _ALPINE
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -29,46 +34,124 @@ extern "C" {
#define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID
#endif #endif
typedef struct TdCmd* TdCmdPtr; typedef struct TdCmd *TdCmdPtr;
TdCmdPtr taosOpenCmd(const char* cmd); 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);
void* taosLoadDll(const char* filename); int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf);
void* taosLoadSym(void* handle, char* name);
void taosCloseDll(void* handle); 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); int32_t taosSetConsoleEcho(bool on);
void taosSetTerminalMode();
void taosSetTerminalMode();
int32_t taosGetOldTerminalMode(); int32_t taosGetOldTerminalMode();
void taosResetTerminalMode();
void taosResetTerminalMode();
#define STACKSIZE 100 #define STACKSIZE 100
#if !defined(WINDOWS) #if defined(_ALPINE)
#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \ #define taosLogTraceToBuf(buf, bufSize, ignoreNum) \
void* array[STACKSIZE]; \ { \
int32_t size = backtrace(array, STACKSIZE); \ unw_cursor_t cursor; \
char** strings = backtrace_symbols(array, size); \ unw_context_t context; \
int32_t offset = 0; \ \
if (strings != NULL) { \ unw_getcontext(&context); \
offset = snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? size - ignoreNum : size); \ unw_init_local(&cursor, &context); \
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]); \ char *array[STACKSIZE]; \
} \ int32_t size = 0; \
} \ int32_t ignores = ignoreNum; \
\ int32_t offset = 0; \
taosMemoryFree(strings); \ 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) \ #define taosPrintTrace(flags, level, dflag, ignoreNum) \
{ \ { \
void* array[STACKSIZE]; \ void *array[STACKSIZE]; \
int32_t size = backtrace(array, STACKSIZE); \ int32_t size = backtrace(array, STACKSIZE); \
char** strings = backtrace_symbols(array, size); \ char **strings = backtrace_symbols(array, size); \
if (strings != NULL) { \ if (strings != NULL) { \
taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \ taosPrintLog(flags, level, dflag, "obtained %d stack frames", (ignoreNum > 0) ? size - ignoreNum : size); \
for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \ for (int32_t i = (ignoreNum > 0) ? ignoreNum : 0; i < size; i++) { \
@ -80,65 +163,70 @@ void taosResetTerminalMode();
} }
#else #else
#include <windows.h>
#include <dbghelp.h> #include <dbghelp.h>
#include <windows.h>
#define taosLogTraceToBuf(buf, bufSize, ignoreNum) { \ #define taosLogTraceToBuf(buf, bufSize, ignoreNum) \
unsigned int i; \ { \
void* stack[STACKSIZE]; \ unsigned int i; \
unsigned short frames; \ void *stack[STACKSIZE]; \
SYMBOL_INFO* symbol; \ unsigned short frames; \
HANDLE process; \ SYMBOL_INFO *symbol; \
int32_t offset = 0; \ HANDLE process; \
\ int32_t offset = 0; \
process = GetCurrentProcess(); \ \
\ process = GetCurrentProcess(); \
SymInitialize(process, NULL, TRUE); \ \
\ SymInitialize(process, NULL, TRUE); \
frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ \
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
if (symbol != NULL) { \ symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
symbol->MaxNameLen = 255; \ if (symbol != NULL) { \
symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ 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); \ if (frames > 0) { \
for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ offset = \
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ snprintf(buf, bufSize - 1, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \
offset += snprintf(buf + offset, bufSize - 1 - offset, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \ 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", \
free(symbol); \ (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; \ unsigned int i; \
void* stack[STACKSIZE]; \ void *stack[STACKSIZE]; \
unsigned short frames; \ unsigned short frames; \
SYMBOL_INFO* symbol; \ SYMBOL_INFO *symbol; \
HANDLE process; \ HANDLE process; \
\ \
process = GetCurrentProcess(); \ process = GetCurrentProcess(); \
\ \
SymInitialize(process, NULL, TRUE); \ SymInitialize(process, NULL, TRUE); \
\ \
frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \ frames = CaptureStackBackTrace(0, STACKSIZE, stack, NULL); \
symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \ symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); \
if (symbol != NULL) { \ if (symbol != NULL) { \
symbol->MaxNameLen = 255; \ symbol->MaxNameLen = 255; \
symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \ symbol->SizeOfStruct = sizeof(SYMBOL_INFO); \
\ \
if (frames > 0) { \ if (frames > 0) { \
taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", (ignoreNum > 0) ? frames - ignoreNum : frames); \ taosPrintLog(flags, level, dflag, "obtained %d stack frames\n", \
for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \ (ignoreNum > 0) ? frames - ignoreNum : frames); \
SymFromAddr(process, (DWORD64)(stack[i]), 0, symbol); \ for (i = (ignoreNum > 0) ? ignoreNum : 0; i < frames; i++) { \
taosPrintLog(flags, level, dflag, "frame:%i, %s - 0x%0X\n", (ignoreNum > 0) ? i - ignoreNum : i, symbol->Name, symbol->Address); \ 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); \ } \
} \ } \
free(symbol); \
} \
} }
#endif #endif

View File

@ -22,7 +22,7 @@
extern "C" { extern "C" {
#endif #endif
#ifndef WINDOWS #if !defined(WINDOWS) && !defined(_ALPINE)
#ifndef __USE_XOPEN2K #ifndef __USE_XOPEN2K
#define TD_USE_SPINLOCK_AS_MUTEX #define TD_USE_SPINLOCK_AS_MUTEX
typedef pthread_mutex_t pthread_spinlock_t; 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_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID
#define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID
#define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID
#if !defined(_ALPINE)
#define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID
#endif
#define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID
#define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID
#define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# #
# This file is used to install TAOS time-series database on linux systems. The operating system # 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 # is required to use systemd to manage services at boot
@ -340,7 +340,7 @@ function install_lib() {
#install_avro lib64 #install_avro lib64
if [ "$osType" != "Darwin" ]; then if [ "$osType" != "Darwin" ]; then
${csudo}ldconfig ${csudo}ldconfig /etc/ld.so.conf.d
fi fi
} }

View File

@ -351,7 +351,9 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1; if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1;
if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 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; 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 (cfgAddInt32(pCfg, "pageSizeKB", tsPageSizeKB, 0, INT64_MAX, 1) != 0) return -1;
if (cfgAddInt64(pCfg, "totalMemoryKB", tsTotalMemoryKB, 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; if (cfgAddString(pCfg, "os sysname", info.sysname, 1) != 0) return -1;

View File

@ -528,7 +528,12 @@ SArray *mndBuildDnodesArray(SMnode *pMnode, int32_t exceptDnodeId) {
return pArray; 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) { static float mndGetDnodeScore(SDnodeObj *pDnode, int32_t additionDnodes, float ratio) {
float totalDnodes = pDnode->numOfVnodes + (float)pDnode->numOfOtherNodes * ratio + additionDnodes; 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) { static int32_t mndCompareDnodeVnodes(SDnodeObj *pDnode1, SDnodeObj *pDnode2) {
float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9); float d1Score = mndGetDnodeScore(pDnode1, 0, 0.9);
float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9); float d2Score = mndGetDnodeScore(pDnode2, 0, 0.9);
return d1Score >= d2Score ? 1 : 0; if (d1Score == d2Score) {
return 0;
}
return d1Score > d2Score ? 1 : -1;
} }
void mndSortVnodeGid(SVgObj *pVgroup) { void mndSortVnodeGid(SVgObj *pVgroup) {

View File

@ -51,6 +51,10 @@ elseif(TD_DARWIN_64)
target_link_libraries( target_link_libraries(
os PUBLIC dl m iconv os PUBLIC dl m iconv
) )
elseif(TD_ALPINE)
target_link_libraries(
os PUBLIC dl m rt unwind
)
else() else()
target_link_libraries( target_link_libraries(
os PUBLIC dl m rt os PUBLIC dl m rt

View File

@ -16,7 +16,7 @@
#define ALLOW_FORBID_FUNC #define ALLOW_FORBID_FUNC
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include "os.h" #include "talgo.h"
#ifdef WINDOWS #ifdef WINDOWS
void swapStr(char* j, char* J, int width) { 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) { void taosSort(void* base, int64_t sz, int64_t width, __compar_fn_t compar) {
#ifdef _ALPINE #ifdef _ALPINE
void* param = compar; void* param = compar;
taosqsort(base, width, sz, param, qsortHelper); taosqsort(base, sz, width, param, qsortHelper);
#else #else
qsort(base, sz, width, compar); qsort(base, sz, width, compar);
#endif #endif

View File

@ -346,7 +346,7 @@ int64_t taosMemorySize(void *ptr) {
} }
void taosMemoryTrim(int32_t size) { void taosMemoryTrim(int32_t size) {
#if defined(WINDOWS) || defined(DARWIN) #if defined(WINDOWS) || defined(DARWIN) || defined(_ALPINE)
// do nothing // do nothing
return; return;
#else #else

View File

@ -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 taosStr2Int64(const char *str, char **pEnd, int32_t radix) {
int64_t tmp = strtoll(str, pEnd, radix); int64_t tmp = strtoll(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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 taosStr2UInt64(const char *str, char **pEnd, int32_t radix) {
uint64_t tmp = strtoull(str, pEnd, radix); uint64_t tmp = strtoull(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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 taosStr2Int32(const char *str, char **pEnd, int32_t radix) {
int32_t tmp = strtol(str, pEnd, radix); int32_t tmp = strtol(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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 taosStr2UInt32(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtol(str, pEnd, radix); uint32_t tmp = strtol(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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) { int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix) {
int32_t tmp = strtol(str, pEnd, radix); int32_t tmp = strtol(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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) { uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtoul(str, pEnd, radix); uint32_t tmp = strtoul(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #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) { uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix) {
uint32_t tmp = strtoul(str, pEnd, radix); uint32_t tmp = strtoul(str, pEnd, radix);
#ifdef DARWIN #if defined(DARWIN) || defined(_ALPINE)
if (errno == EINVAL) errno = 0; if (errno == EINVAL) errno = 0;
#endif #endif
#ifdef TD_CHECK_STR_TO_INT_ERROR #ifdef TD_CHECK_STR_TO_INT_ERROR

View File

@ -124,7 +124,7 @@ static char tsProcIOFile[25] = {0};
static void taosGetProcIOnfos() { static void taosGetProcIOnfos() {
tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024; tsPageSizeKB = sysconf(_SC_PAGESIZE) / 1024;
tsOpenMax = sysconf(_SC_OPEN_MAX); tsOpenMax = sysconf(_SC_OPEN_MAX);
tsStreamMax = sysconf(_SC_STREAM_MAX); tsStreamMax = TMAX(sysconf(_SC_STREAM_MAX), 0);
tsProcId = (pid_t)syscall(SYS_gettid); tsProcId = (pid_t)syscall(SYS_gettid);
snprintf(tsProcMemFile, sizeof(tsProcMemFile), "/proc/%d/status", tsProcId); snprintf(tsProcMemFile, sizeof(tsProcMemFile), "/proc/%d/status", tsProcId);

View File

@ -99,8 +99,8 @@ static void *taosProcessAlarmSignal(void *tharg) {
setThreadName("tmr"); setThreadName("tmr");
#ifdef _ALPINE #ifdef _ALPINE
sevent.sigev_notify = SIGEV_THREAD; sevent.sigev_notify = SIGEV_THREAD_ID;
sevent.sigev_value.sival_int = syscall(__NR_gettid); sevent.sigev_notify_thread_id = syscall(__NR_gettid);
#else #else
sevent.sigev_notify = SIGEV_THREAD_ID; sevent.sigev_notify = SIGEV_THREAD_ID;
sevent._sigev_un._tid = syscall(__NR_gettid); sevent._sigev_un._tid = syscall(__NR_gettid);

View File

@ -15,6 +15,7 @@ import sys
import os import os
import os.path import os.path
import platform import platform
import distro
import subprocess import subprocess
from time import sleep from time import sleep
import base64 import base64
@ -22,6 +23,7 @@ import json
import copy import copy
from fabric2 import Connection from fabric2 import Connection
from util.log import * from util.log import *
from shutil import which
class TDSimClient: class TDSimClient:
@ -166,9 +168,9 @@ class TDDnode:
if value: if value:
selfPath = os.path.dirname(os.path.realpath(__file__)) selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath): 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: 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): def getDataSize(self):
totalSize = 0 totalSize = 0
@ -686,7 +688,7 @@ class TDDnodes:
if ("community" in selfPath): if ("community" in selfPath):
self.stopDnodesPath = os.path.abspath(self.path + "/community/tests/script/sh/stop_dnodes.sh") 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") 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.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") self.stopDnodesSigintPath = os.path.abspath(self.path + "/tests/script/sh/sigint_stop_dnodes.sh")
tdLog.info("run in address sanitizer mode") tdLog.info("run in address sanitizer mode")
@ -765,7 +767,8 @@ class TDDnodes:
def stopAll(self): def stopAll(self):
tdLog.info("stop all dnodes, asan:%d" % self.asan) 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) tdLog.info("execute script: %s" % self.stopDnodesPath)
os.system(self.stopDnodesPath) os.system(self.stopDnodesPath)
tdLog.info("execute finished") tdLog.info("execute finished")
@ -777,24 +780,41 @@ class TDDnodes:
for i in range(len(self.dnodes)): for i in range(len(self.dnodes)):
self.dnodes[i].stop() 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 (distro_id == "alpine"):
if processID: print(distro_id)
cmd = "sudo systemctl stop taosd" psCmd = "ps -ef | grep -w taosd | grep 'root' | grep -v grep| grep -v defunct | awk '{print $2}' | xargs"
os.system(cmd) processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip()
# if os.system(cmd) != 0 : while(processID):
# tdLog.exit(cmd) print(processID)
psCmd = "ps -ef|grep -w taosd| grep -v grep| grep -v defunct | awk '{print $2}' | xargs" if platform.system().lower() == 'windows':
processID = subprocess.check_output(psCmd, shell=True).decode("utf-8").strip() killCmd = "kill -9 %s > nul 2>&1" % processID
while(processID): else:
if platform.system().lower() == 'windows': killCmd = "kill -9 %s > /dev/null 2>&1" % processID
killCmd = "kill -9 %s > nul 2>&1" % processID os.system(killCmd)
else: time.sleep(1)
killCmd = "kill -9 %s > /dev/null 2>&1" % processID processID = subprocess.check_output(
os.system(killCmd) psCmd, shell=True).decode("utf-8").strip()
time.sleep(1)
processID = subprocess.check_output( else:
psCmd, shell=True).decode("utf-8").strip() 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: if self.killValgrind == 1:
psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs" psCmd = "ps -ef|grep -w valgrind.bin| grep -v grep | awk '{print $2}' | xargs"

View File

@ -4,3 +4,7 @@ fabric2
psutil psutil
pandas pandas
toml toml
distro
requests
pexpect
faker

View File

@ -45,11 +45,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -2,7 +2,19 @@
set +e set +e
#set -x #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 unset LD_PRELOAD
SCRIPT_DIR=`dirname $0` SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../ cd $SCRIPT_DIR/../

View File

@ -48,11 +48,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -39,11 +39,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -54,11 +54,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -10,6 +10,14 @@
set +e set +e
#set -x #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 unset LD_PRELOAD
UNAME_BIN=`which uname` UNAME_BIN=`which uname`
@ -44,7 +52,10 @@ do
;; ;;
esac esac
done done
if [[ "$VALGRIND_OPTION" = "true" ]] && [[ "$TD_OS" == "Alpine" ]]; then
echo alpine skip valgrind
VALGRIND_OPTION="false"
fi
SCRIPT_DIR=`dirname $0` SCRIPT_DIR=`dirname $0`
cd $SCRIPT_DIR/../ cd $SCRIPT_DIR/../
SCRIPT_DIR=`pwd` SCRIPT_DIR=`pwd`
@ -59,11 +70,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -51,11 +51,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -20,11 +20,7 @@ fi
TAOS_DIR=`pwd` TAOS_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -51,11 +51,7 @@ fi
TOP_DIR=`pwd` TOP_DIR=`pwd`
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1`
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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`

View File

@ -130,13 +130,13 @@ print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 1 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
if $data(2)[2] != 1 then if $data(2)[2] != 2 then
return -1 return -1
endi endi
if $data(3)[2] != 2 then if $data(3)[2] != 2 then
return -1 return -1
endi endi
if $data(4)[2] != 2 then if $data(4)[2] != 1 then
return -1 return -1
endi endi
@ -216,7 +216,7 @@ endi
print ========== step4 print ========== step4
sql create database d3 replica 3 vgroups 1 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+1s, 35)
sql insert into d3.t3 values(now+2s, 34) sql insert into d3.t3 values(now+2s, 34)
sql insert into d3.t3 values(now+3s, 33) 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 if $data(1)[2] != 2 then
return -1 return -1
endi endi
if $data(3)[2] != 2 then if $data(3)[2] != 3 then
return -1 return -1
endi endi
if $data(4)[2] != 3 then if $data(4)[2] != 2 then
return -1 return -1
endi endi
if $data(5)[2] != 2 then if $data(5)[2] != 2 then
@ -315,10 +315,10 @@ endi
if $data(3)[2] != null then if $data(3)[2] != null then
return -1 return -1
endi endi
if $data(4)[2] != 2 then if $data(4)[2] != 3 then
return -1 return -1
endi endi
if $data(5)[2] != 3 then if $data(5)[2] != 2 then
return -1 return -1
endi endi
if $data(6)[2] != 2 then if $data(6)[2] != 2 then

View File

@ -145,10 +145,10 @@ print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 1 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
if $data(2)[2] != 1 then if $data(2)[2] != 2 then
return -1 return -1
endi endi
if $data(3)[2] != 2 then if $data(3)[2] != 1 then
return -1 return -1
endi endi
if $data(4)[2] != 1 then if $data(4)[2] != 1 then

View File

@ -120,9 +120,9 @@ if $rows != 12 then
return -1 return -1
endi endi
print =============== step3: create qnode snode on dnode 2 print =============== step3: create qnode snode on dnode 3
sql create qnode on dnode 2 sql create qnode on dnode 3
sql create snode on dnode 2 sql create snode on dnode 3
sql select * from information_schema.ins_qnodes sql select * from information_schema.ins_qnodes
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -136,16 +136,16 @@ print =============== step4: create mnode on dnode 2
sql create mnode on dnode 3 sql create mnode on dnode 3
sql create mnode on dnode 2 sql create mnode on dnode 2
$x = 0 $x = 0
step4: step4:
$x = $x + 1 $x = $x + 1
sleep 1000 sleep 1000
if $x == 10 then if $x == 10 then
return -1 return -1
endi endi
sql select * from information_schema.ins_mnodes -x step4 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[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[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[2][0] $data[2][1] $data[2][2] $data[2][3] $data[1][4]
#if $data(1)[2] != leader then #if $data(1)[2] != leader then
# goto step4 # goto step4
#endi #endi
@ -157,7 +157,7 @@ endi
#endi #endi
print =============== step5: create dnode 5 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 system sh/exec.sh -n dnode5 -s start
$x = 0 $x = 0
step5: step5:
@ -179,10 +179,10 @@ endi
if $data(1)[4] != ready then if $data(1)[4] != ready then
goto step5 goto step5
endi endi
if $data(2)[4] != offline then if $data(2)[4] != ready then
goto step5 goto step5
endi endi
if $data(3)[4] != ready then if $data(3)[4] != offline then
goto step5 goto step5
endi endi
if $data(4)[4] != ready then if $data(4)[4] != ready then
@ -192,9 +192,9 @@ if $data(5)[4] != ready then
goto step5 goto step5
endi endi
print =============== step5a: drop dnode 2 print =============== step5a: drop dnode 3
sql_error drop dnode 2 sql_error drop dnode 3
sql drop dnode 2 force sql drop dnode 3 force
print select * from information_schema.ins_dnodes; print select * from information_schema.ins_dnodes;
sql select * from information_schema.ins_dnodes; sql select * from information_schema.ins_dnodes;

View File

@ -207,10 +207,10 @@ print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 1 then if $data(1)[2] != 1 then
return -1 return -1
endi endi
if $data(3)[2] != 1 then if $data(3)[2] != 2 then
return -1 return -1
endi endi
if $data(4)[2] != 2 then if $data(4)[2] != 1 then
return -1 return -1
endi endi

View File

@ -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: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:33:00', 3, '3');
sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4'); 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 if $rows != 4 then
return -1 return -1
endi endi

View File

@ -99,6 +99,10 @@ class TDTestCase:
def run(self): def run(self):
distro_id = distro.id()
if distro_id == "alpine":
tdLog.info(f"alpine skip compatibility test")
return True
bPath = self.getBuildPath() bPath = self.getBuildPath()
cPath = self.getCfgPath() cPath = self.getCfgPath()
dbname = "test" dbname = "test"

View File

@ -97,7 +97,7 @@ class TDTestCase:
tdSql.execute( 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}" )') 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( 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 )" 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 )"
) )

View File

@ -145,8 +145,8 @@ class TDTestCase:
tdSql.query("show db.alive;") tdSql.query("show db.alive;")
tdSql.checkData(0, 0, 1) tdSql.checkData(0, 0, 1)
# stop 5 dnode # stop 3 dnode
self.TDDnodes.stoptaosd(5) self.TDDnodes.stoptaosd(3)
tdSql.checkDataLoop(0, 0, 2, "show cluster alive;", 20, 0.5) tdSql.checkDataLoop(0, 0, 2, "show cluster alive;", 20, 0.5)
tdSql.query("show db.alive;") tdSql.query("show db.alive;")

View File

@ -236,8 +236,8 @@ class TDTestCase:
tdDnodes[0].starttaosd() tdDnodes[0].starttaosd()
self.check3mnode() self.check3mnode()
tdLog.info("3. stop dnode 1") tdLog.info("3. stop dnode 2")
tdDnodes[1].stoptaosd() tdDnodes[2].stoptaosd()
time.sleep(10) time.sleep(10)
self.check3mnode1off() self.check3mnode1off()

View File

@ -192,7 +192,7 @@ class TDTestCase:
topicList = topicNameList[0] topicList = topicNameList[0]
ifcheckdata = 1 ifcheckdata = 1
ifManualCommit = 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) tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit)
tdLog.info("start consume processor 0") tdLog.info("start consume processor 0")

View File

@ -8,15 +8,23 @@
set +e set +e
#set -x #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` UNAME_BIN=$(which uname)
OS_TYPE=`$UNAME_BIN` OS_TYPE=$($UNAME_BIN)
cd . cd .
# Get responsible directories # Get responsible directories
CODE_DIR=`dirname $0` CODE_DIR=$(dirname $0)
CODE_DIR=`pwd` CODE_DIR=$(pwd)
IN_TDINTERNAL="community" IN_TDINTERNAL="community"
if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then if [[ "$CODE_DIR" == *"$IN_TDINTERNAL"* ]]; then
@ -25,19 +33,15 @@ else
cd ../../ cd ../../
fi fi
TOP_DIR=`pwd` TOP_DIR=$(pwd)
TAOSD_DIR=`find . -name "taosd"|grep bin|head -n1` TAOSD_DIR=$(find . -name "taosd" | grep bin | head -n1)
if [[ "$OS_TYPE" != "Darwin" ]]; then cut_opt="-f "
cut_opt="--field="
else
cut_opt="-f "
fi
if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then 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 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 fi
declare -x BUILD_DIR=$TOP_DIR/$BIN_DIR 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 #sudo sysctl -w kernel.core_pattern=$TOP_DIR/core.%p.%e
echo "ExcuteCmd:" $* echo "ExcuteCmd:" $*
AsanFile=$ASAN_DIR/psim.info
echo "AsanFile:" $AsanFile
unset LD_PRELOAD if [[ "$TD_OS" == "Alpine" ]]; then
#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 else
echo "Execute script failure" AsanFile=$ASAN_DIR/psim.info
exit 1 echo "AsanFile:" $AsanFile
fi
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

View File

@ -7,25 +7,45 @@ IF (TD_WEBSOCKET)
SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}") SET(websocket_lib_file "{taosws.dll,taosws.dll.lib}")
ENDIF () ENDIF ()
MESSAGE("${Green} use libtaos-ws${ColourReset}") MESSAGE("${Green} use libtaos-ws${ColourReset}")
IF (TD_ALPINE)
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(taosws-rs ExternalProject_Add(taosws-rs
PREFIX "taosws-rs" PREFIX "taosws-rs"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
BUILD_ALWAYS off BUILD_ALWAYS off
DEPENDS taos DEPENDS taos
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config" CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
PATCH_COMMAND PATCH_COMMAND
COMMAND git clean -f -d COMMAND git clean -f -d
BUILD_COMMAND BUILD_COMMAND
COMMAND cargo update COMMAND cargo update
COMMAND cargo build --release -p taos-ws-sys --features native-tls-vendored COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features native-tls
INSTALL_COMMAND INSTALL_COMMAND
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib 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 make_directory ${CMAKE_BINARY_DIR}/build/include
COMMAND cmake -E copy target/release/taosws.h ${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 () ENDIF ()
IF (TD_TAOS_TOOLS) IF (TD_TAOS_TOOLS)

View File

@ -30,15 +30,23 @@ IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL)
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging) ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) 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) if(TD_WINDOWS)
target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET}) target_link_libraries(shell PUBLIC taos_static ${LINK_WEBSOCKET})
else() else()
target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC}) target_link_libraries(shell PUBLIC taos ${LINK_WEBSOCKET} ${LINK_JEMALLOC} ${LINK_ARGP})
endif () endif ()
target_link_libraries( target_link_libraries(
shell shell
PRIVATE os common transport util PRIVATE os common transport util
) )
target_include_directories( target_include_directories(
shell shell
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"

View File

@ -97,7 +97,11 @@ void shellPrintHelp() {
#ifdef LINUX #ifdef LINUX
#include <argp.h> #include <argp.h>
#ifdef _ALPINE
#include <termios.h>
#else
#include <termio.h> #include <termio.h>
#endif
const char *argp_program_version = version; const char *argp_program_version = version;
const char *argp_program_bug_address = cusEmail; const char *argp_program_bug_address = cusEmail;