From 2c777079d93e23781c1100002074b7d759b6edc8 Mon Sep 17 00:00:00 2001 From: TatyanaLeontovich Date: Mon, 4 Nov 2013 16:09:08 +0200 Subject: [PATCH] Fix parsiong of network provider Patch include fixes: * Change uri for parsing network_provider * For create instance method add create_kargs parameter with specified network id * Fix pep8 issues Fixes bug/1247230 bug/1247082 Change-Id: I154dfec16ee54de33787766f03025840ff15783a --- fuel_health/common/test_mixins.py | 6 ++-- fuel_health/config.py | 4 +-- fuel_health/nmanager.py | 29 +++++++++++++++---- fuel_health/test.py | 10 +++---- .../tests/smoke/test_nova_image_actions.py | 16 +++++++++- .../nose_plugin/nose_discovery.py | 3 +- 6 files changed, 51 insertions(+), 17 deletions(-) diff --git a/fuel_health/common/test_mixins.py b/fuel_health/common/test_mixins.py index 16e508e4..044f07f6 100644 --- a/fuel_health/common/test_mixins.py +++ b/fuel_health/common/test_mixins.py @@ -157,9 +157,9 @@ class FuelTestAssertMixin(object): return if failed_step: failed_step_msg = ('Step %s failed: ' % str(failed_step)) - self.fail(''.join(failed_step_msg + - 'Actual value - {actual_content}'.format( - actual_content=act_content), '\n', msg)) + self.fail(''.join( + failed_step_msg + 'Actual value - {actual_content}'.format( + actual_content=act_content), '\n', msg)) def verify_response_true(self, resp, msg): if resp: diff --git a/fuel_health/config.py b/fuel_health/config.py index 0c27d7b5..1797b7e0 100644 --- a/fuel_health/config.py +++ b/fuel_health/config.py @@ -513,15 +513,15 @@ class NailgunConfig(object): response = self.req_session.get(self.nailgun_url + api_url) LOG.info('RESPONSE %s STATUS %s' % (api_url, response.status_code)) data = response.json() - network_provider = data.get('net_provider', 'nova_network') LOG.info('RESPONSE FROM %s - %s' % (api_url, data)) access_data = data['editable']['access'] self.identity.admin_tenant_name = access_data['tenant']['value'] self.identity.admin_username = access_data['user']['value'] self.identity.admin_password = access_data['password']['value'] - self.network.network_provider = network_provider api_url = '/api/clusters/%s' % self.cluster_id cluster_data = self.req_session.get(self.nailgun_url + api_url).json() + network_provider = cluster_data.get('net_provider', 'nova_network') + self.network.network_provider = network_provider deployment_os = cluster_data['release']['operating_system'] if deployment_os != 'RHEL': storage = data['editable']['storage']['volumes_ceph']['value'] diff --git a/fuel_health/nmanager.py b/fuel_health/nmanager.py index d7679a57..019de612 100644 --- a/fuel_health/nmanager.py +++ b/fuel_health/nmanager.py @@ -287,6 +287,7 @@ class NovaNetworkScenarioTest(OfficialClientTest): cls.floating_ips = [] cls.sec_group = [] cls.error_msg = [] + cls.private_net = 'net04' def _create_keypair(self, client, namestart='ost1_test-keypair-smoke-'): kp_name = rand_name(namestart) @@ -368,11 +369,18 @@ class NovaNetworkScenarioTest(OfficialClientTest): return nets def _create_server(self, client, name, security_groups): - base_image_id = get_image_from_name() - create_kwargs = { - 'security_groups': security_groups, - } self._create_nano_flavor() + base_image_id = get_image_from_name() + if 'neutron' in self.config.network.network_provider: + network = [net.id for net in + self.compute_client.networks.list() + if net.label == self.private_net] + + create_kwargs = {'nics': [{'net-id': network[0]}], + 'security_groups': security_groups} + else: + create_kwargs = {'security_groups': security_groups} + server = client.servers.create(name, base_image_id, 42, **create_kwargs) self.verify_response_body_content(server.name, @@ -623,6 +631,7 @@ class SmokeChecksTest(OfficialClientTest): cls.roles = [] cls.volumes = [] cls.error_msg = [] + cls.private_net = 'net04' def _create_flavors(self, client, ram, disk, vcpus=1): name = rand_name('ost1_test-flavor-') @@ -720,7 +729,17 @@ class SmokeChecksTest(OfficialClientTest): name = rand_name('ost1_test-volume-instance') base_image_id = get_image_from_name() flavor_id = self._create_nano_flavor().id - server = client.servers.create(name, base_image_id, flavor_id) + if 'neutron' in self.config.network.network_provider: + network = [net.id for net in + self.compute_client.networks.list() + if net.label == self.private_net] + + create_kwargs = {'nics': [{'net-id': network[0]}]} + server = client.servers.create( + name, base_image_id, flavor_id, **create_kwargs) + else: + server = client.servers.create(name, base_image_id, flavor_id) + self.set_resource(name, server) self.verify_response_body_content(server.name, name, diff --git a/fuel_health/test.py b/fuel_health/test.py index 119b4614..2ac85561 100644 --- a/fuel_health/test.py +++ b/fuel_health/test.py @@ -113,11 +113,11 @@ class TestCase(BaseTestCase): # that all implement a get() method taking an identifier # for the singular resource to retrieve. thing = things.get(thing_id) - new_status = thing.status - if new_status == 'ERROR': - self.fail("Failed to get to expected status." - "In ERROR state.") - elif new_status == expected_status: + new_status = thing.status.lower() + if new_status == 'error': + self.fail("Failed to get to expected status. " + "In error state.") + elif new_status == expected_status.lower(): return True # All good. LOG.debug("Waiting for %s to get to %s status. " "Currently in %s status", diff --git a/fuel_health/tests/smoke/test_nova_image_actions.py b/fuel_health/tests/smoke/test_nova_image_actions.py index 908151ae..e93237bd 100644 --- a/fuel_health/tests/smoke/test_nova_image_actions.py +++ b/fuel_health/tests/smoke/test_nova_image_actions.py @@ -71,7 +71,21 @@ class TestImageAction(nmanager.SmokeChecksTest): client = self.compute_client flavor_id = self._create_nano_flavor().id LOG.debug("name:%s, image:%s" % (name, image_id)) - server = client.servers.create(name=name, + if 'neutron' in self.config.network.network_provider: + network = [net.id for net in + self.compute_client.networks.list() + if net.label == self.private_net] + + create_kwargs = { + 'nics': [ + {'net-id': network[0]}, + ], + } + server = client.servers.create(name=name, + image=image_id, + flavor=flavor_id, **create_kwargs) + else: + server = client.servers.create(name=name, image=image_id, flavor=flavor_id) self.set_resource(name, server) diff --git a/fuel_plugin/ostf_adapter/nose_plugin/nose_discovery.py b/fuel_plugin/ostf_adapter/nose_plugin/nose_discovery.py index ece63ac4..0dc003f9 100644 --- a/fuel_plugin/ostf_adapter/nose_plugin/nose_discovery.py +++ b/fuel_plugin/ostf_adapter/nose_plugin/nose_discovery.py @@ -99,8 +99,9 @@ class DiscoveryPlugin(plugins.Plugin): #tests existing with such test_set_id and cluster_id #so we won't ended up with dublicating data upon tests #in db. + _cluster_id = self.test_sets[test_set_id].cluster_id tests = self.session.query(models.Test)\ - .filter_by(cluster_id=self.test_sets[test_set_id].cluster_id)\ + .filter_by(cluster_id=_cluster_id)\ .filter_by(test_set_id=test_set_id)\ .filter_by(test_run_id=None)\ .filter_by(name=data['name'])\