[openstack-dev] [watcher] Catch bad filters on DB API side

Egor Panfilov erakli00 at gmail.com
Sat Apr 21 16:58:18 UTC 2018


Hi all. 

I currently work on tests for https://review.openstack.org/#/c/559481/
and found that test
watcher.tests.db.test_audit_template.DbAuditTemplateTestCase.test_get_a
udit_template_list_with_filters() works not as supposed. When it calls
get_audit_template_list() with filters on 'goal', it's done
incorrectly. Filter named 'goal' is accepted by API and it converts
'goal' to 'goal_name' or 'goal_uuid" filter, that is actualy sent to
DB.

So, DB wait only fields that explicitly passed to
Connection._add_filters() method. The most interesting part is that
Connection._add_audit_templates_filters() doesn't define 'goal' field
in plain_fields variable.

And the key point is here: Connection._add_filters() method iterates
over plain_fields and join_fieldmap but do nothing with filter, that is
not a part of these arguments. I wonder why not to add something like
exception or log entry on bad filter?

This is the reason, why bug https://bugs.launchpad.net/watcher/+bug/176
1956 wasn't caught by tests. Test, that should caught it checks
nothing. I fix it, but would it be a good idea to add checks on bad
filters?

Thanks.



More information about the OpenStack-dev mailing list