diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 7d96a89e853665af8a7c43499468ad1c52976d0c..bff49c2ca91d3b03ee0d832bfc7b996959576f18 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -348,7 +348,7 @@ static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIn int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; char* t = taosMemoryCalloc(1, outputMaxLen); - /*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), outputMaxLen, &len); + /*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len); varDataSetLen(t, len); colDataAppend(pOut->columnData, rowIndex, t, false); diff --git a/source/os/src/osTime.c b/source/os/src/osTime.c index 5d6b4e7c2b840098324c1fea1067356fecfd32a9..7e6e5088177c9d157041211f77368f58fb6a37ee 100644 --- a/source/os/src/osTime.c +++ b/source/os/src/osTime.c @@ -28,92 +28,48 @@ #ifdef WINDOWS -#include -#include +#include #include +#include //#define TM_YEAR_BASE 1970 //origin -#define TM_YEAR_BASE 1900 //slguan +#define TM_YEAR_BASE 1900 // slguan /* -* We do not implement alternate representations. However, we always -* check whether a given modifier is allowed for a certain conversion. -*/ -#define ALT_E 0x01 -#define ALT_O 0x02 -#define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); } - + * We do not implement alternate representations. However, we always + * check whether a given modifier is allowed for a certain conversion. + */ +#define ALT_E 0x01 +#define ALT_O 0x02 +#define LEGAL_ALT(x) \ + { \ + if (alt_format & ~(x)) return (0); \ + } -static int conv_num(const char **buf, int *dest, int llim, int ulim) -{ - int result = 0; +static int conv_num(const char **buf, int *dest, int llim, int ulim) { + int result = 0; - /* The limit also determines the number of valid digits. */ - int rulim = ulim; + /* The limit also determines the number of valid digits. */ + int rulim = ulim; - if (**buf < '0' || **buf > '9') - return (0); + if (**buf < '0' || **buf > '9') return (0); - do { - result *= 10; - result += *(*buf)++ - '0'; - rulim /= 10; - } while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9'); + do { + result *= 10; + result += *(*buf)++ - '0'; + rulim /= 10; + } while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9'); - if (result < llim || result > ulim) - return (0); + if (result < llim || result > ulim) return (0); - *dest = result; - return (1); + *dest = result; + return (1); } -static const char *day[7] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday" -}; -static const char *abday[7] = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" -}; -static const char *mon[12] = { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" -}; -static const char *abmon[12] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" -}; -static const char *am_pm[2] = { - "AM", "PM" -}; - -#define BILLION (1E9) - -static BOOL g_first_time = 1; -static LARGE_INTEGER g_counts_per_sec; - -int clock_gettime(int dummy, struct timespec *ct) -{ - LARGE_INTEGER count; - - if (g_first_time) - { - g_first_time = 0; - - if (0 == QueryPerformanceFrequency(&g_counts_per_sec)) - { - g_counts_per_sec.QuadPart = 0; - } - } - - if ((NULL == ct) || (g_counts_per_sec.QuadPart <= 0) || - (0 == QueryPerformanceCounter(&count))) - { - return -1; - } - - ct->tv_sec = count.QuadPart / g_counts_per_sec.QuadPart; - ct->tv_nsec = ((count.QuadPart % g_counts_per_sec.QuadPart) * BILLION) / g_counts_per_sec.QuadPart; - - return 0; -} +static const char *day[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; +static const char *abday[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; +static const char *mon[12] = {"January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"}; +static const char *abmon[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; +static const char *am_pm[2] = {"AM", "PM"}; #else #include @@ -121,301 +77,265 @@ int clock_gettime(int dummy, struct timespec *ct) char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm) { #ifdef WINDOWS - char c; - const char *bp; - size_t len = 0; - int alt_format, i, split_year = 0; + char c; + const char *bp; + size_t len = 0; + int alt_format, i, split_year = 0; - bp = buf; + bp = buf; - while ((c = *fmt) != '\0') { - /* Clear `alternate' modifier prior to new conversion. */ - alt_format = 0; + while ((c = *fmt) != '\0') { + /* Clear `alternate' modifier prior to new conversion. */ + alt_format = 0; - /* Eat up white-space. */ - if (isspace(c)) { - while (isspace(*bp)) - bp++; + /* Eat up white-space. */ + if (isspace(c)) { + while (isspace(*bp)) bp++; - fmt++; - continue; - } - - if ((c = *fmt++) != '%') - goto literal; + fmt++; + continue; + } + if ((c = *fmt++) != '%') goto literal; - again: switch (c = *fmt++) { - case '%': /* "%%" is converted to "%". */ - literal : - if (c != *bp++) - return (0); + again: + switch (c = *fmt++) { + case '%': /* "%%" is converted to "%". */ + literal: + if (c != *bp++) return (0); break; /* - * "Alternative" modifiers. Just set the appropriate flag - * and start over again. - */ - case 'E': /* "%E?" alternative conversion modifier. */ + * "Alternative" modifiers. Just set the appropriate flag + * and start over again. + */ + case 'E': /* "%E?" alternative conversion modifier. */ LEGAL_ALT(0); alt_format |= ALT_E; goto again; - case 'O': /* "%O?" alternative conversion modifier. */ + case 'O': /* "%O?" alternative conversion modifier. */ LEGAL_ALT(0); alt_format |= ALT_O; goto again; /* - * "Complex" conversion rules, implemented through recursion. - */ - case 'c': /* Date and time, using the locale's format. */ + * "Complex" conversion rules, implemented through recursion. + */ + case 'c': /* Date and time, using the locale's format. */ LEGAL_ALT(ALT_E); - if (!(bp = taosStrpTime(bp, "%x %X", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%x %X", tm))) return (0); break; - case 'D': /* The date as "%m/%d/%y". */ + case 'D': /* The date as "%m/%d/%y". */ LEGAL_ALT(0); - if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) return (0); break; - case 'R': /* The time as "%H:%M". */ + case 'R': /* The time as "%H:%M". */ LEGAL_ALT(0); - if (!(bp = taosStrpTime(bp, "%H:%M", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%H:%M", tm))) return (0); break; - case 'r': /* The time in 12-hour clock representation. */ + case 'r': /* The time in 12-hour clock representation. */ LEGAL_ALT(0); - if (!(bp = taosStrpTime(bp, "%I:%M:%S %p", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%I:%M:%S %p", tm))) return (0); break; - case 'T': /* The time as "%H:%M:%S". */ + case 'T': /* The time as "%H:%M:%S". */ LEGAL_ALT(0); - if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) return (0); break; - case 'X': /* The time, using the locale's format. */ + case 'X': /* The time, using the locale's format. */ LEGAL_ALT(ALT_E); - if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%H:%M:%S", tm))) return (0); break; - case 'x': /* The date, using the locale's format. */ + case 'x': /* The date, using the locale's format. */ LEGAL_ALT(ALT_E); - if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) - return (0); + if (!(bp = taosStrpTime(bp, "%m/%d/%y", tm))) return (0); break; /* - * "Elementary" conversion rules. - */ - case 'A': /* The day of week, using the locale's form. */ - case 'a': + * "Elementary" conversion rules. + */ + case 'A': /* The day of week, using the locale's form. */ + case 'a': LEGAL_ALT(0); for (i = 0; i < 7; i++) { - /* Full name. */ - len = strlen(day[i]); - if (strncmp(day[i], bp, len) == 0) - break; - - /* Abbreviated name. */ - len = strlen(abday[i]); - if (strncmp(abday[i], bp, len) == 0) - break; + /* Full name. */ + len = strlen(day[i]); + if (strncmp(day[i], bp, len) == 0) break; + + /* Abbreviated name. */ + len = strlen(abday[i]); + if (strncmp(abday[i], bp, len) == 0) break; } /* Nothing matched. */ - if (i == 7) - return (0); + if (i == 7) return (0); tm->tm_wday = i; bp += len; break; - case 'B': /* The month, using the locale's form. */ - case 'b': - case 'h': + case 'B': /* The month, using the locale's form. */ + case 'b': + case 'h': LEGAL_ALT(0); for (i = 0; i < 12; i++) { - /* Full name. */ - len = strlen(mon[i]); - if (strncmp(mon[i], bp, len) == 0) - break; - - /* Abbreviated name. */ - len = strlen(abmon[i]); - if (strncmp(abmon[i], bp, len) == 0) - break; + /* Full name. */ + len = strlen(mon[i]); + if (strncmp(mon[i], bp, len) == 0) break; + + /* Abbreviated name. */ + len = strlen(abmon[i]); + if (strncmp(abmon[i], bp, len) == 0) break; } /* Nothing matched. */ - if (i == 12) - return (0); + if (i == 12) return (0); tm->tm_mon = i; bp += len; break; - case 'C': /* The century number. */ + case 'C': /* The century number. */ LEGAL_ALT(ALT_E); - if (!(conv_num(&bp, &i, 0, 99))) - return (0); + if (!(conv_num(&bp, &i, 0, 99))) return (0); if (split_year) { - tm->tm_year = (tm->tm_year % 100) + (i * 100); - } - else { - tm->tm_year = i * 100; - split_year = 1; + tm->tm_year = (tm->tm_year % 100) + (i * 100); + } else { + tm->tm_year = i * 100; + split_year = 1; } break; - case 'd': /* The day of month. */ - case 'e': + case 'd': /* The day of month. */ + case 'e': LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_mday, 1, 31))) - return (0); + if (!(conv_num(&bp, &tm->tm_mday, 1, 31))) return (0); break; - case 'k': /* The hour (24-hour clock representation). */ + case 'k': /* The hour (24-hour clock representation). */ LEGAL_ALT(0); /* FALLTHROUGH */ - case 'H': + case 'H': LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_hour, 0, 23))) - return (0); + if (!(conv_num(&bp, &tm->tm_hour, 0, 23))) return (0); break; - case 'l': /* The hour (12-hour clock representation). */ + case 'l': /* The hour (12-hour clock representation). */ LEGAL_ALT(0); /* FALLTHROUGH */ - case 'I': + case 'I': LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_hour, 1, 12))) - return (0); - if (tm->tm_hour == 12) - tm->tm_hour = 0; + if (!(conv_num(&bp, &tm->tm_hour, 1, 12))) return (0); + if (tm->tm_hour == 12) tm->tm_hour = 0; break; - case 'j': /* The day of year. */ + case 'j': /* The day of year. */ LEGAL_ALT(0); - if (!(conv_num(&bp, &i, 1, 366))) - return (0); + if (!(conv_num(&bp, &i, 1, 366))) return (0); tm->tm_yday = i - 1; break; - case 'M': /* The minute. */ + case 'M': /* The minute. */ LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_min, 0, 59))) - return (0); + if (!(conv_num(&bp, &tm->tm_min, 0, 59))) return (0); break; - case 'm': /* The month. */ + case 'm': /* The month. */ LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &i, 1, 12))) - return (0); + if (!(conv_num(&bp, &i, 1, 12))) return (0); tm->tm_mon = i - 1; break; - case 'p': /* The locale's equivalent of AM/PM. */ + case 'p': /* The locale's equivalent of AM/PM. */ LEGAL_ALT(0); /* AM? */ if (strcmp(am_pm[0], bp) == 0) { - if (tm->tm_hour > 11) - return (0); + if (tm->tm_hour > 11) return (0); - bp += strlen(am_pm[0]); - break; + bp += strlen(am_pm[0]); + break; } /* PM? */ else if (strcmp(am_pm[1], bp) == 0) { - if (tm->tm_hour > 11) - return (0); + if (tm->tm_hour > 11) return (0); - tm->tm_hour += 12; - bp += strlen(am_pm[1]); - break; + tm->tm_hour += 12; + bp += strlen(am_pm[1]); + break; } /* Nothing matched. */ return (0); - case 'S': /* The seconds. */ + case 'S': /* The seconds. */ LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_sec, 0, 61))) - return (0); + if (!(conv_num(&bp, &tm->tm_sec, 0, 61))) return (0); break; - case 'U': /* The week of year, beginning on sunday. */ - case 'W': /* The week of year, beginning on monday. */ + case 'U': /* The week of year, beginning on sunday. */ + case 'W': /* The week of year, beginning on monday. */ LEGAL_ALT(ALT_O); /* - * XXX This is bogus, as we can not assume any valid - * information present in the tm structure at this - * point to calculate a real value, so just check the - * range for now. - */ - if (!(conv_num(&bp, &i, 0, 53))) - return (0); + * XXX This is bogus, as we can not assume any valid + * information present in the tm structure at this + * point to calculate a real value, so just check the + * range for now. + */ + if (!(conv_num(&bp, &i, 0, 53))) return (0); break; - case 'w': /* The day of week, beginning on sunday. */ + case 'w': /* The day of week, beginning on sunday. */ LEGAL_ALT(ALT_O); - if (!(conv_num(&bp, &tm->tm_wday, 0, 6))) - return (0); + if (!(conv_num(&bp, &tm->tm_wday, 0, 6))) return (0); break; - case 'Y': /* The year. */ + case 'Y': /* The year. */ LEGAL_ALT(ALT_E); - if (!(conv_num(&bp, &i, 0, 9999))) - return (0); + if (!(conv_num(&bp, &i, 0, 9999))) return (0); tm->tm_year = i - TM_YEAR_BASE; break; - case 'y': /* The year within 100 years of the epoch. */ + case 'y': /* The year within 100 years of the epoch. */ LEGAL_ALT(ALT_E | ALT_O); - if (!(conv_num(&bp, &i, 0, 99))) - return (0); + if (!(conv_num(&bp, &i, 0, 99))) return (0); if (split_year) { - tm->tm_year = ((tm->tm_year / 100) * 100) + i; - break; + tm->tm_year = ((tm->tm_year / 100) * 100) + i; + break; } split_year = 1; if (i <= 68) - tm->tm_year = i + 2000 - TM_YEAR_BASE; + tm->tm_year = i + 2000 - TM_YEAR_BASE; else - tm->tm_year = i + 1900 - TM_YEAR_BASE; + tm->tm_year = i + 1900 - TM_YEAR_BASE; break; /* - * Miscellaneous conversions. - */ - case 'n': /* Any kind of white-space. */ - case 't': + * Miscellaneous conversions. + */ + case 'n': /* Any kind of white-space. */ + case 't': LEGAL_ALT(0); - while (isspace(*bp)) - bp++; + while (isspace(*bp)) bp++; break; - - default: /* Unknown/unsupported conversion. */ + default: /* Unknown/unsupported conversion. */ return (0); } + } - - } - - /* LINTED functional specification */ - return ((char *)bp); + /* LINTED functional specification */ + return ((char *)bp); #else - return strptime(buf, fmt, tm); + return strptime(buf, fmt, tm); #endif } @@ -435,13 +355,9 @@ FORCE_INLINE int32_t taosGetTimeOfDay(struct timeval *tv) { #endif } -time_t taosTime(time_t *t) { - return time(t); -} +time_t taosTime(time_t *t) { return time(t); } -time_t taosMktime(struct tm *timep) { - return mktime(timep); -} +time_t taosMktime(struct tm *timep) { return mktime(timep); } struct tm *taosLocalTime(const time_t *timep, struct tm *result) { if (result == NULL) { @@ -456,5 +372,36 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result) { } int32_t taosGetTimestampSec() { return (int32_t)time(NULL); } - -int32_t taosClockGetTime(int clock_id, struct timespec *pTS) { return clock_gettime(clock_id, pTS); } \ No newline at end of file +int32_t taosClockGetTime(int clock_id, struct timespec *pTS) { +#ifdef WINDOWS + LARGE_INTEGER t; + FILETIME f; + static FILETIME ff; + static SYSTEMTIME ss; + static LARGE_INTEGER offset; + + ss.wYear = 1970; + ss.wMonth = 1; + ss.wDay = 1; + ss.wHour = 0; + ss.wMinute = 0; + ss.wSecond = 0; + ss.wMilliseconds = 0; + SystemTimeToFileTime(&ss, &ff); + offset.QuadPart = ff.dwHighDateTime; + offset.QuadPart <<= 32; + offset.QuadPart |= ff.dwLowDateTime; + + GetSystemTimeAsFileTime(&f); + t.QuadPart = f.dwHighDateTime; + t.QuadPart <<= 32; + t.QuadPart |= f.dwLowDateTime; + + t.QuadPart -= offset.QuadPart; + pTS->tv_sec = t.QuadPart / 10000000; + pTS->tv_nsec = (t.QuadPart % 10000000)*100; + return (0); +#else + return clock_gettime(clock_id, pTS); +#endif +} \ No newline at end of file diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index c2aed6555d62af128eddc29eef21ee0de174ec14..56989597eca856c4cd3fa80135ffce6429bb3ba0 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -574,6 +574,9 @@ class TDDnodes: def stopAll(self): tdLog.info("stop all dnodes") + if (not self.dnodes[0].remoteIP == ""): + self.dnodes[0].remoteExec(self.dnodes[0].cfgDict, "for i in range(len(tdDnodes.dnodes)):\n tdDnodes.dnodes[i].running=1\ntdDnodes.stopAll()") + return for i in range(len(self.dnodes)): self.dnodes[i].stop() diff --git a/tests/system-test/0-others/taosdlog.py b/tests/system-test/0-others/taosdlog.py index f9f80bb9109100aa3e19efdbf558bc980e2beb9a..f8898daf4190dfeb12181fb060a75295c483259f 100644 --- a/tests/system-test/0-others/taosdlog.py +++ b/tests/system-test/0-others/taosdlog.py @@ -23,7 +23,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/0-others/udf_cluster.py b/tests/system-test/0-others/udf_cluster.py index de998e9087c2bc8ef1ff3b1aab09695cf57fd8f4..c5c0c7b8f2b460be28170f921c027575f28c7636 100644 --- a/tests/system-test/0-others/udf_cluster.py +++ b/tests/system-test/0-others/udf_cluster.py @@ -37,7 +37,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index 0d24b09616c3eb57dc3b9a6ecbced9a045919289..170d9b1421ad146553d8d0a5e1d9c9632b4787be 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -9,8 +9,9 @@ from util.sql import * from util.cases import * from util.dnodes import * import subprocess -# import win32gui -# import threading +if (platform.system().lower() == 'windows'): + import win32gui +import threading class TDTestCase: @@ -535,17 +536,18 @@ class TDTestCase: return udf1_sqls ,udf2_sqls - # def checkRunTimeError(self): - # while 1: - # time.sleep(1) - # hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library") - # if hwnd: - # os.system("TASKKILL /F /IM udfd.exe") + def checkRunTimeError(self): + if (platform.system().lower() == 'windows' and tdDnodes.dnodes[0].remoteIP == ""): + while 1: + time.sleep(1) + hwnd = win32gui.FindWindow(None, "Microsoft Visual C++ Runtime Library") + if hwnd: + os.system("TASKKILL /F /IM udfd.exe") def unexpected_create(self): - # if (platform.system().lower() == 'windows' and tdDnodes.dnodes[0].remoteIP == ""): - # checkErrorThread = threading.Thread(target=self.checkRunTimeError,daemon=True) - # checkErrorThread.start() + if (platform.system().lower() == 'windows' and tdDnodes.dnodes[0].remoteIP == ""): + checkErrorThread = threading.Thread(target=self.checkRunTimeError,daemon=True) + checkErrorThread.start() tdLog.info(" create function with out bufsize ") tdSql.query("drop function udf1 ") diff --git a/tests/system-test/0-others/user_control.py b/tests/system-test/0-others/user_control.py index 3adc31cc39c182fcc2ba5a6083eb4d2f4c7aaeb9..4d59129b91dc62eec744ca2e33498a6cf9e9cb04 100644 --- a/tests/system-test/0-others/user_control.py +++ b/tests/system-test/0-others/user_control.py @@ -3,6 +3,7 @@ import taos import time import inspect import traceback +import socket from dataclasses import dataclass from util.log import * @@ -102,7 +103,7 @@ class TDconnect: def taos_connect( - host = "127.0.0.1", + host = socket.gethostname(), port = 6030, user = "root", passwd = "taosdata", diff --git a/tests/system-test/1-insert/insertWithMoreVgroup.py b/tests/system-test/1-insert/insertWithMoreVgroup.py index 8d2870fc2cf068153a424d2b1613188c018c6463..97220350e0a1f1d50357837d4469def5a9772193 100644 --- a/tests/system-test/1-insert/insertWithMoreVgroup.py +++ b/tests/system-test/1-insert/insertWithMoreVgroup.py @@ -54,7 +54,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root)-len("/build/bin")] diff --git a/tests/system-test/1-insert/mutipythonnodebugtaosd.py b/tests/system-test/1-insert/mutipythonnodebugtaosd.py index 73d70b43488b57345a822f971190f4e62212f865..3d6358f3ff54554ca58099ec36344aabe02e4dd8 100644 --- a/tests/system-test/1-insert/mutipythonnodebugtaosd.py +++ b/tests/system-test/1-insert/mutipythonnodebugtaosd.py @@ -52,7 +52,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root)-len("/build/bin")] diff --git a/tests/system-test/1-insert/test_stmt_insert_query_ex.py b/tests/system-test/1-insert/test_stmt_insert_query_ex.py index c0836b79c8da4ef50b20e4763bb2208780d274b1..6d49f6065a329ca833cbf927452799a85c6e6337 100644 --- a/tests/system-test/1-insert/test_stmt_insert_query_ex.py +++ b/tests/system-test/1-insert/test_stmt_insert_query_ex.py @@ -49,7 +49,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root)-len("/build/bin")] diff --git a/tests/system-test/1-insert/test_stmt_muti_insert_query.py b/tests/system-test/1-insert/test_stmt_muti_insert_query.py index f838fd90f51246ee11f5e16648167491cfe52989..971be6c85fb20e4960fe902cd3b329acb4931237 100644 --- a/tests/system-test/1-insert/test_stmt_muti_insert_query.py +++ b/tests/system-test/1-insert/test_stmt_muti_insert_query.py @@ -49,7 +49,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root)-len("/build/bin")] diff --git a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py index fb9f455d4da6fa75efd380dc9bedf6aa3e415906..b540642847e6e8cc41407e40a6e6913a7f343265 100644 --- a/tests/system-test/1-insert/test_stmt_set_tbname_tag.py +++ b/tests/system-test/1-insert/test_stmt_set_tbname_tag.py @@ -49,7 +49,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root)-len("/build/bin")] diff --git a/tests/system-test/2-query/histogram.py b/tests/system-test/2-query/histogram.py index 2c203bdceb1c6f180fc3e653aa1dd6c62512d0e2..c8952c4af59f43733125e3044957186f7862f8cb 100644 --- a/tests/system-test/2-query/histogram.py +++ b/tests/system-test/2-query/histogram.py @@ -400,7 +400,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/2-query/timezone.py b/tests/system-test/2-query/timezone.py index ff55ab31bff3ef0c3bd315e9cf190fc517bd7c78..20ee58feac23fa9eee6039787c602c5c696f284d 100644 --- a/tests/system-test/2-query/timezone.py +++ b/tests/system-test/2-query/timezone.py @@ -3,7 +3,10 @@ from util.log import * from util.sql import * from util.cases import * +import platform import os +if platform.system().lower() == 'windows': + import tzlocal class TDTestCase: @@ -15,16 +18,20 @@ class TDTestCase: def run(self): # sourcery skip: extract-duplicate-method tdSql.prepare() # get system timezone - time_zone_arr = os.popen('timedatectl | grep zone').read( - ).strip().split(':') - if len(time_zone_arr) > 1: - time_zone = time_zone_arr[1].lstrip() - else: - # possibly in a docker container - time_zone_1 = os.popen('ls -l /etc/localtime|awk -F/ \'{print $(NF-1) "/" $NF}\'').read().strip() - time_zone_2 = os.popen('date "+(%Z, %z)"').read().strip() + if platform.system().lower() == 'windows': + time_zone_1 = tzlocal.get_localzone_name() + time_zone_2 = time.strftime('(UTC, %z)') time_zone = time_zone_1 + " " + time_zone_2 - print("expected time zone: " + time_zone) + else: + time_zone_arr = os.popen('timedatectl | grep zone').read().strip().split(':') + if len(time_zone_arr) > 1: + time_zone = time_zone_arr[1].lstrip() + else: + # possibly in a docker container + time_zone_1 = os.popen('ls -l /etc/localtime|awk -F/ \'{print $(NF-1) "/" $NF}\'').read().strip() + time_zone_2 = os.popen('date "+(%Z, %z)"').read().strip() + time_zone = time_zone_1 + " " + time_zone_2 + print("expected time zone: " + time_zone) tdLog.printNoPrefix("==========step1:create tables==========") tdSql.execute( diff --git a/tests/system-test/7-tmq/basic5.py b/tests/system-test/7-tmq/basic5.py index 500e8671217f5d4bb8ae0793f288791095303135..d6ac4d4208b47d866797236b6353edad3806ac6d 100644 --- a/tests/system-test/7-tmq/basic5.py +++ b/tests/system-test/7-tmq/basic5.py @@ -13,6 +13,12 @@ from util.dnodes import * class TDTestCase: hostname = socket.gethostname() + if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""): + try: + config = eval(tdDnodes.dnodes[0].remoteIP) + hostname = config["host"] + except Exception: + hostname = tdDnodes.dnodes[0].remoteIP #rpcDebugFlagVal = '143' #clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} #clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal @@ -34,7 +40,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] @@ -192,7 +198,10 @@ class TDTestCase: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd += "> nul 2>&1 &" + else: + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -306,7 +315,10 @@ class TDTestCase: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd += "> nul 2>&1 &" + else: + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) @@ -438,7 +450,10 @@ class TDTestCase: shellCmd = 'nohup ' + buildPath + '/build/bin/tmq_sim -c ' + cfgPath shellCmd += " -y %d -d %s -g %d -r %d -w %s "%(pollDelay, parameterDict["dbName"], showMsg, showRow, cdbName) - shellCmd += "> /dev/null 2>&1 &" + if (platform.system().lower() == 'windows'): + shellCmd += "> nul 2>&1 &" + else: + shellCmd += "> /dev/null 2>&1 &" tdLog.info(shellCmd) os.system(shellCmd) diff --git a/tests/system-test/7-tmq/db.py b/tests/system-test/7-tmq/db.py index e2c6cc2e771932a8dfef2ba71fe1ff32c97b327f..70d02c4e29680bd5087d2ddad1eb357ed580deb6 100644 --- a/tests/system-test/7-tmq/db.py +++ b/tests/system-test/7-tmq/db.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/schema.py b/tests/system-test/7-tmq/schema.py index 51c8da241303c65e734d32f7659aeca38d13efe5..54b68813184dea10b7745de4a26d2df9f03f401b 100644 --- a/tests/system-test/7-tmq/schema.py +++ b/tests/system-test/7-tmq/schema.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index 43b707e65127586124caa16f8e5ec060d57a9f11..279518d283797f099a1098606225eae8360e8859 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeDb0.py b/tests/system-test/7-tmq/subscribeDb0.py index ce273367c75d014d4a6d4228f97e50fd7f3b7df6..b0b8b0607675b21568aa002fc0dd0aabd0610608 100644 --- a/tests/system-test/7-tmq/subscribeDb0.py +++ b/tests/system-test/7-tmq/subscribeDb0.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index ca87f0dba533404aaf14a6cd2437417d962260ed..9af78ce6c3763a9a9adac95095345d3a90cfe8f8 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 2b7f0d3d5ff06ea0c36f9768c3a7f6d3eae715a0..9f308abd7c238bf540b9daf402fbf5b2a8aa346b 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb0.py b/tests/system-test/7-tmq/subscribeStb0.py index a212cf759066f4cc67bec18800e6b9581013ab0e..f7e56b4550f53017ab78d1fa729d13fe18329c37 100644 --- a/tests/system-test/7-tmq/subscribeStb0.py +++ b/tests/system-test/7-tmq/subscribeStb0.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py index 92347690d9a14f35e50ac11e18c51daa7fb1f716..4098d151d1dd01f326a913a3d6894c9400aa0c17 100644 --- a/tests/system-test/7-tmq/subscribeStb1.py +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb2.py b/tests/system-test/7-tmq/subscribeStb2.py index d08adcdc8374d01a0f91dfd596b2de6521d86f84..45feb2101991d0f302baeca587ced111996cfdcf 100644 --- a/tests/system-test/7-tmq/subscribeStb2.py +++ b/tests/system-test/7-tmq/subscribeStb2.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb3.py b/tests/system-test/7-tmq/subscribeStb3.py index 58e36911c1407add56a5ef023364f5925e2629b1..81105f5352115939809311508fcf86f518d0a283 100644 --- a/tests/system-test/7-tmq/subscribeStb3.py +++ b/tests/system-test/7-tmq/subscribeStb3.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/subscribeStb4.py b/tests/system-test/7-tmq/subscribeStb4.py index d06e14479667d172a2a7cc42f8019957d131f749..a6f1cab4a4efa89084966c762a966cf9dbbc29a6 100644 --- a/tests/system-test/7-tmq/subscribeStb4.py +++ b/tests/system-test/7-tmq/subscribeStb4.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/tmqDnode.py b/tests/system-test/7-tmq/tmqDnode.py index bb287134b12010a6697e437622ec1ddcff11e7b9..235e9ef971ba57e3bc945494e0c9b934580f8a79 100644 --- a/tests/system-test/7-tmq/tmqDnode.py +++ b/tests/system-test/7-tmq/tmqDnode.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/7-tmq/tmqModule.py b/tests/system-test/7-tmq/tmqModule.py index ad5b4d70b35ba1ade92bb00c1903ce02340ebb19..086fde8f05a9e798a3a1219d4053cf2808bb0b25 100644 --- a/tests/system-test/7-tmq/tmqModule.py +++ b/tests/system-test/7-tmq/tmqModule.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/99-TDcase/TD-15517.py b/tests/system-test/99-TDcase/TD-15517.py index b7cac43954d34848737ecf2838ca3c6f48734c0c..ebab6617c21cc9fe24e3323bf7e5c899b9018e6d 100644 --- a/tests/system-test/99-TDcase/TD-15517.py +++ b/tests/system-test/99-TDcase/TD-15517.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/99-TDcase/TD-15554.py b/tests/system-test/99-TDcase/TD-15554.py index d7b2856b417ccf57394e504fd3ef17c42e7138d0..d97dd8c187ebc5a6f2062b88b9fafa712e7026f5 100644 --- a/tests/system-test/99-TDcase/TD-15554.py +++ b/tests/system-test/99-TDcase/TD-15554.py @@ -33,7 +33,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/99-TDcase/TD-15557.py b/tests/system-test/99-TDcase/TD-15557.py index e005985fe02246ce502f9414321c1448869afab3..7a282e3176706a081312c5148a83680ea91f8f36 100644 --- a/tests/system-test/99-TDcase/TD-15557.py +++ b/tests/system-test/99-TDcase/TD-15557.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/99-TDcase/TD-15563.py b/tests/system-test/99-TDcase/TD-15563.py index 5931360b905aa4c7f75bb1bc68402224001c1270..ca182820d56cbabe4797bef1d152454b2035aa2b 100644 --- a/tests/system-test/99-TDcase/TD-15563.py +++ b/tests/system-test/99-TDcase/TD-15563.py @@ -34,7 +34,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/99-TDcase/TD-16025.py b/tests/system-test/99-TDcase/TD-16025.py index 3a70eaf71bf3f6ccfeb3a97444677bab5838ae0e..6016b56192be5a3a63af3f7c2f5d1e5cd99c363d 100644 --- a/tests/system-test/99-TDcase/TD-16025.py +++ b/tests/system-test/99-TDcase/TD-16025.py @@ -41,7 +41,7 @@ class TDTestCase: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ("taosd" in files or "taosd.exe" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 8350f6752fa32ff4819fd774f1ae939e5e5e3d43..47e0cefb52ead4763ff0c2552aa5b2af39377958 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -20,6 +20,7 @@ import time import base64 import json import platform +import socket from distutils.log import warn as printf from fabric2 import Connection sys.path.append("../pytest") @@ -149,7 +150,7 @@ if __name__ == "__main__": tdLog.info('stop All dnodes') if masterIp == "": - host = '127.0.0.1' + host = socket.gethostname() else: try: config = eval(masterIp) @@ -170,8 +171,8 @@ if __name__ == "__main__": try: if key_word in open(fileName, encoding='UTF-8').read(): is_test_framework = 1 - except: - pass + except Exception as r: + print(r) updateCfgDictStr = '' if is_test_framework: moduleName = fileName.replace(".py", "").replace(os.sep, ".") @@ -181,8 +182,8 @@ if __name__ == "__main__": if ((json.dumps(updateCfgDict) == '{}') and (ucase.updatecfgDict is not None)): updateCfgDict = ucase.updatecfgDict updateCfgDictStr = "-d %s"%base64.b64encode(json.dumps(updateCfgDict).encode()).decode() - except : - pass + except Exception as r: + print(r) else: pass tdDnodes.deploy(1,updateCfgDict)