summaryrefslogtreecommitdiffstats
path: root/reporting/reporting/functest/testCase.py
blob: 5240533f3ce685f2d7ac29ff01d8410d7e4043e7 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/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)',
                               'tempest_defcore': 'Tempest (Defcore)',
                               'refstack_defcore': 'Refstack',
                               'rally_sanity': 'Rally (smoke)',
                               'bgpvpn': 'bgpvpn',
                               'rally_full': 'Rally (full)',
                               'vims': 'vIMS',
                               'doctor-notification': 'Doctor',
                               'promise': 'Promise',
                               'moon': 'Moon',
                               'copper': 'Copper',
                               'security_scan': 'Security',
                               'multisite': 'Multisite',
                               'domino-multinode': 'Domino',
                               'functest-odl-sfc': 'SFC',
                               'onos_sfc': 'SFC',
                               'parser-basics': 'Parser',
                               'connection_check': 'connectivity',
                               'api_check': 'api',
                               'snaps_smoke': 'SNAPS',
                               'snaps_health_check': 'dhcp',
                               'gluon_vping': 'Netready',
                               'fds': 'FDS',
                               'cloudify_ims': 'vIMS (Cloudify)',
                               'orchestra_openims': 'OpenIMS (OpenBaton)',
                               'orchestra_clearwaterims': 'vIMS (OpenBaton)',
                               'opera_ims': 'vIMS (Open-O)',
                               'vyos_vrouter': 'vyos (Cloudify)',
                               'barometercollectd': 'Barometer',
                               'odl_netvirt': 'Netvirt',
                               'security_scan': 'Security',
                               'patrole': 'Patrole',
                               'tenantnetwork1': 'tenant network 1',
                               'tenantnetwork2': 'tenant network 2',
                               'vmready1': 'vm ready 1',
                               'vmready2': 'vm ready 2',
                               'singlevm1': 'single vm 1',
                               'singlevm2': 'single vm 2',
                               'cinder_test': 'cinder tests',
                               'barbican': 'barbican',
                               'juju_epc': 'vEPC (Juju)',
                               'shaker': 'shaker',
                               'neutron_trunk': 'Neutron trunk',
                               'tempest_scenario': 'tempest_scenario',
                               'networking-bgpvpn': 'networking-bgpvpn',
                               'networking-sfc': 'networking-sfc',
                               'tempest_full': 'Tempest (full)',
                               'cloudify': 'cloudify',
                               'heat_ims': 'vIMS (Heat)',
                               'vmtp': 'vmtp',
                               'tempest_smoke': 'Tempest (smoke)',
                               'neutron-tempest-plugin-api': 'Neutron API',
                               'vgpu': 'vgpu',
                               'stor4nfv_os': 'stor4nfv_os'}
        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 getCriteria(self):
        return self.criteria

    def getTier(self):
        return self.tier

    def getConstraints(self):
        return self.constraints

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

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

    def checkRunnable(self, installer, scenario, arch, 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_TYPE": installer,
                                  "DEPLOY_SCENARIO": scenario,
                                  "POD_ARCH": arch}

        # 3 types of constraints
        # INSTALLER_TYPE
        # DEPLOY_SCENARIO
        # POD_ARCH

        # By default we assume that all the tests are always runnable...
        # if test_env not empty => dependencies to be checked
        try:
            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 criterias in config_test:
                    for criteria_key, criteria_value in criterias.iteritems():
                        if re.search(
                                criteria_value,
                                test_execution_context[criteria_key]) is None:
                            is_runnable = False
        except AttributeError:
            is_runnable = False
        # print is_runnable
        self.isRunnable = is_runnable

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

    def getDisplayName(self):
        return self.displayName