Merge "Clean imports in code"

This commit is contained in:
Jenkins 2016-09-08 08:58:21 +00:00 committed by Gerrit Code Review
commit bf60400656
13 changed files with 85 additions and 84 deletions

View File

@ -17,7 +17,7 @@ import logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health import nmanager from fuel_health import nmanager
@ -43,8 +43,8 @@ class CloudValidationTest(nmanager.OfficialClientTest):
def _run_ssh_cmd(self, host, cmd): def _run_ssh_cmd(self, host, cmd):
"""Open SSH session with host and execute command.""" """Open SSH session with host and execute command."""
try: try:
sshclient = SSHClient(host, self.usr, self.pwd, sshclient = ssh.Client(host, self.usr, self.pwd,
key_filename=self.key, timeout=self.timeout) key_filename=self.key, timeout=self.timeout)
return sshclient.exec_longrun_command(cmd) return sshclient.exec_longrun_command(cmd)
except Exception: except Exception:
LOG.exception('Failure on ssh run cmd') LOG.exception('Failure on ssh run cmd')

View File

@ -18,7 +18,7 @@ import logging
from fuel_health import nmanager from fuel_health import nmanager
import fuel_health.test import fuel_health.test
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from ironicclient.common import utils from ironicclient.common import utils
from ironicclient import exc as ironic_exc from ironicclient import exc as ironic_exc
@ -83,9 +83,9 @@ class IronicTest(nmanager.SanityChecksTest):
def check_services(): def check_services():
succeed_count = 0 succeed_count = 0
for node in nodes: for node in nodes:
remote = SSHClient(node, self.usr, self.pwd, remote = ssh.Client(node, self.usr, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=self.timeout) timeout=self.timeout)
try: try:
output = remote.exec_command(cmd) output = remote.exec_command(cmd)
LOG.debug(output) LOG.debug(output)

View File

@ -71,7 +71,7 @@ import keystoneclient
import novaclient.client import novaclient.client
import novaclient.exceptions as nova_exc import novaclient.exceptions as nova_exc
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh as f_ssh
from fuel_health.common.utils.data_utils import rand_int_id from fuel_health.common.utils.data_utils import rand_int_id
from fuel_health.common.utils.data_utils import rand_name from fuel_health.common.utils.data_utils import rand_name
from fuel_health import exceptions from fuel_health import exceptions
@ -614,8 +614,9 @@ class NovaNetworkScenarioTest(OfficialClientTest):
'"online_controllers" parameter is empty.') '"online_controllers" parameter is empty.')
try: try:
sshclient = SSHClient(self.host[0], self.usr, self.pwd, sshclient = f_ssh.Client(self.host[0], self.usr, self.pwd,
key_filename=self.key, timeout=self.timeout) key_filename=self.key,
timeout=self.timeout)
return sshclient.exec_longrun_command(cmd) return sshclient.exec_longrun_command(cmd)
except Exception: except Exception:
LOG.exception() LOG.exception()
@ -828,10 +829,10 @@ class NovaNetworkScenarioTest(OfficialClientTest):
if self.host: if self.host:
try: try:
ssh = SSHClient(self.host[0], ssh = f_ssh.Client(self.host[0],
self.usr, self.pwd, self.usr, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=timeout) timeout=timeout)
except Exception: except Exception:
LOG.exception() LOG.exception()
@ -858,10 +859,10 @@ class NovaNetworkScenarioTest(OfficialClientTest):
try: try:
host = viaHost or self.host[0] host = viaHost or self.host[0]
LOG.debug('Get ssh to instance') LOG.debug('Get ssh to instance')
ssh = SSHClient(host, ssh = f_ssh.Client(host,
self.usr, self.pwd, self.usr, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=timeout) timeout=timeout)
except Exception: except Exception:
LOG.exception() LOG.exception()
@ -888,10 +889,10 @@ class NovaNetworkScenarioTest(OfficialClientTest):
try: try:
host = viaHost or self.host[0] host = viaHost or self.host[0]
LOG.debug('Get ssh to instance') LOG.debug('Get ssh to instance')
ssh = SSHClient(host, ssh = f_ssh.Client(host,
self.usr, self.pwd, self.usr, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=timeout) timeout=timeout)
LOG.debug('Host is {0}'.format(host)) LOG.debug('Host is {0}'.format(host))
except Exception: except Exception:

View File

@ -22,8 +22,8 @@ import testresources
import unittest2 import unittest2
from fuel_health.common import log as logging from fuel_health.common import log as logging
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health.common.test_mixins import FuelTestAssertMixin from fuel_health.common import test_mixins
from fuel_health import config from fuel_health import config
@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
class BaseTestCase(unittest2.TestCase, class BaseTestCase(unittest2.TestCase,
testresources.ResourcedTestCase, testresources.ResourcedTestCase,
FuelTestAssertMixin): test_mixins.FuelTestAssertMixin):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(BaseTestCase, self).__init__(*args, **kwargs) super(BaseTestCase, self).__init__(*args, **kwargs)
@ -137,8 +137,8 @@ class TestCase(BaseTestCase):
Fail if exit code != 0 Fail if exit code != 0
""" """
try: try:
sshclient = SSHClient(host, self.usr, self.pwd, sshclient = ssh.Client(host, self.usr, self.pwd,
key_filename=self.key, timeout=self.timeout) key_filename=self.key, timeout=self.timeout)
return sshclient.exec_command(cmd) return sshclient.exec_command(cmd)
except Exception: except Exception:
LOG.exception("Failed while opening ssh session with host") LOG.exception("Failed while opening ssh session with host")

View File

@ -15,10 +15,10 @@
import logging import logging
import paramiko.ssh_exception as exc import paramiko.ssh_exception as exc
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health import exceptions from fuel_health import exceptions
from fuel_health import nmanager from fuel_health import nmanager
from keystoneclient.exceptions import Unauthorized from keystoneclient import exceptions as k_exceptions
from keystoneclient.v2_0 import Client as keystoneclient from keystoneclient.v2_0 import Client as keystoneclient
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -52,10 +52,10 @@ class SanityConfigurationTest(nmanager.SanityChecksTest):
""" """
ip = self.config.nailgun_host ip = self.config.nailgun_host
ssh_client = SSHClient(ip, ssh_client = ssh.Client(ip,
self.config.master.master_node_ssh_user, self.config.master.master_node_ssh_user,
self.config.master.master_node_ssh_password, self.config.master.master_node_ssh_password,
timeout=self.config.master.ssh_timeout) timeout=self.config.master.ssh_timeout)
cmd = "date" cmd = "date"
output = [] output = []
try: try:
@ -122,7 +122,7 @@ class SanityConfigurationTest(nmanager.SanityChecksTest):
password=pwd, password=pwd,
auth_url=url) auth_url=url)
keystone.authenticate() keystone.authenticate()
except Unauthorized: except k_exceptions.Unauthorized:
pass pass
else: else:
self.fail('Step 1 failed: Default credentials ' self.fail('Step 1 failed: Default credentials '

View File

@ -14,7 +14,7 @@
import logging import logging
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health import test from fuel_health import test
@ -71,9 +71,9 @@ class HAProxyCheck(test.BaseTestCase):
""" """
LOG.info("Controllers nodes are %s" % self.controllers) LOG.info("Controllers nodes are %s" % self.controllers)
for controller in self.controllers: for controller in self.controllers:
remote = SSHClient(controller, self.controller_user, remote = ssh.Client(controller, self.controller_user,
key_filename=self.controller_key, key_filename=self.controller_key,
timeout=100) timeout=100)
ignore_services = [] ignore_services = []
if 'neutron' not in self.config.network.network_provider: if 'neutron' not in self.config.network.network_provider:
ignore_services.append('nova-metadata-api') ignore_services.append('nova-metadata-api')

View File

@ -14,14 +14,14 @@
import logging import logging
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health.common.utils import data_utils from fuel_health.common.utils import data_utils
from fuel_health.tests.ha.test_mysql_status import BaseMysqlTest from fuel_health.tests.ha import test_mysql_status
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class TestMysqlReplication(BaseMysqlTest): class TestMysqlReplication(test_mysql_status.BaseMysqlTest):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestMysqlReplication, cls).setUpClass() super(TestMysqlReplication, cls).setUpClass()
@ -38,8 +38,8 @@ class TestMysqlReplication(BaseMysqlTest):
if cls.master_ip: if cls.master_ip:
try: try:
cmd = "mysql -h localhost -e 'DROP DATABASE %s'" % cls.database cmd = "mysql -h localhost -e 'DROP DATABASE %s'" % cls.database
SSHClient(cls.master_ip, cls.node_user, ssh.Client(cls.master_ip, cls.node_user,
key_filename=cls.node_key).exec_command(cmd) key_filename=cls.node_key).exec_command(cmd)
except Exception: except Exception:
LOG.exception("Failed to connect to mysql cmd:{0}".format(cmd)) LOG.exception("Failed to connect to mysql cmd:{0}".format(cmd))
@ -76,7 +76,7 @@ class TestMysqlReplication(BaseMysqlTest):
# check that mysql is running on all hosts # check that mysql is running on all hosts
cmd = 'mysql -h localhost -e "" ' cmd = 'mysql -h localhost -e "" '
for db_node in databases: for db_node in databases:
ssh_client = SSHClient( ssh_client = ssh.Client(
db_node, self.node_user, db_node, self.node_user,
key_filename=self.node_key, timeout=100) key_filename=self.node_key, timeout=100)
self.verify( self.verify(
@ -122,9 +122,9 @@ class TestMysqlReplication(BaseMysqlTest):
# create db, table, insert data on one node # create db, table, insert data on one node
LOG.info('target node ip/hostname: "{0}" '.format(self.master_ip)) LOG.info('target node ip/hostname: "{0}" '.format(self.master_ip))
master_ssh_client = SSHClient(self.master_ip, self.node_user, master_ssh_client = ssh.Client(self.master_ip, self.node_user,
key_filename=self.node_key, key_filename=self.node_key,
timeout=100) timeout=100)
self.verify(20, master_ssh_client.exec_command, 2, self.verify(20, master_ssh_client.exec_command, 2,
'Database creation failed', 'create database', 'Database creation failed', 'create database',
@ -141,9 +141,9 @@ class TestMysqlReplication(BaseMysqlTest):
# Verify that data is replicated on other databases # Verify that data is replicated on other databases
for db_node in databases: for db_node in databases:
if db_node != self.master_ip: if db_node != self.master_ip:
client = SSHClient(db_node, client = ssh.Client(db_node,
self.node_user, self.node_user,
key_filename=self.node_key) key_filename=self.node_key)
output = self.verify( output = self.verify(
20, client.exec_command, 5, 20, client.exec_command, 5,
@ -155,8 +155,8 @@ class TestMysqlReplication(BaseMysqlTest):
failed_step='6') failed_step='6')
# Drop created db # Drop created db
ssh_client = SSHClient(self.master_ip, self.node_user, ssh_client = ssh.Client(self.master_ip, self.node_user,
key_filename=self.node_key) key_filename=self.node_key)
self.verify(20, ssh_client.exec_command, 7, self.verify(20, ssh_client.exec_command, 7,
'Can not delete created database', 'Can not delete created database',
'database deletion', drop_db) 'database deletion', drop_db)

View File

@ -15,13 +15,13 @@
from distutils import version from distutils import version
import logging import logging
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health.test import BaseTestCase from fuel_health import test
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class BaseMysqlTest(BaseTestCase): class BaseMysqlTest(test.BaseTestCase):
"""Base methods for MySQL DB tests """Base methods for MySQL DB tests
""" """
@classmethod @classmethod
@ -54,10 +54,10 @@ class BaseMysqlTest(BaseTestCase):
< version.StrictVersion('7.0'): < version.StrictVersion('7.0'):
return cls.config.compute.online_controllers return cls.config.compute.online_controllers
# retrieve data from controller # retrieve data from controller
ssh_client = SSHClient(controller_ip, ssh_client = ssh.Client(controller_ip,
username, username,
key_filename=key, key_filename=key,
timeout=100) timeout=100)
hiera_cmd = ('ruby -e \'require "hiera"; ' hiera_cmd = ('ruby -e \'require "hiera"; '
'db_h = Hiera.new().lookup("database_nodes", {}, {}); ' 'db_h = Hiera.new().lookup("database_nodes", {}, {}); '
@ -118,7 +118,7 @@ class TestMysqlStatus(BaseMysqlTest):
LOG.info('Current database node is %s' % node) LOG.info('Current database node is %s' % node)
cmd1 = cmd % {'database': database} cmd1 = cmd % {'database': database}
LOG.info('Try to execute command %s' % cmd1) LOG.info('Try to execute command %s' % cmd1)
tables = SSHClient( tables = ssh.Client(
node, self.node_user, node, self.node_user,
key_filename=self.node_key, key_filename=self.node_key,
timeout=self.config.compute.ssh_timeout) timeout=self.config.compute.ssh_timeout)
@ -181,9 +181,9 @@ class TestMysqlStatus(BaseMysqlTest):
for db_node in databases: for db_node in databases:
command = "mysql -h localhost -e \"SHOW STATUS LIKE 'wsrep_%'\"" command = "mysql -h localhost -e \"SHOW STATUS LIKE 'wsrep_%'\""
ssh_client = SSHClient(db_node, self.node_user, ssh_client = ssh.Client(db_node, self.node_user,
key_filename=self.node_key, key_filename=self.node_key,
timeout=100) timeout=100)
output = self.verify( output = self.verify(
20, ssh_client.exec_command, 2, 20, ssh_client.exec_command, 2,
"Verification of galera cluster node status failed", "Verification of galera cluster node status failed",

View File

@ -17,7 +17,7 @@
import logging import logging
import time import time
from fuel_health.common.ssh import Client as SSHClient from fuel_health.common import ssh
from fuel_health import nmanager from fuel_health import nmanager
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -108,11 +108,11 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
cmd = "ping -q -c1 -w10 8.8.8.8" cmd = "ping -q -c1 -w10 8.8.8.8"
ssh_client = SSHClient(self.computes[0], ssh_client = ssh.Client(self.computes[0],
self.usr, self.usr,
self.pwd, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=self.timeout) timeout=self.timeout)
self.verify(100, self.retry_command, 1, self.verify(100, self.retry_command, 1,
"'ping' command failed. Looks like there is no " "'ping' command failed. Looks like there is no "
"Internet connection on the compute node.", "Internet connection on the compute node.",
@ -137,11 +137,11 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
dns = self.fuel_dns.spit(',') if self.fuel_dns else ['8.8.8.8'] dns = self.fuel_dns.spit(',') if self.fuel_dns else ['8.8.8.8']
ssh_client = SSHClient(self.computes[0], ssh_client = ssh.Client(self.computes[0],
self.usr, self.usr,
self.pwd, self.pwd,
key_filename=self.key, key_filename=self.key,
timeout=self.timeout) timeout=self.timeout)
expected_output = "{0}.in-addr.arpa domain name pointer".format(dns[0]) expected_output = "{0}.in-addr.arpa domain name pointer".format(dns[0])
cmd = "host {0}".format(dns[0]) cmd = "host {0}".format(dns[0])

View File

@ -23,7 +23,7 @@ except ImportError:
from oslo_config import cfg from oslo_config import cfg
from fuel_plugin import consts from fuel_plugin import consts
from fuel_plugin.ostf_adapter.logger import ResultsLogger from fuel_plugin.ostf_adapter import logger
from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin from fuel_plugin.ostf_adapter.nose_plugin import nose_storage_plugin
from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner from fuel_plugin.ostf_adapter.nose_plugin import nose_test_runner
from fuel_plugin.ostf_adapter.nose_plugin import nose_utils from fuel_plugin.ostf_adapter.nose_plugin import nose_utils
@ -58,7 +58,7 @@ class NoseDriver(object):
else: else:
argv_add = [test_set.test_path] + test_set.additional_arguments argv_add = [test_set.test_path] + test_set.additional_arguments
results_log = ResultsLogger(test_set.id, test_run.cluster_id) results_log = logger.ResultsLogger(test_set.id, test_run.cluster_id)
lock_path = cfg.CONF.adapter.lock_dir lock_path = cfg.CONF.adapter.lock_dir
test_run.pid = nose_utils.run_proc(self._run_tests, test_run.pid = nose_utils.run_proc(self._run_tests,

View File

@ -20,7 +20,7 @@ import re
import traceback import traceback
from nose import case from nose import case
from nose.suite import ContextSuite from nose import suite
try: try:
from oslo.serialization import jsonutils from oslo.serialization import jsonutils
@ -169,7 +169,7 @@ def get_tests_to_update(test):
if isinstance(test, case.Test): if isinstance(test, case.Test):
tests.append(test) tests.append(test)
elif isinstance(test, ContextSuite): elif isinstance(test, suite.ContextSuite):
for sub_test in test._tests: for sub_test in test._tests:
tests.extend(get_tests_to_update(sub_test)) tests.extend(get_tests_to_update(sub_test))

View File

@ -15,7 +15,7 @@
import functools import functools
import unittest import unittest
from fuel_plugin.ostf_client.client import TestingAdapterClient from fuel_plugin.ostf_client import client
class EmptyResponseError(Exception): class EmptyResponseError(Exception):
@ -66,10 +66,10 @@ class Response(object):
class AdapterClientProxy(object): class AdapterClientProxy(object):
def __init__(self, url): def __init__(self, url):
self.client = TestingAdapterClient(url) self.client = client.TestingAdapterClient(url)
def __getattr__(self, item): def __getattr__(self, item):
if item in TestingAdapterClient.__dict__: if item in client.TestingAdapterClient.__dict__:
call = getattr(self.client, item) call = getattr(self.client, item)
return self._decorate_call(call) return self._decorate_call(call)

View File

@ -16,11 +16,11 @@
import mock import mock
from fuel_plugin.ostf_adapter.logger import ResultsLogger from fuel_plugin.ostf_adapter import logger
from fuel_plugin.testing.tests import base from fuel_plugin.testing.tests import base
@mock.patch.object(ResultsLogger, '_init_file_logger') @mock.patch.object(logger.ResultsLogger, '_init_file_logger')
class TestResultsLogger(base.BaseUnitTest): class TestResultsLogger(base.BaseUnitTest):
def get_logger(self, **kwargs): def get_logger(self, **kwargs):
@ -29,7 +29,7 @@ class TestResultsLogger(base.BaseUnitTest):
'cluster_id': 1, 'cluster_id': 1,
} }
options.update(kwargs) options.update(kwargs)
return ResultsLogger(**options) return logger.ResultsLogger(**options)
def test_filename(self, m_init_logger): def test_filename(self, m_init_logger):
logger = self.get_logger(testset='testset_name', logger = self.get_logger(testset='testset_name',