Comment 3 for bug 1386525

Revision history for this message
Eli Qiao (taget-9) wrote :

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(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)

compared with nova api unit test

def test_fixed_ip_reserve_invalid_ip_address(self):
        body = {'reserve': None}
        req = fakes.HTTPRequest.blank('%s/inv.ali.d.ip/action' % self.url)
        action = self._get_reserve_action()

        self.assertRaises(webob.exc.HTTPBadRequest,
                          action, req, 'inv.ali.d.ip', body)

I will submit a tempest patch to fix this one.

Eli.