[resultdb] Update resultdb proto

Sync'd to commit:15458901113063d2a0d95be2e27a245c4cfd5690
https://crrev.com/c/3278543

Bug: 90486
Change-Id: Ib46727eda3437b9c61eb1dc18ee67b9bdd3f492e
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/luci-go/+/620821
Reviewed-by: Oliver Newman <olivernewman@google.com>
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
diff --git a/resultdb/proto/v1/BUILD.gn b/resultdb/proto/v1/BUILD.gn
index 4b047ef..b3fb5e2 100644
--- a/resultdb/proto/v1/BUILD.gn
+++ b/resultdb/proto/v1/BUILD.gn
@@ -7,6 +7,7 @@
 
 _protos = [
   "common",
+  "failure_reason",
   "test_metadata",
   "test_result",
 ]
diff --git a/resultdb/proto/v1/common.proto b/resultdb/proto/v1/common.proto
index 675d4d4..bcecb74 100644
--- a/resultdb/proto/v1/common.proto
+++ b/resultdb/proto/v1/common.proto
@@ -16,13 +16,14 @@
 
 package luci.resultdb.v1;
 
+import "google/protobuf/timestamp.proto";
+
 option go_package = "go.chromium.org/luci/resultdb/proto/v1;resultpb";
 
 // A key-value map describing one variant of a test case.
 //
 // The same test case can be executed in different ways, for example on
-// different OS, GPUs, with different compile options, runtime flags or even
-// with different values of the test parameter (for parameterized tests).
+// different OS, GPUs, with different compile options or runtime flags.
 // A variant definition captures one variant.
 // A test case with a specific variant definition is called test variant.
 //
@@ -40,7 +41,7 @@
 //   For example, if GN args are among variant key-value pairs, then adding a
 //   new GN arg changes the identity of the test variant and resets its history.
 //
-// In Chromium, typical variant keys are:
+// In Chromium, variant keys are:
 // - bucket: the LUCI bucket, e.g. "ci"
 // - builder: the LUCI builder, e.g. "linux-rel"
 // - test_suite: a name from
@@ -60,4 +61,44 @@
 
   // Max length: 256.
   string value = 2;
-}
\ No newline at end of file
+}
+
+// CommitPosition specifies the numerical position of the commit an invocation
+// runs against, in a repository's commit log. More specifically, a ref's commit
+// log.
+// It also specifies the repo/ref combination that the commit position exists
+// in, to provide context.
+message CommitPosition {
+  // The following fields identify a git repository and a ref within which the
+  // numerical position below identifies a single commit.
+  string host = 1;
+  string project = 2;
+  string ref = 3;
+
+  // The numerical position of the commit in the log for the host/project/ref
+  // above.
+  int64 position = 4;
+}
+
+// A range of commit positions.
+// Commit positions are assumed to increase from earliest to latest.
+// Note that if both earliest and latest are set, their host/project/ref must
+// be identical.
+// Used for specifying ranges to query in ResultDB.GetTestResultHistory.
+message CommitPositionRange {
+  // The lowest commit position to include in the range.
+  CommitPosition earliest = 1;
+
+  // Include only commit positions that that are strictly lower than this.
+  CommitPosition latest = 2;
+}
+
+// A range of timestamps.
+// Used for specifying ranges to query in ResultDB.GetTestResultHistory.
+message TimeRange {
+  // The oldest timestamp to include in the range.
+  google.protobuf.Timestamp earliest = 1;
+
+  // Include only timestamps that are strictly older than this.
+  google.protobuf.Timestamp latest = 2;
+}
diff --git a/resultdb/proto/v1/failure_reason.proto b/resultdb/proto/v1/failure_reason.proto
new file mode 100644
index 0000000..136b61a
--- /dev/null
+++ b/resultdb/proto/v1/failure_reason.proto
@@ -0,0 +1,38 @@
+// Copyright 2021 The LUCI Authors.
+//
+// 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.
+
+syntax = "proto3";
+
+package luci.resultdb.v1;
+
+option go_package = "go.chromium.org/luci/resultdb/proto/v1;resultpb";
+
+// Information about why a test failed. This information may be displayed
+// to developers in result viewing UIs and will also be used to cluster
+// similar failures together.
+// For example, this will contain assertion failure messages and stack traces.
+message FailureReason {
+  // The error message that ultimately caused the test to fail. This should
+  // only be the error message and should not include any stack traces.
+  // An example would be the message from an Exception in a Java test.
+  // In the case that a test failed due to multiple expectation failures, any
+  // immediately fatal failure should be chosen, or otherwise the first
+  // expectation failure.
+  // If this field is empty, other fields (including those from the TestResult)
+  // may be used to cluster the failure instead.
+  //
+  // The size of the message must be equal to or smaller than 1024 bytes in
+  // UTF-8.
+  string primary_error_message = 1;
+}
diff --git a/resultdb/proto/v1/test_result.proto b/resultdb/proto/v1/test_result.proto
index e32009a..5e41488 100644
--- a/resultdb/proto/v1/test_result.proto
+++ b/resultdb/proto/v1/test_result.proto
@@ -21,6 +21,7 @@
 
 import "resultdb/proto/v1/common.proto";
 import "resultdb/proto/v1/test_metadata.proto";
+import "resultdb/proto/v1/failure_reason.proto";
 
 option go_package = "go.chromium.org/luci/resultdb/proto/v1;resultpb";
 
@@ -33,6 +34,8 @@
 // This message does not specify the test id.
 // It should be available in the message that embeds this message.
 message TestResult {
+  reserved 11;  // test_location
+
   // Can be used to refer to this test result, e.g. in ResultDB.GetTestResult
   // RPC.
   // Format:
@@ -44,7 +47,7 @@
   string name = 1;
 
   // Test id, a unique identifier of the test in a LUCI project.
-  // Regex: ^[[::print::]]{1,256}$
+  // Regex: ^[[::print::]]{1,512}$
   //
   // If two tests have a common test id prefix that ends with a
   // non-alphanumeric character, they considered a part of a group. Examples:
@@ -89,6 +92,14 @@
   //
   // The size of the summary must be equal to or smaller than 4096 bytes in
   // UTF-8.
+  //
+  // Supports artifact embedding using custom tags:
+  // * <text-artifact> renders contents of an artifact as text.
+  //   Usage:
+  //   * To embed result level artifact: <text-artifact
+  //   artifact-id="<artifact_id>">
+  //   * To embed invocation level artifact: <text-artifact
+  //   artifact-id="<artifact_id>" inv-level>
   string summary_html = 7;
 
   // The point in time when the test case started to execute.
@@ -100,18 +111,20 @@
 
   // Metadata for this test result.
   // It might describe this particular execution or the test case.
+  // A key can be repeated.
   repeated StringPair tags = 10;
 
-  // Where the test is defined, e.g. the file name.
-  // Deprecated. In favor of test_metadata.
-  TestLocation test_location = 11;
-
   // Hash of the variant.
   // hex(sha256(sorted(''.join('%s:%s\n' for k, v in variant.items())))).
+  //
+  // Output only.
   string variant_hash = 12;
 
   // Information about the test at the time of its execution.
   TestMetadata test_metadata = 13;
+
+  // Information about the test failure. Only present if the test failed.
+  FailureReason failure_reason = 14;
 }
 
 // Machine-readable status of a test result.