1/*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto3";
18
19package luci.resultdb.v1;
20
21import public "tools/tradefederation/core/proto/resultdb/common.proto";
22
23option go_package = "go.chromium.org/luci/resultdb/proto/v1;resultpb";
24option java_package = "com.android.resultdb.proto";
25option java_multiple_files = true;
26
27// Represents a function TestResult -> bool.
28// Empty message matches all test results.
29//
30// Most clients would want to set expected_results to
31// VARIANTS_WITH_UNEXPECTED_RESULTS.
32message TestResultPredicate {
33  // A test result must have a test id matching this regular expression
34  // entirely, i.e. the expression is implicitly wrapped with ^ and $.
35  string test_id_regexp = 1;
36
37  // A test result must have a variant satisfying this predicate.
38  VariantPredicate variant = 2;
39
40  // Filters test results based on TestResult.expected field.
41  enum Expectancy {
42    // All test results satisfy this.
43    // WARNING: using this significantly increases response size and latency.
44    ALL = 0;
45
46    // A test result must belong to a test variant that has one or more
47    // unexpected results. It can be used to fetch both unexpected and flakily
48    // expected results.
49    //
50    // Note that the predicate is defined at the test variant level.
51    // For example, if a test variant expects a PASS and has results
52    // [FAIL, FAIL, PASS], then all results satisfy the predicate because
53    // the variant satisfies the predicate.
54    VARIANTS_WITH_UNEXPECTED_RESULTS = 1;
55
56    // Similar to VARIANTS_WITH_UNEXPECTED_RESULTS, but the test variant
57    // must not have any expected results.
58    VARIANTS_WITH_ONLY_UNEXPECTED_RESULTS = 2;
59  }
60
61  // A test result must match this predicate based on TestResult.expected field.
62  // Most clients would want to override this field because the default
63  // typically causes a large response size.
64  Expectancy expectancy = 3;
65
66  // If true, filter out exonerated test variants.
67  // Mutually exclusive with Expectancy.ALL.
68  //
69  // If false, the filter is NOT applied.
70  // That is, the test result may or may not be exonerated.
71  bool exclude_exonerated = 4;
72}
73
74// Represents a function TestExoneration -> bool.
75// Empty message matches all test exonerations.
76message TestExonerationPredicate {
77  // A test exoneration must have a test id matching this regular expression
78  // entirely, i.e. the expression is implicitly wrapped with ^ and $.
79  string test_id_regexp = 1;
80
81  // A test exoneration must have a variant satisfying this predicate.
82  VariantPredicate variant = 2;
83}
84
85// Represents a function Variant -> bool.
86message VariantPredicate {
87  oneof predicate {
88    // A variant must be equal this definition exactly.
89    Variant equals = 1;
90
91    // A variant's key-value pairs must contain those in this one.
92    Variant contains = 2;
93  }
94}
95
96// Represents a function Artifact -> bool.
97message ArtifactPredicate {
98  // A set of Invocation's outgoing edge types.
99  message EdgeTypeSet {
100    // The edges represented by Invocation.included_invocations field.
101    bool included_invocations = 1;
102    // The parent-child relationship between Invocation and TestResult.
103    bool test_results = 2;
104  }
105
106  // Specifies which edges to follow when retrieving directly/indirectly
107  // included artifacts.
108  // For example,
109  // - to retrieve only invocation-level artifacts, use
110  //   {included_invocations: true}.
111  // - to retrieve only test-result-level artifacts, use {test_results: true}.
112  //
113  // By default, follows all edges.
114  EdgeTypeSet follow_edges = 1; // defaults to All.
115
116  // If an Artifact belongs to a TestResult, then the test result must satisfy
117  // this predicate.
118  // Note: this predicate does NOT apply to invocation-level artifacts.
119  // To exclude them from the response, use follow_edges.
120  TestResultPredicate test_result_predicate = 2;
121
122  // An artifact must have a content type matching this regular expression
123  // entirely, i.e. the expression is implicitly wrapped with ^ and $.
124  // Defaults to ".*".
125  string content_type_regexp = 3;
126
127  // An artifact must have an ID matching this regular expression entirely, i.e.
128  // the expression is implicitly wrapped with ^ and $.  Defaults to ".*".
129  string artifact_id_regexp = 4;
130}
131
132
133// Represents a function TestMetadata -> bool.
134// Empty message matches all test metadata.
135message TestMetadataPredicate {
136  // A test metadata must have the test id in this list.
137  repeated string test_ids = 1;
138}
139