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',
45 self.displayName = display_name_matrix[self.name]
47 self.displayName = "unknown"
55 def getConstraints(self):
56 return self.constraints
58 def getCriteria(self):
64 def setCriteria(self, criteria):
65 self.criteria = criteria
67 def setIsRunnable(self, isRunnable):
68 self.isRunnable = isRunnable
70 def checkRunnable(self, installer, scenario, config):
71 # Re-use Functest declaration
72 # Retrieve Functest configuration file functest_config.yaml
75 # print " *********************** "
77 # print " ---------------------- "
78 # print "case = " + self.name
79 # print "installer = " + installer
80 # print "scenario = " + scenario
81 # print "project = " + self.project
83 # Retrieve test constraints
84 # Retrieve test execution param
85 test_execution_context = {"installer": installer,
88 # By default we assume that all the tests are always runnable...
89 # if test_env not empty => dependencies to be checked
90 if config_test is not None and len(config_test) > 0:
91 # possible criteria = ["installer", "scenario"]
92 # consider test criteria from config file
93 # compare towards CI env through CI en variable
94 for criteria in config_test:
95 if re.search(config_test[criteria],
96 test_execution_context[criteria]) is None:
97 # print "Test "+ test + " cannot be run on the environment"
100 self.isRunnable = is_runnable
103 testcase = ("Name=" + self.name + ";Criteria=" +
104 str(self.criteria) + ";Project=" + self.project +
105 ";Constraints=" + str(self.constraints) +
106 ";IsRunnable" + str(self.isRunnable))
110 # Correspondance name of the test case / name in the DB
111 # ideally we should modify the DB to avoid such interface....
112 # '<name in the config>':'<name in the DB>'
113 # I know it is uggly...
114 test_match_matrix = {'healthcheck': 'healthcheck',
115 'vping_ssh': 'vping_ssh',
116 'vping_userdata': 'vping_userdata',
120 'tempest_smoke_serial': 'tempest_smoke_serial',
121 'tempest_full_parallel': 'tempest_full_parallel',
122 'rally_sanity': 'rally_sanity',
124 'rally_full': 'rally_full',
126 'doctor': 'doctor-notification',
127 'promise': 'promise',
130 'security_scan': 'security',
131 'multisite': 'multisite',
132 'domino': 'domino-multinode',
133 'odl-sfc': 'odl-sfc',
134 'onos_sfc': 'onos_sfc'
137 return test_match_matrix[self.name]
141 def getDisplayName(self):
142 return self.displayName