ha one controller tests: make unicode

Use repr in logwrap
make unicode strings ha one controller tests
get_cluster_block_devices -> make unicode output
  (method used 1 times in single test)

Change-Id: Ia72f57b6be13c66edfcb4512f99f01f11da20f13
Closes-bug: #1620330
(cherry picked from commit 5fb4f5d)
This commit is contained in:
Alexey Stepanov 2016-09-06 08:11:19 +03:00
parent 5c4bf0c2f9
commit dca635ef0a
4 changed files with 19 additions and 17 deletions

View File

@ -47,10 +47,10 @@ class TestLogWrap(unittest.TestCase):
logger.assert_has_calls((
call.debug(
"Calling: func with args: {} {}".format(
"Calling: 'func' with args: {!r} {!r}".format(
call_args, call_kwargs)),
call.debug(
"Done: func with result: {}".format(result))
"Done: 'func' with result: {!r}".format(result))
))
def test_negative(self, logger):
@ -66,10 +66,10 @@ class TestLogWrap(unittest.TestCase):
logger.assert_has_calls((
call.debug(
"Calling: func with args: {} {}".format(
"Calling: 'func' with args: {!r} {!r}".format(
call_args, call_kwargs)),
call.exception(
'func raised: ValueError({}, {})\n'.format(
"'func' raised: ValueError({}, {})\n".format(
call_args, call_kwargs))
))

View File

@ -24,17 +24,17 @@ def logwrap(func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
logger.debug(
"Calling: {} with args: {} {}".format(
"Calling: {!r} with args: {!r} {!r}".format(
func.__name__, args, kwargs
)
)
try:
result = func(*args, **kwargs)
logger.debug(
"Done: {} with result: {}".format(func.__name__, result))
"Done: {!r} with result: {!r}".format(func.__name__, result))
except BaseException as e:
logger.exception(
'{func} raised: {exc!r}\n'.format(func=func.__name__, exc=e))
'{func!r} raised: {exc!r}\n'.format(func=func.__name__, exc=e))
raise
return result
return wrapped

View File

@ -1067,8 +1067,7 @@ class FuelWebClient29(object):
def get_cluster_block_devices(self, node_name):
logger.info('Get %s node block devices (lsblk)', node_name)
with self.get_ssh_for_node(node_name) as remote:
ret = remote.check_call('/bin/lsblk')
return ''.join(ret['stdout'])
return remote.check_call('/bin/lsblk').stdout_str
@logwrap
def get_pacemaker_status(self, controller_node_name):

View File

@ -13,8 +13,10 @@
# under the License.
from __future__ import division
from warnings import warn
from __future__ import unicode_literals
import re
from warnings import warn
from proboscis.asserts import assert_equal
from proboscis.asserts import assert_true
@ -287,10 +289,12 @@ class HAOneControllerNeutron(HAOneControllerNeutronBase):
self.fuel_web.run_ostf(cluster_id=cluster_id)
_ip = self.fuel_web.get_nailgun_node_by_name("slave-03")['ip']
result = self.ssh_manager.execute_on_remote(cmd='hiera roles',
ip=_ip)['stdout_str']
assert_equal('[\"base-os\"]', result,
message="Role mismatch. Node slave-03 is not base-os")
result = self.ssh_manager.check_call(
command='hiera roles', ip=_ip).stdout_str
assert_equal(
'["base-os"]',
result,
message="Role mismatch. Node slave-03 is not base-os")
self.env.make_snapshot("deploy_base_os_node")
@ -453,8 +457,7 @@ class MultiroleMultipleServices(TestBasic):
"sed -i 's,http://archive.ubuntu.com/ubuntu,{0},g'" \
" /usr/share/fuel-mirror/ubuntu.yaml".format(
ubuntu_url)
self.ssh_manager.execute_on_remote(ip=admin_ip,
cmd=replace_cmd)
self.ssh_manager.check_call(ip=admin_ip, command=replace_cmd)
create_mirror_cmd = 'fuel-mirror create -P ubuntu -G mos ubuntu'
self.env.admin_actions.ensure_cmd(create_mirror_cmd)
@ -478,7 +481,7 @@ class MultiroleMultipleServices(TestBasic):
self.show_step(4)
apply_mirror_cmd = 'fuel-mirror apply -P ubuntu -G mos ubuntu ' \
'--env {0} --replace'.format(cluster_id)
self.ssh_manager.execute_on_remote(ip=admin_ip, cmd=apply_mirror_cmd)
self.ssh_manager.check_call(ip=admin_ip, command=apply_mirror_cmd)
self.fuel_web.update_nodes(
cluster_id,