[TD-4290]<test>: modify testcase that compact wal file
This commit is contained in:
parent
3c2681fafc
commit
119537014b
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from distutils.log import debug
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import taos
|
import taos
|
||||||
|
@ -18,6 +19,7 @@ from util.log import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
from util.dnodes import *
|
from util.dnodes import *
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
@ -47,11 +49,13 @@ class TDTestCase:
|
||||||
tdLog.exit("taosd not found!")
|
tdLog.exit("taosd not found!")
|
||||||
else:
|
else:
|
||||||
tdLog.info("taosd found in %s" % buildPath)
|
tdLog.info("taosd found in %s" % buildPath)
|
||||||
|
|
||||||
binPath = buildPath+ "/build/bin/"
|
binPath = buildPath+ "/build/bin/"
|
||||||
|
testPath = buildPath[:buildPath.find("debug")]
|
||||||
|
|
||||||
#new db and insert data
|
#new db and insert data
|
||||||
os.system("rm -rf /home/chr/TDengine/sim/dnode1/data/mnode_tmp/")
|
os.system("rm -rf %s/sim/dnode1/data/mnode_tmp/" % testPath)
|
||||||
os.system("rm -rf /home/chr/TDengine/sim/dnode1/data/mnode_bak/")
|
os.system("rm -rf %s/sim/dnode1/data/mnode_bak/" % testPath)
|
||||||
tdSql.execute("drop database if exists db2")
|
tdSql.execute("drop database if exists db2")
|
||||||
os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath)
|
os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath)
|
||||||
tdSql.execute("drop database if exists db1")
|
tdSql.execute("drop database if exists db1")
|
||||||
|
@ -73,23 +77,19 @@ class TDTestCase:
|
||||||
tdSql.execute("alter table stb2_0 add column col2 binary(4)")
|
tdSql.execute("alter table stb2_0 add column col2 binary(4)")
|
||||||
tdSql.execute("alter table stb2_0 drop column col1")
|
tdSql.execute("alter table stb2_0 drop column col1")
|
||||||
tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')")
|
tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')")
|
||||||
|
|
||||||
# stop taosd and compact wal file
|
# stop taosd and compact wal file
|
||||||
os.system("ps -ef |grep taosd |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
|
tdDnodes.stop(1)
|
||||||
sleep(2)
|
sleep(10)
|
||||||
# os.system("nohup taosd --compact-mnode-wal -c /home/chr/TDengine/sim/dnode1/cfg/ & ")
|
os.system("nohup %s/taosd --compact-mnode-wal -c %s/sim/dnode1/cfg/ & " %(binPath,testPath) )
|
||||||
sleep(5)
|
# os.system("nohup taosd --compact-mnode-wal -c %s/sim/dnode1/cfg/ & " % testPath )
|
||||||
os.system("nohup /home/chr/TDengine/debug/build/bin/taosd -c /home/chr/TDengine/sim/dnode1/cfg > /dev/null 2>&1 &")
|
# tdDnodes.start(1)
|
||||||
|
os.system("nohup %s/taosd -c %s/sim/dnode1/cfg > /dev/null 2>&1 &" %(binPath,testPath) )
|
||||||
sleep(4)
|
sleep(4)
|
||||||
tdSql.execute("reset query cache")
|
tdSql.execute("reset query cache")
|
||||||
query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1])
|
query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1])
|
||||||
print(query_pid2)
|
print(query_pid2)
|
||||||
|
|
||||||
# use new wal file to start up tasod
|
# use new wal file to start up tasod
|
||||||
# conn1 = taos.connect(host="chenhaoran02", user="root", password="taosdata", config="/home/chr/TDengine/sim/dnode1/cfg/" )
|
|
||||||
# cur1 = conn1.cursor()
|
|
||||||
# tdSql.init(cur1, True)
|
|
||||||
|
|
||||||
tdSql.execute("use db2")
|
tdSql.execute("use db2")
|
||||||
tdSql.query("select count (tbname) from stb0")
|
tdSql.query("select count (tbname) from stb0")
|
||||||
tdSql.checkData(0, 0, 1)
|
tdSql.checkData(0, 0, 1)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import threading
|
||||||
|
|
||||||
class TwoClients:
|
class TwoClients:
|
||||||
def initConnection(self):
|
def initConnection(self):
|
||||||
self.host = "chenhaoran01"
|
self.host = "chenhaoran02"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
self.password = "taosdata"
|
self.password = "taosdata"
|
||||||
self.config = "/etc/taos/"
|
self.config = "/etc/taos/"
|
||||||
|
@ -61,33 +61,60 @@ class TwoClients:
|
||||||
cur1 = conn1.cursor()
|
cur1 = conn1.cursor()
|
||||||
tdSql.init(cur1, True)
|
tdSql.init(cur1, True)
|
||||||
# tdSql.init(cur2, True)
|
# tdSql.init(cur2, True)
|
||||||
|
|
||||||
|
# new db and insert data
|
||||||
|
os.system("rm -rf /var/lib/taos/mnode_bak/")
|
||||||
|
os.system("rm -rf /var/lib/taos/mnode_temp/")
|
||||||
|
tdSql.execute("drop database if exists db2")
|
||||||
os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath)
|
os.system("%staosdemo -f wal/insertDataDb1.json -y " % binPath)
|
||||||
tdSql.execute("drop database if exists db1")
|
tdSql.execute("drop database if exists db1")
|
||||||
os.system("%staosdemo -f wal/insertDataDb2.json -y " % binPath)
|
os.system("%staosdemo -f wal/insertDataDb2.json -y " % binPath)
|
||||||
tdSql.execute("drop table if exists db2.stb0")
|
tdSql.execute("drop table if exists db2.stb0")
|
||||||
os.system("%staosdemo -f wal/insertDataDb2Newstab.json -y " % binPath)
|
os.system("%staosdemo -f wal/insertDataDb2Newstab.json -y " % binPath)
|
||||||
|
query_pid1 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1])
|
||||||
|
print(query_pid1)
|
||||||
|
tdSql.execute("use db2")
|
||||||
|
tdSql.execute("drop table if exists stb1_0")
|
||||||
|
tdSql.execute("drop table if exists stb1_1")
|
||||||
|
tdSql.execute("insert into stb0_0 values(1614218412000,8637,78.861045,'R','bf3')(1614218422000,8637,98.861045,'R','bf3')")
|
||||||
tdSql.execute("alter table db2.stb0 add column col4 int")
|
tdSql.execute("alter table db2.stb0 add column col4 int")
|
||||||
tdSql.execute("alter table db2.stb0 drop column col2")
|
tdSql.execute("alter table db2.stb0 drop column col2")
|
||||||
os.system("ps -ef |grep taosd |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
|
tdSql.execute("alter table db2.stb0 add tag t3 int")
|
||||||
os.system("nohup taosd --compact-mnode-wal & ")
|
tdSql.execute("alter table db2.stb0 drop tag t1")
|
||||||
sleep(5)
|
tdSql.execute("create table if not exists stb2_0 (ts timestamp, col0 int, col1 float) ")
|
||||||
os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &")
|
tdSql.execute("insert into stb2_0 values(1614218412000,8637,78.861045)")
|
||||||
sleep(10)
|
tdSql.execute("alter table stb2_0 add column col2 binary(4)")
|
||||||
|
tdSql.execute("alter table stb2_0 drop column col1")
|
||||||
|
tdSql.execute("insert into stb2_0 values(1614218422000,8638,'R')")
|
||||||
|
|
||||||
conn2 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config )
|
conn2 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config )
|
||||||
print(conn2)
|
print(conn2)
|
||||||
cur2 = conn2.cursor()
|
cur2 = conn2.cursor()
|
||||||
tdSql.init(cur2, True)
|
tdSql.init(cur2, True)
|
||||||
|
|
||||||
|
# stop taosd and compact wal file
|
||||||
|
os.system("ps -ef |grep taosd |grep -v 'grep' |awk '{print $2}'|xargs kill -9")
|
||||||
|
sleep(2)
|
||||||
|
os.system("nohup taosd --compact-mnode-wal -c /etc/taos/taos.cfg & ")
|
||||||
|
sleep(5)
|
||||||
|
os.system("nohup /usr/bin/taosd > /dev/null 2>&1 &")
|
||||||
|
sleep(4)
|
||||||
|
tdSql.execute("reset query cache")
|
||||||
|
query_pid2 = int(subprocess.getstatusoutput('ps aux|grep taosd |grep -v "grep"|awk \'{print $2}\'')[1])
|
||||||
|
print(query_pid2)
|
||||||
|
|
||||||
|
# use new wal file to start up tasod
|
||||||
tdSql.execute("use db2")
|
tdSql.execute("use db2")
|
||||||
tdSql.query("select count (tbname) from stb0")
|
tdSql.query("select count (tbname) from stb0")
|
||||||
tdSql.checkData(0, 0, 1)
|
tdSql.checkData(0, 0, 1)
|
||||||
tdSql.query("select count (tbname) from stb1")
|
tdSql.query("select count (tbname) from stb1")
|
||||||
|
tdSql.checkRows(0)
|
||||||
|
tdSql.query("select count(*) from stb0_0")
|
||||||
tdSql.checkData(0, 0, 2)
|
tdSql.checkData(0, 0, 2)
|
||||||
tdSql.query("select count(*) from stb00_0")
|
|
||||||
tdSql.checkData(0, 0, 1)
|
|
||||||
tdSql.query("select count(*) from stb0")
|
tdSql.query("select count(*) from stb0")
|
||||||
tdSql.checkData(0, 0, 1)
|
tdSql.checkData(0, 0, 2)
|
||||||
tdSql.query("select count(*) from stb1")
|
tdSql.query("select count(*) from stb2_0")
|
||||||
tdSql.checkData(0, 0, 20)
|
tdSql.checkData(0, 0, 2)
|
||||||
|
|
||||||
clients = TwoClients()
|
clients = TwoClients()
|
||||||
clients.initConnection()
|
clients.initConnection()
|
||||||
|
|
Loading…
Reference in New Issue