cloudify_ims reporting fixes
[releng.git] / utils / test / reporting / 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                                'tempest_defcore': 'Tempest (Defcore)',
31                                'refstack_defcore': 'Refstack',
32                                'rally_sanity': 'Rally (smoke)',
33                                'bgpvpn': 'bgpvpn',
34                                'rally_full': 'Rally (full)',
35                                'vims': 'vIMS',
36                                'doctor-notification': 'Doctor',
37                                'promise': 'Promise',
38                                'moon': 'Moon',
39                                'copper': 'Copper',
40                                'security_scan': 'Security',
41                                'multisite': 'Multisite',
42                                'domino-multinode': 'Domino',
43                                'functest-odl-sfc': 'SFC',
44                                'onos_sfc': 'SFC',
45                                'parser-basics': 'Parser',
46                                'connection_check': 'Health (connection)',
47                                'api_check': 'Health (api)',
48                                'snaps_smoke': 'SNAPS',
49                                'snaps_health_check': 'Health (dhcp)',
50                                'gluon_vping': 'Netready',
51                                'fds': 'FDS',
52                                'cloudify_ims': 'vIMS (Cloudify)',
53                                'orchestra_openims': 'OpenIMS (OpenBaton)',
54                                'orchestra_clearwaterims': 'vIMS (OpenBaton)',
55                                'opera_ims': 'vIMS (Open-O)',
56                                'vyos_vrouter': 'vyos (Cloudify)',
57                                'barometercollectd': 'Barometer',
58                                'odl_netvirt': 'Netvirt',
59                                'security_scan': 'Security'}
60         try:
61             self.displayName = display_name_matrix[self.name]
62         except:
63             self.displayName = "unknown"
64
65     def getName(self):
66         return self.name
67
68     def getProject(self):
69         return self.project
70
71     def getConstraints(self):
72         return self.constraints
73
74     def getCriteria(self):
75         return self.criteria
76
77     def getTier(self):
78         return self.tier
79
80     def setCriteria(self, criteria):
81         self.criteria = criteria
82
83     def setIsRunnable(self, isRunnable):
84         self.isRunnable = isRunnable
85
86     def checkRunnable(self, installer, scenario, config):
87         # Re-use Functest declaration
88         # Retrieve Functest configuration file functest_config.yaml
89         is_runnable = True
90         config_test = config
91         # print " *********************** "
92         # print TEST_ENV
93         # print " ---------------------- "
94         # print "case = " + self.name
95         # print "installer = " + installer
96         # print "scenario = " + scenario
97         # print "project = " + self.project
98
99         # Retrieve test constraints
100         # Retrieve test execution param
101         test_execution_context = {"installer": installer,
102                                   "scenario": scenario}
103
104         # By default we assume that all the tests are always runnable...
105         # if test_env not empty => dependencies to be checked
106         if config_test is not None and len(config_test) > 0:
107             # possible criteria = ["installer", "scenario"]
108             # consider test criteria from config file
109             # compare towards CI env through CI en variable
110             for criteria in config_test:
111                 if re.search(config_test[criteria],
112                              test_execution_context[criteria]) is None:
113                     # print "Test "+ test + " cannot be run on the environment"
114                     is_runnable = False
115         # print is_runnable
116         self.isRunnable = is_runnable
117
118     def toString(self):
119         testcase = ("Name=" + self.name + ";Criteria=" +
120                     str(self.criteria) + ";Project=" + self.project +
121                     ";Constraints=" + str(self.constraints) +
122                     ";IsRunnable" + str(self.isRunnable))
123         return testcase
124
125     def getDisplayName(self):
126         return self.displayName