with session.begin(subtransactions=True):
try:
result = model_query(context, models.FixedIp, session=session)
for column in columns_to_join: result = result.options(joinedload_all(column))
result = result.filter_by(address=address).first()
if not result: raise exception.FixedIpNotFoundForAddress(address=address)
except db_exc.DBError:
msg = _("Invalid fixed IP Address %s in request") % address LOG.warn(msg)
raise exception.FixedIpInvalid(msg)
if passing a invalid address to db, it will raises a DBError, and will reraise an FixedIpInvalid exception.
in nova-api, it will except FixedIpInvalid exception and raise an HTTPBadRequest
except exception.FixedIpInvalid:
msg = _("Fixed IP %s not valid") % address
raise webob.exc.HTTPBadRequest(explanation=msg)
but seen from tempest test case.
def test_set_reserve_with_invalid_ip(self):
# NOTE(maurosr): since this exercises the same code snippet, we do it
# only for reserve action
body = {"reserve": "None"} self.assertRaises(exceptions.NotFound, <<<----- here should be HTTPBadRequest self.client.reserve_fixed_ip, "my.invalid.ip", body)
After reading the stack trace of gate.
I think this is an tempest test case error.
in sqlalchemy api.
def _fixed_ ip_get_ by_address( context, address, session=None,
columns_ to_join= None):
...
with session. begin(subtransa ctions= True): context, models.FixedIp, session=session)
result = result. options( joinedload_ all(column) ) filter_ by(address= address) .first( )
raise exception. FixedIpNotFound ForAddress( address= address)
LOG. warn(msg) FixedIpInvalid( msg)
try:
result = model_query(
for column in columns_to_join:
result = result.
if not result:
except db_exc.DBError:
msg = _("Invalid fixed IP Address %s in request") % address
raise exception.
if passing a invalid address to db, it will raises a DBError, and will reraise an FixedIpInvalid exception.
in nova-api, it will except FixedIpInvalid exception and raise an HTTPBadRequest FixedIpInvalid: HTTPBadRequest( explanation= msg)
except exception.
msg = _("Fixed IP %s not valid") % address
raise webob.exc.
but seen from tempest test case.
def test_set_ reserve_ with_invalid_ ip(self) :
self.assertRai ses(exceptions. NotFound, <<<----- here should be HTTPBadRequest
self. client. reserve_ fixed_ip,
"my. invalid. ip", body)
# NOTE(maurosr): since this exercises the same code snippet, we do it
# only for reserve action
body = {"reserve": "None"}
compared with nova api unit test
def test_fixed_ ip_reserve_ invalid_ ip_address( self): st.blank( '%s/inv. ali.d.ip/ action' % self.url) reserve_ action( )
body = {'reserve': None}
req = fakes.HTTPReque
action = self._get_
I will submit a tempest patch to fix this one.
Eli.