create-tags-boundary.py 2.1 KB
Newer Older
S
Shuduo Sang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
###################################################################
#           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 -*-

import sys
S
Shuduo Sang 已提交
15
import subprocess
S
Shuduo Sang 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28
from util.log import *
from util.cases import *
from util.sql import *


class TDTestCase:
    def init(self, conn):
        tdLog.debug("start to execute %s" % __file__)
        tdSql.init(conn.cursor())

    def run(self):
        tdSql.prepare()

S
Shuduo Sang 已提交
29 30
        getMaxTagNum = "grep -w TSDB_MAX_TAGS ../../src/inc/taosdef.h|awk '{print $3}'"
        boundary = int(subprocess.check_output(getMaxTagNum, shell=True))
S
Shuduo Sang 已提交
31
        tdLog.info("get max tags number is %d" % boundary)
S
Shuduo Sang 已提交
32 33 34 35
        for x in range(0, boundary):
            stb_name = "stb%d" % x

            tagSeq = "tag0 int"
S
Shuduo Sang 已提交
36
            for y in range(1, x + 1):
S
Shuduo Sang 已提交
37 38
                tagSeq = tagSeq + ", tag%d int" % y

S
Shuduo Sang 已提交
39 40 41 42 43 44
            tdLog.info(
                "create table %s (ts timestamp, value int) tags (%s)" %
                (stb_name, tagSeq))
            tdSql.execute(
                "create table %s (ts timestamp, value int) tags (%s)" %
                (stb_name, tagSeq))
S
Shuduo Sang 已提交
45 46 47 48

        tdSql.query("show stables")
        tdSql.checkRows(boundary)

S
Shuduo Sang 已提交
49
        stb_name = "stb%d" % (boundary + 1)
S
Shuduo Sang 已提交
50
        tagSeq = tagSeq + ", tag%d int" % (boundary)
S
Shuduo Sang 已提交
51 52 53 54 55 56
        tdLog.info(
            "create table %s (ts timestamp, value int) tags (%s)" %
            (stb_name, tagSeq))
        tdSql.error(
            "create table %s (ts timestamp, value int) tags (%s)" %
            (stb_name, tagSeq))
S
Shuduo Sang 已提交
57 58 59 60 61 62 63 64 65 66
        tdSql.query("show stables")
        tdSql.checkRows(boundary)

    def stop(self):
        tdSql.close()
        tdLog.success("%s successfully executed" % __file__)


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