提交 2558e74b 编写于 作者: S Shuduo Sang

launch taosd from build directory instead of system.

上级 b962651e
...@@ -91,9 +91,8 @@ def installExtension(): ...@@ -91,9 +91,8 @@ def installExtension():
os.chdir(currentDir) os.chdir(currentDir)
def stopHiveMQ(): def stopProgram(prog: str):
toBeKilled = "hivemq.jar" psCmd = "ps ax|grep -w %s| grep -v grep | awk '{print $1}'" % prog
psCmd = "ps ax|grep -w %s| grep -v grep | awk '{print $1}'" % toBeKilled
processID = subprocess.check_output( processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8") psCmd, shell=True).decode("utf-8")
...@@ -104,7 +103,10 @@ def stopHiveMQ(): ...@@ -104,7 +103,10 @@ def stopHiveMQ():
time.sleep(1) time.sleep(1)
processID = subprocess.check_output( processID = subprocess.check_output(
psCmd, shell=True).decode("utf-8") psCmd, shell=True).decode("utf-8")
print("hiveMQ processID: %s" % processID) pass
def stopHiveMQ():
stopProgram("hivemq.jar")
v_print("%s", "hivemq is NOT running") v_print("%s", "hivemq is NOT running")
def runHiveMQ(): def runHiveMQ():
...@@ -115,12 +117,44 @@ def runHiveMQ(): ...@@ -115,12 +117,44 @@ def runHiveMQ():
time.sleep(10) time.sleep(10)
v_print("%s", "hivemq is running") v_print("%s", "hivemq is running")
def getBuildPath():
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root)-len("/build/bin")]
break
return buildPath
def runTDengine(): def runTDengine():
pass stopProgram("taosd")
buildPath = getBuildPath()
if (buildPath == ""):
v_print("%s", "taosd NOT found!")
os.exit(1)
else:
v_print("%s", "taosd found in %s" % buildPath)
binPath = buildPath + "/build/bin/taosd"
os.system('%s > /dev/null &' % binPath)
time.sleep(10)
def reCreateDatabase(): def reCreateDatabase():
os.system('taos -s "DROP DATABASE IF EXISTS hivemq"') buildPath = getBuildPath()
os.system('taos -s "CREATE DATABASE IF NOT EXISTS hivemq"') binPath = buildPath + "/build/bin/taos"
os.system('%s -s "DROP DATABASE IF EXISTS hivemq"' % binPath)
os.system('%s -s "CREATE DATABASE IF NOT EXISTS hivemq"' % binPath)
def sendMqttMsg(topic: str, payload: str): def sendMqttMsg(topic: str, payload: str):
testStr = 'mosquitto_pub -t %s -m "%s"' % (topic, payload) testStr = 'mosquitto_pub -t %s -m "%s"' % (topic, payload)
...@@ -128,7 +162,10 @@ def sendMqttMsg(topic: str, payload: str): ...@@ -128,7 +162,10 @@ def sendMqttMsg(topic: str, payload: str):
time.sleep(3) time.sleep(3)
def checkTDengineData(topic: str, payload: str): def checkTDengineData(topic: str, payload: str):
output = subprocess.check_output('taos -s "select * from hivemq.mqtt_payload"', shell=True).decode('utf-8') buildPath = getBuildPath()
binPath = buildPath + "/build/bin/taos"
output = subprocess.check_output('%s -s "select * from hivemq.mqtt_payload"' % binPath, shell=True).decode('utf-8')
if (topic in output) and (payload in output): if (topic in output) and (payload in output):
v_print("%s", output) v_print("%s", output)
return True return True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册