Change testools to unittest2

This commit is contained in:
Tatyana Leontovich 2013-07-12 18:48:24 +03:00
parent 913cf2a131
commit 3494289e29
17 changed files with 124 additions and 153 deletions

View File

@ -184,12 +184,12 @@ ComputeGroup = [
default=[],
help="If false, skip config tests regardless of the "
"extension status"),
cfg.StrOpt('controller_node',
default='127.0.0.1',
help="IP address of one of the controller nodes"),
cfg.StrOpt('controller_node_name',
default='',
help="DNS name of one of the controller nodes"),
cfg.ListOpt('controller_node',
default= [],
help="IP address of one of the controller nodes"),
cfg.ListOpt('controller_node_name',
default= [],
help="DNS name of one of the controller nodes"),
cfg.StrOpt('controller_node_ssh_user',
default='ssh_user',
help="ssh user of one of the controller nodes"),

View File

@ -2,7 +2,7 @@
# This section contains configuration options that a variety of
# test clients use when authenticating with different user/tenant
# combinations
url = http://172.18.164.200/
url = http://172.18.198.75:8088/
# The type of endpoint for a Identity service. Unless you have a
# custom Keystone service catalog implementation, you probably want to leave
# this value as "identity"
@ -11,7 +11,7 @@ catalog_type = identity
# environments that have self-signed SSL certs.
disable_ssl_certificate_validation = False
# URL for where to find the OpenStack Identity API endpoint (Keystone)
uri = http://172.18.164.200:5000/v2.0
uri = http://172.18.198.75:8088/v2.0
# URL for where to find the OpenStack V3 Identity API endpoint (Keystone)
#uri_v3 = http://127.0.0.1:5000/v3/
# Should typically be left as keystone unless you have a non-Keystone
@ -27,13 +27,6 @@ password = admin
# The above non-administrative user's tenant name
tenant_name = admin
# This should be the username of an alternate user WITHOUT
# administrative privileges
alt_username = alt_demo
# The above non-administrative user's password
alt_password = nova
# The above non-administrative user's tenant name
alt_tenant_name = alt_demo
# This should be the username of a user WITH administrative privileges
admin_username = admin
@ -47,14 +40,14 @@ admin_tenant_name = admin
# against the OpenStack Compute API.
#One of the controller nodes
controller_node = 10.50.3.134
controller_node_name = controller-20.domain.tld.
controller_node = 10.60.0.135
controller_node_name = controller-7
#Controller node user who able connect via ssh
controller_node_ssh_user = root
#Controller node ssh user's password
controller_node_ssh_password =
controller_node_ssh_password = r00t
controller_node_ssh_key_path = ~/.ssh/id_rsa
#The list of the services should be enabled
@ -75,7 +68,6 @@ allow_tenant_reuse = true
# Reference data for tests. The ref and ref_alt should be
# distinct images/flavors.
image_name = TestVM
image_ref_alt = 53734a0d-60a8-4689-b7c8-3c14917a7197
flavor_ref = 1
flavor_ref_alt = 2
@ -109,7 +101,7 @@ network_for_ssh = private
ip_version_for_ssh = 4
# Number of seconds to wait to authenticate to an instance
ssh_timeout = 300
ssh_timeout = 220
# Number of seconds to wait for output from ssh channel
ssh_channel_timeout = 60
@ -191,13 +183,13 @@ tenant_network_mask_bits = 28
tenant_networks_reachable = true
# Id of the public network that provides external connectivity.
public_network_id = cdb94175-2002-449f-be41-6b8afce8de13
public_network_id =
# Id of a shared public router that provides external connectivity.
# A shared public router would commonly be used where IP namespaces
# were disabled. If namespaces are enabled, it would be preferable
# for each tenant to have their own router.
public_router_id = 2a6bf65b-01f7-4c91-840a-2b5f676e7016
public_router_id =
# Whether or not quantum is expected to be available
quantum_available = false
@ -260,7 +252,6 @@ allow_tenant_reuse = true
# Reference data for tests. The ref and ref_alt should be
# distinct images/flavors.
image_name = TestVM
image_ref_alt = 53734a0d-60a8-4689-b7c8-3c14917a7197
flavor_ref = 1
flavor_ref_alt = 2
@ -294,7 +285,7 @@ network_for_ssh = net04
ip_version_for_ssh = 4
# Number of seconds to wait to authenticate to an instance
ssh_timeout = 320
ssh_timeout = 220
# Number of seconds to wait for output from ssh channel
ssh_channel_timeout = 60

View File

@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import testtools
import unittest2
class FuelException(Exception):
@ -53,7 +53,7 @@ class InvalidConfiguration(FuelException):
class RestClientException(FuelException,
testtools.TestCase.failureException):
unittest2.TestCase.failureException):
pass

View File

@ -55,11 +55,11 @@ class OfficialClientManager(fuel_health.manager.Manager):
# identified user, so a new client needs to be created for
# each user that operations need to be performed for.
if not username:
username = self.config.identity.username
username = self.config.identity.admin_username
if not password:
password = self.config.identity.password
password = self.config.identity.admin_password
if not tenant_name:
tenant_name = self.config.identity.tenant_name
tenant_name = self.config.identity.admin_tenant_name
if None in (username, password, tenant_name):
msg = ("Missing required credentials for compute client. "
@ -92,11 +92,11 @@ class OfficialClientManager(fuel_health.manager.Manager):
def _get_volume_client(self, username=None, password=None,
tenant_name=None):
if not username:
username = self.config.identity.username
username = self.config.identity.admin_username
if not password:
password = self.config.identity.password
password = self.config.identity.admin_password
if not tenant_name:
tenant_name = self.config.identity.tenant_name
tenant_name = self.config.identity.admin_tenant_name
auth_url = self.config.identity.uri
return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
@ -223,9 +223,9 @@ class NovaNetworkScenarioTest(OfficialClientTest):
def setUpClass(cls):
super(NovaNetworkScenarioTest, cls).setUpClass()
cls.tenant_id = cls.manager._get_identity_client(
cls.config.identity.username,
cls.config.identity.password,
cls.config.identity.tenant_name).tenant_id
cls.config.identity.admin_username,
cls.config.identity.admin_password,
cls.config.identity.admin_tenant_name).tenant_id
cls.network = []
cls.floating_ips = []

View File

@ -17,12 +17,9 @@
import time
import signal
import traceback
import nose.plugins.attrib
import testresources
import testtools
import unittest2
from fuel_health import config
from fuel_health import manager
@ -33,74 +30,7 @@ from fuel_health.common.test_mixins import FuelTestAssertMixin
LOG = logging.getLogger(__name__)
class TimeOutError(Exception):
def __init__(self):
Exception.__init__(self)
def _raise_TimeOut(sig, stack):
raise TimeOutError()
class ExecutionTimeout(object):
"""
Timeout context that will stop code running within context
if timeout (sec) is reached
>>with timeout(2):
... requests.get("http://msdn.com")
"""
def __init__(self, timeout):
self.timeout = timeout
def __enter__(self):
signal.signal(signal.SIGALRM, _raise_TimeOut)
signal.alarm(self.timeout)
def __exit__(self, exc_type, exc_val, exc_tb):
signal.alarm(0) # disable the alarm
if exc_type is not TimeOutError:
return False # never swallow other exceptions
else:
call_that_caused_timeout = traceback.extract_tb(exc_tb)[0][-1]
msg = '''
{call} terminated with the timeout of {timeout} seconds.
Please check that this service timeout meets your expectation.
'''.format(call=call_that_caused_timeout, timeout=self.timeout)
raise AssertionError(msg)
def attr(*args, **kwargs):
"""A decorator which applies the nose and testtools attr decorator
This decorator applies the nose attr decorator as well as the
the testtools.testcase.attr if it is in the list of attributes
to testtools we want to apply.
"""
def decorator(f):
if 'type' in kwargs and isinstance(kwargs['type'], str):
f = testtools.testcase.attr(kwargs['type'])(f)
if kwargs['type'] == 'smoke':
f = testtools.testcase.attr('smoke')(f)
elif 'type' in kwargs and isinstance(kwargs['type'], str):
f = testtools.testcase.attr(kwargs['type'])(f)
if kwargs['type'] == 'sanity':
f = testtools.testcase.attr('sanity')(f)
elif 'type' in kwargs and isinstance(kwargs['type'], list):
for attr in kwargs['type']:
f = testtools.testcase.attr(attr)(f)
if attr == 'sanity':
f = testtools.testcase.attr('sanity')(f)
elif attr == 'smoke':
f = testtools.testcase.attr('smoke')(f)
return nose.plugins.attrib.attr(*args, **kwargs)(f)
return decorator
class BaseTestCase(testtools.TestCase,
testtools.testcase.WithAttributes,
class BaseTestCase(unittest2.TestCase,
testresources.ResourcedTestCase,
FuelTestAssertMixin):

View File

@ -1,4 +1,6 @@
from fuel_health.test import attr
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.tests.sanity import base
@ -9,6 +11,7 @@ class SanityComputeTest(base.BaseComputeTest):
_interface = 'json'
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_instances(self):
"""Test checks that existing instances can be listed."""
resp, body = self.servers_client.list_servers()
@ -18,6 +21,7 @@ class SanityComputeTest(base.BaseComputeTest):
'Looks like something is broken in Nova.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_images(self):
"""Test checks that existing images can be listed."""
resp, body = self.images_client.list_images()
@ -27,6 +31,7 @@ class SanityComputeTest(base.BaseComputeTest):
'Looks like something is broken in Glance.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_volumes(self):
"""Test checks that existing volumes can be listed."""
resp, body = self.volumes_client.list_volumes()
@ -36,6 +41,7 @@ class SanityComputeTest(base.BaseComputeTest):
'Looks like something is broken in Swift.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_snapshots(self):
"""Test checks that existing snapshots can be listed."""
resp, body = self.snapshots_client.list_snapshots()
@ -45,6 +51,7 @@ class SanityComputeTest(base.BaseComputeTest):
'Looks like something is broken in Swift.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_flavors(self):
"""Test checks that existing flavors can be listed."""
resp, body = self.flavors_client.list_flavors()
@ -54,6 +61,7 @@ class SanityComputeTest(base.BaseComputeTest):
'Looks like something is broken in Nova.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_rate_limits(self):
"""Test checks that absolute limits can be listed."""
resp, body = self.limits_client.get_absolute_limits()

View File

@ -1,5 +1,7 @@
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.tests.sanity import base
from fuel_health.test import attr
class ServicesTestJSON(base.BaseIdentityAdminTest):
@ -10,6 +12,7 @@ class ServicesTestJSON(base.BaseIdentityAdminTest):
_interface = 'json'
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_services(self):
"""Test checks that active services can be listed."""
resp, body = self.client.list_services()
@ -19,6 +22,7 @@ class ServicesTestJSON(base.BaseIdentityAdminTest):
u'Looks like something is broken in Nova.')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_users(self):
"""Test checks that existing users can be listed."""
resp, body = self.client.get_users()

View File

@ -1,7 +1,8 @@
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.common.ssh import Client as SSHClient
from fuel_health.exceptions import SSHExecCommandFailed
from fuel_health.test import attr
from fuel_health.test import ExecutionTimeout
from fuel_health.tests.sanity import base
@ -29,37 +30,55 @@ class SanityInfrastructureTest(base.BaseComputeAdminTest):
cls.pwd = cls.config.compute.controller_node_ssh_password
cls.key = cls.config.compute.controller_node_ssh_key_path
cls.hostname = cls.config.compute.controller_node_name
cls.timeout = cls.config.compute.ssh_timeout
@classmethod
def tearDownClass(cls):
pass
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_services_state(self):
"""Test all of the expected services are on."""
output_msg = ''
try:
output = SSHClient(self.host, self.usr, self.pwd,
pkey=self.key).exec_command('nova-manage '
'service list')
except SSHExecCommandFailed:
output_msg = "Error: 'nova-manage' command execution failed."
cmd = 'nova-manage service list'
if len(self.hostname) and len(self.host):
output_msg = output_msg or ('Some service has not been started:' +
str(self.list_of_expected_services))
self.assertFalse(u'XXX' in output, output_msg)
self.assertTrue(len(self.list_of_expected_services) <=
output.count(u':-)'),
output_msg)
try:
output = SSHClient(self.host[0],
self.usr, self.pwd,
pkey=self.key,
timeout=self.timeout).exec_command(cmd)
except SSHExecCommandFailed:
output_msg = "Error: 'nova-manage' command execution failed."
output_msg = output_msg or (
'Some service has not been started:' + str(
self.list_of_expected_services))
self.assertFalse(u'XXX' in output, output_msg)
self.assertTrue(len(self.list_of_expected_services) <=
output.count(u':-)'),
output_msg)
else:
self.fail('Wrong tests configurations, one from the next '
'parameters are empty controller_node_name or '
'controller_node_ip ')
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_dns_state(self):
"""Test dns is available."""
expected_output = "in-addr.arpa domain name pointer " + self.hostname
try:
output = SSHClient(self.host, self.usr, self.pwd,
pkey=self.key).exec_command("host " + self.host)
except SSHExecCommandFailed:
output = "'host' command failed."
self.assertTrue(expected_output in output,
'DNS name cannot be resolved')
if len(self.hostname) and len(self.host):
expected_output = "in-addr.arpa domain name pointer"
cmd = "host " + self.host[0]
try:
output = SSHClient(self.host[0], self.usr, self.pwd,
pkey=self.key, timeout=self.timeout).exec_command(cmd)
except SSHExecCommandFailed:
output = "'host' command failed."
self.assertTrue(expected_output in output,
'DNS name cannot be resolved')
else:
self.fail('Wrong tests configurations, one from the next '
'parameters are empty controller_node_name or '
'controller_node_ip ')

View File

@ -1,4 +1,6 @@
from fuel_health.test import attr
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.tests.sanity import base
@ -8,6 +10,7 @@ class NetworksTest(base.BaseNetworkTest):
"""
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_networks(self):
"""Test checks that available networks can be listed."""
resp, body = self.client.list_networks()
@ -18,6 +21,7 @@ class NetworksTest(base.BaseNetworkTest):
"(Neutron or Nova).")
@attr(type=['sanity', 'fuel'])
@timed(5.5)
def test_list_ports(self):
"""Test checks that existing ports can be listed."""
resp, body = self.client.list_ports()

View File

@ -154,7 +154,7 @@ class BaseComputeAdminTest(BaseComputeTest):
cls.client = cls.os_adm.flavors_client
cls.user_client = cls.os.flavors_client
new_flavor_id = rand_int_id(start=1000)
name = 'ost1_test-flavor' + cls.__name__
name = rand_name('ost1_test-flavor' + cls.__name__)
f_params = {'name': name,
'ram': 256,

View File

@ -1,5 +1,6 @@
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.test import attr
from fuel_health.tests.smoke import base
@ -12,16 +13,16 @@ class FlavorsAdminTest(base.BaseComputeAdminTest):
_interface = 'json'
@attr(type=["fuel", "smoke"])
@timed(10.9)
def test_create_flavor(self):
"""Test low requirements flavor can be created."""
resp, flavor = self.create_flavor(ram=255,
name='ost1_test-flavor-smoke-test',
disk=1)
self.verify_response_status(
resp.status, appl="Nova")
self.verify_response_body_value(
flavor['name'], u'ost1_test-flavor-smoke-test',
self.verify_response_body(
flavor['name'], u'ost1_test-flavor',
msg="Flavor name is not the same as requested.")
self.verify_response_body_value(
flavor['disk'], 1,

View File

@ -1,5 +1,7 @@
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.common.utils.data_utils import rand_name
from fuel_health.test import attr
from fuel_health.tests.smoke import base
class VolumesTest(base.BaseComputeTest):
@ -23,6 +25,7 @@ class VolumesTest(base.BaseComputeTest):
super(VolumesTest, cls).tearDownClass()
@attr(type=["fuel", "smoke"])
@timed(60.5)
def test_volume_create(self):
"""Test volume can be created, attached to an instance, detached and deleted."""
v_name = rand_name('ost1_test-test')

View File

@ -1,4 +1,7 @@
import logging
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.common.utils.data_utils import rand_name
from fuel_health import nmanager
@ -63,6 +66,8 @@ class TestImageAction(nmanager.OfficialClientTest):
msg="Looks like Glance service doesn`t work properly.")
return image_id
@attr(type=['sanity', 'fuel'])
@timed(130.9)
def test_snapshot(self):
"""Test instance can be booted and snapshoted from new image."""
# prepare for booting a instance

View File

@ -1,6 +1,8 @@
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.common.utils.data_utils import rand_name
from fuel_health import nmanager
from fuel_health.test import attr
class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
@ -21,7 +23,7 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
super(TestNovaNetwork, cls).check_preconditions()
cfg = cls.config.network
if not cfg.tenant_networks_reachable:
msg = 'Either tenant_networks_reachable must be "true.'
msg = 'Either tenant networks reachable must be "true.'
cls.enabled = False
raise cls.skipException(msg)
@ -30,9 +32,9 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
super(TestNovaNetwork, cls).setUpClass()
cls.check_preconditions()
cls.tenant_id = cls.manager._get_identity_client(
cls.config.identity.username,
cls.config.identity.password,
cls.config.identity.tenant_name).tenant_id
cls.config.identity.admin_username,
cls.config.identity.admin_password,
cls.config.identity.admin_tenant_name).tenant_id
cls.keypairs = {}
cls.security_groups = {}
@ -41,24 +43,21 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
cls.floating_ips = []
@attr(type=['fuel', 'smoke'])
@timed(20.5)
def test_001_create_keypairs(self):
""" Test verifies keypair creation """
self.keypairs[self.tenant_id] = self._create_keypair(
self.compute_client)
@attr(type=['fuel', 'smoke'])
@timed(20.5)
def test_002_create_security_groups(self):
"""Test verifies security group creation"""
self.security_groups[self.tenant_id] = self._create_security_group(
self.compute_client)
@attr(type=['fuel', 'smoke'])
def test_003_create_networks(self):
"""Test verifies network creation"""
networks = self._create_network()
self.network.append(networks)
@attr(type=['fuel', 'smoke'])
@timed(45.5)
def test_004_check_networks(self):
"""Test verifies created network"""
seen_nets = self._list_networks()
@ -71,10 +70,11 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
'properly'))
self.verify_response_body(seen_ids,
mynet.id,
('Network does is created'
('Network is not created'
' properly '))
@attr(type=['fuel', 'smoke'])
@timed(60.7)
def test_005_create_servers(self):
"""
Test verifies instance creation
@ -94,7 +94,6 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
self.fail("Necessary resources for booting instance"
" has not been created")
#for i, network in enumerate(self.networks):
name = rand_name('ost1_test-server-smoke-')
keypair_name = self.keypairs[self.tenant_id].name
security_groups = [self.security_groups[self.tenant_id].name]
@ -104,6 +103,7 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
self.servers.append(server)
@attr(type=['fuel', 'smoke'])
@timed(45.9)
def test_006_check_tenant_network_connectivity(self):
"""
Test verifies created network connectivity
@ -146,7 +146,9 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
private_key)
@attr(type=['fuel', 'smoke'])
@timed(49.9)
def test_007_assign_floating_ips(self):
"""
Test verifies assignment of floating ip to created instance
"""
@ -181,6 +183,7 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
self.floating_ips.append(floating_ip)
@attr(type=['fuel', 'smoke'])
@timed(49.9)
def test_008_check_public_network_connectivity(self):
"""
Test verifies network connectivity trough floating ip

View File

@ -1,7 +1,8 @@
import requests
from nose.plugins.attrib import attr
from nose.tools import timed
from fuel_health.common.utils import data_utils
from fuel_health.test import attr
from fuel_health.tests.smoke import base
@ -23,6 +24,7 @@ class TestUserTenantRole(base.BaseIdentityAdminTest):
alt_role = data_utils.rand_name('ost1_test-role_')
@attr(type=["fuel", "smoke"])
@timed(30.9)
def test_create_user(self):
""" Test verifies user creation and auth in Horizon """
# Create a tenant:

View File

@ -29,6 +29,6 @@ setuptools-git==1.0
simplejson==3.3.0
six==1.3.0
testresources==0.2.7
testtools==0.9.32
warlock==1.0.1
wsgiref==0.1.2
unittest2==0.5.1

View File

@ -31,6 +31,7 @@ requirements = ['argparse==1.2.1',
'requests==1.2.3',
'setuptools-git==1.0',
'simplejson==3.3.0',
'unittest2',
'six==1.3.0',
'testresources==0.2.7',
'testtools==0.9.32',