Skip to content

Commit

Permalink
[antlir][oss] fix/disable more tests and enable those that work (#236)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #236

We don't have centos8 in OSS and it's not worth adding.
We don't yet have buckified gtest.
Buck binaries are built against the system platform which then conflicts with
the system platform installed in the image (this would be a good use case for
epilatow's antlir2 toolchain stuff)

Enable a lot of other tests that should work.

Test Plan: https://github.com/facebookincubator/antlir/actions/runs/9079202977/job/24947904836?pr=236

Reviewed By: sergeyfd

Differential Revision: D57311394

fbshipit-source-id: 2dca30d2a04db515dde62d8c19f9c8d52e7cd0b7
  • Loading branch information
vmagro authored and facebook-github-bot committed May 14, 2024
1 parent 530cda0 commit 59e7aad
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 16 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: facebook/install-dotslash@latest
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu
- name: BTRFS-ify antlir2-out
run: |
mkdir antlir2-out
Expand All @@ -34,12 +34,14 @@ jobs:
- name: Find tests
run: |
./buck2 uquery 'kind(".*_test", set(%s)) - attrfilter(labels, disabled, set(%s))' \
//antlir/antlir2/antlir2_facts/... \
//antlir/antlir2/features/clone/tests: \
//antlir/antlir2/features/install/tests: \
//antlir/antlir2/features/rpm/tests: \
//antlir/antlir2/features/tarball/tests: \
./buck2 bxl :find_tests.bxl:find_tests -- \
--pattern //antlir/antlir2/antlir2_facts/... \
--pattern //antlir/antlir2/features/... \
--pattern //antlir/antlir2/test_images/... \
--disable //antlir/antlir2/test_images/cfg/os/... \
--disable //antlir/antlir2/test_images/cfg/target_arch/... \
--disable //antlir/antlir2/test_images/package/ext3/... \
--disable //antlir/antlir2/test_images/package/xar/... \
| tee ${{ runner.temp }}/tests.txt
- name: Build tests
Expand Down
15 changes: 12 additions & 3 deletions antlir/antlir2/features/dot_meta/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("//antlir/antlir2/bzl/image:defs.bzl", "image")
load("//antlir/antlir2/bzl/package:defs.bzl", "package")
load("//antlir/antlir2/features/dot_meta:dot_meta.bzl", "dot_meta")
load("//antlir/antlir2/testing:image_diff_test.bzl", "image_diff_test")
load("//antlir/bzl:build_defs.bzl", "buck_sh_test")
load("//antlir/bzl:build_defs.bzl", "buck_sh_test", "internal_external")

# Normally, the `dot_meta` feature is included only when packaging up a final
# layer, but we want to make it easier to test with image_diff_test, so these
Expand Down Expand Up @@ -31,7 +31,10 @@ image.layer(

image_diff_test(
name = "dot_meta-test",
diff = "dot_meta.toml",
diff = internal_external(
fb = "dot_meta.toml",
oss = "dot_meta.oss.toml",
),
diff_type = "file",
layer = ":dot_meta",
)
Expand All @@ -47,6 +50,12 @@ package.cpio_gz(

buck_sh_test(
name = "cpio-is-stamped",
args = ["$(location :stamped.cpio.gz)"],
args = [
"$(location :stamped.cpio.gz)",
internal_external(
fb = "fbcode//antlir/antlir2/features/dot_meta/tests:stamped.cpio.gz",
oss = "antlir//antlir/antlir2/features/dot_meta/tests:stamped.cpio.gz",
),
],
test = "test-cpio-is-stamped.sh",
)
35 changes: 35 additions & 0 deletions antlir/antlir2/features/dot_meta/tests/dot_meta.oss.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[file.".meta/package"]
op = "added"

[file.".meta/package".diff]
mode = "u+rw,g+r,o+r"
file-type = "regular-file"
user = "root"
group = "root"
text = """
foo:bar
"""

[file.".meta/revision"]
op = "added"

[file.".meta/revision".diff]
mode = "u+rw,g+r,o+r"
file-type = "regular-file"
user = "root"
group = "root"
text = """
deadbeef
"""

[file.".meta/target"]
op = "diff"

[file.".meta/target".diff]
text-patch = """
--- parent
+++ child
@@ -1 +1 @@
-antlir//antlir/antlir2/features/dot_meta/tests:base
+antlir//antlir/antlir2/features/dot_meta/tests:dot_meta
"""
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
# LICENSE file in the root directory of this source tree.

set -e

target="$(zcat "$1" | cpio -i --to-stdout .meta/target)"
if [ "$target" != "fbcode//antlir/antlir2/features/dot_meta/tests:stamped.cpio.gz" ]; then
expected="$2"
if [ "$target" != "$expected" ]; then
echo "bad target: $target"
echo "expected: $expected"
exit 1
fi
10 changes: 9 additions & 1 deletion antlir/antlir2/features/extract/tests/BUCK
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//antlir/antlir2/bzl/feature:defs.bzl", "feature")
load("//antlir/antlir2/bzl/image:defs.bzl", "image")
load("//antlir/antlir2/testing:image_test.bzl", "image_sh_test")
load("//antlir/bzl:build_defs.bzl", "rust_binary")
load("//antlir/bzl:build_defs.bzl", "internal_external", "rust_binary")

oncall("antlir")

Expand Down Expand Up @@ -36,11 +36,19 @@ image.layer(
dst = "/usr/bin/test-binary-extracted",
),
],
labels = internal_external(
fb = [],
oss = ["disabled"],
),
parent_layer = ":base",
)

image_sh_test(
name = "extract-buck-test",
labels = internal_external(
fb = [],
oss = ["disabled"],
),
layer = ":extract-buck",
test = "test-extract-buck.sh",
)
Expand Down
6 changes: 4 additions & 2 deletions antlir/antlir2/features/genrule/tests/genrule-with-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ if [ -f "/is-facebook" ]; then
echo "not in repo" > /status
fi
else
if [ -f ".git" ]; then
if [ -d ".git" ]; then
echo "in repo" > /status
elif [ -f ".hg" ]; then
elif [ -d ".hg" ]; then
echo "in repo" > /status
elif [ -d ".sl" ]; then
echo "in repo" > /status
else
echo "not in repo" > /status
Expand Down
13 changes: 13 additions & 0 deletions antlir/antlir2/features/rpm/tests/centos8/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("//antlir/antlir2/bzl/image:defs.bzl", "image")
load("//antlir/antlir2/features/rpm/tests:defs.bzl", "expected_t", "test_rpms")
load("//antlir/antlir2/package_managers/dnf/rules:repo.bzl", "repo_set")
load("//antlir/antlir2/testing:image_test.bzl", "image_python_test")
load("//antlir/bzl:build_defs.bzl", "internal_external")

oncall("antlir")

Expand Down Expand Up @@ -33,17 +34,29 @@ test_rpms(
] + _RPM_DEPS_OF_TEST,
),
],
labels = internal_external(
fb = [],
oss = ["disabled"],
),
)

image.layer(
name = "simple",
features = [
feature.rpms_install(rpms = _RPM_DEPS_OF_TEST),
],
labels = internal_external(
fb = [],
oss = ["disabled"],
),
)

image_python_test(
name = "test-db-backend",
srcs = ["test_db_backend.py"],
labels = internal_external(
fb = [],
oss = ["disabled"],
),
layer = ":simple",
)
8 changes: 6 additions & 2 deletions antlir/antlir2/testing/image_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load("//antlir/antlir2/bzl:types.bzl", "LayerInfo")
load("//antlir/antlir2/bzl/feature:defs.bzl", "feature")
load("//antlir/antlir2/bzl/image:cfg.bzl", "cfg_attrs", "layer_cfg")
load("//antlir/antlir2/bzl/image:defs.bzl", "image")
load("//antlir/bzl:build_defs.bzl", "add_test_framework_label", "buck_sh_test", "cpp_unittest", "is_facebook", "python_unittest", "rust_unittest")
load("//antlir/bzl:build_defs.bzl", "add_test_framework_label", "buck_sh_test", "cpp_unittest", "internal_external", "is_facebook", "python_unittest", "rust_unittest")
load("//antlir/bzl:constants.bzl", "REPO_CFG")
load("//antlir/bzl:systemd.bzl", "systemd")
load("//antlir/bzl:oss_shim.bzl", "special_tags") # @oss-enable
Expand Down Expand Up @@ -253,7 +253,11 @@ image_cpp_test = partial(
_implicit_image_test,
cpp_unittest,
_static_list_wrapper = antlir2_dep("//antlir/antlir2/testing/image_test:static-list-cpp"),
_add_outer_labels = ["tpx:optout-test-result-output-spec"],
_add_outer_labels = ["tpx:optout-test-result-output-spec"] + internal_external(
fb = [],
# don't have working gtest in oss (yet)
oss = ["disabled"],
),
)

image_rust_test = partial(_implicit_image_test, rust_unittest)
Expand Down
20 changes: 20 additions & 0 deletions find_tests.bxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

def _impl(ctx):
tests = ctx.uquery().kind(".*_test", ctx.cli_args.pattern)

tests = tests - ctx.uquery().attrregexfilter("labels", "disabled", tests)
disable = ctx.unconfigured_targets([t for disable in ctx.cli_args.disable for t in disable])
tests = tests - disable
ctx.output.print("\n".join([str(t.label) for t in tests]))

find_tests = bxl_main(
impl = _impl,
cli_args = {
"disable": cli_args.list(cli_args.target_expr(), default = []),
"pattern": cli_args.list(cli_args.string(), default = ["antlir//..."]),
},
)

0 comments on commit 59e7aad

Please sign in to comment.