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'
41 self.displayName = display_name_matrix[self.name]
43 self.displayName = "unknown"
51 def getConstraints(self):
52 return self.constraints
54 def getCriteria(self):
60 def setCriteria(self, criteria):
61 self.criteria = criteria
63 def setIsRunnable(self, isRunnable):
64 self.isRunnable = isRunnable
66 def checkRunnable(self, installer, scenario, config):
67 # Re-use Functest declaration
68 # Retrieve Functest configuration file functest_config.yaml
71 # print " *********************** "
73 # print " ---------------------- "
74 # print "case = " + self.name
75 # print "installer = " + installer
76 # print "scenario = " + scenario
77 # print "project = " + self.project
79 # Retrieve test constraints
80 # Retrieve test execution param
81 test_execution_context = {"installer": installer,
84 # By default we assume that all the tests are always runnable...
85 # if test_env not empty => dependencies to be checked
86 if config_test is not None and len(config_test) > 0:
87 # possible criteria = ["installer", "scenario"]
88 # consider test criteria from config file
89 # compare towards CI env through CI en variable
90 for criteria in config_test:
91 if re.search(config_test[criteria],
92 test_execution_context[criteria]) is None:
93 # print "Test "+ test + " cannot be run on the environment"
96 self.isRunnable = is_runnable
99 testcase = ("Name=" + self.name + ";Criteria=" +
100 str(self.criteria) + ";Project=" + self.project +
101 ";Constraints=" + str(self.constraints) +
102 ";IsRunnable" + str(self.isRunnable))
106 # Correspondance name of the test case / name in the DB
107 # ideally we should modify the DB to avoid such interface....
108 # '<name in the config>':'<name in the DB>'
109 # I know it is uggly...
110 test_match_matrix = {'healthcheck': 'healthcheck',
111 'vping_ssh': 'vping_ssh',
112 'vping_userdata': 'vping_userdata',
116 'tempest_smoke_serial': 'tempest_smoke_serial',
117 'tempest_full_parallel': 'tempest_full_parallel',
118 'rally_sanity': 'rally_sanity',
120 'rally_full': 'rally_full',
122 'doctor': 'doctor-notification',
123 'promise': 'promise',
126 'security_scan': 'security'
129 return test_match_matrix[self.name]
133 def getDisplayName(self):
134 return self.displayName