0

Attempt of "Add test directory -> monorail component metadata to test"

This is a reland of 39b25a5f892c66354301b0bd505d45d5a38e6e74; the
root problem seems to have been trying to run `dirmd` on Win7,
and we've upgraded the Win7 builders to be Win10, so in theory
we won't have this issue this time.

Original change's description:
> Add test directory -> monorail component metadata to test invocations.
>
> The new ResultDB system has the ability to associate test results with
> Monorail components and teams, but in order to do that, we need to
> upload the mapping information contained in the testing/DIR_METADATA
> files along with the test results.
>
> This CL adds a gclient hook to generate the metadata in a
> ResultDB-friendly format that can be accessed by `rdb` and uploaded
> as part of a test invocation, and makes the generated data a
> dependency of the bin/run_* test scripts, to ensure that every
> test invocation will have the data.
>
> Change-Id: I83dcf7f460b6fbd1d4c23616d972510712019148
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568896
> Commit-Queue: Dirk Pranke <dpranke@google.com>
> Reviewed-by: Chan Li <chanli@chromium.org>
> Reviewed-by: Nodir Turakulov <nodir@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#861612}

Bug: 1191087
Change-Id: I767fcbfb295723444902cfae27e25398df98b5d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2785124
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Chan Li <chanli@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/master@{#866323}
This commit is contained in:
Dirk Pranke
2021-03-24 22:26:22 +00:00
committed by Chromium LUCI CQ
parent 00443a3464
commit 19a5873afc
5 changed files with 95 additions and 6 deletions

1
.gitignore vendored

@ -280,6 +280,7 @@ vs-chromium-project.txt
/sql/sql_unittests_run.xml
/sync/sync.xml
/testing/libfuzzer/fuzzer_corpus_for_bots/
/testing/location_tags.json
/testing/rts/
/testserver.log
# See third_party/.gitignore for entries covering src/third_party.

11
DEPS

@ -4387,6 +4387,17 @@ hooks = [
],
},
{
'name': 'Generate component metadata for tests',
'pattern': '.',
'action': [
'vpython',
'src/testing/generate_location_tags.py',
'--out',
'src/testing/location_tags.json',
],
},
# Download and initialize "vpython" VirtualEnv environment packages.
{
'name': 'vpython_common',

@ -91,6 +91,10 @@ template("fuchsia_package_runner") {
data = []
}
if (defined(invoker.data)) {
data += invoker.data
}
wrapper_script = generated_run_pkg_script_path
data_deps = [

@ -0,0 +1,44 @@
#!/usr/bin/env python
# Copyright (c) 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Generates the directory->tags mapping used by ResultDB."""
# pylint: disable=line-too-long
#
# For more on the tags, see
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/go.chromium.org/luci/resultdb/sink/proto/v1/location_tag.proto
#
# pylint: enable=line-too-long
import argparse
import os
import subprocess
import sys
THIS_DIR = os.path.dirname(__file__)
SRC_DIR = os.path.dirname(THIS_DIR)
BUILD_DIR = os.path.join(SRC_DIR, 'build')
sys.path.insert(0, BUILD_DIR)
import find_depot_tools
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--out', required=True,
help='path to write location tag metadata to')
args = parser.parse_args()
exe = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'dirmd')
if sys.platform == 'win32':
exe = exe + '.bat'
return subprocess.call([
exe,
'location-tags',
'-out', args.out,
'-root', SRC_DIR,
'-repo', 'https://chromium.googlesource.com/chromium/src',
])
if __name__ == '__main__':
sys.exit(main())

@ -78,11 +78,13 @@ template("test") {
executable(_exec_target) {
# Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
configs = []
data_deps = []
forward_variables_from(invoker,
"*",
TESTONLY_AND_VISIBILITY + _wrapper_script_vars +
[ "extra_dist_files" ])
forward_variables_from(
invoker,
"*",
TESTONLY_AND_VISIBILITY + _wrapper_script_vars + [
"data_deps",
"extra_dist_files",
])
# Thanks to the set_defaults() for test(), configs are initialized with
# the default shared_library configs rather than executable configs.
@ -92,6 +94,16 @@ template("test") {
]
configs += [ "//build/config:executable_config" ]
if (defined(invoker.data_deps)) {
data_deps = invoker.data_deps
} else {
data_deps = []
}
if (!defined(data)) {
data = []
}
data += [ "//testing/location_tags.json" ]
# Don't output to the root or else conflict with the group() below.
output_name = rebase_path(_exec_output, root_out_dir)
}
@ -225,6 +237,13 @@ template("test") {
":$_library_target",
]
}
if (defined(invoker.data_deps)) {
data_deps = invoker.data_deps
} else {
data_deps = []
}
data = [ "//testing/location_tags.json" ]
}
} else if (is_fuchsia) {
assert(!defined(invoker.use_xvfb) || !invoker.use_xvfb)
@ -272,6 +291,7 @@ template("test") {
package = ":$_pkg_target"
package_name_override = _output_name
data = [ "//testing/location_tags.json" ]
data_deps = [ "//testing/buildbot/filters:fuchsia_filters" ]
}
@ -303,7 +323,6 @@ template("test") {
forward_variables_from(invoker,
[
"data",
"data_deps",
"deps",
"executable_args",
"retries",
@ -321,6 +340,11 @@ template("test") {
]
wrapper_output_name = "${_wrapper_output_name}"
if (!defined(data)) {
data = []
}
data += [ "//testing/location_tags.json" ]
}
_resources_bundle_data = target_name + "_resources_bundle_data"
@ -391,6 +415,7 @@ template("test") {
generated_script = "$root_build_dir/bin/run_" + invoker.target_name
test_exe = invoker.target_name
runtime_deps_file = _runtime_deps_file
data = [ "//testing/location_tags.json" ]
}
executable(target_name) {
@ -440,6 +465,7 @@ template("test") {
executable = "//testing/test_env.py"
data += [ "//testing/test_env.py" ]
}
data += [ "//testing/location_tags.json" ]
executable_args = [
"@WrappedPath(../../build/lacros/test_runner.py)",
@ -515,6 +541,7 @@ template("test") {
executable = "//testing/test_env.py"
data += [ "//testing/test_env.py" ]
}
data += [ "//testing/location_tags.json" ]
executable_args = [
"@WrappedPath(./${_executable})",
@ -618,6 +645,8 @@ template("script_test") {
if (defined(invoker.data)) {
data += invoker.data
}
data += [ "//testing/location_tags.json" ]
data_deps = []
if (defined(invoker.data_deps)) {
data_deps += invoker.data_deps