def __init__(self, node, db_schema):
        self.top_node = node

        self.name = Parser.getNodeVal(self, self.top_node, "name")
        method_nodes = Parser.getNodeList(self, self.top_node, "method")
        self.methods = [MethodTemplate(method_node, db_schema) for method_node in method_nodes]

        self.method_map = {}
        for method in self.methods:
            self.method_map[method.name] = method
    def __init__(self, xml, db_schema="madlib"):
        Parser.__init__(self, xml)
        self.algorithms = {}

        algorithms = Parser.getNodeTag(self, self.xmlDoc, "algorithms")
        algorithm_list = Parser.getNodeList(self, algorithms, "algorithm")
        self.algorithm_map = {}
        self.algorithms = [AlgorithmTemplate(algorithm, db_schema) for algorithm in algorithm_list]
        for algorithm in self.algorithms:
            self.algorithm_map[algorithm.name] = algorithm
Exemple #3
0
    def GenCase(self, mtdList, exeIteration, tsType, debug):
        """generate each test case
    
        params:    
            mtdList: method node list
            exeIteration: number of this execution iteration
            tsType: test suite type
        """

        mtSeq = 0
        for mtd in mtdList:

            caseItem = []
            caseItemPara = []
            caseItemRows = 0
            caseItemDataset = ""

            # test case start command, which is the path of template executor
            caseItem.append(Path.templateExecutorPath)

            # try to attach pre parameters, it is optional
            try:
                mtdName = Parser.getNodeVal(self, mtd, "name")

                #configuration for template executor
                caseItemPara.append("--method " + mtdName)
                caseItemPara.append("--algorithm " + self.algorithm)
                caseItemPara.append("--spec_file " + os.path.join(
                    os.getcwd(), Path.CfgSpecPath + Path.algorithmsSpecXml))

                caseItemPara.extend(self.preParas[mtdName])

            except Exception, exp:
                #print 'pre', str(exp)
                pass

            # try to attach parameters, it is optional
            try:
                paraList = Parser.getNodeList(self, mtd, "parameter")
                for para in paraList:
                    paraName = Parser.getNodeVal(self, para, "name")
                    paraVal = Parser.getNodeVal(self, para, "value")
                    caseItemPara.extend(
                        self.paraHandler.handle(paraName, paraVal, "para",
                                                mtdName))

                    if "dataset" == paraName:
                        caseItemDataset = paraVal
                    if "rows" == paraName:
                        caseItemRows = paraVal
            except Exception, exp:
                pass
Exemple #4
0
    def getDataSets(self):
        """Return map of datasets.
    
        key: datasetName  value: dic(method : parameter)
        """
        datasets = Parser.getNodeTag(self, self.xmlDoc,"datasets")

        dsList = Parser.getNodeList(self, datasets, "dataset")

        self.num = len(dsList)
        for dsNode in dsList:
            self.__getDataSet(dsNode)
        return self.descs
Exemple #5
0
    def __init__(self, node, db_schema):
        self.top_node = node

        self.name = Parser.getNodeVal(self, self.top_node, "name")
        method_nodes = Parser.getNodeList(self, self.top_node, "method")
        self.methods = [
            MethodTemplate(method_node, db_schema)
            for method_node in method_nodes
        ]

        self.method_map = {}
        for method in self.methods:
            self.method_map[method.name] = method
Exemple #6
0
    def getDataSets(self):
        """Return map of datasets.
    
        key: datasetName  value: dic(method : parameter)
        """
        datasets = Parser.getNodeTag(self, self.xmlDoc, "datasets")

        dsList = Parser.getNodeList(self, datasets, "dataset")

        self.num = len(dsList)
        for dsNode in dsList:
            self.__getDataSet(dsNode)
        return self.descs
Exemple #7
0
    def __init__(self, xml, db_schema='madlib'):
        Parser.__init__(self, xml)
        self.algorithms = {}

        algorithms = Parser.getNodeTag(self, self.xmlDoc, "algorithms")
        algorithm_list = Parser.getNodeList(self, algorithms, "algorithm")
        self.algorithm_map = {}
        self.algorithms = [
            AlgorithmTemplate(algorithm, db_schema)
            for algorithm in algorithm_list
        ]
        for algorithm in self.algorithms:
            self.algorithm_map[algorithm.name] = algorithm
Exemple #8
0
    def GenCase(self, mtdList, exeIteration, tsType, debug):
        """generate each test case
    
        params:    
            mtdList: method node list
            exeIteration: number of this execution iteration
            tsType: test suite type
        """

        mtSeq = 0
        for mtd in  mtdList:

            caseItem = []
            caseItemPara = []
            caseItemRows = 0
            caseItemDataset = ""

            # test case start command, which is the path of template executor
            caseItem.append(Path.templateExecutorPath)

            # try to attach pre parameters, it is optional
            try :
                mtdName = Parser.getNodeVal(self, mtd , "name")

                #configuration for template executor
                caseItemPara.append("--method "+mtdName)
                caseItemPara.append("--algorithm "+self.algorithm)
                caseItemPara.append("--spec_file "+ os.path.join( 
                    os.getcwd(), Path.CfgSpecPath + Path.algorithmsSpecXml))

                caseItemPara.extend(self.preParas[mtdName])

            except Exception, exp:
                #print 'pre', str(exp)
                pass

            # try to attach parameters, it is optional
            try :
                paraList = Parser.getNodeList(self, mtd,"parameter")
                for para in paraList:
                    paraName = Parser.getNodeVal(self, para, "name")
                    paraVal  = Parser.getNodeVal(self, para, "value")
                    caseItemPara.extend(self.paraHandler.handle(paraName, 
                        paraVal, "para", mtdName))

                    if "dataset" == paraName :
                        caseItemDataset = paraVal
                    if "rows" == paraName :
                        caseItemRows = paraVal
            except Exception, exp:
                pass
    def __init__(self, node, db_schema):
        self.top_node = node
        self.db_schema = db_schema

        self.name = Parser.getNodeVal(self, self.top_node, "name")
        self.create = Parser.getNodeVal(self, self.top_node, "create")
        self.template = Parser.getNodeVal(self, self.top_node, "template")
        input_para_nodes = Parser.getNodeList(self, self.top_node, "input_parameter")
        self.input_paras = [InputParameter(input_para_node) for input_para_node in input_para_nodes]
        self.output_paras = [
            InputParameter(output_para_node)
            for output_para_node in Parser.getNodeList(self, self.top_node, "output_parameter")
        ]

        self.para_map = {}
        for para in self.output_paras:
            self.para_map[para.name] = para
        # input parameter can overwrite output parameter
        for para in self.input_paras:
            self.para_map[para.name] = para
Exemple #10
0
    def __preParas(self, mtdNodeList):
        """Get prepared parameters.

        params:
            mtdNodeList: method node list.
        return:
            preParameters Hash tablb, the table format.
        key:methodName, value : method's preParameters array (including parameter name)
        """

        preParas = {}
        for mtd in mtdNodeList:
            prePara = []
            mtdName = Parser.getNodeVal(self, mtd,"name")
            for para in Parser.getNodeList(self, mtd,"parameter"):
                pName = Parser.getNodeVal(self, para, "name")
                pVal = Parser.getNodeVal(self, para, "value")
                prePara.extend(self.paraHandler.handle(pName, pVal, "pre", mtdName))
            preParas[mtdName] = prePara
        return preParas
Exemple #11
0
    def __init__(self, node):
        self.top_node = node

        # input parameter name
        self.name = Parser.getNodeVal(self, self.top_node, "name").lower()
        # input parameter value
        self.type = Parser.getNodeVal(self, self.top_node, "type").lower()
        # should we quote the parameter name?
        quote = Parser.getNodeVal(self, self.top_node, "quote")
        # default is True
        if not quote:
            self.quote = True
        elif quote.lower in ("t", "true"):
            self.quote = True
        else:
            self.quote = False

        try:
            self.default = Parser.getNodeVal(self, self.top_node, "default")
        except Exception:
            self.default = ""
Exemple #12
0
    def __multiTestSuite(self, mlTs, tsType, debug):
        """Parse one multi-test suite.

        params:
            mlTs: multi-test suite node
            tsType: <test_type>
        """

        algorithm   =   Parser.getNodeVal(self, mlTs, "algorithm")
        # parse pre parameters (hash table)
        methods     =   Parser.getNodeTag(self, mlTs, "methods")
        mtdNodeList =   Parser.getNodeList(self, methods, "method")
        preParas    =   self.__preParas(mtdNodeList)
        # get test suite nodes list
        tsNodeList  =   Parser.getNodeList(self, mlTs, "test_suite")
        # init a MutiTestSuite instance
        mlTs        =   multi_testsuite.MultiTestSuite(self.configer, self.analyticsTools, \
                                      self.datasets, self.paraHandler, algorithm, preParas, \
                                      tsNodeList, tsType, self.caseScheduleFileHd, \
                                      self.caseSQLFileHd, self.testSuiteSqlHd, self.testItemSqlHd)
        mlTs.GenCases(debug)
Exemple #13
0
    def GenCases(self, debug = False):
        """Generate cases for each test case xml spec file

        Parse the root tag <test_suites>.
        <test_type> has two options: feature and performance. For performance test,
        each test case should be wraped by gpstart and gpstop
        output:
            1) one case schedule file which include gpstart/gpstop and test case file name,
               as caseScheduleF in __init__'s para
            2) multiply test case file with executor commands
            3) one sql output file, as caseSQLF in __init__'s para
            4) one sql file of inserting test suite, as tsSqlF in __init__'s para
            5) one sql file of inserting test case, as tiSqlF in __init__'s para
        """

        ts          =   Parser.getNodeTag(self, self.xmlDoc, "test_suites")
        tsType      =   Parser.getNodeVal(self, ts, "test_type")
        mulTsList   =   Parser.getNodeList(self, ts, "multi_test_suites")
        # loop to parse each multi test suite
        for mulTs in mulTsList:
            self.__multiTestSuite(mulTs, tsType, debug)
Exemple #14
0
    def __init__(self, node):
        self.top_node = node

        # input parameter name
        self.name = Parser.getNodeVal(self, self.top_node, "name").lower()
        # input parameter value
        self.type = Parser.getNodeVal(self, self.top_node, "type").lower()
        # should we quote the parameter name?
        quote = Parser.getNodeVal(self, self.top_node, "quote")
        # default is True
        if not quote:
            self.quote = True
        elif quote.lower in ('t', 'true'):
            self.quote = True
        else:
            self.quote = False

        try:
            self.default = Parser.getNodeVal(self, self.top_node, "default")
        except Exception:
            self.default = ''
Exemple #15
0
 def __init__(self, configer, analyticsTools, datasets, specXml,
              caseScheduleFileHd, caseSQLFileHd, tsSqlFileHd, tiSqlFileHd):
     """
     params:
         configer: configer class from test_config
         analyticsTools: all alalyticsTool info map
         datasets: dataset class to parse dataset xml
         specXml: test case spec xml file
         caseScheduleFileHd: test case schedule file descriptor
         caseSQLFileHd: test case sql out file descriptor
         tsSqlFileHd: sql file of inserting test suite, as tsSqlF in __init__'s para
         tiSqlFileHd: sql file of inserting test case, as tiSqlF in __init__'s para
     """
     Parser.__init__(self, specXml)
     self.configer           =   configer
     self.analyticsTools     =   analyticsTools
     self.datasets           =   datasets
     self.paraHandler        =   para_handler.ParaHandler(analyticsTools, datasets)
     self.caseScheduleFileHd =   open(caseScheduleFileHd, "w")
     self.caseSQLFileHd      =   open(caseSQLFileHd, "w")
     self.testSuiteSqlHd     =   open(tsSqlFileHd, "w")
     self.testItemSqlHd      =   open(tiSqlFileHd, "w")
Exemple #16
0
    def __init__(self, node, db_schema):
        self.top_node = node
        self.db_schema = db_schema

        self.name = Parser.getNodeVal(self, self.top_node, "name")
        self.create = Parser.getNodeVal(self, self.top_node, "create")
        self.template = Parser.getNodeVal(self, self.top_node, "template")
        input_para_nodes = Parser.getNodeList(self, self.top_node,
                                              "input_parameter")
        self.input_paras = [
            InputParameter(input_para_node)
            for input_para_node in input_para_nodes
        ]
        self.output_paras = [
            InputParameter(output_para_node) for output_para_node in
            Parser.getNodeList(self, self.top_node, "output_parameter")
        ]

        self.para_map = {}
        for para in self.output_paras:
            self.para_map[para.name] = para
        # input parameter can overwrite output parameter
        for para in self.input_paras:
            self.para_map[para.name] = para
Exemple #17
0
    def __getDataSet(self, dsNode):
        desc = {}
        dsName = Parser.getNodeVal(self, dsNode, "name")
        dsRows = Parser.getNodeVal(self, dsNode, "rows")
        desc["rows"] = dsRows

        mtList = Parser.getNodeList(self, dsNode, "method")
        for mt in mtList:
            mtName = Parser.getNodeVal(self, mt, "name")
            paraList = Parser.getNodeList(self, mt, "parameter")

            paras = []
            for para in paraList:
                pName = Parser.getNodeVal(self, para, "name")
                pVal = Parser.getNodeVal(self, para, "value")
                paras.append("--" + pName + " " + pVal)
            desc[mtName] = " ".join(paras)  # method's parameter string

        self.descs[dsName] = desc
Exemple #18
0
    def __getDataSet(self, dsNode):
        desc = {}
        dsName = Parser.getNodeVal(self, dsNode, "name")
        dsRows = Parser.getNodeVal(self, dsNode, "rows")
        desc["rows"] = dsRows

        mtList = Parser.getNodeList(self, dsNode, "method")
        for mt in mtList :
            mtName = Parser.getNodeVal(self, mt, "name")
            paraList = Parser.getNodeList(self, mt, "parameter")

            paras = []
            for para in paraList:
                pName = Parser.getNodeVal(self, para, "name")
                pVal = Parser.getNodeVal(self, para, "value")
                paras.append("--" + pName + " " + pVal)
            desc[mtName] = " ".join(paras)  # method's parameter string

        self.descs[dsName] = desc
Exemple #19
0
 def __init__(self, fileName):
     """fileName of dataset xml file.""" 
     Parser.__init__(self, fileName)
     self.num = 0   # number of datasets
     self.descs = {} # Key: datasetName  Value: dic(method : parameter)
Exemple #20
0
            self.caseFileHd.write(madlibCMD + "\n")

            if debug is True:
                try:
                    exe = template_executor.Executor(madlibCMD.split(), None)
                    exe.parseArgument()
                    if exeIteration == 0:
                        self.caseSQLFileHd.write("-- method: " +
                                                 targetBaseName + "\n")
                        self.caseSQLFileHd.write(exe.generateSQL() + "\n\n")
                except Exception, exp:
                    print str(exp)

            # try to add tear down operation, this step is optional
            try:
                teardown = Parser.getNodeVal(self, mtd, "tear_down")
                teardownSQL = "psql " + teardown
                self.caseFileHd.write(teardownSQL)
                self.caseSQLFileHd.write(teardownSQL)
            except Exception, exp:
                pass

            self.caseFileHd.write("\n")

            if exeIteration == 0:
                self.__writeTestItemsSql(targetBaseName, self.algorithm,
                mtdName, ",".join(caseItemPara), varValues, varNames, \
                caseItemDataset,caseItemRows)

        self.caseFileHd.write("\n")
Exemple #21
0
 def __init__(self, fileName):
     """fileName of dataset xml file."""
     Parser.__init__(self, fileName)
     self.num = 0  # number of datasets
     self.descs = {}  # Key: datasetName  Value: dic(method : parameter)
Exemple #22
0
            madlibCMD = " ".join(caseItem)
            self.caseFileHd.write(madlibCMD + "\n")

            if debug is True:
                try:
                    exe = template_executor.Executor(madlibCMD.split(), None)
                    exe.parseArgument()
                    if exeIteration == 0:
                        self.caseSQLFileHd.write( "-- method: " + targetBaseName + "\n")
                        self.caseSQLFileHd.write( exe.generateSQL() + "\n\n")
                except Exception, exp:
                    print str(exp)

            # try to add tear down operation, this step is optional
            try:
                teardown = Parser.getNodeVal(self, mtd, "tear_down")
                teardownSQL = "psql " + teardown
                self.caseFileHd.write(teardownSQL)
                self.caseSQLFileHd.write( teardownSQL )
            except Exception, exp:
                pass

            self.caseFileHd.write("\n")

            if exeIteration == 0:
                self.__writeTestItemsSql(targetBaseName, self.algorithm,
                mtdName, ",".join(caseItemPara), varValues, varNames, \
                caseItemDataset,caseItemRows)

        self.caseFileHd.write("\n")