Fix functional tests for USE_NEUTRON

If USE_NEUTRON is True, we should be using the NeutronFixture
and not starting the nova-network service or stubbing out
fake networks in the nova database.

This makes that change and fixes the fallout in busted tests.

Change-Id: I9b35ed7497db8bd1eb74f4bb89631aabbcfeec0d
This commit is contained in:
Matt Riedemann 2017-12-20 21:33:25 -05:00
parent 0c97889799
commit c5ea3fb41b
5 changed files with 11 additions and 14 deletions

View File

@ -112,7 +112,9 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios,
super(ApiSampleTestBaseV21, self)._setup_services()
self.useFixture(test.SampleNetworks(host=self.network.host))
if not self.USE_NEUTRON:
# self.network is only setup if USE_NEUTRON=False
self.useFixture(test.SampleNetworks(host=self.network.host))
fake_network.stub_compute_with_ips(self.stubs)
self.useFixture(fixtures.SpawnIsSynchronousFixture())
# this is used to generate sample docs

View File

@ -26,10 +26,9 @@ class MultinicSampleJsonTest(integrated_helpers.InstanceHelperMixin,
def setUp(self):
super(MultinicSampleJsonTest, self).setUp()
self.neutron = fixtures.NeutronFixture(self)
self.useFixture(self.neutron)
server = self._boot_a_server(
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
extra_params={'networks': [
{'port': fixtures.NeutronFixture.port_1['id']}]})
self.uuid = server['id']
def _boot_a_server(self, expected_status='ACTIVE', extra_params=None):
@ -46,7 +45,7 @@ class MultinicSampleJsonTest(integrated_helpers.InstanceHelperMixin,
return found_server
def _add_fixed_ip(self):
subs = {"networkId": 'e1882e38-38c2-4239-ade7-35d644cb963a'}
subs = {"networkId": fixtures.NeutronFixture.network_1['id']}
response = self._do_post('servers/%s/action' % (self.uuid),
'multinic-add-fixed-ip-req', subs)
self.assertEqual(202, response.status_code)

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from nova.tests import fixtures
from nova.tests.functional.api_sample_tests import test_servers
import nova.tests.functional.api_samples_test_base as astb
@ -86,8 +85,6 @@ class SecurityGroupsJsonTest(test_servers.ServersSampleBase):
USE_NEUTRON = True
def setUp(self):
self.neutron = fixtures.NeutronFixture(self)
self.useFixture(self.neutron)
super(SecurityGroupsJsonTest, self).setUp()
path = 'nova.network.security_group.neutron_driver.SecurityGroupAPI.'
self.stub_out(path + 'get', fake_get)

View File

@ -101,8 +101,11 @@ class _IntegratedTestBase(test.TestCase):
self.conductor = self.start_service('conductor')
self.consoleauth = self.start_service('consoleauth')
self.network = self.start_service('network',
manager=CONF.network_manager)
if self.USE_NEUTRON:
self.neutron = self.useFixture(nova_fixtures.NeutronFixture(self))
else:
self.network = self.start_service('network',
manager=CONF.network_manager)
self.scheduler = self._setup_scheduler_service()
self.compute = self._setup_compute_service()

View File

@ -109,10 +109,6 @@ class InterfaceFullstackWithNeutron(test_servers.ServersTestBase):
api_major_version = 'v2.1'
USE_NEUTRON = True
def setUp(self):
super(InterfaceFullstackWithNeutron, self).setUp()
self.useFixture(nova_fixtures.NeutronFixture(self))
def test_detach_interface_negative_invalid_state(self):
# Create server with network
image = self.api.get_images()[0]['id']