Merge "Make configurable timeouts in scenario tests"

This commit is contained in:
Jenkins 2015-05-11 21:37:48 +00:00 committed by Gerrit Code Review
commit 4a40660ec7
6 changed files with 101 additions and 31 deletions

View File

@ -99,29 +99,37 @@ Section "clusters"
This sections is an array-type.
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| Fields | Type | Required | Default | Value |
+=====================+=========+==========+===================================+=======================================+
| plugin_name | string | True | | name of plugin |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| plugin_version | string | True | | version of plugin |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| image | string | True | | name or id of image |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| node_group_templates| object | | | see `section "node_group_templates"`_ |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| cluster_template | object | | | see `section "cluster_template"`_ |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| cluster | object | | | see `section "cluster"`_ |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| scaling | object | | | see `section "scaling"`_ |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| scenario | array | | ['run_jobs', 'scale', 'run_jobs'] | "run_jobs", "scale", "transient" |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| edp_jobs_flow | string | | | name of edp job flow |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
| retain_resources | boolean | | False | |
+---------------------+---------+----------+-----------------------------------+---------------------------------------+
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| Fields | Type | Required | Default | Value |
+=============================+=========+==========+===================================+=======================================+
| plugin_name | string | True | | name of plugin |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| plugin_version | string | True | | version of plugin |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| image | string | True | | name or id of image |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| node_group_templates | object | | | see `section "node_group_templates"`_ |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| cluster_template | object | | | see `section "cluster_template"`_ |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| cluster | object | | | see `section "cluster"`_ |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| scaling | object | | | see `section "scaling"`_ |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| timeout_check_transient | integer | | 300 | timeout for checking transient |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| timeout_poll_jobs_status | integer | | 1800 | timeout for polling jobs state |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| timeout_delete_resource | integer | | 300 | timeout for delete resource |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| timeout_poll_cluster_status | integer | | 1800 | timeout for polling cluster state |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| scenario | array | | ['run_jobs', 'scale', 'run_jobs'] | "run_jobs", "scale", "transient" |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| edp_jobs_flow | string | | | name of edp job flow |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
| retain_resources | boolean | | False | |
+-----------------------------+---------+----------+-----------------------------------+---------------------------------------+
Section "node_group_templates"

View File

@ -31,6 +31,7 @@ from tempest_lib import base
from tempest_lib import exceptions as exc
from sahara.tests.scenario import clients
from sahara.tests.scenario import timeouts
from sahara.tests.scenario import utils
@ -82,6 +83,7 @@ class BaseTestCase(base.BaseTestCase):
def setUp(self):
super(BaseTestCase, self).setUp()
self._init_clients()
timeouts.Defaults.init_defaults(self.testcase)
self.plugin_opts = {
'plugin_name': self.testcase['plugin_name'],
'hadoop_version': self.testcase['plugin_version']
@ -118,8 +120,9 @@ class BaseTestCase(base.BaseTestCase):
@track_result("Check transient")
def check_transient(self):
# TODO(sreshetniak): make timeout configurable
with fixtures.Timeout(300, gentle=True):
with fixtures.Timeout(
timeouts.Defaults.instance.timeout_check_transient,
gentle=True):
while True:
if self.sahara.is_resource_deleted(
self.sahara.get_cluster_status, self.cluster_id):
@ -219,8 +222,9 @@ class BaseTestCase(base.BaseTestCase):
configs)
def _poll_jobs_status(self, exec_ids):
# TODO(sreshetniak): make timeout configurable
with fixtures.Timeout(1800, gentle=True):
with fixtures.Timeout(
timeouts.Defaults.instance.timeout_poll_jobs_status,
gentle=True):
success = False
while not success:
success = True
@ -395,8 +399,9 @@ class BaseTestCase(base.BaseTestCase):
self._poll_cluster_status(cluster_id)
def _poll_cluster_status(self, cluster_id):
# TODO(sreshetniak): make timeout configurable
with fixtures.Timeout(1800, gentle=True):
with fixtures.Timeout(
timeouts.Defaults.instance.timeout_poll_cluster_status,
gentle=True):
while True:
status = self.sahara.get_cluster_status(cluster_id)
if status == 'Active':

View File

@ -38,14 +38,17 @@ def get_session(auth_url=None, username=None, password=None,
project_domain_name='default')
return session.Session(auth=auth)
from sahara.tests.scenario import timeouts
class Client(object):
def is_resource_deleted(self, method, *args, **kwargs):
raise NotImplementedError
def delete_resource(self, method, *args, **kwargs):
# TODO(sreshetniak): make timeout configurable
with fixtures.Timeout(300, gentle=True):
with fixtures.Timeout(
timeouts.Defaults.instance.timeout_delete_resource,
gentle=True):
while True:
if self.is_resource_deleted(method, *args, **kwargs):
break

View File

@ -0,0 +1,32 @@
# Copyright (c) 2015 Mirantis Inc.
#
# 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.
class Defaults(object):
def __init__(self, config):
self.timeout_check_transient = config.get('timeout_check_transient',
300)
self.timeout_delete_resource = config.get('timeout_delete_resource',
300)
self.timeout_poll_cluster_status = config.get(
'timeout_poll_cluster_status', 1800)
self.timeout_poll_jobs_status = config.get('timeout_poll_jobs_status',
1800)
@classmethod
def init_defaults(cls, config):
if not hasattr(cls, 'instance'):
cls.instance = Defaults(config)
return cls.instance

View File

@ -206,6 +206,22 @@ SCHEMA = {
"required": ["name"],
"additionalProperties": False,
},
"timeout_check_transient": {
"type": "integer",
"minimum": 1
},
"timeout_delete_resource": {
"type": "integer",
"minimum": 1
},
"timeout_poll_cluster_status": {
"type": "integer",
"minimum": 1
},
"timeout_poll_jobs_status": {
"type": "integer",
"minimum": 1
},
"scaling": {
"type": "array",
"minItems": 1,

View File

@ -28,6 +28,7 @@ from tempest_lib import exceptions as exc
import testtools
from sahara.tests.scenario import base
from sahara.tests.scenario import timeouts
class FakeSaharaClient(object):
@ -103,6 +104,10 @@ class TestBase(testtools.TestCase):
'worker': 3
}
},
'timeout_poll_cluster_status': 300,
'timeout_delete_resource': 300,
'timeout_poll_jobs_status': 2,
'timeout_check_transient': 3,
'retain_resources': True,
'image': 'image_name',
"edp_jobs_flow":
@ -137,6 +142,7 @@ class TestBase(testtools.TestCase):
self.job = self.base_scenario.testcase["edp_jobs_flow"].get(
'test_flow')[0]
self.base_scenario.setUpClass()
timeouts.Defaults.init_defaults(self.base_scenario.testcase)
@mock.patch('keystoneclient.auth.identity.v3.Password')
@mock.patch('keystoneclient.session.Session')