udfd: coverage
This commit is contained in:
parent
1cc8c6d6cc
commit
50dbfdd4a3
|
@ -1667,7 +1667,6 @@ static int32_t udfdGlobalDataInit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udfdGlobalDataDeinit() {
|
static void udfdGlobalDataDeinit() {
|
||||||
taosHashCleanup(global.udfsHash);
|
|
||||||
uv_mutex_destroy(&global.udfsMutex);
|
uv_mutex_destroy(&global.udfsMutex);
|
||||||
uv_mutex_destroy(&global.scriptPluginsMutex);
|
uv_mutex_destroy(&global.scriptPluginsMutex);
|
||||||
taosMemoryFreeClear(global.loop);
|
taosMemoryFreeClear(global.loop);
|
||||||
|
@ -1720,8 +1719,11 @@ void udfdDeinitResidentFuncs() {
|
||||||
SUdf **udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName));
|
SUdf **udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName));
|
||||||
if (udfInHash) {
|
if (udfInHash) {
|
||||||
SUdf *udf = *udfInHash;
|
SUdf *udf = *udfInHash;
|
||||||
int32_t code = udf->scriptPlugin->udfDestroyFunc(udf->scriptUdfCtx);
|
int32_t code = 0;
|
||||||
fnDebug("udfd destroy function returns %d", code);
|
if (udf->scriptPlugin->udfDestroyFunc) {
|
||||||
|
code = udf->scriptPlugin->udfDestroyFunc(udf->scriptUdfCtx);
|
||||||
|
fnDebug("udfd %s destroy function returns %d", funcName, code);
|
||||||
|
}
|
||||||
if(taosHashRemove(global.udfsHash, funcName, strlen(funcName)) != 0)
|
if(taosHashRemove(global.udfsHash, funcName, strlen(funcName)) != 0)
|
||||||
{
|
{
|
||||||
fnError("udfd remove resident function %s failed", funcName);
|
fnError("udfd remove resident function %s failed", funcName);
|
||||||
|
@ -1729,6 +1731,7 @@ void udfdDeinitResidentFuncs() {
|
||||||
taosMemoryFree(udf);
|
taosMemoryFree(udf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taosHashCleanup(global.udfsHash);
|
||||||
taosArrayDestroy(global.residentFuncs);
|
taosArrayDestroy(global.residentFuncs);
|
||||||
fnInfo("udfd resident functions are deinit");
|
fnInfo("udfd resident functions are deinit");
|
||||||
}
|
}
|
||||||
|
@ -1838,15 +1841,15 @@ int main(int argc, char *argv[]) {
|
||||||
fnInfo("udfd exit normally");
|
fnInfo("udfd exit normally");
|
||||||
|
|
||||||
removeListeningPipe();
|
removeListeningPipe();
|
||||||
udfdDeinitScriptPlugins();
|
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (globalDataInited) {
|
|
||||||
udfdGlobalDataDeinit();
|
|
||||||
}
|
|
||||||
if (residentFuncsInited) {
|
if (residentFuncsInited) {
|
||||||
udfdDeinitResidentFuncs();
|
udfdDeinitResidentFuncs();
|
||||||
}
|
}
|
||||||
|
udfdDeinitScriptPlugins();
|
||||||
|
if (globalDataInited) {
|
||||||
|
udfdGlobalDataDeinit();
|
||||||
|
}
|
||||||
if (udfSourceDirInited) {
|
if (udfSourceDirInited) {
|
||||||
udfdDestroyUdfSourceDir();
|
udfdDestroyUdfSourceDir();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
from util.log import *
|
from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
|
@ -12,7 +14,7 @@ from util.dnodes import *
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
updatecfgDict = {'udfdResFuncs': "udf1,udf2"}
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
@ -652,10 +654,20 @@ class TDTestCase:
|
||||||
tdDnodes.start(1)
|
tdDnodes.start(1)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
def test_udfd_cmd(self):
|
||||||
|
tdLog.info(" test udfd -V ")
|
||||||
|
os.system("udfd -V")
|
||||||
|
tdLog.info(" test udfd -c ")
|
||||||
|
os.system("udfd -c")
|
||||||
|
|
||||||
|
letters = string.ascii_letters + string.digits + '\\'
|
||||||
|
path = ''.join(random.choice(letters) for i in range(5000))
|
||||||
|
|
||||||
|
os.system(f"udfd -c {path}")
|
||||||
|
|
||||||
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring
|
||||||
|
|
||||||
print(" env is ok for all ")
|
print(" env is ok for all ")
|
||||||
|
self.test_udfd_cmd()
|
||||||
self.prepare_udf_so()
|
self.prepare_udf_so()
|
||||||
self.prepare_data()
|
self.prepare_data()
|
||||||
self.create_udf_function()
|
self.create_udf_function()
|
||||||
|
|
|
@ -11,7 +11,7 @@ from util.dnodes import *
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
updatecfgDict = {'udfdResFuncs': "udf1,udf2"}
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
|
|
Loading…
Reference in New Issue