sysinfo.py 2.2 KB
Newer Older
J
jiacy-jcy 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
###################################################################
#           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 -*-


from util.log import *
from util.cases import *
from util.sql import *
import subprocess
from util.common import *


class TDTestCase:
    def init(self, conn, logSql):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor())
        self.dbname = 'db'
J
jiacy-jcy 已提交
27
        self.delaytime = 3
J
jiacy-jcy 已提交
28 29 30 31 32 33 34 35
    def get_database_info(self):
        tdSql.query('select database()')
        tdSql.checkData(0,0,None)
        tdSql.execute(f'create database if not exists {self.dbname}')
        tdSql.execute(f'use {self.dbname}')
        tdSql.query('select database()')
        tdSql.checkData(0,0,self.dbname)
        tdSql.execute(f'drop database {self.dbname}')
G
Ganlin Zhao 已提交
36

J
jiacy-jcy 已提交
37 38 39 40 41 42
    def check_version(self):
        taos_list = ['server','client']
        for i in taos_list:
            tdSql.query(f'select {i}_version()')
            version_info = str(subprocess.run('cat ../../source/util/src/version.c |grep "char version"', shell=True,capture_output=True).stdout.decode('utf8')).split('"')[1]
            tdSql.checkData(0,0,version_info)
G
Ganlin Zhao 已提交
43

J
jiacy-jcy 已提交
44
    def get_server_status(self):
J
jiacy-jcy 已提交
45
        sleep(self.delaytime)
J
jiacy-jcy 已提交
46 47
        tdSql.query('select server_status()')
        tdSql.checkData(0,0,1)
J
update  
jiacy-jcy 已提交
48
        #!for bug
J
jiacy-jcy 已提交
49 50
        tdDnodes.stoptaosd(1)
        sleep(self.delaytime)
wafwerar's avatar
wafwerar 已提交
51 52
        if platform.system().lower() == 'windows':
            sleep(10)
J
jiacy-jcy 已提交
53
        tdSql.error('select server_status()')
G
Ganlin Zhao 已提交
54

J
jiacy-jcy 已提交
55 56 57
    def run(self):
        self.get_database_info()
        self.check_version()
J
update  
jiacy-jcy 已提交
58
        self.get_server_status()
J
jiacy-jcy 已提交
59 60 61 62 63
    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
G
Ganlin Zhao 已提交
64
tdCases.addLinux(__file__, TDTestCase())