summaryrefslogtreecommitdiffstats
path: root/utils/test/reporting/functest/testCase.py
blob: 876beb2672abef3c37bebc183a3568011b4e6846 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Numbe
#!/usr/bin/python
#
# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
import re


class TestCase(object):

    def __init__(self, name, project, constraints,
                 criteria=-1, isRunnable=True, tier=-1):
        self.name = name
        self.project = project
        self.constraints = constraints
        self.criteria = criteria
        self.isRunnable = isRunnable
        self.tier = tier
        display_name_matrix = {'healthcheck': 'healthcheck',
                               'vping_ssh': 'vPing (ssh)',
                               'vping_userdata': 'vPing (userdata)',
                               'odl': 'ODL',
                               'onos': 'ONOS',
                               'ocl': 'OCL',
                               'tempest_smoke_serial': 'Tempest (smoke)',
                               'tempest_full_parallel': 'Tempest (full)',
                               'rally_sanity': 'Rally (smoke)',
                               'bgpvpn': 'bgpvpn',
                               'rally_full': 'Rally (full)',
                               'vims': 'vIMS',
                               'doctor': 'Doctor',
                               'promise': 'Promise',
                               'moon': 'moon',
                               'copper': 'copper',
                               'security_scan': 'security',
                               'multisite': 'multisite',
                               'domino': 'domino',
                               'odl-sfc': 'SFC',
                               'onos_sfc': 'SFC',
                               'parser': 'parser'
                               }
        try:
            self.displayName = display_name_matrix[self.name]
        except:
            self.displayName = "unknown"

    def getName(self):
        return self.name

    def getProject(self):
        return self.project

    def getConstraints(self):
        return self.constraints

    def getCriteria(self):
        return self.criteria

    def getTier(self):
        return self.tier

    def setCriteria(self, criteria):
        self.criteria = criteria

    def setIsRunnable(self, isRunnable):
        self.isRunnable = isRunnable

    def checkRunnable(self, installer, scenario, config):
        # Re-use Functest declaration
        # Retrieve Functest configuration file functest_config.yaml
        is_runnable = True
        config_test = config
        # print " *********************** "
        # print TEST_ENV
        # print " ---------------------- "
        # print "case = " + self.name
        # print "installer = " + installer
        # print "scenario = " + scenario
        # print "project = " + self.project

        # Retrieve test constraints
        # Retrieve test execution param
        test_execution_context = {"installer": installer,
                                  "scenario": scenario}

        # By default we assume that all the tests are always runnable...
        # if test_env not empty => dependencies to be checked
        if config_test is not None and len(config_test) > 0:
            # possible criteria = ["installer", "scenario"]
            # consider test criteria from config file
            # compare towards CI env through CI en variable
            for criteria in config_test:
                if re.search(config_test[criteria],
                             test_execution_context[criteria]) is None:
                    # print "Test "+ test + " cannot be run on the environment"
                    is_runnable = False
        # print is_runnable
        self.isRunnable = is_runnable

    def toString(self):
        testcase = ("Name=" + self.name + ";Criteria=" +
                    str(self.criteria) + ";Project=" + self.project +
                    ";Constraints=" + str(self.constraints) +
                    ";IsRunnable" + str(self.isRunnable))
        return testcase

    def getDbName(self):
        # Correspondance name of the test case / name in the DB
        # ideally we should modify the DB to avoid such interface....
        # '<name in the config>':'<name in the DB>'
        # I know it is uggly...
        test_match_matrix = {'healthcheck': 'healthcheck',
                             'vping_ssh': 'vping_ssh',
                             'vping_userdata': 'vping_userdata',
                             'odl': 'odl',
                             'onos': 'onos',
                             'ocl': 'ocl',
                             'tempest_smoke_serial': 'tempest_smoke_serial',
                             'tempest_full_parallel': 'tempest_full_parallel',
                             'rally_sanity': 'rally_sanity',
                             'bgpvpn': 'bgpvpn',
                             'rally_full': 'rally_full',
                             'vims': 'vims',
                             'doctor': 'doctor-notification',
                             'promise': 'promise',
                             'moon': 'moon',
                             'copper': 'copper-notification',
                             'security_scan': 'security',
                             'multisite': 'multisite',
                             'domino': 'domino-multinode',
                             'odl-sfc': 'functest-odl-sfc',
                             'onos_sfc': 'onos_sfc',
                             'parser': 'parser-basics'
                             }
        try:
            return test_match_matrix[self.name]
        except:
            return "unknown"

    def getDisplayName(self):
        return self.displayName