Add skipp verification to setup

This commit is contained in:
Tatyana Leontovich 2013-08-02 13:06:55 +03:00
parent 2f19e84754
commit f5143abf11
6 changed files with 64 additions and 43 deletions

View File

@ -17,7 +17,6 @@
# under the License.
import logging
import subprocess
# Default client libs
import cinderclient.client
@ -25,8 +24,8 @@ import glanceclient.client
import keystoneclient.v2_0.client
import novaclient.client
#from fuel_health.common import ssh
import time
from fuel_health.common.ssh import Client as SSHClient
from fuel_health.exceptions import SSHExecCommandFailed
from fuel_health.common.utils.data_utils import rand_name
@ -180,9 +179,11 @@ class OfficialClientTest(fuel_health.test.TestCase):
@classmethod
def tearDownClass(cls):
cls.error_msg = []
try:
cls.compute_client.flavors.delete('42')
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
while cls.os_resources:
@ -198,6 +199,7 @@ class OfficialClientTest(fuel_health.test.TestCase):
# If the resource is already missing, mission accomplished.
if e.__class__.__name__ == 'NotFound':
continue
cls.error_msg.append(e)
LOG.debug(e)
def is_deletion_complete():
@ -212,6 +214,7 @@ class OfficialClientTest(fuel_health.test.TestCase):
# called 'NotFound' if retrieval fails.
if e.__class__.__name__ == 'NotFound':
return True
cls.error_msg.append(e)
LOG.debug(e)
return False
@ -244,6 +247,8 @@ class NovaNetworkScenarioTest(OfficialClientTest):
super(NovaNetworkScenarioTest, self).setUp()
if not self._enabled:
self.skip(reason='Nova Networking not available')
if not self.config.compute.compute_nodes:
self.skip(reason='There are not any compute nodes')
@classmethod
def setUpClass(cls):
@ -260,6 +265,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
cls.network = []
cls.floating_ips = []
cls.sec_group = []
cls.error_msg = []
def _create_keypair(self, client, namestart='ost1_test-keypair-smoke-'):
kp_name = rand_name(namestart)
@ -333,6 +339,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
for net in cls.network:
cls.compute_client.networks.delete(net)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -387,6 +394,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
try:
cls.compute_client.floating_ips.delete(ip)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -448,21 +456,7 @@ class NovaNetworkScenarioTest(OfficialClientTest):
# TODO Allow configuration of execution and sleep duration.
return fuel_health.test.call_until_true(ping, 40, 1)
# def ping():
# proc = subprocess.Popen(cmd,
# stdout=subprocess.PIPE,
# stderr=subprocess.PIPE)
# proc.wait()
# if proc.returncode == 0:
# return True
#
# def _is_reachable_via_ssh(self, ip_address, username, private_key,
# timeout=120):
# ssh_client = SSHClient(ip_address, username,
# pkey=private_key,
# timeout=timeout)
# return ssh_client.test_connection_auth()
def _check_vm_connectivity(self, ip_address):
self.assertTrue(self._ping_ip_address(ip_address),
"Timed out waiting for %s to become "
@ -475,11 +469,25 @@ class NovaNetworkScenarioTest(OfficialClientTest):
"reachable. Please, check Network "
"configuration" % ip_address)
@classmethod
def _verification_of_exceptions(cls):
if cls.error_msg:
for err in cls.error_msg:
if err.__class__.__name__ == 'InternalServerError':
raise cls.failureException('REST API of '
'OpenStack is inaccessible.'
' Please try again')
if err.__class__.__name__ == 'ClientException':
raise cls.failureException('REST API of '
'OpenStack is inaccessible.'
' Please try again')
@classmethod
def tearDownClass(cls):
super(NovaNetworkScenarioTest, cls).tearDownClass()
cls._clean_floating_is()
cls._clear_networks()
cls._verification_of_exceptions()
def get_image_from_name():
@ -584,6 +592,11 @@ class SmokeChecksTest(OfficialClientTest):
super(SmokeChecksTest, self).setUp()
if not self._enabled:
self.skip(reason='Nova Networking not available')
if not self.config.volume.cinder_node_exist:
self.skip(reason='There are not any cinder nodes')
if not self.config.compute.compute_nodes:
self.skip(reason='There are not any compute nodes')
@classmethod
def setUpClass(cls):
@ -601,6 +614,7 @@ class SmokeChecksTest(OfficialClientTest):
cls.users = []
cls.roles = []
cls.volumes = []
cls.error_msg = []
def _create_flavors(self, client, ram, disk, vcpus=1):
name = rand_name('ost1_test-flavor-')
@ -616,6 +630,7 @@ class SmokeChecksTest(OfficialClientTest):
try:
cls.compute_client.flavors.delete(flav)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -632,6 +647,7 @@ class SmokeChecksTest(OfficialClientTest):
try:
cls.identity_client.tenants.delete(ten)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -650,6 +666,7 @@ class SmokeChecksTest(OfficialClientTest):
try:
cls.identity_client.users.delete(user)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -666,6 +683,7 @@ class SmokeChecksTest(OfficialClientTest):
try:
cls.identity_client.roles.delete(role)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
@ -684,6 +702,7 @@ class SmokeChecksTest(OfficialClientTest):
try:
cls.volume_client.volumes.delete(v)
except Exception as exc:
cls.error_msg.append(exc)
LOG.debug(exc)
pass
else:
@ -721,6 +740,19 @@ class SmokeChecksTest(OfficialClientTest):
return True
return False
@classmethod
def _verification_of_exceptions(cls):
if cls.error_msg:
for err in cls.error_msg:
if err.__class__.__name__ == 'InternalServerError':
raise cls.failureException('REST API of '
'OpenStack is inaccessible.'
' Please try again')
if err.__class__.__name__ == 'ClientException':
raise cls.failureException('REST API of '
'OpenStack is inaccessible.'
' Please try again')
@classmethod
def tearDownClass(cls):
super(SmokeChecksTest, cls).tearDownClass()
@ -729,3 +761,4 @@ class SmokeChecksTest(OfficialClientTest):
cls._clean_users()
cls._clean_roles()
cls._clean_volumes()
cls._verification_of_exceptions()

View File

@ -86,6 +86,10 @@ class TestCase(BaseTestCase):
cls.resource_keys = {}
cls.os_resources = []
def setUp(self):
if not self.config.compute.compute_nodes:
self.skip(reason='There are not any compute nodes')
def set_resource(self, key, thing):
LOG.debug("Adding %r to shared resources of %s" %
(thing, self.__class__.__name__))

View File

@ -102,7 +102,6 @@ class SanityInfrastructureTest(nmanager.SanityChecksTest):
if self.computes:
expected_output = "0% packet loss"
cmd = "ping 8.8.8.8 -c 1 -w 1"
output = ''
try:
ssh_client = SSHClient(self.computes[0],
self.usr,

View File

@ -33,12 +33,6 @@ class VolumesTest(nmanager.SmokeChecksTest):
def tearDownClass(cls):
super(VolumesTest, cls).tearDownClass()
def setUp(self):
if not self.config.volume.cinder_node_exist:
self.fail('There are not any cinder nodes')
if not self.config.compute.compute_nodes:
self.fail('There are not any compute nodes')
def _wait_for_volume_status(self, volume, status):
self.status_timeout(self.volume_client.volumes, volume.id, status)
@ -67,7 +61,7 @@ class VolumesTest(nmanager.SmokeChecksTest):
msg_s1 = 'Volume was not created.'
#Create volume
volume = self.verify(20, self._create_volume, 1,
volume = self.verify(120, self._create_volume, 1,
msg_s1,
"volume creation",
self.volume_client)
@ -82,7 +76,7 @@ class VolumesTest(nmanager.SmokeChecksTest):
'Step 3 failed: ' + msg_s1)
# create instance
instance = self.verify(100, self._create_server, 4,
instance = self.verify(200, self._create_server, 4,
"Instance creation failed. ",
"server creation",
self.compute_client)
@ -93,12 +87,12 @@ class VolumesTest(nmanager.SmokeChecksTest):
instance, 'ACTIVE')
# Attach volume
self.verify(20, self._attach_volume_to_instance, 6,
self.verify(120, self._attach_volume_to_instance, 6,
'Volume couldn`t be attached.',
'volume attachment',
volume, instance.id)
self.verify(100, self._wait_for_volume_status, 7,
self.verify(180, self._wait_for_volume_status, 7,
'Attached volume can not '
'get expected state',
"volume becoming 'in-use'",
@ -119,7 +113,7 @@ class VolumesTest(nmanager.SmokeChecksTest):
"volume detachment",
self.volume_client, volume)
self.verify(100, self._wait_for_volume_status, 10,
self.verify(180, self._wait_for_volume_status, 10,
'Volume does not get "available"'
' status.',
"volume becoming 'available'",

View File

@ -25,7 +25,7 @@ from fuel_health import nmanager
LOG = logging.getLogger(__name__)
class TestImageAction(nmanager.OfficialClientTest):
class TestImageAction(nmanager.SmokeChecksTest):
"""
Test class verifies the following:
- verify image can be created;
@ -34,10 +34,6 @@ class TestImageAction(nmanager.OfficialClientTest):
- verify instance can be booted from snapshot.
"""
def setUp(self):
if not self.config.compute.compute_nodes:
self.fail('There are not any compute nodes')
def _wait_for_server_status(self, server, status):
self.status_timeout(self.compute_client.servers,
server.id,
@ -89,7 +85,7 @@ class TestImageAction(nmanager.OfficialClientTest):
@attr(type=['sanity', 'fuel'])
def test_snapshot(self):
"""Launching instance
"""Launching instance, snapshot it and launching from snapshot
Target component: Glance
Scenario:
@ -111,19 +107,18 @@ class TestImageAction(nmanager.OfficialClientTest):
nmanager.get_image_from_name())
# snapshot the instance
snapshot_image_id = self.verify(100, self._create_image, 3,
snapshot_image_id = self.verify(180, self._create_image, 3,
"Making snapshot of an"
" instance failed.",
'snapshotting an instance',
server)
self.verify(100, self.compute_client.servers.delete, 4,
self.verify(180, self.compute_client.servers.delete, 4,
"Instance deletion failed.",
'Instance deletion',
server)
self.verify(100, self._boot_image, 5,
self.verify(180, self._boot_image, 5,
"Booting instance from the snapshot failed.",
'booting instance from snapshot',
snapshot_image_id)

View File

@ -61,10 +61,6 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
cls.servers = []
cls.floating_ips = []
def setUp(self):
if not self.config.compute.compute_nodes:
self.fail('There are not any compute nodes')
@classmethod
def tearDownClass(cls):
super(TestNovaNetwork, cls).tearDownClass()
@ -136,7 +132,7 @@ class TestNovaNetwork(nmanager.NovaNetworkScenarioTest):
@attr(type=['fuel', 'smoke'])
def test_005_create_servers(self):
"""Instance creation
"""Launching instance
Target component: Nova
Scenario: