Correct SFC testcase match in the reporting Dashboard
[releng.git] / utils / test / reporting / functest / testCase.py
1 #!/usr/bin/python
2 #
3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 import re
10
11
12 class TestCase(object):
13
14     def __init__(self, name, project, constraints,
15                  criteria=-1, isRunnable=True, tier=-1):
16         self.name = name
17         self.project = project
18         self.constraints = constraints
19         self.criteria = criteria
20         self.isRunnable = isRunnable
21         self.tier = tier
22         display_name_matrix = {'healthcheck': 'healthcheck',
23                                'vping_ssh': 'vPing (ssh)',
24                                'vping_userdata': 'vPing (userdata)',
25                                'odl': 'ODL',
26                                'onos': 'ONOS',
27                                'ocl': 'OCL',
28                                'tempest_smoke_serial': 'Tempest (smoke)',
29                                'tempest_full_parallel': 'Tempest (full)',
30                                'rally_sanity': 'Rally (smoke)',
31                                'bgpvpn': 'bgpvpn',
32                                'rally_full': 'Rally (full)',
33                                'vims': 'vIMS',
34                                'doctor': 'Doctor',
35                                'promise': 'Promise',
36                                'moon': 'moon',
37                                'copper': 'copper',
38                                'security_scan': 'security',
39                                'multisite': 'multisite',
40                                'domino': 'domino',
41                                'odl-sfc': 'SFC',
42                                'onos_sfc': 'SFC',
43                                'parser': 'parser'
44                                }
45         try:
46             self.displayName = display_name_matrix[self.name]
47         except:
48             self.displayName = "unknown"
49
50     def getName(self):
51         return self.name
52
53     def getProject(self):
54         return self.project
55
56     def getConstraints(self):
57         return self.constraints
58
59     def getCriteria(self):
60         return self.criteria
61
62     def getTier(self):
63         return self.tier
64
65     def setCriteria(self, criteria):
66         self.criteria = criteria
67
68     def setIsRunnable(self, isRunnable):
69         self.isRunnable = isRunnable
70
71     def checkRunnable(self, installer, scenario, config):
72         # Re-use Functest declaration
73         # Retrieve Functest configuration file functest_config.yaml
74         is_runnable = True
75         config_test = config
76         # print " *********************** "
77         # print TEST_ENV
78         # print " ---------------------- "
79         # print "case = " + self.name
80         # print "installer = " + installer
81         # print "scenario = " + scenario
82         # print "project = " + self.project
83
84         # Retrieve test constraints
85         # Retrieve test execution param
86         test_execution_context = {"installer": installer,
87                                   "scenario": scenario}
88
89         # By default we assume that all the tests are always runnable...
90         # if test_env not empty => dependencies to be checked
91         if config_test is not None and len(config_test) > 0:
92             # possible criteria = ["installer", "scenario"]
93             # consider test criteria from config file
94             # compare towards CI env through CI en variable
95             for criteria in config_test:
96                 if re.search(config_test[criteria],
97                              test_execution_context[criteria]) is None:
98                     # print "Test "+ test + " cannot be run on the environment"
99                     is_runnable = False
100         # print is_runnable
101         self.isRunnable = is_runnable
102
103     def toString(self):
104         testcase = ("Name=" + self.name + ";Criteria=" +
105                     str(self.criteria) + ";Project=" + self.project +
106                     ";Constraints=" + str(self.constraints) +
107                     ";IsRunnable" + str(self.isRunnable))
108         return testcase
109
110     def getDbName(self):
111         # Correspondance name of the test case / name in the DB
112         # ideally we should modify the DB to avoid such interface....
113         # '<name in the config>':'<name in the DB>'
114         # I know it is uggly...
115         test_match_matrix = {'healthcheck': 'healthcheck',
116                              'vping_ssh': 'vping_ssh',
117                              'vping_userdata': 'vping_userdata',
118                              'odl': 'odl',
119                              'onos': 'onos',
120                              'ocl': 'ocl',
121                              'tempest_smoke_serial': 'tempest_smoke_serial',
122                              'tempest_full_parallel': 'tempest_full_parallel',
123                              'rally_sanity': 'rally_sanity',
124                              'bgpvpn': 'bgpvpn',
125                              'rally_full': 'rally_full',
126                              'vims': 'vims',
127                              'doctor': 'doctor-notification',
128                              'promise': 'promise',
129                              'moon': 'moon',
130                              'copper': 'copper-notification',
131                              'security_scan': 'security',
132                              'multisite': 'multisite',
133                              'domino': 'domino-multinode',
134                              'odl-sfc': 'functest-odl-sfc',
135                              'onos_sfc': 'onos_sfc',
136                              'parser': 'parser-basics'
137                              }
138         try:
139             return test_match_matrix[self.name]
140         except:
141             return "unknown"
142
143     def getDisplayName(self):
144         return self.displayName