diff --git a/qa/qa-sample.json b/qa/qa-sample.json index 4034814b9746e476dbedb98eeea9daf887618abf..82f9c6cf758364200c8968f65848d67ae772d949 100644 --- a/qa/qa-sample.json +++ b/qa/qa-sample.json @@ -27,6 +27,9 @@ "# Script to check instance status": null, "instance-check": null, + "# Regular expression to ignore existing tags": null, + "ignore-tags-re": null, + "nodes": [ { "# Master node": null, diff --git a/qa/qa_rapi.py b/qa/qa_rapi.py index e265764595c9f421f484835721c3c5a07d344b64..b53b8cfe9cf87627fcb11c83eaf37d5cd5bef407 100644 --- a/qa/qa_rapi.py +++ b/qa/qa_rapi.py @@ -25,6 +25,8 @@ import tempfile import random +import re +import itertools from ganeti import utils from ganeti import constants @@ -416,6 +418,18 @@ def TestNode(node): ]) +def _FilterTags(seq): + """Removes unwanted tags from a sequence. + + """ + ignore_re = qa_config.get("ignore-tags-re", None) + + if ignore_re: + return itertools.ifilterfalse(re.compile(ignore_re).match, seq) + else: + return seq + + def TestTags(kind, name, tags): """Tests .../tags resources. @@ -432,7 +446,7 @@ def TestTags(kind, name, tags): raise errors.ProgrammerError("Unknown tag kind") def _VerifyTags(data): - AssertEqual(sorted(tags), sorted(data)) + AssertEqual(sorted(tags), sorted(_FilterTags(data))) queryargs = "&".join("tag=%s" % i for i in tags)