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
7 # http://www.apache.org/licenses/LICENSE-2.0
12 class TestCase(object):
14 def __init__(self, name, project, constraints,
15 criteria=-1, isRunnable=True, tier=-1):
17 self.project = project
18 self.constraints = constraints
19 self.criteria = criteria
20 self.isRunnable = isRunnable
22 display_name_matrix = {'healthcheck': 'healthcheck',
23 'vping_ssh': 'vPing (ssh)',
24 'vping_userdata': 'vPing (userdata)',
28 'tempest_smoke_serial': 'Tempest (smoke)',
29 'tempest_full_parallel': 'Tempest (full)',
30 'tempest_defcore': 'Tempest (Defcore)',
31 'rally_sanity': 'Rally (smoke)',
33 'rally_full': 'Rally (full)',
39 'security_scan': 'Security',
40 'multisite': 'Multisite',
45 'connection_check': 'Health (connection)',
46 'api_check': 'Health (api)',
47 'snaps_smoke': 'SNAPS',
48 'snaps_health_check': 'Health (dhcp)',
49 'netready': 'Netready',
50 'barometer': 'Barometer'}
52 self.displayName = display_name_matrix[self.name]
54 self.displayName = "unknown"
62 def getConstraints(self):
63 return self.constraints
65 def getCriteria(self):
71 def setCriteria(self, criteria):
72 self.criteria = criteria
74 def setIsRunnable(self, isRunnable):
75 self.isRunnable = isRunnable
77 def checkRunnable(self, installer, scenario, config):
78 # Re-use Functest declaration
79 # Retrieve Functest configuration file functest_config.yaml
82 # print " *********************** "
84 # print " ---------------------- "
85 # print "case = " + self.name
86 # print "installer = " + installer
87 # print "scenario = " + scenario
88 # print "project = " + self.project
90 # Retrieve test constraints
91 # Retrieve test execution param
92 test_execution_context = {"installer": installer,
95 # By default we assume that all the tests are always runnable...
96 # if test_env not empty => dependencies to be checked
97 if config_test is not None and len(config_test) > 0:
98 # possible criteria = ["installer", "scenario"]
99 # consider test criteria from config file
100 # compare towards CI env through CI en variable
101 for criteria in config_test:
102 if re.search(config_test[criteria],
103 test_execution_context[criteria]) is None:
104 # print "Test "+ test + " cannot be run on the environment"
107 self.isRunnable = is_runnable
110 testcase = ("Name=" + self.name + ";Criteria=" +
111 str(self.criteria) + ";Project=" + self.project +
112 ";Constraints=" + str(self.constraints) +
113 ";IsRunnable" + str(self.isRunnable))
117 # Correspondance name of the test case / name in the DB
118 # ideally we should modify the DB to avoid such interface....
119 # '<name in the config>':'<name in the DB>'
120 # I know it is uggly...
121 test_match_matrix = {'healthcheck': 'healthcheck',
122 'vping_ssh': 'vping_ssh',
123 'vping_userdata': 'vping_userdata',
127 'tempest_smoke_serial': 'tempest_smoke_serial',
128 'tempest_full_parallel': 'tempest_full_parallel',
129 'tempest_defcore': 'tempest_defcore',
130 'rally_sanity': 'rally_sanity',
132 'rally_full': 'rally_full',
134 'doctor': 'doctor-notification',
135 'promise': 'promise',
136 'moon': 'moon_authentication',
137 'copper': 'copper-notification',
138 'security_scan': 'security',
139 'multisite': 'multisite',
140 'domino': 'domino-multinode',
141 'odl-sfc': 'functest-odl-sfc',
142 'onos_sfc': 'onos_sfc',
143 'parser': 'parser-basics',
144 'connection_check': 'connection_check',
145 'api_check': 'api_check',
146 'snaps_smoke': 'snaps_smoke',
147 'snaps_health_check': 'snaps_health_check',
148 'netready': 'gluon_vping',
149 'barometer': 'barometercollectd'}
151 return test_match_matrix[self.name]
155 def getDisplayName(self):
156 return self.displayName