Merge "Add check for cinder in scenario tests"
This commit is contained in:
commit
92800c3ce7
|
@ -124,6 +124,7 @@ class BaseTestCase(base.BaseTestCase):
|
|||
self.cluster_id = self._create_cluster(cl_tmpl_id)
|
||||
self._poll_cluster_status_tracked(self.cluster_id)
|
||||
cluster = self.sahara.get_cluster(self.cluster_id, show_progress=True)
|
||||
self.check_cinder()
|
||||
if not getattr(cluster, "provision_progress", None):
|
||||
return
|
||||
self._check_event_logs(cluster)
|
||||
|
@ -302,6 +303,40 @@ class BaseTestCase(base.BaseTestCase):
|
|||
if body:
|
||||
self.sahara.scale_cluster(self.cluster_id, body)
|
||||
self._poll_cluster_status(self.cluster_id)
|
||||
self.check_cinder()
|
||||
|
||||
@track_result("Check cinder volumes")
|
||||
def check_cinder(self):
|
||||
if not self._get_node_list_with_volumes():
|
||||
print("All tests for Cinder were skipped")
|
||||
return
|
||||
for node_with_volumes in self._get_node_list_with_volumes():
|
||||
volume_count_on_node = int(self._run_command_on_node(
|
||||
node_with_volumes['node_ip'],
|
||||
'mount | grep %s | wc -l' %
|
||||
node_with_volumes['volume_mount_prefix']
|
||||
))
|
||||
self.assertEqual(
|
||||
node_with_volumes['volume_count'], volume_count_on_node,
|
||||
'Some volumes were not mounted to node.\n'
|
||||
'Expected count of mounted volumes to node is %s.\n'
|
||||
'Actual count of mounted volumes to node is %s.'
|
||||
% (node_with_volumes['volume_count'], volume_count_on_node)
|
||||
)
|
||||
|
||||
def _get_node_list_with_volumes(self):
|
||||
node_groups = self.sahara.get_cluster(self.cluster_id).node_groups
|
||||
node_list_with_volumes = []
|
||||
for node_group in node_groups:
|
||||
if node_group['volumes_per_node'] != 0:
|
||||
for instance in node_group['instances']:
|
||||
node_list_with_volumes.append({
|
||||
'node_ip': instance['management_ip'],
|
||||
'volume_count': node_group['volumes_per_node'],
|
||||
'volume_mount_prefix':
|
||||
node_group['volume_mount_prefix']
|
||||
})
|
||||
return node_list_with_volumes
|
||||
|
||||
@track_result("Create node group templates")
|
||||
def _create_node_group_templates(self):
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# 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.
|
||||
|
||||
|
||||
def check(self):
|
||||
self.check_cinder()
|
|
@ -332,6 +332,8 @@ class TestBase(testtools.TestCase):
|
|||
['id_for_job_binaries'],
|
||||
[]))
|
||||
|
||||
@mock.patch('sahara.tests.scenario.base.BaseTestCase.check_cinder',
|
||||
return_value=None)
|
||||
@mock.patch('sahara.tests.scenario.clients.SaharaClient.get_job_status',
|
||||
return_value='SUCCEEDED')
|
||||
@mock.patch('saharaclient.api.base.ResourceManager._get',
|
||||
|
@ -360,7 +362,7 @@ class TestBase(testtools.TestCase):
|
|||
mock_job_binaries, mock_job,
|
||||
mock_node_group_template, mock_cluster_template,
|
||||
mock_cluster, mock_cluster_status, mock_create,
|
||||
mock_get, mock_client):
|
||||
mock_get, mock_client, mock_cinder):
|
||||
self.base_scenario._init_clients()
|
||||
self.base_scenario.create_cluster()
|
||||
self.base_scenario.testcase["edp_jobs_flow"] = [
|
||||
|
@ -440,3 +442,27 @@ class TestBase(testtools.TestCase):
|
|||
])):
|
||||
self.assertEqual(
|
||||
[], self.base_scenario._get_nodes_with_process('test'))
|
||||
|
||||
@mock.patch('keystoneclient.session.Session')
|
||||
def test_get_node_list_with_volumes(self, mock_keystone):
|
||||
self.base_scenario._init_clients()
|
||||
with mock.patch(
|
||||
'sahara.tests.scenario.clients.SaharaClient.get_cluster',
|
||||
return_value=FakeResponse(node_groups=[
|
||||
{
|
||||
'node_processes': 'test',
|
||||
'volumes_per_node': 2,
|
||||
'volume_mount_prefix': 2,
|
||||
'instances': [
|
||||
{
|
||||
'management_ip': 'test_ip'
|
||||
}
|
||||
]
|
||||
}
|
||||
])):
|
||||
self.assertEqual(
|
||||
[{
|
||||
'node_ip': 'test_ip',
|
||||
'volume_count': 2,
|
||||
'volume_mount_prefix': 2
|
||||
}], self.base_scenario._get_node_list_with_volumes())
|
||||
|
|
Loading…
Reference in New Issue