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 'rally_sanity': 'Rally (smoke)',
32 'rally_full': 'Rally (full)',
38 'security_scan': 'Security',
39 'multisite':'Multisite',
44 'connection_check':'Health (connection)',
45 'api_check':'Health (api)',
46 'snaps_smoke':'SNAPS' }
48 self.displayName = display_name_matrix[self.name]
50 self.displayName = "unknown"
58 def getConstraints(self):
59 return self.constraints
61 def getCriteria(self):
67 def setCriteria(self, criteria):
68 self.criteria = criteria
70 def setIsRunnable(self, isRunnable):
71 self.isRunnable = isRunnable
73 def checkRunnable(self, installer, scenario, config):
74 # Re-use Functest declaration
75 # Retrieve Functest configuration file functest_config.yaml
78 # print " *********************** "
80 # print " ---------------------- "
81 # print "case = " + self.name
82 # print "installer = " + installer
83 # print "scenario = " + scenario
84 # print "project = " + self.project
86 # Retrieve test constraints
87 # Retrieve test execution param
88 test_execution_context = {"installer": installer,
91 # By default we assume that all the tests are always runnable...
92 # if test_env not empty => dependencies to be checked
93 if config_test is not None and len(config_test) > 0:
94 # possible criteria = ["installer", "scenario"]
95 # consider test criteria from config file
96 # compare towards CI env through CI en variable
97 for criteria in config_test:
98 if re.search(config_test[criteria],
99 test_execution_context[criteria]) is None:
100 # print "Test "+ test + " cannot be run on the environment"
103 self.isRunnable = is_runnable
106 testcase = ("Name=" + self.name + ";Criteria=" +
107 str(self.criteria) + ";Project=" + self.project +
108 ";Constraints=" + str(self.constraints) +
109 ";IsRunnable" + str(self.isRunnable))
113 # Correspondance name of the test case / name in the DB
114 # ideally we should modify the DB to avoid such interface....
115 # '<name in the config>':'<name in the DB>'
116 # I know it is uggly...
117 test_match_matrix = {'healthcheck': 'healthcheck',
118 'vping_ssh': 'vping_ssh',
119 'vping_userdata': 'vping_userdata',
123 'tempest_smoke_serial': 'tempest_smoke_serial',
124 'tempest_full_parallel': 'tempest_full_parallel',
125 'rally_sanity': 'rally_sanity',
127 'rally_full': 'rally_full',
129 'doctor': 'doctor-notification',
130 'promise': 'promise',
131 'moon': 'moon_authentication',
132 'copper': 'copper-notification',
133 'security_scan': 'security',
134 'multisite':'multisite',
135 'domino':'domino-multinode',
136 'odl-sfc':'functest-odl-sfc',
137 'onos_sfc':'onos_sfc',
138 'parser':'parser-basics',
139 'connection_check':'connection_check',
140 'api_check':'api_check',
141 'snaps_smoke':'snaps_smoke'
144 return test_match_matrix[self.name]
148 def getDisplayName(self):
149 return self.displayName