Test: Distinguish expected added resources

Some resources can't be cleaned up (default security groups) and some
shouldn't be (the _member_ role), so we filter those out of the added
resources and report them separately.

Change-Id: Ibb601f59df509895b438ac142cd8811df3e1d956
This commit is contained in:
Chris St. Pierre 2016-03-31 13:34:11 -05:00
parent 80255f0a57
commit 13ac75f152

View File

@ -319,11 +319,28 @@ def main():
changes = resources.compare(with_list=given_list)
removed, added = changes
# filter out expected additions
expected = []
for resource_tuple in added:
resource = dict(resource_tuple)
if ((resource["class"] == "keystone" and
resource["resource_name"] == "role" and
resource["name"] == "_member_") or
(resource["class"] == "nova" and
resource["resource_name"] == "security_group" and
resource["name"] == "default")):
expected.append(resource_tuple)
for resource in expected:
added.remove(resource)
if removed:
_print_tabular_resources(removed, "Removed resources")
if added:
_print_tabular_resources(added, "Added resources")
_print_tabular_resources(added, "Added resources (unexpected)")
if expected:
_print_tabular_resources(expected, "Added resources (expected)")
if any(changes):
return 0 # `1' will fail gate job