Skip to content

Commit

Permalink
nova-net: Add TODOs for remaining nova-network functional tests
Browse files Browse the repository at this point in the history
These are for the few tests that can't be converted since they're for
nova-network. The following APIs have no neutron equivalent and
therefore can't be converted:

- POST /os-security-group-default-rules
    Raises 'HTTPNotImplemented' from the neutron security group driver
- GET /os-security-group-default-rules
    Raises 'HTTPNotImplemented' from the neutron security group driver
- GET /os-security-group-default-rules/{id}
    Raises 'HTTPNotImplemented' from the neutron security group driver
- POST /os-tenant-networks
    Raises 'NotImplemented' from the neutron network driver
- DELETE /os-tenant-networks/{id}
    Raises 'NotImplemented' from the neutron network driver
- POST /os-networks
    Raises 'NotImplemented' from the neutron network driver
- POST /os-networks/add
    Raises 'NotImplemented' from the neutron network driver
- POST /os-networks/{id}/action
    Raises 'NotImplemented' from the neutron network driver
- DELETE /os-networks/{id}
    Raises 'NotImplemented' from the neutron network driver

The following work but need to be converted separately. We'll do that
later when we remove the nova-network side of the APIs.

- GET /os-networks
- GET /os-networks/{id}
- GET /os-tenant-networks

Change-Id: Ide357a4e1479cacc8fcee80893dfbffb65ce8712
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Nov 18, 2019
1 parent 449a5e7 commit 1dac054
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions nova/tests/functional/api_sample_tests/api_sample_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def setUp(self):

super(ApiSampleTestBaseV21, self)._setup_services()

# TODO(stephenfin): Remove once we remove the few remaining
# nova-network-only APIs
if not self.USE_NEUTRON:
# self.network is only setup if USE_NEUTRON=False
self.useFixture(test.SampleNetworks(host=self.network.host))
Expand Down
10 changes: 9 additions & 1 deletion nova/tests/functional/api_sample_tests/test_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def call(self, *args, **kwargs):
return call


# TODO(stephenfin): Remove the parts of this test that are nova-network only
class NetworksJsonTests(api_sample_base.ApiSampleTestBaseV21):
USE_NEUTRON = False
USE_NEUTRON = False # partially nova-net only
ADMIN_API = True
sample_dir = "os-networks"

Expand All @@ -59,39 +60,46 @@ def setUp(self):
self.stub_out("nova.network.api.API.add_network_to_project",
_fixtures_passthrough('add_network_to_project'))

# TODO(stephenfin): Rework this to work with neutron
def test_network_list(self):
response = self._do_get('os-networks')
self._verify_response('networks-list-resp', {}, response, 200)

# TODO(stephenfin): Rework this to work with neutron
def test_network_show(self):
uuid = test_networks.FAKE_NETWORKS[0]['uuid']
response = self._do_get('os-networks/%s' % uuid)
self._verify_response('network-show-resp', {}, response, 200)

# TODO(stephenfin): Rework this to work with neutron
@mock.patch('nova.network.api.API.get', side_effect=exception.Unauthorized)
def test_network_show_token_expired(self, mock_get):
uuid = test_networks.FAKE_NETWORKS[0]['uuid']
response = self._do_get('os-networks/%s' % uuid)
self.assertEqual(401, response.status_code)

# TODO(stephenfin): Remove this API since it's nova-network only
@mock.patch('nova.network.api.API.create',
side_effect=exception.Forbidden)
def test_network_create_forbidden(self, mock_create):
response = self._do_post("os-networks",
'network-create-req', {})
self.assertEqual(403, response.status_code)

# TODO(stephenfin): Remove this API since it's nova-network only
def test_network_create(self):
response = self._do_post("os-networks",
'network-create-req', {})
self._verify_response('network-create-resp', {}, response, 200)

# TODO(stephenfin): Remove this API since it's nova-network only
def test_network_add(self):
response = self._do_post("os-networks/add",
'network-add-req', {})
self.assertEqual(202, response.status_code)
self.assertEqual("", response.text)

# TODO(stephenfin): Remove this API since it's nova-network only
def test_network_delete(self):
response = self._do_delete('os-networks/always_delete')
self.assertEqual(202, response.status_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from nova.tests.functional.api_sample_tests import api_sample_base


# TODO(stephenfin): Remove this API since it's nova-network only
class NetworksAssociateJsonTests(api_sample_base.ApiSampleTestBaseV21):
USE_NEUTRON = False
USE_NEUTRON = False # nova-net only
ADMIN_API = True
sample_dir = "os-networks-associate"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
from nova.tests.functional.api_sample_tests import api_sample_base


# TODO(stephenfin): Remove this API since it's nova-network only
class SecurityGroupDefaultRulesSampleJsonTest(
api_sample_base.ApiSampleTestBaseV21):
USE_NEUTRON = False
USE_NEUTRON = False # nova-net only
ADMIN_API = True
sample_dir = 'os-security-group-default-rules'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
CONF = nova.conf.CONF


# TODO(stephenfin): Remove the parts of this test that are nova-network only
class TenantNetworksJsonTests(api_sample_base.ApiSampleTestBaseV21):
USE_NEUTRON = False
USE_NEUTRON = False # partially nova-net only
ADMIN_API = True
sample_dir = "os-tenant-networks"

Expand All @@ -43,14 +44,17 @@ def fake(*args, **kwargs):
self.stub_out("nova.quota.QuotaEngine.commit", fake)
self.stub_out("nova.quota.QuotaEngine.rollback", fake)

# TODO(stephenfin): Rework this to work with neutron
def test_list_networks(self):
response = self._do_get('os-tenant-networks')
self._verify_response('networks-list-res', {}, response, 200)

# TODO(stephenfin): Remove this API since it's nova-network only
def test_create_network(self):
response = self._do_post('os-tenant-networks', "networks-post-req", {})
self._verify_response('networks-post-res', {}, response, 200)

# TODO(stephenfin): Remove this API since it's nova-network only
def test_delete_network(self):
response = self._do_post('os-tenant-networks', "networks-post-req", {})
net = jsonutils.loads(response.content)
Expand Down
3 changes: 2 additions & 1 deletion nova/tests/functional/integrated_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class _IntegratedTestBase(test.TestCase):
# Override this in subclasses which use the legacy nova-network service.
# New tests should rely on Neutron and old ones migrated to use this since
# nova-network is deprecated.
# TODO(stephenfin): Remove once we remove the few remaining
# nova-network-only APIs
USE_NEUTRON = True
# This indicates whether to include the project ID in the URL for API
# requests through OSAPIFixture. Overridden by subclasses.
Expand All @@ -87,7 +89,6 @@ class _IntegratedTestBase(test.TestCase):
def setUp(self):
super(_IntegratedTestBase, self).setUp()

# TODO(mriedem): Fix the functional tests to work with Neutron.
self.flags(use_neutron=self.USE_NEUTRON)

# NOTE(mikal): this is used to stub away privsep helpers
Expand Down
3 changes: 2 additions & 1 deletion nova/tests/functional/wsgi/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def create_request_body():
}


# TODO(stephenfin): Remove this test since it's nova-network only
class InterfaceFullstack(integrated_helpers._IntegratedTestBase):
"""Tests for port interfaces command.
Expand All @@ -56,7 +57,7 @@ class InterfaceFullstack(integrated_helpers._IntegratedTestBase):
"""
api_major_version = 'v2.1'
USE_NEUTRON = False
USE_NEUTRON = False # nova-net only
_image_ref_parameter = 'imageRef'
_flavor_ref_parameter = 'flavorRef'

Expand Down

0 comments on commit 1dac054

Please sign in to comment.