Merge pull request #25823 from taosdata/feat/TD-30053-3.0
feat(grant): support industry edition
This commit is contained in:
commit
0e512c7127
|
@ -11,6 +11,10 @@ ELSE ()
|
||||||
SET(TD_VER_COMPATIBLE "3.0.0.0")
|
SET(TD_VER_COMPATIBLE "3.0.0.0")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
IF (TD_PRODUCT_NAME)
|
||||||
|
ADD_DEFINITIONS(-DTD_PRODUCT_NAME="${TD_PRODUCT_NAME}")
|
||||||
|
ENDIF ()
|
||||||
|
|
||||||
find_program(HAVE_GIT NAMES git)
|
find_program(HAVE_GIT NAMES git)
|
||||||
|
|
||||||
IF (DEFINED GITINFO)
|
IF (DEFINED GITINFO)
|
||||||
|
|
|
@ -73,7 +73,7 @@ char *tGetMachineId();
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
|
@ -85,7 +85,7 @@ char *tGetMachineId();
|
||||||
#else
|
#else
|
||||||
#define GRANTS_SCHEMA \
|
#define GRANTS_SCHEMA \
|
||||||
static const SSysDbTableSchema grantsSchema[] = { \
|
static const SSysDbTableSchema grantsSchema[] = { \
|
||||||
{.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "version", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
{.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \
|
||||||
|
|
|
@ -78,6 +78,14 @@ extern const int32_t TYPE_BYTES[21];
|
||||||
#define TSDB_DEFAULT_PASS "taosdata"
|
#define TSDB_DEFAULT_PASS "taosdata"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TD_PRODUCT_NAME
|
||||||
|
#ifdef TD_ENTERPRISE
|
||||||
|
#define TD_PRODUCT_NAME "TDengine Enterprise Edition"
|
||||||
|
#else
|
||||||
|
#define TD_PRODUCT_NAME "TDengine Community Edition"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TSDB_TRUE 1
|
#define TSDB_TRUE 1
|
||||||
#define TSDB_FALSE 0
|
#define TSDB_FALSE 0
|
||||||
#define TSDB_OK 0
|
#define TSDB_OK 0
|
||||||
|
|
|
@ -258,17 +258,12 @@ static void dmPrintArgs(int32_t argc, char const *argv[]) {
|
||||||
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
static void dmGenerateGrant() { mndGenerateMachineCode(); }
|
||||||
|
|
||||||
static void dmPrintVersion() {
|
static void dmPrintVersion() {
|
||||||
|
printf("%s\ntaosd version: %s compatible_version: %s\n", TD_PRODUCT_NAME, version, compatible_version);
|
||||||
|
printf("git: %s\n", gitinfo);
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
char *releaseName = "enterprise";
|
printf("git: %s\n", gitinfoOfInternal);
|
||||||
#else
|
|
||||||
char *releaseName = "community";
|
|
||||||
#endif
|
#endif
|
||||||
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
printf("build: %s\n", buildinfo);
|
||||||
printf("gitinfo: %s\n", gitinfo);
|
|
||||||
#ifdef TD_ENTERPRISE
|
|
||||||
printf("gitinfoOfInternal: %s\n", gitinfoOfInternal);
|
|
||||||
#endif
|
|
||||||
printf("buildInfo: %s\n", buildinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dmPrintHelp() {
|
static void dmPrintHelp() {
|
||||||
|
|
|
@ -36,8 +36,7 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
||||||
if (pShow->numOfRows < 1) {
|
if (pShow->numOfRows < 1) {
|
||||||
cols = 0;
|
cols = 0;
|
||||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
|
||||||
const char *src = "community";
|
STR_WITH_MAXSIZE_TO_VARSTR(tmp, TD_PRODUCT_NAME, 32);
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(tmp, src, 32);
|
|
||||||
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
colDataSetVal(pColInfo, numOfRows, tmp, false);
|
||||||
|
|
||||||
GRANT_ITEM_SHOW("unlimited");
|
GRANT_ITEM_SHOW("unlimited");
|
||||||
|
|
|
@ -1242,14 +1242,9 @@ static int32_t udfdParseArgs(int32_t argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udfdPrintVersion() {
|
static void udfdPrintVersion() {
|
||||||
#ifdef TD_ENTERPRISE
|
printf("udfd version: %s compatible_version: %s\n", version, compatible_version);
|
||||||
char *releaseName = "enterprise";
|
printf("git: %s\n", gitinfo);
|
||||||
#else
|
printf("build: %s\n", buildinfo);
|
||||||
char *releaseName = "community";
|
|
||||||
#endif
|
|
||||||
printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version);
|
|
||||||
printf("gitinfo: %s\n", gitinfo);
|
|
||||||
printf("buildInfo: %s\n", buildinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t udfdInitLog() {
|
static int32_t udfdInitLog() {
|
||||||
|
|
|
@ -2,6 +2,6 @@ char version[64] = "${TD_VER_NUMBER}";
|
||||||
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
|
||||||
char gitinfo[48] = "${TD_VER_GIT}";
|
char gitinfo[48] = "${TD_VER_GIT}";
|
||||||
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
|
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
|
||||||
char buildinfo[64] = "Built ${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} at ${TD_VER_DATE}";
|
char buildinfo[64] = "${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} ${TD_VER_DATE}";
|
||||||
|
|
||||||
void libtaos_${TD_LIB_VER_NUMBER}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
|
void libtaos_${TD_LIB_VER_NUMBER}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
|
||||||
|
|
|
@ -269,6 +269,10 @@ class TDTestCase:
|
||||||
|
|
||||||
def ins_grants_check(self):
|
def ins_grants_check(self):
|
||||||
grant_name_dict = {
|
grant_name_dict = {
|
||||||
|
'service':'Service Time',
|
||||||
|
'timeseries':'Timeseries',
|
||||||
|
'dnodes':'Dnodes',
|
||||||
|
'cpu_cores':'CPU Cores',
|
||||||
'stream':'Stream',
|
'stream':'Stream',
|
||||||
'subscription':'Subscription',
|
'subscription':'Subscription',
|
||||||
'view':'View',
|
'view':'View',
|
||||||
|
@ -293,6 +297,7 @@ class TDTestCase:
|
||||||
'mysql':'MySQL',
|
'mysql':'MySQL',
|
||||||
'postgres':'PostgreSQL',
|
'postgres':'PostgreSQL',
|
||||||
'oracle':'Oracle',
|
'oracle':'Oracle',
|
||||||
|
'mssql':'SqlServer'
|
||||||
}
|
}
|
||||||
|
|
||||||
tdSql.execute('drop database if exists db2')
|
tdSql.execute('drop database if exists db2')
|
||||||
|
@ -304,7 +309,7 @@ class TDTestCase:
|
||||||
if result[i][0] in grant_name_dict:
|
if result[i][0] in grant_name_dict:
|
||||||
tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]])
|
tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]])
|
||||||
index += 1
|
index += 1
|
||||||
tdSql.checkEqual(index, 24)
|
tdSql.checkEqual(index, len(grant_name_dict))
|
||||||
tdSql.query(f'select * from information_schema.ins_grants_logs')
|
tdSql.query(f'select * from information_schema.ins_grants_logs')
|
||||||
result = tdSql.queryResult
|
result = tdSql.queryResult
|
||||||
tdSql.checkEqual(True, len(result) >= 0)
|
tdSql.checkEqual(True, len(result) >= 0)
|
||||||
|
|
|
@ -186,17 +186,17 @@ class TDTestCase:
|
||||||
tdSql.query('show dnode 1 variables')
|
tdSql.query('show dnode 1 variables')
|
||||||
for i in tdSql.queryResult:
|
for i in tdSql.queryResult:
|
||||||
if i[1].lower() == "gitinfo":
|
if i[1].lower() == "gitinfo":
|
||||||
taosd_gitinfo_sql = f"gitinfo: {i[2]}"
|
taosd_gitinfo_sql = f"git: {i[2]}"
|
||||||
taos_gitinfo_sql = ''
|
taos_gitinfo_sql = ''
|
||||||
tdSql.query('show local variables')
|
tdSql.query('show local variables')
|
||||||
for i in tdSql.queryResult:
|
for i in tdSql.queryResult:
|
||||||
if i[0].lower() == "gitinfo":
|
if i[0].lower() == "gitinfo":
|
||||||
taos_gitinfo_sql = f"gitinfo: {i[1]}"
|
taos_gitinfo_sql = f"git: {i[1]}"
|
||||||
taos_info = os.popen('taos -V').read()
|
taos_info = os.popen('taos -V').read()
|
||||||
taos_gitinfo = re.findall("^gitinfo.*",taos_info,re.M)
|
taos_gitinfo = re.findall("^git: .*",taos_info,re.M)
|
||||||
tdSql.checkEqual(taos_gitinfo_sql,taos_gitinfo[0])
|
tdSql.checkEqual(taos_gitinfo_sql,taos_gitinfo[0])
|
||||||
taosd_info = os.popen('taosd -V').read()
|
taosd_info = os.popen('taosd -V').read()
|
||||||
taosd_gitinfo = re.findall("^gitinfo.*",taosd_info,re.M)
|
taosd_gitinfo = re.findall("^git: .*",taosd_info,re.M)
|
||||||
tdSql.checkEqual(taosd_gitinfo_sql,taosd_gitinfo[0])
|
tdSql.checkEqual(taosd_gitinfo_sql,taosd_gitinfo[0])
|
||||||
|
|
||||||
def show_base(self):
|
def show_base(self):
|
||||||
|
|
|
@ -5,6 +5,7 @@ import time
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import re
|
||||||
if platform.system().lower() == 'windows':
|
if platform.system().lower() == 'windows':
|
||||||
import wexpect as taosExpect
|
import wexpect as taosExpect
|
||||||
else:
|
else:
|
||||||
|
@ -370,10 +371,11 @@ class TDTestCase:
|
||||||
if retCode != "TAOS_OK":
|
if retCode != "TAOS_OK":
|
||||||
tdLog.exit("taos -V fail")
|
tdLog.exit("taos -V fail")
|
||||||
|
|
||||||
version = 'version: ' + version
|
version = 'taos version: ' + version
|
||||||
retVal = retVal.replace("\n", "")
|
# retVal = retVal.replace("\n", "")
|
||||||
retVal = retVal.replace("\r", "")
|
# retVal = retVal.replace("\r", "")
|
||||||
if retVal.startswith(version) == False:
|
taosVersion = re.findall((f'^%s'%(version)), retVal,re.M)
|
||||||
|
if len(taosVersion) == 0:
|
||||||
print ("return version: [%s]"%retVal)
|
print ("return version: [%s]"%retVal)
|
||||||
print ("dict version: [%s]"%version)
|
print ("dict version: [%s]"%version)
|
||||||
tdLog.exit("taos -V version not match")
|
tdLog.exit("taos -V version not match")
|
||||||
|
|
|
@ -435,12 +435,12 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) {
|
||||||
shell.info.promptSize = strlen(shell.info.promptHeader);
|
shell.info.promptSize = strlen(shell.info.promptHeader);
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
|
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
|
||||||
"version: %s compatible_version: %s\ngitinfo: %s\ngitinfoOfInternal: %s\nbuildInfo: %s", version,
|
"%s\ntaos version: %s compatible_version: %s\ngit: %s\ngit: %s\nbuild: %s", TD_PRODUCT_NAME, version,
|
||||||
compatible_version, gitinfo, gitinfoOfInternal, buildinfo);
|
compatible_version, gitinfo, gitinfoOfInternal, buildinfo);
|
||||||
#else
|
#else
|
||||||
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
|
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),
|
||||||
"version: %s compatible_version: %s\ngitinfo: %s\nbuildInfo: %s", version, compatible_version, gitinfo,
|
"%s\ntaos version: %s compatible_version: %s\ngit: %s\nbuild: %s", TD_PRODUCT_NAME, version,
|
||||||
buildinfo);
|
compatible_version, gitinfo, buildinfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)
|
||||||
|
|
|
@ -1189,12 +1189,11 @@ bool shellGetGrantInfo(char* buf) {
|
||||||
fprintf(stderr, "\r\nFailed to get grant information from server. Abort.\r\n");
|
fprintf(stderr, "\r\nFailed to get grant information from server. Abort.\r\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
char serverVersion[64] = {0};
|
||||||
char serverVersion[32] = {0};
|
|
||||||
char expiretime[32] = {0};
|
char expiretime[32] = {0};
|
||||||
char expired[32] = {0};
|
char expired[32] = {0};
|
||||||
|
|
||||||
memcpy(serverVersion, row[0], fields[0].bytes);
|
tstrncpy(serverVersion, row[0], 64);
|
||||||
memcpy(expiretime, row[1], fields[1].bytes);
|
memcpy(expiretime, row[1], fields[1].bytes);
|
||||||
memcpy(expired, row[2], fields[2].bytes);
|
memcpy(expired, row[2], fields[2].bytes);
|
||||||
|
|
||||||
|
@ -1202,10 +1201,10 @@ bool shellGetGrantInfo(char* buf) {
|
||||||
community = true;
|
community = true;
|
||||||
} else if (strcmp(expiretime, "unlimited") == 0) {
|
} else if (strcmp(expiretime, "unlimited") == 0) {
|
||||||
community = false;
|
community = false;
|
||||||
sprintf(buf, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo);
|
sprintf(buf, "Server is %s, %s and will never expire.\r\n", serverVersion, sinfo);
|
||||||
} else {
|
} else {
|
||||||
community = false;
|
community = false;
|
||||||
sprintf(buf, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo,
|
sprintf(buf, "Server is %s, %s and will expire at %s.\r\n", serverVersion, sinfo,
|
||||||
expiretime);
|
expiretime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue