Merge lp:~salvatore-orlando/neutron/bug841982 into lp:neutron/diablo

Proposed by Salvatore Orlando
Status: Merged
Merged at revision: 66
Proposed branch: lp:~salvatore-orlando/neutron/bug841982
Merge into: lp:neutron/diablo
Diff against target: 43 lines (+16/-0)
2 files modified
quantum/db/api.py (+2/-0)
tests/unit/test_api.py (+14/-0)
To merge this branch: bzr merge lp:~salvatore-orlando/neutron/bug841982
Reviewer Review Type Date Requested Status
dan wendlandt Approve
Tyler Smith Approve
Brad Hall (community) Approve
Review via email: mp+74122@code.launchpad.net

Description of the change

Fixes a bug in FakePlugin.get_all_ports
This method was returning an empty list instead of raising an exception if the network did not exist.

Also adding the relevant API unit test.

To post a comment you must log in.
Revision history for this message
dan wendlandt (danwent) wrote :

lgtm... hooray for increased test coverage.

review: Approve
Revision history for this message
Brad Hall (bgh) wrote :

Looks good

review: Approve
Revision history for this message
Tyler Smith (tylesmit) wrote :

Tests pass, lgtm.

review: Approve
Revision history for this message
dan wendlandt (danwent) wrote :

This fixes the issue in FakePlugin, but I'd prefer to see it fixed for any plugins that use the DB model. I think tweaking the quantum/db/api.py would be more inline with how we detect invalid networks in port related calls (all other calls in quantum/db/api.py already do this, not sure why port_list() does not). Something like:

=== modified file 'quantum/db/api.py'
--- quantum/db/api.py 2011-08-30 01:16:39 +0000
+++ quantum/db/api.py 2011-09-06 21:24:53 +0000
@@ -170,6 +170,9 @@

 def port_list(net_id):
+ # confirm network exists
+ network_get(net_id)
+
     session = get_session()
     return session.query(models.Port).\
       filter_by(network_id=net_id).\

Thoughts?

review: Needs Information
65. By Salvatore Orlando

Implementing Dan's suggestion concerning fixing the bug in db api rather than FakePlugin

Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

Good point.
I updated the code. The bug is now fixed in db/api.py

Revision history for this message
dan wendlandt (danwent) wrote :

great. I fixed a minor pep8 issue as part of the merge into trunk, hope you don't mind.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'quantum/db/api.py'
2--- quantum/db/api.py 2011-08-30 01:16:39 +0000
3+++ quantum/db/api.py 2011-09-07 10:20:44 +0000
4@@ -170,6 +170,8 @@
5
6
7 def port_list(net_id):
8+ # confirm network exists
9+ network_get(net_id)
10 session = get_session()
11 return session.query(models.Port).\
12 filter_by(network_id=net_id).\
13
14=== modified file 'tests/unit/test_api.py'
15--- tests/unit/test_api.py 2011-08-30 16:30:15 +0000
16+++ tests/unit/test_api.py 2011-09-07 10:20:44 +0000
17@@ -298,6 +298,14 @@
18 self.assertEqual(len(port_data['ports']), 2)
19 LOG.debug("_test_list_ports - format:%s - END", format)
20
21+ def _test_list_ports_networknotfound(self, format):
22+ LOG.debug("_test_list_ports_networknotfound - format:%s - START", format)
23+ list_port_req = testlib.port_list_request(self.tenant_id,
24+ "A_BAD_ID", format)
25+ list_port_res = list_port_req.get_response(self.api)
26+ self.assertEqual(list_port_res.status_int, 420)
27+ LOG.debug("_test_list_ports_networknotfound - format:%s - END", format)
28+
29 def _test_list_ports_detail(self, format):
30 LOG.debug("_test_list_ports_detail - format:%s - START", format)
31 content_type = "application/%s" % format
32@@ -882,6 +890,12 @@
33 def test_list_ports_xml(self):
34 self._test_list_ports('xml')
35
36+ def test_list_ports_networknotfound_json(self):
37+ self._test_list_ports_networknotfound('json')
38+
39+ def test_list_ports_networknotfound_xml(self):
40+ self._test_list_ports_networknotfound('xml')
41+
42 def test_list_ports_detail_json(self):
43 self._test_list_ports_detail('json')
44

Subscribers

People subscribed via source and target branches