diff --git a/include/util/tconfig.h b/include/util/tconfig.h index a8e3343ad0..8126e7e6a9 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -114,7 +114,8 @@ typedef struct SConfigIter SConfigIter; int32_t cfgInit(SConfig **ppCfg); int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const void *sourceStr); -int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair +int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair +int32_t cfgUpdateFromArray(SConfig *pCfg, SArray *pArgs); // SConfigItem void cfgCleanup(SConfig *pCfg); int32_t cfgGetSize(SConfig *pCfg); SConfigItem *cfgGetItem(SConfig *pCfg, const char *pName); diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index 822a89810d..c17d3affb3 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -330,6 +330,7 @@ static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { } } if (needUpdate) { + code = cfgUpdateFromArray(tsCfg, configRsp.array); code = setAllConfigs(tsCfg); if (code != TSDB_CODE_SUCCESS) { dError("failed to set all configs since %s", tstrerror(code)); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 8bd81f612f..486b18ac29 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -319,13 +319,12 @@ typedef struct { typedef struct { char name[CFG_NAME_MAX_LEN]; ECfgDataType dtype; - int32_t strLen; union { bool bval; float fval; int32_t i32; int64_t i64; - char* str; + char str[TSDB_CONFIG_VALUE_LEN]; }; } SConfigObj; diff --git a/source/dnode/mnode/impl/src/mndConfig.c b/source/dnode/mnode/impl/src/mndConfig.c index b9108776b3..5b21131df2 100644 --- a/source/dnode/mnode/impl/src/mndConfig.c +++ b/source/dnode/mnode/impl/src/mndConfig.c @@ -32,7 +32,7 @@ enum CfgAlterType { static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t optLen, int32_t *pOutValue); static int32_t cfgUpdateItem(SConfigItem *pItem, SConfigObj *obj); -static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue); +static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype); static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq); static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp); static int32_t mndProcessConfigReq(SRpcMsg *pReq); @@ -66,7 +66,7 @@ SSdbRaw *mnCfgActionEncode(SConfigObj *obj) { terrno = TSDB_CODE_OUT_OF_MEMORY; char buf[30]; - int32_t sz = sizeof(SConfigObj) + obj->strLen + CFG_RESERVE_SIZE; + int32_t sz = sizeof(SConfigObj) + CFG_RESERVE_SIZE; SSdbRaw *pRaw = sdbAllocRaw(SDB_CFG, CFG_VER_NUMBER, sz); if (pRaw == NULL) goto _OVER; @@ -75,7 +75,6 @@ SSdbRaw *mnCfgActionEncode(SConfigObj *obj) { strncpy(name, obj->name, CFG_NAME_MAX_LEN); SDB_SET_BINARY(pRaw, dataPos, name, CFG_NAME_MAX_LEN, _OVER) SDB_SET_INT32(pRaw, dataPos, obj->dtype, _OVER) - SDB_SET_INT32(pRaw, dataPos, obj->strLen, _OVER) switch (obj->dtype) { case CFG_DTYPE_NONE: break; @@ -97,9 +96,7 @@ SSdbRaw *mnCfgActionEncode(SConfigObj *obj) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: - if (obj->str != NULL) { - SDB_SET_BINARY(pRaw, dataPos, obj->str, obj->strLen, _OVER) - } + SDB_SET_BINARY(pRaw, dataPos, obj->str, TSDB_CONFIG_VALUE_LEN, _OVER) break; } SDB_SET_RESERVE(pRaw, dataPos, CFG_RESERVE_SIZE, _OVER) @@ -141,7 +138,6 @@ SSdbRow *mndCfgActionDecode(SSdbRaw *pRaw) { SDB_GET_BINARY(pRaw, dataPos, obj->name, CFG_NAME_MAX_LEN, _OVER) SDB_GET_INT32(pRaw, dataPos, (int32_t *)&obj->dtype, _OVER) - SDB_GET_INT32(pRaw, dataPos, &obj->strLen, _OVER) switch (obj->dtype) { case CFG_DTYPE_NONE: break; @@ -163,10 +159,7 @@ SSdbRow *mndCfgActionDecode(SSdbRaw *pRaw) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: - if (len > 0) { - obj->str = taosMemoryMalloc(len); - SDB_GET_BINARY(pRaw, dataPos, obj->str, len, _OVER) - } + SDB_GET_BINARY(pRaw, dataPos, obj->str, TSDB_CONFIG_VALUE_LEN, _OVER) break; } terrno = TSDB_CODE_SUCCESS; @@ -175,7 +168,6 @@ _OVER: if (terrno != 0) { mError("cfg failed to decode from raw:%p since %s", pRaw, terrstr()); taosMemoryFreeClear(pRow); - taosMemoryFreeClear(obj->str); return NULL; } @@ -195,7 +187,31 @@ static int32_t mndCfgActionDelete(SSdb *pSdb, SConfigObj *obj) { static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *pOld, SConfigObj *pNew) { mTrace("cfg:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); - return 0; + switch (pNew->dtype) { + case CFG_DTYPE_NONE: + break; + case CFG_DTYPE_BOOL: + pOld->bval = pNew->bval; + break; + case CFG_DTYPE_INT32: + pOld->i32 = pNew->i32; + break; + case CFG_DTYPE_INT64: + pOld->i64 = pNew->i64; + break; + case CFG_DTYPE_FLOAT: + case CFG_DTYPE_DOUBLE: + pOld->fval = pNew->fval; + break; + case CFG_DTYPE_STRING: + case CFG_DTYPE_DIR: + case CFG_DTYPE_LOCALE: + case CFG_DTYPE_CHARSET: + case CFG_DTYPE_TIMEZONE: + tstrncpy(pOld->str, pNew->str, TSDB_CONFIG_VALUE_LEN); + break; + } + return TSDB_CODE_SUCCESS; } static int32_t mndCfgActionDeploy(SMnode *pMnode) { return mndInitWriteCfg(pMnode); } @@ -272,7 +288,6 @@ int32_t mndInitWriteCfg(SMnode *pMnode) { taosMemoryFree(versionObj); goto _OVER; } - taosMemoryFree(versionObj->str); taosMemoryFree(versionObj); sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg)); @@ -282,9 +297,6 @@ int32_t mndInitWriteCfg(SMnode *pMnode) { if ((code = mndSetCreateConfigCommitLogs(pTrans, obj)) != 0) { mError("failed to init mnd config:%s, since %s", item->name, terrstr()); } - if (obj->strLen > 0) { - taosMemoryFree(obj->str); - } taosMemoryFree(obj); } if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER; @@ -297,7 +309,7 @@ _OVER: int32_t mndInitReadCfg(SMnode *pMnode) { int32_t code = 0; int32_t sz = -1; - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "init-read-config"); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "init-read-config"); if (pTrans == NULL) { mError("failed to init read cfg in create trans, since %s", terrstr()); goto _OVER; @@ -374,7 +386,8 @@ int32_t cfgUpdateItem(SConfigItem *pItem, SConfigObj *obj) { case CFG_DTYPE_STRING: { if (obj->str != NULL) { taosMemoryFree(pItem->str); - pItem->str = obj->str; + pItem->str = taosMemoryMalloc(strlen(obj->str) + 1); + tstrncpy(pItem->str, obj->str, strlen(obj->str) + 1); } break; } @@ -510,7 +523,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { goto _err_out; } if (pItem->category == CFG_CATEGORY_GLOBAL) { - TAOS_CHECK_GOTO(mndConfigUpdateTrans(pMnode, dcfgReq.config, dcfgReq.value), &lino, _err_out); + TAOS_CHECK_GOTO(mndConfigUpdateTrans(pMnode, dcfgReq.config, dcfgReq.value, pItem->dtype), &lino, _err_out); } _send_req : @@ -565,31 +578,38 @@ _err: TAOS_RETURN(code); } -static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue) { - int32_t code = -1; - int32_t lino = -1; - SConfigObj *pVersion = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion"); - if (pVersion == NULL) { - mError("failed to acquire tsmmConfigVersion while update config, since %s", terrstr()); - code = terrno; - goto _OVER; - } - pVersion->i32 = ++tsmmConfigVersion; - SConfigObj *pObj = sdbAcquire(pMnode->pSdb, SDB_CFG, name); - if (pObj == NULL) { - mError("failed to acquire mnd config:%s while update config, since %s", name, terrstr()); - code = terrno; - goto _OVER; - } - TAOS_CHECK_GOTO(mndUpdateObj(pObj, name, pValue), &lino, _OVER); +static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype) { + int32_t code = -1; + int32_t lino = -1; + // SConfigObj *pVersion = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion"); + // if (pVersion == NULL) { + // mError("failed to acquire tsmmConfigVersion while update config, since %s", terrstr()); + // code = terrno; + // goto _OVER; + // } + // pVersion->i32 = ++tsmmConfigVersion; + // SConfigObj *pObj = sdbAcquire(pMnode->pSdb, SDB_CFG, name); + // if (pObj == NULL) { + // mError("failed to acquire mnd config:%s while update config, since %s", name, terrstr()); + // code = terrno; + // goto _OVER; + // } + SConfigObj pVersion = {0}, pObj = {0}; + pVersion.i32 = ++tsmmConfigVersion; + strncpy(pVersion.name, "tsmmConfigVersion", CFG_NAME_MAX_LEN); + + pObj.dtype = dtype; + strncpy(pObj.name, name, CFG_NAME_MAX_LEN); + + TAOS_CHECK_GOTO(mndUpdateObj(&pObj, name, pValue), &lino, _OVER); STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_ARBGROUP, NULL, "update-config"); if (pTrans == NULL) { if (terrno != 0) code = terrno; goto _OVER; } mInfo("trans:%d, used to update config:%s to value:%s", pTrans->id, name, pValue); - TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pVersion), &lino, _OVER); - TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pObj), &lino, _OVER); + TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, &pVersion), &lino, _OVER); + TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, &pObj), &lino, _OVER); if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER; code = 0; _OVER: diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index c26e5ac171..f257991381 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -758,17 +758,15 @@ SConfigObj *mndInitConfigObj(SConfigItem *pItem) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: - pObj->str = taosStrdup(pItem->str); - pObj->strLen = strlen(pItem->str) + 1; + tstrncpy(pObj->str, pItem->str, TSDB_CONFIG_VALUE_LEN); break; } return pObj; } -int32_t mndUpdateObj(SConfigObj *pObj, const char *name, char *value) { +int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) { int32_t code = 0; - - switch (pObj->dtype) { + switch (pObjNew->dtype) { case CFG_DTYPE_BOOL: { bool tmp = false; if (strcasecmp(value, "true") == 0) { @@ -777,26 +775,26 @@ int32_t mndUpdateObj(SConfigObj *pObj, const char *name, char *value) { if (atoi(value) > 0) { tmp = true; } - pObj->bval = tmp; + pObjNew->bval = tmp; break; } case CFG_DTYPE_INT32: { int32_t ival; TAOS_CHECK_RETURN(taosStrHumanToInt32(value, &ival)); - pObj->i32 = ival; + pObjNew->i32 = ival; break; } case CFG_DTYPE_INT64: { int64_t ival; TAOS_CHECK_RETURN(taosStrHumanToInt64(value, &ival)); - pObj->i64 = ival; + pObjNew->i64 = ival; break; } case CFG_DTYPE_FLOAT: case CFG_DTYPE_DOUBLE: { float dval = 0; TAOS_CHECK_RETURN(parseCfgReal(value, &dval)); - pObj->fval = dval; + pObjNew->fval = dval; break; } case CFG_DTYPE_DIR: @@ -804,10 +802,8 @@ int32_t mndUpdateObj(SConfigObj *pObj, const char *name, char *value) { case CFG_DTYPE_CHARSET: case CFG_DTYPE_LOCALE: case CFG_DTYPE_STRING: { - char *tmp = taosStrdup(value); - taosMemoryFreeClear(pObj->str); - pObj->str = tmp; - pObj->strLen = strlen(value) + 1; + strncpy(pObjNew->str, value, strlen(value)); + pObjNew->str[strlen(value)] = 0; break; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index a84e77b9bc..029ada0a75 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -95,6 +95,51 @@ int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs) { return TSDB_CODE_SUCCESS; } +int32_t cfgUpdateFromArray(SConfig *pCfg, SArray *pArgs) { + int32_t size = taosArrayGetSize(pArgs); + for (int32_t i = 0; i < size; ++i) { + SConfigItem *pItemNew = taosArrayGet(pArgs, i); + + (void)taosThreadMutexLock(&pCfg->lock); + + SConfigItem *pItemOld = cfgGetItem(pCfg, pItemNew->name); + if (pItemOld == NULL) { + (void)taosThreadMutexUnlock(&pCfg->lock); + TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); + } + char value[30]; + switch (pItemNew->dtype) { + case CFG_DTYPE_BOOL: + strncpy(value, pItemNew->bval ? "true" : "false", sizeof(value) - 1); + break; + case CFG_DTYPE_INT32: + sprintf(value, "%d", pItemNew->i32); + break; + case CFG_DTYPE_INT64: + sprintf(value, "%" PRId64, pItemNew->i64); + break; + case CFG_DTYPE_FLOAT: + sprintf(value, "%f", pItemNew->fval); + break; + case CFG_DTYPE_STRING: + case CFG_DTYPE_DIR: + case CFG_DTYPE_LOCALE: + case CFG_DTYPE_CHARSET: + case CFG_DTYPE_TIMEZONE: + strcpy(value, pItemNew->str); + default: + break; + } + value[sizeof(value) - 1] = '\0'; + + TAOS_CHECK_RETURN(cfgSetItemVal(pItemOld, pItemNew->name, value, CFG_STYPE_ARG_LIST)); + + (void)taosThreadMutexUnlock(&pCfg->lock); + } + + return TSDB_CODE_SUCCESS; +} + void cfgItemFreeVal(SConfigItem *pItem) { if (pItem->dtype == CFG_DTYPE_STRING || pItem->dtype == CFG_DTYPE_DIR || pItem->dtype == CFG_DTYPE_LOCALE || pItem->dtype == CFG_DTYPE_CHARSET || pItem->dtype == CFG_DTYPE_TIMEZONE) { diff --git a/tests/army/alter/test_alter_config.py b/tests/army/alter/test_alter_config.py new file mode 100644 index 0000000000..7395268549 --- /dev/null +++ b/tests/army/alter/test_alter_config.py @@ -0,0 +1,556 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import time + +import taos +import frame +import frame.etool + +from frame.log import * +from frame.cases import * +from frame.sql import * +from frame.caseBase import * +from frame.epath import * +from frame.srvCtl import * +from frame import * + +class TDTestCase: + """This test case is used to veirfy hot refresh configurations + """ + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + self.configration_dic = { + "cli": [ + ], + "svr": [ + { + "name": "audit", + "value": 0, + "category": "global" + }, + { + "name": "asyncLog", + "value": 0, + "category": "local" + }, + { + "name": "disableStream", + "value": 1, + "category": "global" + }, + { + "name": "enableWhiteList", + "value": 1, + "category": "global" + }, + { + "name": "statusInterval", + "value": 3, + "category": "global" + }, + { + "name": "telemetryReporting", + "value" : 1, + "category" : "global" + }, + { + "name" : "monitor", + "value" : 0, + "category" : "global" + }, + { + "name" : "monitorInterval", + "value" : 3, + "category" : "global" + }, + { + "name" : "monitorComp", + "value" : 1, + "category" : "global" + }, + { + "name" : "monitorForceV2", + "value" : 0, + "category" : "global" + }, + { + "name" : "monitorLogProtocol", + "value" : 1, + "category" : "global" + }, + { + "name": "monitorMaxLogs", + "value": 1000, + "category": "global" + }, + { + "name": "auditCreateTable", + "value": 0, + "category": "global" + }, + { + "name": "auditInterval", + "value": 4000, + "category": "global" + }, + { + "name": "slowLogThreshold", + "value": 20, + "category": "global" + }, + { + "name": "compressMsgSize", + "value": 0, + "category": "global" + }, + { + "name": "compressor", + "value": "GZIP_COMPRESSOR", + "category": "global" + }, + { + "name": "curRange", + "value": 200, + "category": "global" + }, + { + "name": "fPrecision", + "value": "1000.000000", + "category": "global" + }, + { + "name": "dPrecision", + "value": "1000.000000", + "category": "global" + }, + { + "name": "ifAdtFse", + "value": 1, + "category": "global" + }, + { + "name": "maxRange", + "value": 1000, + "category": "global" + }, + { + "name": "maxTsmaNum", + "value": 2, + "category": "global" + }, + { + "name": "queryRsmaTolerance", + "value": 2000, + "category": "global" + }, + { + "name": "uptimeInterval", + "value": 600, + "category": "global" + }, + { + "name": "slowLogMaxLen", + "value": 8192, + "category": "global" + }, + { + "name": "slowLogScope", + "value": "insert", + "category": "global" + }, + { + "name": "slowLogExceptDb", + "value": "db1", + "category": "global" + }, + { + "name": "mndSdbWriteDelta", + "value": 1000, + "category": "global" + }, + { + "name": "minDiskFreeSize", + "value": 100*1024*1024, + "category": "global" + }, + { + "name": "randErrorChance", + "value": 5, + "category": "global" + }, + { + "name": "randErrorDivisor", + "value": 20001, + "category": "global" + }, + { + "name": "randErrorScope", + "value": 8, + "category": "global" + }, + { + "name": "syncLogBufferMemoryAllowed", + "value": 1024 * 1024 * 20 * 10, + "category": "global" + }, + { + "name": "resolveFQDNRetryTime", + "value": 500, + "category": "global" + }, + { + "name": "syncElectInterval", + "value": 50000, + "category": "global" + }, + { + "name": "syncHeartbeatInterval", + "value": 3000, + "category": "global" + }, + { + "name": "syncHeartbeatTimeout", + "value": 40000, + "category": "global" + }, + { + "name": "syncSnapReplMaxWaitN", + "value": 32, + "category": "global" + }, + { + "name": "walFsyncDataSizeLimit", + "value": 200 * 1024 * 1024, + "category": "global" + }, + { + "name": "numOfCores", + "value": "30.000000", + "category": "global" + }, + { + "name": "enableCoreFile", + "value": 0, + "category": "global" + }, + { + "name": "telemetryInterval", + "value": 6000, + "category": "global" + }, + { + "name": "cacheLazyLoadThreshold", + "value": 1000, + "category": "global" + }, + { + "name": "checkpointInterval", + "value": 120, + "category": "global" + }, + { + "name": "concurrentCheckpoint", + "value": 3, + "category": "global" + }, + { + "name": "retentionSpeedLimitMB", + "value": 24, + "category": "global" + }, + { + "name": "ttlChangeOnWrite", + "value": 1, + "category": "global" + }, + { + "name": "logKeepDays", + "value": 30, + "category": "local" + }, + { + "name": "maxStreamBackendCache", + "value": 256, + "category": "global" + }, + { + "name": "mqRebalanceInterval", + "value": 30, + "category": "global" + }, + { + "name": "numOfLogLines", + "value": 20000000, + "category": "local" + }, + { + "name": "queryRspPolicy", + "value": 1, + "category": "global" + }, + { + "name": "timeseriesThreshold", + "value": 100, + "category": "global" + }, + { + "name": "tmqMaxTopicNum", + "value": 30, + "category": "global" + }, + { + "name": "tmqRowSize", + "value": 8192, + "category": "global" + }, + { + "name": "transPullupInterval", + "value": 4, + "category": "global" + }, + { + "name": "compactPullupInterval", + "value": 20, + "category": "global" + }, + { + "name": "trimVDbIntervalSec", + "value": 7200, + "category": "global" + }, + { + "name": "ttlBatchDropNum", + "value": 20000, + "category": "global" + }, + { + "name": "ttlFlushThreshold", + "value": 200, + "category": "global" + }, + { + "name": "ttlPushInterval", + "value": 20, + "category": "global" + }, + { + "name": "ttlUnit", + "value": 86500, + "category": "global" + }, + { + "name": "udf", + "value": 0, + "category": "global" + }, + # { + # "name": "udfdLdLibPath", + # "value": 1000, + # "category": "global" + # }, + # { + # "name": "udfdResFuncs", + # "value": 1000, + # "category": "global" + # }, + # { + # "name": "s3Accesskey", + # "value": 1000, + # "category": "global" + # }, + # { + # "name": "s3BucketName", + # "value": 1000, + # "category": "global" + # }, + # { + # "name": "s3Endpoint", + # "value": 1000, + # "category": "global" + # }, + { + "name": "s3MigrateIntervalSec", + "value": 1800, + "category": "global" + }, + { + "name": "s3MigrateEnabled", + "value": 1, + "category": "global" + }, + # { + # "name": "s3BlockCacheSize", + # "value": 32, + # "category": "global" + # }, + { + "name": "s3PageCacheSize", + "value": 8192, + "category": "global" + }, + { + "name": "s3UploadDelaySec", + "value": 30, + "category": "global" + }, + { + "name": "mndLogRetention", + "value": 1000, + "category": "global" + }, + { + "name": "supportVnodes", + "value": 128, + "category": "global" + }, + { + "name": "experimental", + "value": 0, + "category": "global" + }, + { + "name": "maxTsmaNum", + "value": 2, + "category": "global" + }, + { + "name": "maxShellConns", + "value": 25000, + "category": "global" + }, + { + "name": "numOfRpcSessions", + "value": 15000, + "category": "global" + }, + { + "name": "numOfRpcThreads", + "value": 2, + "category": "global" + }, + { + "name": "rpcQueueMemoryAllowed", + "value": 1024*1024*20*10, + "category": "global" + }, + { + "name": "shellActivityTimer", + "value": 2, + "category": "global" + }, + { + "name": "timeToGetAvailableConn", + "value": 200000, + "category": "global" + }, + { + "name": "readTimeout", + "value": 800, + "category": "global" + }, + { + "name": "safetyCheckLevel", + "value": 2, + "category": "global" + }, + { + "name": "bypassFlag", + "value": 4, + "category": "global" + } + ] + } + def cli_get_param_value(self, config_name): + res = tdSql.getResult("show local variables") + for row in res: + if config_name == row[0]: + return row[1] + + def svr_get_param_value(self, config_name): + res = tdSql.getResult("show dnode 1 variables") + for row in res: + if config_name == row[1]: + return row[2] + + def configuration_alter(self): + for key in self.configration_dic: + if "svr" == key: + for item in self.configration_dic[key]: + name = item["name"] + value = item["value"] + category = item["category"] + if category == "global": + tdSql.execute(f'alter all dnodes "{name} {value}";') + else: + tdSql.execute(f'alter dnode 1 "{name} {value}";') + elif "cli" == key: + for item in self.configration_dic[key]: + name = item["name"] + value = item["value"] + category = item["category"] + if category == "global": + tdSql.execute(f'alter all dnodes "{name} {value}";') + else: + tdSql.execute(f'alter local "{name} {value}";') + else: + raise Exception(f"unknown key: {key}") + + def run(self): + self.configuration_alter() + for key in self.configration_dic: + if "cli" == key: + for item in self.configration_dic[key]: + actVal = self.cli_get_param_value(item["name"]) + assert str(actVal) == str(item["value"]), f"tem name: {item['name']}, Expected value: {item['value']}, actual value: {actVal}" + elif "svr" == key: + for item in self.configration_dic[key]: + actVal = self.svr_get_param_value(item["name"]) + assert str(actVal) == str(item["value"]), f"tem name: {item['name']}, Expected value: {item['value']}, actual value: {actVal}" + else: + raise Exception(f"unknown key: {key}") + + tdLog.info("success to alter all configurations") + + tdLog.info("stop and restart taosd") + time.sleep(3) + sc.dnodeStopAll() + sc.dnodeStart(1) + sc.dnodeStart(2) + sc.dnodeStart(3) + time.sleep(10) + + for key in self.configration_dic: + if "cli" == key: + for item in self.configration_dic[key]: + actVal = self.cli_get_param_value(item["name"]) + assert str(actVal) == str(item["oldVal"]), f"item name: {item['name']}, Expected value: {item['value']}, actual value: {actVal}" + elif "svr" == key: + for item in self.configration_dic[key]: + actVal = self.svr_get_param_value(item["name"]) + assert str(actVal) == str(item["value"]), f"item name: {item['name']}, Expected value: {item['value']}, actual value: {actVal}" + else: + raise Exception(f"unknown key: {key}") + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/test_alter_config.py b/tests/system-test/0-others/test_alter_config.py index 3cbfc88fc7..14e77bb489 100644 --- a/tests/system-test/0-others/test_alter_config.py +++ b/tests/system-test/0-others/test_alter_config.py @@ -21,7 +21,8 @@ from util.sql import * from util.cases import * from util.dnodes import * from util.common import * - +from frame.srvCtl import * +from frame import * class TDTestCase: """This test case is used to veirfy hot refresh configurations