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
29 def getConstraints(self):
30 return self.constraints
32 def getCriteria(self):
38 def setCriteria(self, criteria):
39 self.criteria = criteria
41 def setIsRunnable(self, isRunnable):
42 self.isRunnable = isRunnable
44 def checkRunnable(self, installer, scenario, config):
45 # Re-use Functest declaration
46 # Retrieve Functest configuration file functest_config.yaml
49 # print " *********************** "
51 # print " ---------------------- "
52 # print "case = " + self.name
53 # print "installer = " + installer
54 # print "scenario = " + scenario
55 # print "project = " + self.project
57 # Retrieve test constraints
58 # Retrieve test execution param
59 test_execution_context = {"installer": installer,
62 # By default we assume that all the tests are always runnable...
63 # if test_env not empty => dependencies to be checked
64 if config_test is not None and len(config_test) > 0:
65 # possible criteria = ["installer", "scenario"]
66 # consider test criteria from config file
67 # compare towards CI env through CI en variable
68 for criteria in config_test:
69 if re.search(config_test[criteria],
70 test_execution_context[criteria]) is None:
71 # print "Test "+ test + " cannot be run on the environment"
74 self.isRunnable = is_runnable
77 testcase = ("Name=" + self.name + ";Criteria=" + str(self.criteria)
78 + ";Project=" + self.project + ";Constraints="
79 + str(self.constraints) + ";IsRunnable"
80 + str(self.isRunnable))
84 # Correspondance name of the test case / name in the DB
85 # ideally we should modify the DB to avoid such interface....
86 # '<name in the config>':'<name in the DB>'
87 # I know it is uggly...
88 test_match_matrix = {'healthcheck': 'healthcheck',
89 'vping_ssh': 'vping_ssh',
90 'vping_userdata': 'vping_userdata',
94 'tempest_smoke_serial': 'tempest_smoke_serial',
95 'tempest_full_parallel': 'tempest_full_parallel',
96 'rally_sanity': 'rally_sanity',
98 'rally_full': 'rally_full',
100 'doctor': 'doctor-notification',
104 return test_match_matrix[self.name]
108 def getTestDisplayName(self):
109 # Correspondance name of the test case / name in the DB
110 test_match_matrix = {'healthcheck': 'healthcheck',
111 'vping_ssh': 'vPing (ssh)',
112 'vping_userdata': 'vPing (userdata)',
116 'tempest_smoke_serial': 'Tempest (smoke)',
117 'tempest_full_parallel': 'Tempest (full)',
118 'rally_sanity': 'Rally (smoke)',
120 'rally_full': 'Rally (full)',
126 return test_match_matrix[self.name]