Run commands with --debug in tests
This is required for cliff to not mute exceptions. This patch also fixes all problems that were hidden by the bug. Closes-bug: #1604868 Change-Id: Id90d6bd6f62b7cb6ca48a0a4af64999d322f53b6
This commit is contained in:
parent
6a5a8fad74
commit
81d1905c00
|
@ -130,12 +130,12 @@ class OpenstackConfigUpload(OpenstackConfigMixin, base.BaseListCommand):
|
|||
return parser
|
||||
|
||||
def take_action(self, args):
|
||||
configs = self.client.upload(
|
||||
path=args.file, cluster_id=args.env,
|
||||
node_ids=args.node, node_role=args.role)
|
||||
configs = self.client.upload(path=args.file,
|
||||
cluster_id=args.env,
|
||||
node_ids=args.node,
|
||||
node_role=args.role)
|
||||
|
||||
data = [c.data for c in configs]
|
||||
data = data_utils.get_display_data_multi(self.columns, data)
|
||||
data = data_utils.get_display_data_multi(self.columns, configs)
|
||||
return self.columns, data
|
||||
|
||||
|
||||
|
@ -154,11 +154,14 @@ class OpenstackConfigExecute(OpenstackConfigMixin, base.BaseCommand):
|
|||
return parser
|
||||
|
||||
def take_action(self, args):
|
||||
self.client.execute(
|
||||
cluster_id=args.env, node_ids=args.node, node_role=args.role,
|
||||
force=args.force)
|
||||
task = self.client.execute(cluster_id=args.env,
|
||||
node_ids=args.node,
|
||||
node_role=args.role,
|
||||
force=args.force)
|
||||
|
||||
msg = ('Deployment of the OpenStack configuration was started within '
|
||||
'task with id {task_id}.\n').format(task_id=task['id'])
|
||||
|
||||
msg = "OpenStack configuration execution started.\n"
|
||||
self.app.stdout.write(msg)
|
||||
|
||||
|
||||
|
|
|
@ -252,6 +252,8 @@ class TestGraphActions(test_engine.BaseCLITest):
|
|||
)
|
||||
|
||||
def test_download(self):
|
||||
self.m_client.download.return_value = yaml.safe_load(TASKS_YAML)
|
||||
|
||||
self._test_cmd(
|
||||
'download',
|
||||
'--env 1 --all --file existing_graph.yaml --type custom_graph',
|
||||
|
|
|
@ -24,6 +24,7 @@ import fuelclient
|
|||
from fuelclient.commands import environment as env
|
||||
from fuelclient.commands import node as node
|
||||
from fuelclient import main as main_mod
|
||||
from fuelclient.tests import utils
|
||||
|
||||
|
||||
class BaseCLITest(oslo_base.BaseTestCase):
|
||||
|
@ -48,8 +49,11 @@ class BaseCLITest(oslo_base.BaseTestCase):
|
|||
|
||||
def exec_command(self, command=''):
|
||||
"""Executes fuelclient with the specified arguments."""
|
||||
argv = shlex.split(command)
|
||||
if '--debug' not in argv:
|
||||
argv = ['--debug'] + argv
|
||||
|
||||
return main_mod.main(argv=shlex.split(command))
|
||||
return main_mod.main(argv=argv)
|
||||
|
||||
def exec_command_interactive(self, commands):
|
||||
"""Executes specified commands in one sesstion of interactive mode
|
||||
|
@ -115,6 +119,8 @@ class BaseCLITest(oslo_base.BaseTestCase):
|
|||
def test_settings_override_called(self, m_update):
|
||||
cmd = ('--os-password tpass --os-username tname --os-tenant-name tten '
|
||||
'node list')
|
||||
self.m_client.get_all.return_value = [utils.get_fake_node()
|
||||
for _ in range(10)]
|
||||
|
||||
self.exec_command(cmd)
|
||||
|
||||
|
|
|
@ -177,16 +177,15 @@ node-4 ansible_host=10.20.0.5
|
|||
self.m_get_client.assert_called_once_with('node', mock.ANY)
|
||||
self.m_client.node_vms_create.assert_called_once_with(node_id, config)
|
||||
|
||||
@mock.patch('argparse.ArgumentParser.error')
|
||||
def test_node_vms_conf_create_fail(self, m_error):
|
||||
def test_node_vms_conf_create_fail(self):
|
||||
vms_conf = '[{"id": '
|
||||
node_id = 42
|
||||
|
||||
args = "node create-vms-conf {0} --conf '{1}'".format(
|
||||
node_id, vms_conf)
|
||||
self.exec_command(args)
|
||||
args, _ = m_error.call_args
|
||||
self.assertIn('--conf', args[0])
|
||||
args = "node create-vms-conf {0} --conf '{1}'".format(node_id,
|
||||
vms_conf)
|
||||
self.assertRaises(SystemExit,
|
||||
self.exec_command,
|
||||
args)
|
||||
|
||||
def test_node_set_hostname(self):
|
||||
self.m_client._updatable_attributes = \
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import mock
|
||||
|
||||
from fuelclient.tests.unit.v2.cli import test_engine
|
||||
from fuelclient.tests import utils
|
||||
|
||||
|
||||
class TestOpenstackConfig(test_engine.BaseCLITest):
|
||||
|
@ -61,7 +62,8 @@ class TestOpenstackConfig(test_engine.BaseCLITest):
|
|||
mocked_stderr.write.call_args_list[-1][0][0])
|
||||
|
||||
def test_config_upload(self):
|
||||
self.m_client.upload.return_value = 'config.yaml'
|
||||
self.m_client.upload.return_value = [utils.get_fake_openstack_config()
|
||||
for i in range(10)]
|
||||
|
||||
cmd = 'openstack-config upload --env {0} --node {1} --file ' \
|
||||
'config.yaml'.format(self.CLUSTER_ID, self.NODE_ID)
|
||||
|
@ -114,8 +116,14 @@ class TestOpenstackConfig(test_engine.BaseCLITest):
|
|||
node_role=None, force=False)
|
||||
|
||||
def test_config_force_execute(self):
|
||||
cmd = 'openstack-config execute --env {0} --node {1} --force' \
|
||||
''.format(self.CLUSTER_ID, self.NODE_ID)
|
||||
task_id = 42
|
||||
test_task = utils.get_fake_task(task_id=task_id)
|
||||
|
||||
self.m_client.execute.return_value = test_task
|
||||
|
||||
cmd = ('openstack-config execute --env {0}'
|
||||
' --node {1} --force ').format(self.CLUSTER_ID, self.NODE_ID)
|
||||
|
||||
self.exec_command(cmd)
|
||||
|
||||
self.m_get_client.assert_called_once_with('openstack-config', mock.ANY)
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
|
||||
def get_fake_task(task_id=None, status=None, name=None,
|
||||
cluster=None, result=None, progress=None):
|
||||
cluster=None, result=None, progress=None,
|
||||
message=None, uuid=None):
|
||||
"""Create a fake task
|
||||
|
||||
Returns the serialized and parametrized representation of a dumped Fuel
|
||||
|
@ -26,6 +27,8 @@ def get_fake_task(task_id=None, status=None, name=None,
|
|||
return {'status': status or 'running',
|
||||
'name': name or 'deploy',
|
||||
'id': task_id or 42,
|
||||
'uuid': uuid or '14474652-4f3e-4dc6-b2f3-5921b62b4a9e',
|
||||
'message': message or 'I am a human being!',
|
||||
'task_id': task_id or 42,
|
||||
'cluster': cluster or 34,
|
||||
'result': result or '',
|
||||
|
|
|
@ -22,9 +22,13 @@ class OpenstackConfigClient(base_v1.BaseV1Client):
|
|||
|
||||
def upload(self, path, cluster_id, node_ids=None, node_role=None):
|
||||
data = self._entity_wrapper.read_file(path)
|
||||
return self._entity_wrapper.create(
|
||||
cluster_id=cluster_id, configuration=data['configuration'],
|
||||
node_ids=node_ids, node_role=node_role)
|
||||
configuration = data['configuration']
|
||||
|
||||
config_obj = self._entity_wrapper.create(cluster_id=cluster_id,
|
||||
configuration=configuration,
|
||||
node_ids=node_ids,
|
||||
node_role=node_role)
|
||||
return [obj.data for obj in config_obj]
|
||||
|
||||
def download(self, config_id, path):
|
||||
config = self._entity_wrapper(config_id)
|
||||
|
@ -35,9 +39,13 @@ class OpenstackConfigClient(base_v1.BaseV1Client):
|
|||
|
||||
def execute(self, cluster_id, config_id=None, node_ids=None,
|
||||
node_role=None, force=False):
|
||||
return self._entity_wrapper.execute(
|
||||
cluster_id=cluster_id, config_id=config_id, node_ids=node_ids,
|
||||
node_role=node_role, force=force)
|
||||
task = self._entity_wrapper.execute(cluster_id=cluster_id,
|
||||
config_id=config_id,
|
||||
node_ids=node_ids,
|
||||
node_role=node_role,
|
||||
force=force)
|
||||
|
||||
return task.data
|
||||
|
||||
def get_filtered(self, cluster_id, node_ids=None,
|
||||
node_role=None, is_active=True):
|
||||
|
|
Loading…
Reference in New Issue