summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaurang Tapase <gaurang.tapase@in.ibm.com>2015-10-12 20:47:19 +0530
committerMatt Riedemann <mriedem@us.ibm.com>2015-10-13 11:36:47 -0700
commitf1eded1fbcaf309e1c9a4be3f8a14bd25daa3e46 (patch)
treeff0c1dde040508b920c63be815903038bbd3fb30
parent3b79a76b5d293bdec677f691c43456a69b1933c0 (diff)
Fix usage of dependencies1.0.0.0rc31.0.0
Manila is broken is threee places, so fix them: 1) test 'test_misc' with WebOb 1.5 WebOb 1.5 was released at 2015-10-11. With this new version, webob.exc.WSGIHTTPException() constructor now fails with a KeyError when the HTTP status code is 0. test_exceptions_raise() of test_misc tries to instantiate all exceptions of manila.exception. The problem is that ConvertedException uses a default HTTP status code of 0. Modify the default HTTP status code of ConvertedException to 400 to fix the unit tests. 2) Add dependency for 'testresources' that is required by migration tests. 3) Remove 2 unit tests related to testing of oslo.policy lib functionality that should not be tested in Manila. It started failing because under-the-hood behaviour was changed in new realese 0.12.0 Closes-Bug: #1505153 Closes-Bug: #1505374 (cherry picked from commit 9c99814ce5943bd4c33bf3650b832666e31b3411) -- squashed with another change to get tests to pass on stable/liberty -- Fix broken unit tests With release of six module version 1.10.0 several our unit tests started to fail because of usage of not strict constructions. Changes: 1) Manila unit test "manila.tests.share.test_api.ShareAPITestCase.test_extend_quota_error" used str for int substitution. So, use int data for int substitution. 2) Module 'manila.share.drivers.hp.hp_3par_mediator' was using LOG.exception function when no traceback were exist it led to AttributeError on py34. So, replace all usages of 'LOG.exception' with 'LOG.error' where no raised exceptions exist. Change-Id: Ic5b37bfb9d939d03f6ff68bc53d134bf9e5f996e Closes-Bug: #1503969 (cherry picked from commit f38b8d4efd1f68f4ea29747f7377e0936f61d89c) -- Change-Id: I0f28f3c3fb2c7eec1bafc3a617344990f86810cf
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Thierry Carrez <thierry@openstack.org> Workflow+1: Thierry Carrez <thierry@openstack.org> Code-Review+2: Ben Swartzlander <ben@swartzlander.org> Code-Review+2: Sean Dague <sean@dague.net> Submitted-by: Jenkins Submitted-at: Tue, 13 Oct 2015 20:53:05 +0000 Reviewed-on: https://review.openstack.org/234288 Project: openstack/manila Branch: refs/heads/stable/liberty
-rw-r--r--manila/exception.py2
-rw-r--r--manila/share/drivers/hp/hp_3par_mediator.py28
-rw-r--r--manila/tests/share/test_api.py4
-rw-r--r--manila/tests/test_policy.py25
-rw-r--r--test-requirements.txt1
5 files changed, 18 insertions, 42 deletions
diff --git a/manila/exception.py b/manila/exception.py
index 9da2a14..8b0cdaf 100644
--- a/manila/exception.py
+++ b/manila/exception.py
@@ -48,7 +48,7 @@ ProcessExecutionError = processutils.ProcessExecutionError
48 48
49 49
50class ConvertedException(webob.exc.WSGIHTTPException): 50class ConvertedException(webob.exc.WSGIHTTPException):
51 def __init__(self, code=0, title="", explanation=""): 51 def __init__(self, code=400, title="", explanation=""):
52 self.code = code 52 self.code = code
53 self.title = title 53 self.title = title
54 self.explanation = explanation 54 self.explanation = explanation
diff --git a/manila/share/drivers/hp/hp_3par_mediator.py b/manila/share/drivers/hp/hp_3par_mediator.py
index 0e222cf..2cdc3b8 100644
--- a/manila/share/drivers/hp/hp_3par_mediator.py
+++ b/manila/share/drivers/hp/hp_3par_mediator.py
@@ -91,7 +91,7 @@ class HP3ParMediator(object):
91 if self.no_client(): 91 if self.no_client():
92 msg = _('You must install hp3parclient before using the 3PAR ' 92 msg = _('You must install hp3parclient before using the 3PAR '
93 'driver.') 93 'driver.')
94 LOG.exception(msg) 94 LOG.error(msg)
95 raise exception.HP3ParInvalidClient(message=msg) 95 raise exception.HP3ParInvalidClient(message=msg)
96 96
97 self.client_version = hp3parclient.version_tuple 97 self.client_version = hp3parclient.version_tuple
@@ -101,7 +101,7 @@ class HP3ParMediator(object):
101 {'found': '.'.join(map(six.text_type, self.client_version)), 101 {'found': '.'.join(map(six.text_type, self.client_version)),
102 'minimum': '.'.join(map(six.text_type, 102 'minimum': '.'.join(map(six.text_type,
103 MIN_CLIENT_VERSION))}) 103 MIN_CLIENT_VERSION))})
104 LOG.exception(msg) 104 LOG.error(msg)
105 raise exception.HP3ParInvalidClient(message=msg) 105 raise exception.HP3ParInvalidClient(message=msg)
106 106
107 try: 107 try:
@@ -200,12 +200,12 @@ class HP3ParMediator(object):
200 except Exception as e: 200 except Exception as e:
201 msg = (_('Failed to get capacity for fpg %(fpg)s: %(e)s') % 201 msg = (_('Failed to get capacity for fpg %(fpg)s: %(e)s') %
202 {'fpg': fpg, 'e': six.text_type(e)}) 202 {'fpg': fpg, 'e': six.text_type(e)})
203 LOG.exception(msg) 203 LOG.error(msg)
204 raise exception.ShareBackendException(msg=msg) 204 raise exception.ShareBackendException(msg=msg)
205 205
206 if result['total'] != 1: 206 if result['total'] != 1:
207 msg = (_('Failed to get capacity for fpg %s.') % fpg) 207 msg = (_('Failed to get capacity for fpg %s.') % fpg)
208 LOG.exception(msg) 208 LOG.error(msg)
209 raise exception.ShareBackendException(msg=msg) 209 raise exception.ShareBackendException(msg=msg)
210 210
211 member = result['members'][0] 211 member = result['members'][0]
@@ -229,7 +229,7 @@ class HP3ParMediator(object):
229 if provisioning_type not in (THIN, FULL, DEDUPE): 229 if provisioning_type not in (THIN, FULL, DEDUPE):
230 msg = (_('Unexpected provisioning type for FPG %(fpg)s: ' 230 msg = (_('Unexpected provisioning type for FPG %(fpg)s: '
231 '%(ptype)s.') % {'fpg': fpg, 'ptype': provisioning_type}) 231 '%(ptype)s.') % {'fpg': fpg, 'ptype': provisioning_type})
232 LOG.exception(msg) 232 LOG.error(msg)
233 raise exception.ShareBackendException(msg=msg) 233 raise exception.ShareBackendException(msg=msg)
234 234
235 dedupe = provisioning_type == DEDUPE 235 dedupe = provisioning_type == DEDUPE
@@ -259,7 +259,7 @@ class HP3ParMediator(object):
259 if protocol not in ['smb', 'nfs']: 259 if protocol not in ['smb', 'nfs']:
260 message = (_('Invalid protocol. Expected nfs or smb. Got %s.') % 260 message = (_('Invalid protocol. Expected nfs or smb. Got %s.') %
261 protocol) 261 protocol)
262 LOG.exception(message) 262 LOG.error(message)
263 raise exception.InvalidInput(message) 263 raise exception.InvalidInput(message)
264 return protocol 264 return protocol
265 265
@@ -460,7 +460,7 @@ class HP3ParMediator(object):
460 msg = (_('Failed to get fshare %(share_name)s after creating it. ' 460 msg = (_('Failed to get fshare %(share_name)s after creating it. '
461 'Expected to get 1 fshare. Got %(total)s.') % 461 'Expected to get 1 fshare. Got %(total)s.') %
462 {'share_name': share_name, 'total': result['total']}) 462 {'share_name': share_name, 'total': result['total']})
463 LOG.exception(msg) 463 LOG.error(msg)
464 raise exception.ShareBackendException(msg) 464 raise exception.ShareBackendException(msg)
465 465
466 if protocol == 'nfs': 466 if protocol == 'nfs':
@@ -492,7 +492,7 @@ class HP3ParMediator(object):
492 'fpg': fpg, 492 'fpg': fpg,
493 'vfs': vfs, 493 'vfs': vfs,
494 'tag': snapshot_tag}) 494 'tag': snapshot_tag})
495 LOG.exception(msg) 495 LOG.error(msg)
496 raise exception.ShareBackendException(msg) 496 raise exception.ShareBackendException(msg)
497 497
498 fstore = snapshot['fstoreName'] 498 fstore = snapshot['fstoreName']
@@ -594,7 +594,7 @@ class HP3ParMediator(object):
594 msg = (_('Failed to create snapshot for FPG/VFS/fshare ' 594 msg = (_('Failed to create snapshot for FPG/VFS/fshare '
595 '%(fpg)s/%(vfs)s/%(fshare)s: Failed to find fshare.') % 595 '%(fpg)s/%(vfs)s/%(fshare)s: Failed to find fshare.') %
596 {'fpg': fpg, 'vfs': vfs, 'fshare': orig_share_id}) 596 {'fpg': fpg, 'vfs': vfs, 'fshare': orig_share_id})
597 LOG.exception(msg) 597 LOG.error(msg)
598 raise exception.ShareBackendException(msg) 598 raise exception.ShareBackendException(msg)
599 599
600 sharedir = fshare.get('shareDir') 600 sharedir = fshare.get('shareDir')
@@ -603,7 +603,7 @@ class HP3ParMediator(object):
603 '%(fpg)s/%(vfs)s/%(fshare)s: Share is a read-only ' 603 '%(fpg)s/%(vfs)s/%(fshare)s: Share is a read-only '
604 'share of an existing snapshot.') % 604 'share of an existing snapshot.') %
605 {'fpg': fpg, 'vfs': vfs, 'fshare': orig_share_id}) 605 {'fpg': fpg, 'vfs': vfs, 'fshare': orig_share_id})
606 LOG.exception(msg) 606 LOG.error(msg)
607 raise exception.ShareBackendException(msg) 607 raise exception.ShareBackendException(msg)
608 608
609 fstore = fshare.get('fstoreName') 609 fstore = fshare.get('fstoreName')
@@ -702,13 +702,13 @@ class HP3ParMediator(object):
702 if access_type not in ('ip', 'user'): 702 if access_type not in ('ip', 'user'):
703 msg = (_("Invalid access type. Expected 'ip' or 'user'. " 703 msg = (_("Invalid access type. Expected 'ip' or 'user'. "
704 "Actual '%s'.") % access_type) 704 "Actual '%s'.") % access_type)
705 LOG.exception(msg) 705 LOG.error(msg)
706 raise exception.InvalidInput(msg) 706 raise exception.InvalidInput(msg)
707 707
708 if protocol == 'nfs' and access_type != 'ip': 708 if protocol == 'nfs' and access_type != 'ip':
709 msg = (_("Invalid NFS access type. HP 3PAR NFS supports 'ip'. " 709 msg = (_("Invalid NFS access type. HP 3PAR NFS supports 'ip'. "
710 "Actual '%s'.") % access_type) 710 "Actual '%s'.") % access_type)
711 LOG.exception(msg) 711 LOG.error(msg)
712 raise exception.HP3ParInvalid(msg) 712 raise exception.HP3ParInvalid(msg)
713 713
714 return protocol 714 return protocol
@@ -892,7 +892,7 @@ class HP3ParMediator(object):
892 'FPG/VFS/IP/subnet/VLAN ' 892 'FPG/VFS/IP/subnet/VLAN '
893 '%(fspool)s/%(vfs)s/' 893 '%(fspool)s/%(vfs)s/'
894 '%(address)s/%(prefixLen)s/%(vlanTag)s.') % fsip) 894 '%(address)s/%(prefixLen)s/%(vlanTag)s.') % fsip)
895 LOG.exception(msg) 895 LOG.error(msg)
896 raise exception.ShareBackendException(msg=msg) 896 raise exception.ShareBackendException(msg=msg)
897 897
898 def remove_fsip(self, ip, fpg, vfs): 898 def remove_fsip(self, ip, fpg, vfs):
@@ -920,5 +920,5 @@ class HP3ParMediator(object):
920 if self.fsip_exists(fsip): 920 if self.fsip_exists(fsip):
921 msg = (_('Failed to remove FSIP for FPG/VFS/IP ' 921 msg = (_('Failed to remove FSIP for FPG/VFS/IP '
922 '%(fspool)s/%(vfs)s/%(address)s.') % fsip) 922 '%(fspool)s/%(vfs)s/%(address)s.') % fsip)
923 LOG.exception(msg) 923 LOG.error(msg)
924 raise exception.ShareBackendException(msg=msg) 924 raise exception.ShareBackendException(msg=msg)
diff --git a/manila/tests/share/test_api.py b/manila/tests/share/test_api.py
index 137f343..712295a 100644
--- a/manila/tests/share/test_api.py
+++ b/manila/tests/share/test_api.py
@@ -1517,8 +1517,8 @@ class ShareAPITestCase(test.TestCase):
1517 share = db_utils.create_share(status=constants.STATUS_AVAILABLE, 1517 share = db_utils.create_share(status=constants.STATUS_AVAILABLE,
1518 size=100) 1518 size=100)
1519 new_size = 123 1519 new_size = 123
1520 usages = {'gigabytes': {'reserved': 'fake', 'in_use': 'fake'}} 1520 usages = {'gigabytes': {'reserved': 11, 'in_use': 12}}
1521 quotas = {'gigabytes': 'fake'} 1521 quotas = {'gigabytes': 13}
1522 exc = exception.OverQuota(usages=usages, quotas=quotas, overs=new_size) 1522 exc = exception.OverQuota(usages=usages, quotas=quotas, overs=new_size)
1523 self.mock_object(quota.QUOTAS, 'reserve', mock.Mock(side_effect=exc)) 1523 self.mock_object(quota.QUOTAS, 'reserve', mock.Mock(side_effect=exc))
1524 1524
diff --git a/manila/tests/test_policy.py b/manila/tests/test_policy.py
index 4ec6f65..97a8a92 100644
--- a/manila/tests/test_policy.py
+++ b/manila/tests/test_policy.py
@@ -17,11 +17,8 @@
17 17
18import os.path 18import os.path
19 19
20import mock
21from oslo_config import cfg 20from oslo_config import cfg
22from oslo_policy import policy as common_policy 21from oslo_policy import policy as common_policy
23import six
24from six.moves.urllib import request as urlrequest
25 22
26from manila import context 23from manila import context
27from manila import exception 24from manila import exception
@@ -107,28 +104,6 @@ class PolicyTestCase(test.TestCase):
107 action = "example:allowed" 104 action = "example:allowed"
108 policy.enforce(self.context, action, self.target) 105 policy.enforce(self.context, action, self.target)
109 106
110 def test_enforce_http_true(self):
111
112 def fakeurlopen(url, post_data):
113 return six.StringIO("True")
114
115 action = "example:get_http"
116 target = {}
117 with mock.patch.object(urlrequest, 'urlopen', fakeurlopen):
118 result = policy.enforce(self.context, action, target)
119 self.assertTrue(result)
120
121 def test_enforce_http_false(self):
122
123 def fakeurlopen(url, post_data):
124 return six.StringIO("False")
125
126 action = "example:get_http"
127 target = {}
128 with mock.patch.object(urlrequest, 'urlopen', fakeurlopen):
129 self.assertRaises(exception.PolicyNotAuthorized, policy.enforce,
130 self.context, action, target)
131
132 def test_templatized_enforcement(self): 107 def test_templatized_enforcement(self):
133 target_mine = {'project_id': 'fake'} 108 target_mine = {'project_id': 'fake'}
134 target_not_mine = {'project_id': 'another'} 109 target_not_mine = {'project_id': 'another'}
diff --git a/test-requirements.txt b/test-requirements.txt
index 423b065..14f3efc 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -18,4 +18,5 @@ python-subunit>=0.0.18
18requests-mock>=0.6.0 # Apache-2.0 18requests-mock>=0.6.0 # Apache-2.0
19sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 19sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
20testrepository>=0.0.18 20testrepository>=0.0.18
21testresources>=0.2.4
21testtools>=1.4.0 22testtools>=1.4.0