e456a7afca
By default we add 'voting:1' to all queries so they are filtered from the graph. There are cases where we want to track bugs for non-voting jobs in the graph, so add an 'allow-nonvoting' key for special bugs that we want to track while we're trying to stabilize a job. Updates the docs, adds a test query and unit test for the query loader, fixes a bad query that was setting voting:1 already, and removes the TODO in the query for bug 1539271. Change-Id: I61b1d4b0faaa3f20fc5b04aa3392c68c61990866
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
# Copyright Samsung Electronics 2013. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
"""Loader for elastic search queries.
|
|
|
|
A set of utility methods to load queries for elastic recheck.
|
|
"""
|
|
|
|
import glob
|
|
import os.path
|
|
import yaml
|
|
|
|
|
|
def load(directory='queries'):
|
|
"""Load queries from a set of yaml files in a directory."""
|
|
bugs = glob.glob("%s/*.yaml" % directory)
|
|
data = []
|
|
for fname in bugs:
|
|
bugnum = os.path.basename(fname).rstrip('.yaml')
|
|
query = yaml.load(open(fname).read())
|
|
query['bug'] = bugnum
|
|
# By default we filter out non-voting jobs, but in certain cases we
|
|
# want to show failures for non-voting jobs in the graph while we
|
|
# stabilize a job, so check for a special 'allow-nonvoting' key.
|
|
if not query.get('allow-nonvoting', False):
|
|
query['query'] = "%s AND voting:1" % query['query'].rstrip()
|
|
data.append(query)
|
|
return data
|