sysinfo.py 2.1 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
update  
jiacy-jcy 已提交
27
        self.delaytime = 10
J
jiacy-jcy 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
    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}')
        
    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)
        
    def get_server_status(self):
        tdSql.query('select server_status()')
        tdSql.checkData(0,0,1)
J
update  
jiacy-jcy 已提交
47
        #!for bug
J
update  
jiacy-jcy 已提交
48 49 50
        # tdDnodes.stoptaosd(1)
        # sleep(self.delaytime)
        # tdSql.error('select server_status()')
J
jiacy-jcy 已提交
51 52 53 54
        
    def run(self):
        self.get_database_info()
        self.check_version()
J
update  
jiacy-jcy 已提交
55
        self.get_server_status()
J
jiacy-jcy 已提交
56 57 58 59 60 61
    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)

tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())