From bf6f178dc83a833bb2e28c18bd834f0d8edc5468 Mon Sep 17 00:00:00 2001 From: Anna Kukliansky Date: Thu, 12 Oct 2023 07:22:29 -0700 Subject: [PATCH] [fbcode_macros[sh_test] change labels into remote_execution attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test Plan: CI checked several target and their attributes before and after the change. 1. before ``` 10:23:36 0|[kuki@devvm7557.vll0]:/data/users/kuki/fbsource/fbcode (856d0843b)💜 buck2 targets //antlir/vm/tests:python-remote-execution -A | grep capabili ... "labels":{"__type":"concat","items":[["disabled","vmtest","heavyweight","use-testpilot-adapter","tpx:list-format-migration:json","test-framework=8:vmtest","vmtest_python","antlir_macros","antlir__internal","buck","dev","clang","platform010","x86_64","buck_sh","supports_remote_execution","re_opts_capabilities={\"platform\":\"mtia\",\"codename\":\"freya\"}","re_remote_cache_enabled=False"],... "remote_execution":{"capabilities":{"codename":"freya","platform":"mtia"},"remote_cache_enabled":false,"use_case":null}, ``` after: ``` 10:28:05 0|[kuki@devvm7557.vll0]:/data/users/kuki/fbsource/fbcode (dc24fdba8)💜 buck2 targets //antlir/vm/tests:python-remote-execution -A | grep capabili ... "labels":{"__type":"concat","items":[["supports_remote_execution","re_opts_capabilities={\"platform\":\"mtia\", \"codename\":\"freya\"}","disabled","vmtest","heavyweight","use-testpilot-adapter","tpx:list-format-migration:json","test-framework=8:vmtest","vmtest_python","antlir_macros","antlir__internal","buck","dev","clang","platform010","x86_64","buck_sh"],... "remote_execution":{"capabilities":{"codename":"freya","platform":"mtia"},"use_case":null}, ``` 2. before: ``` 10:42:45 0|[kuki@devvm7557.vll0]:/data/users/kuki/fbsource/fbcode (086cc3cf8)💜 buck2 targets //hphp/test:verify_slow_interp_jit_re -A | grep capa ... "labels":{"__type":"concat","items":[["buck","dev","clang","platform010","x86_64","custom","custom-type-json","fbcode_macros","hphp-test","tpx-test-type:hphp-test","long_running","run_as_bundle","tpx:experimental-shard-size-for-bundle=3","re_opts_capabilities={\"platform\": \"linux-remote-execution\"}","re_opts_use_case=hhvm_test","re_remote_cache_enabled=false","supports_remote_execution","buck2_run_from_project_root"],..., "remote_execution":{"capabilities":{"platform":"linux-remote-execution"},"remote_cache_enabled":false,"use_case":"hhvm_test"}, ``` after: ``` 10:46:47 0|[kuki@devvm7557.vll0]:/data/users/kuki/fbsource/fbcode (2027d6fe0)💜 buck2 targets //hphp/test:verify_slow_interp_jit_re -A | grep capa ... "labels":{"__type":"concat","items":[["buck","dev","clang","platform010","x86_64","custom","custom-type-json","fbcode_macros","hphp-test","tpx-test-type:hphp-test","long_running","run_as_bundle","tpx:experimental-shard-size-for-bundle=3","buck2_run_from_project_root"],...,"re_remote_cache_enabled=False"]]}, "remote_execution":{"capabilities":{"platform":"linux-remote-execution"},"remote_cache_enabled":false,"use_case":"hhvm_test"}, ``` Reviewed By: markisaa Differential Revision: D50178914 fbshipit-source-id: 3e910ef461e7ab19ece4c9d29704f1b27e00dde6 --- antlir/bzl/build_defs.bzl | 1 + antlir/vm/bzl/defs.bzl | 10 +--------- antlir/vm/tests/BUCK | 7 +++++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/antlir/bzl/build_defs.bzl b/antlir/bzl/build_defs.bzl index 3e6660b74f..83fedca362 100644 --- a/antlir/bzl/build_defs.bzl +++ b/antlir/bzl/build_defs.bzl @@ -166,6 +166,7 @@ _PYTHON_UNITTEST_KWARGS = _make_rule_kwargs_dict( "tags", "visibility", "supports_static_listing", + "remote_execution", ], ) diff --git a/antlir/vm/bzl/defs.bzl b/antlir/vm/bzl/defs.bzl index 5c58f45e0d..9559861025 100644 --- a/antlir/vm/bzl/defs.bzl +++ b/antlir/vm/bzl/defs.bzl @@ -58,8 +58,6 @@ with the options allowed there. The key differences with load("@bazel_skylib//lib:new_sets.bzl", "sets") load("@bazel_skylib//lib:shell.bzl", "shell") -load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") -load("@fbsource//tools/build_defs/buck2:is_buck2.bzl", "is_buck2") load("//antlir/bzl:build_defs.bzl", "add_test_framework_label", "buck_sh_test", "cpp_unittest", "python_unittest", "rust_unittest") load("//antlir/bzl:constants.bzl", "REPO_CFG") load("//antlir/bzl:image_unittest_helpers.bzl", helpers = "image_unittest_helpers") @@ -196,12 +194,6 @@ def _vm_unittest( vm_opts = vm_opts, ) - # NOTE: We could put this code in buck_sh_test itself, but that has much wider impact. - # It's safer to start off just doing a local change for antlir. - re_attrs = {} - if is_buck2(): - re_test_utils.set_re_info(re_attrs, wrapper_labels) - # FIXME: We use a bunch of genrules to generate trampoline scripts that # don't specify their runtime dependencies (because they can't: # https://fburl.com/workplace/ljtl2dv3) To support remote execution of @@ -249,7 +241,7 @@ def _vm_unittest( env = {"BUCK_BASE_BINARY": "$(location :{})".format(actual_test_binary)}, antlir_rule = "user-facing", deps = deps, - **re_attrs + remote_execution = kwargs["remote_execution"] if "remote_execution" in kwargs else None, ) def _vm_cpp_unittest( diff --git a/antlir/vm/tests/BUCK b/antlir/vm/tests/BUCK index a19621e816..8c228114fd 100644 --- a/antlir/vm/tests/BUCK +++ b/antlir/vm/tests/BUCK @@ -1,3 +1,4 @@ +load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils") load("//antlir/antlir2/bzl/feature:defs.bzl", antlir2_feature = "feature") load("//antlir/antlir2/bzl/image:defs.bzl", antlir2_image = "image") load("//antlir/antlir2/bzl/package:defs.bzl", antlir2_package = "package") @@ -263,11 +264,13 @@ vm.python_unittest( "test_vm_boot.py", ], labels = [ - "supports_remote_execution", - 're_opts_capabilities={"platform":"mtia", "codename":"freya"}', # FIXME(@pdel): Need some more work to get RE test execution for antlir1 vmtests. "disabled", ], + remote_execution = re_test_utils.remote_execution( + codename = "freya", + platform = "mtia", + ), vm_opts = vm.types.opts.new( disk = vm.types.disk.root( layer = ":vmtest-custom-layer",