예제 #1
0
파일: __main__.py 프로젝트: chiyukuan/ktest
def runConfig():
    from kd.tfwk.kemail import KEmail
    from kd.tfwk.test_case import TestCase
    from kd.tfwk.test_set import TestSet
    from kd.tfwk.test_folder import TestFolder
    from kd.tfwk.test_ctx import TestCtx
    from kd.util.rc_msg import RC
    from kd.util.logger import getLogger
    import kd.tcases

    logger = getLogger(__name__)

    testCtx = TestCtx(Environ.CFG_FILE_NAME)
    desc, whitelist, blacklist = testCtx.loadTestCtx(Environ.TestSuit)
    TestCase.setTestCtx(testCtx)
    whitelist = eval(whitelist)
    blacklistCNs = ['kd.tcases.helper.tch_pause.TchPause'
                    ] if options.skipPause else []
    for tcase in eval(blacklist):
        fcls = tcase.__module__ + "." + tcase.__class__.__name__
        blacklistCNs.append(fcls)

    kemail = KEmail()
    if options.dryRun:
        TestCase.setParam('__force_skip__', 'enable')

    logger.info("****")
    logger.info("**** Run %s", Environ.TestSuit)
    logger.info("****     %s", testCtx.desc)
    logger.info("****\n")
    logger.debug("Run %s test suite with following parameters:\n'%s'", desc,
                 testCtx.params)
    for idx in range(len(whitelist)):
        cls = whitelist[idx]

        tcases = TestSet.genTestCasesBySpec(cls)
        if not bool(tcases):
            continue

        if type(cls) is type and not issubclass(TestFolder, cls):
            for idx in range(len(tcases)):
                tcases[idx].fName = "%s.%s:%d" % (cls.__module__, cls.__name__,
                                                  idx)
        for tcase in tcases:
            fcls = tcase.__module__ + "." + tcase.__class__.__name__
            if fcls in blacklistCNs:
                tcase.skip = True
                tcase.setRC(RC.OK, "Skip due to BlackList")
                continue
            tcase.run()
            kemail.addTCase(idx, tcase)
            if not tcase.canContinue():
                break
        if not tcase.canContinue():
            break

    kemail.send(options.dryRun)
예제 #2
0
#! /usr/bin/env python
''' ------------------------|  Python SOURCE FILE  |------------------------

The Description of this file.

@copyright: Copyright (c) by Kodiak Data, Inc. All rights reserved.
'''

from kd.util.logger import getLogger
from tc_nomad_base import TcNomadBase
from kd.util.rc_msg import RC
from kd.text.stats_colloct import StatsColloct
from kd.tcases.tc_base import TcBase

logger = getLogger(__name__)


class TcNomadLtnc(TcNomadBase):
    class Stats(StatsColloct):
        def __init__(self):
            super(TcNomadLtnc.Stats, self).__init__(
                ['Access Spec', '1-WR', '2-WR', 'WR', '1-RD', 'RD'])

        def _genTbl(self):
            for feedSet in self.feedSets:
                cnts = [0, 0, 0, 0, 0]
                tms = [0.0, 0.0, 0.0, 0.0, 0.0]
                for feed in feedSet[1:]:
                    # feed = opq, cnt, time
                    cnts[feed[0]] += feed[1]
                    tms[feed[0]] += feed[2]