Adding tests for running all endpoint and scenario tests

Change-Id: Id64d43ecb7a2dbb4f0fd108a9b14d4dc2fbc4cf5
This commit is contained in:
Anand Shanmugam 2016-04-26 15:32:41 -07:00
parent a2148dd3b9
commit 433cee2d64
5 changed files with 101 additions and 3 deletions

View File

@ -61,7 +61,7 @@ class Cpulse(base.APIBase):
links = wsme.wsattr([link.Link], readonly=True)
"""A list containing a self link and associated test links"""
result = wtypes.StringType(min_length=1, max_length=1024)
result = wtypes.StringType(min_length=1, max_length=4048)
"""Result of this test"""
testtype = wtypes.StringType(min_length=1, max_length=255)

View File

@ -0,0 +1,56 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from cloudpulse.common.plugin import discover
from cloudpulse.scenario import base
from oslo_config import cfg
cfg.CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token',
group='keystone_authtoken')
TESTS_OPTS = [
cfg.IntOpt('all_tests',
default=0,
help='Run all tests')
]
CONF = cfg.CONF
periodic_test_group = cfg.OptGroup(name='periodic_tests',
title='Periodic tests to be run')
CONF.register_group(periodic_test_group)
CONF.register_opts(TESTS_OPTS, periodic_test_group)
class all_scenario(base.Scenario):
@base.scenario(admin_only=False, operator=False)
def all_tests(self):
enabled_scenarios = cfg.CONF.scenario.enabled_scenarios
all_cases = []
result = 200
resultmsg = ''
discover.import_modules_from_package("cloudpulse.scenario.plugins")
for scenario_group in discover.itersubclasses(base.Scenario):
if scenario_group.__name__ in enabled_scenarios:
all_cases += [getattr(scenario_group(), method)
for method in dir(scenario_group)
if method.startswith("all")]
for func in all_cases:
try:
funres = func()
except Exception as e:
funres = [404, str(e)]
if funres[0] != 200:
resultmsg += ("%s\n\n" % (funres[1]))
result = 404
return (result, resultmsg)

View File

@ -37,7 +37,10 @@ TESTS_OPTS = [
help='The glance endpoint and interval'),
cfg.IntOpt('cinder_endpoint',
default=0,
help='The cinder endpoint and interval')
help='The cinder endpoint and interval'),
cfg.IntOpt('all_endpoint_tests',
default=0,
help='Run all endpoint tests in interval')
]
CONF = cfg.CONF
@ -101,3 +104,21 @@ class endpoint_scenario(base.Scenario):
creds = self._get_nova_v2_credentials()
cinder = CinderHealth(creds)
return cinder.cinder_list()
@base.scenario(admin_only=False, operator=False)
def all_endpoint_tests(self):
test_list = [func for func in dir(self) if base.Scenario.is_scenario(
self, func) if not func.startswith(
'__') if not func.startswith('all')]
result = 200
resultmsg = ''
for func in test_list:
funccall = getattr(self, func)
try:
funres = funccall()
except Exception as e:
funres = [404, str(e)]
if funres[0] != 200:
resultmsg += ("%s failed: %s\n\n" % (func, funres[1]))
result = 404
return (result, resultmsg)

View File

@ -47,7 +47,10 @@ PERIODIC_TESTS_OPTS = [
help='The ceph periodic check'),
cfg.IntOpt('docker_check',
default=0,
help='The docker periodic check')
help='The docker periodic check'),
cfg.IntOpt('all_operator_tests',
default=0,
help='Run all operator tests')
]
CONF = cfg.CONF
@ -192,3 +195,21 @@ class operator_scenario(base.Scenario):
else:
return (404, ("Ceph cluster Test Failed: %s" %
results['status_message']), [])
@base.scenario(admin_only=False, operator=True)
def all_operator_tests(self):
test_list = [func for func in dir(self) if base.Scenario.is_scenario(
self, func) if not func.startswith(
'__') if not func.startswith('all')]
result = 200
resultmsg = ""
for func in test_list:
funccall = getattr(self, func)
try:
funres = funccall()
except Exception as e:
funres = [404, str(e)]
if funres[0] != 200:
resultmsg += ("%s failed: %s\n" % (func, funres[1]))
result = 404
return (result, resultmsg)