Generate partial tempest configuration during post-deploy

Partial-Bug: BZ #1249640
Change-Id: I56348e6421832dbfa79ff977bf2147eb246e7bbc
This commit is contained in:
Imre Farkas 2015-07-06 16:04:33 +02:00
parent 8802345544
commit a8c069c6e7
7 changed files with 74 additions and 205 deletions

View File

@ -39,6 +39,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_overcloudrc')
@ -71,6 +73,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_sleep, mock_setup_endpoints,
mock_create_overcloudrc,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_deploy_postconfig):
arglist = ['--templates', '--ceph-storage-scale', '3']
@ -170,8 +173,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
('/usr/share/openstack-tripleo-heat-templates/overcloud-without-'
'mergepy.yaml'))
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_overcloudrc')
@ -204,6 +211,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_sleep, mock_setup_endpoints,
mock_create_overcloudrc,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_deploy_postconfig):
arglist = ['--templates', '--ceph-storage-scale', '3']
@ -316,8 +324,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
('/usr/share/openstack-tripleo-heat-templates/overcloud-without-'
'mergepy.yaml'))
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_overcloudrc')
@ -349,6 +361,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_sleep, mock_setup_endpoints,
mock_create_overcloudrc,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_deploy_postconfig):
arglist = ['--templates', '/home/stack/tripleo-heat-templates']
@ -403,9 +416,13 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'/home/stack/tripleo-heat-templates/overcloud-without-mergepy.yaml'
)
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.utils.get_config_value', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('heatclient.common.template_utils.'
'process_multiple_environments_and_files')
@ -423,6 +440,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_get_templte_contents,
mock_process_multiple_env,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_get_key,
mock_deploy_postconfig):
@ -511,9 +529,13 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
240
)
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.utils.get_config_value', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('heatclient.common.template_utils.'
'process_multiple_environments_and_files')
@ -531,6 +553,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_get_templte_contents,
mock_process_multiple_env,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_get_key,
mock_deploy_postconfig):
@ -618,9 +641,13 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
240
)
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('rdomanager_oscplugin.utils.get_config_value', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.utils.generate_overcloud_passwords')
@mock.patch('heatclient.common.template_utils.'
'process_multiple_environments_and_files')
@ -639,6 +666,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_get_templte_contents,
mock_process_multiple_env,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_get_key,
mock_deploy_postconfig):
@ -739,6 +767,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.assertEqual(call_args, target)
self.assertEqual(management.plans.patch.call_count, 1)
mock_create_tempest_deployer_input.assert_called_with(self.cmd)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_tuskar', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
@ -790,6 +820,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.assertFalse(mock_deploy_tht.called)
self.assertFalse(mock_deploy_tuskar.called)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_tempest_deployer_input', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
'_create_overcloudrc', autospec=True)
@mock.patch('rdomanager_oscplugin.v1.overcloud_deploy.DeployOvercloud.'
@ -802,7 +834,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'_pre_heat_deploy', autospec=True)
def test_rhel_reg_params_provided(self, mock_pre_deploy, mock_deploy_tht,
mock_deploy_tuskar, mock_oc_endpoint,
mock_create_ocrc):
mock_create_ocrc,
mock_create_tempest_deployer_input):
arglist = ['--templates', '--rhel-reg',
'--reg-sat-url', 'https://example.com',
@ -823,3 +856,5 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
self.assertTrue(mock_oc_endpoint.called)
self.assertTrue(mock_create_ocrc.called)
self.assertFalse(mock_deploy_tuskar.called)
mock_create_tempest_deployer_input.assert_called_with(self.cmd)

View File

@ -1,30 +0,0 @@
# Copyright 2015 Red Hat, 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.
#
import mock
from openstackclient.tests import utils
class FakeClientWrapper(object):
pass
class TestOvercloudValidate(utils.TestCommand):
def setUp(self):
super(TestOvercloudValidate, self).setUp()
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
self.app.client_manager.rdomanager_oscplugin = FakeClientWrapper()

View File

@ -1,76 +0,0 @@
# Copyright 2015 Red Hat, 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.
#
import mock
from rdomanager_oscplugin.tests.v1.overcloud_validate import fakes
from rdomanager_oscplugin.v1 import overcloud_validate
class TestOvercloudValidate(fakes.TestOvercloudValidate):
def setUp(self):
super(TestOvercloudValidate, self).setUp()
# Get the command object to test
self.cmd = overcloud_validate.ValidateOvercloud(self.app, None)
self.cmd.tempest_run_dir = '/home/user/tempest'
@mock.patch('rdomanager_oscplugin.v1.overcloud_validate.ValidateOvercloud.'
'_setup_dir')
@mock.patch('os.chdir')
@mock.patch('rdomanager_oscplugin.utils.run_shell')
def test_validate_ok(self, mock_run_shell, mock_os_chdir, mock_setup_dir):
argslist = ['--overcloud-auth-url', 'http://foo',
'--overcloud-admin-password', 'password',
'--network-id', '42',
'--deployer-input', 'partial_config_file',
'--tempest-args', 'bar',
'--skipfile', 'skip']
verifylist = [
('overcloud_auth_url', 'http://foo'),
('overcloud_admin_password', 'password'),
('deployer_input', 'partial_config_file'),
('tempest_args', 'bar'),
('skipfile', 'skip')
]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.cmd.take_action(parsed_args)
mock_setup_dir.assert_called_once_with()
mock_os_chdir.assert_called_with('/home/user/tempest')
mock_run_shell.assert_has_calls([
mock.call('/usr/share/openstack-tempest-kilo/tools/'
'configure-tempest-directory'),
mock.call('./tools/config_tempest.py --out etc/tempest.conf '
'--network-id 42 '
'--deployer-input partial_config_file '
'--debug --create '
'compute.allow_tenant_isolation true '
'compute.build_timeout 500 '
'compute.image_ssh_user cirros '
'compute.ssh_user cirros '
'identity.admin_password password '
'identity.uri http://foo '
'network.build_timeout 500 '
'network.tenant_network_cidr 192.168.0.0/24 '
'object-storage.operator_role swiftoperator '
'orchestration.stack_owner_role heat_stack_user '
'scenario.ssh_user cirros '
'volume.build_timeout 500'),
mock.call('./tools/run-tests.sh bar --skip-file skip')
])

View File

@ -29,6 +29,7 @@ from openstackclient.i18n import _
from os_cloud_config import keystone
from os_cloud_config import keystone_pki
from os_cloud_config.utils import clients
from six.moves import configparser
from tuskarclient.common import utils as tuskarutils
from rdomanager_oscplugin import utils
@ -601,6 +602,42 @@ class DeployOvercloud(command.Command):
f.write("export %(key)s=%(value)s\n" %
{'key': key, 'value': value})
def _create_tempest_deployer_input(self):
config = configparser.ConfigParser()
config.add_section('compute-feature-enabled')
# Does the test environment support obtaining instance serial console
# output? (default: true)
# set in [nova.serial_console]->enabled
config.set('compute-feature-enabled', 'console_output', 'false')
config.add_section('object-storage')
# Role to add to users created for swift tests to enable creating
# containers (default: 'Member')
# keystone role-list returns this role
config.set('object-storage', 'operator_role', 'swiftoperator')
config.add_section('orchestration')
# Role required for users to be able to manage stacks
# (default: 'heat_stack_owner')
# keystone role-list returns this role
config.set('orchestration', 'stack_owner_role', 'heat_stack_user')
config.add_section('volume')
# Name of the backend1 (must be declared in cinder.conf)
# (default: 'BACKEND_1')
# set in [cinder]->enabled_backends
config.set('volume', 'backend1_name', 'tripleo_iscsi')
config.add_section('volume-feature-enabled')
# Update bootable status of a volume Not implemented on icehouse
# (default: false)
# python-cinderclient supports set-bootable
config.set('volume-feature-enabled', 'bootable', 'true')
with open('tempest-deployer-input.conf', 'w+') as config_file:
config.write(config_file)
def _deploy_postconfig(self, stack, parsed_args):
self.log.debug("_deploy_postconfig(%s)" % parsed_args)
@ -816,6 +853,7 @@ class DeployOvercloud(command.Command):
stack = self._get_stack(orchestration_client)
self._create_overcloudrc(stack, parsed_args)
self._create_tempest_deployer_input()
if stack_create:
self._deploy_postconfig(stack, parsed_args)

View File

@ -1,97 +0,0 @@
# Copyright 2015 Red Hat, 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.
#
import logging
import os
from cliff import command
from rdomanager_oscplugin import utils
class ValidateOvercloud(command.Command):
"""Validates the functionality of an overcloud using Tempest"""
auth_required = False
log = logging.getLogger(__name__ + ".ValidateOvercloud")
tempest_run_dir = os.path.join(os.path.expanduser("~"), "tempest")
def _setup_dir(self):
try:
os.stat(self.tempest_run_dir)
except OSError:
os.mkdir(self.tempest_run_dir)
def _run_tempest(self, overcloud_auth_url, overcloud_admin_password,
network_id, deployer_input, tempest_args, skipfile):
os.chdir(self.tempest_run_dir)
if not deployer_input:
deployer_input = '/dev/null'
utils.run_shell('/usr/share/openstack-tempest-kilo/tools/'
'configure-tempest-directory')
utils.run_shell('./tools/config_tempest.py --out etc/tempest.conf '
'--network-id %(network_id)s '
'--deployer-input %(partial_config_file)s '
'--debug --create '
'compute.allow_tenant_isolation true '
'compute.build_timeout 500 '
'compute.image_ssh_user cirros '
'compute.ssh_user cirros '
'identity.admin_password %(admin_password)s '
'identity.uri %(auth_url)s '
'network.build_timeout 500 '
'network.tenant_network_cidr 192.168.0.0/24 '
'object-storage.operator_role swiftoperator '
'orchestration.stack_owner_role heat_stack_user '
'scenario.ssh_user cirros '
'volume.build_timeout 500' %
{'network_id': network_id,
'partial_config_file': deployer_input,
'auth_url': overcloud_auth_url,
'admin_password': overcloud_admin_password})
args = ['./tools/run-tests.sh', ]
if tempest_args is not None:
args.append(tempest_args)
if skipfile is not None:
args.extend(['--skip-file', skipfile])
utils.run_shell(' '.join(args))
def get_parser(self, prog_name):
parser = super(ValidateOvercloud, self).get_parser(prog_name)
parser.add_argument('--overcloud-auth-url', required=True)
parser.add_argument('--overcloud-admin-password', required=True)
parser.add_argument('--network-id', required=True)
parser.add_argument('--deployer-input')
parser.add_argument('--tempest-args')
parser.add_argument('--skipfile')
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args)
self._setup_dir()
self._run_tempest(parsed_args.overcloud_auth_url,
parsed_args.overcloud_admin_password,
parsed_args.network_id,
parsed_args.deployer_input,
parsed_args.tempest_args,
parsed_args.skipfile)

View File

@ -68,5 +68,4 @@ openstack.rdomanager_oscplugin.v1 =
overcloud_image_upload = rdomanager_oscplugin.v1.overcloud_image:UploadOvercloudImage
overcloud_node_delete = rdomanager_oscplugin.v1.overcloud_node:DeleteNode
overcloud_update_stack = rdomanager_oscplugin.v1.overcloud_update:UpdateOvercloud
overcloud_validate = rdomanager_oscplugin.v1.overcloud_validate:ValidateOvercloud
undercloud_install = rdomanager_oscplugin.v1.undercloud:InstallPlugin