From 0438c03d7bc8e3c45662df1c4ad85becdd0c7a3b Mon Sep 17 00:00:00 2001 From: Vinnie Magro Date: Tue, 31 Oct 2023 11:14:51 -0700 Subject: [PATCH] [antlir2][os] simplify os tests with configured aliases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Dogfood my own features and use `select`, `configured_alias` etc to construct these test rpms Test Plan: ``` ❯ buck2 test fbcode//antlir/antlir2/test_images/cfg/os: Buck UI: https://www.internalfb.com/buck2/66a63a6a-34a0-4492-aa92-99b8a36c4b5b Test UI: https://www.internalfb.com/intern/testinfra/testrun/14355223820810065 Network: Up: 2.8MiB Down: 0B (reSessionID-e066f49f-c87a-4eb4-9fa8-966198a6c0ad) Jobs completed: 150110. Time elapsed: 1:57.0s. Cache hits: 0%. Commands: 234 (cached: 0, remote: 0, local: 234) Tests finished: Pass 36. Fail 0. Fatal 0. Skip 0. Build failure 0 ``` Reviewed By: epilatow Differential Revision: D50822257 fbshipit-source-id: 8e1e4ae60a1be269711b44ddf7568f916bddd3bd --- antlir/antlir2/test_images/cfg/os/BUCK | 95 +++++++++++++++++--------- 1 file changed, 61 insertions(+), 34 deletions(-) diff --git a/antlir/antlir2/test_images/cfg/os/BUCK b/antlir/antlir2/test_images/cfg/os/BUCK index 4f92948c392..a51c04ab7c1 100644 --- a/antlir/antlir2/test_images/cfg/os/BUCK +++ b/antlir/antlir2/test_images/cfg/os/BUCK @@ -1,3 +1,4 @@ +load("//antlir/antlir2/bzl:configured_alias.bzl", "antlir2_configured_alias") load("//antlir/antlir2/bzl/feature:defs.bzl", "feature") load("//antlir/antlir2/bzl/image:defs.bzl", "image") load("//antlir/antlir2/bzl/package:defs.bzl", "package") @@ -103,68 +104,94 @@ image.layer( # rpm installation based on flavor reconfiguration at every level of the # parent_layer chain. -all_rpms = [] - [ [ image.layer( - name = "rpm." + level + "." + f, + name = "rpm." + level, features = [ feature.install_text( dst = "/test_rpm_" + level, - text = f, + text = select({ + "//antlir/antlir2/os:centos8": "centos8", + "//antlir/antlir2/os:centos9": "centos9", + "//antlir/antlir2/os:eln": "eln", + "DEFAULT": "default", + }), ), ], visibility = [], ), package.rpm( - name = "rpm." + level + "." + f + "--package", + name = "rpm." + level + "--package", arch = "noarch", - layer = ":rpm." + level + "." + f, + layer = ":rpm." + level, license = "None", release = "1", - requires = requires, + requires = select({ + # Can't know what the exact version is, so do a >= on the major + # and < on major+1 to match things like 8.6 for c8 + "//antlir/antlir2/os:centos8": [ + "centos-stream-release >= 8", + "centos-stream-release < 9", + ], + "//antlir/antlir2/os:centos9": [ + "centos-stream-release >= 9", + "centos-stream-release < 10", + ], + "//antlir/antlir2/os:eln": [ + "fedora-release-eln", + ], + "DEFAULT": [], + }), rpm_name = "test-rpm-" + level, - version = f, + version = select({ + "//antlir/antlir2/os:centos8": "centos8", + "//antlir/antlir2/os:centos9": "centos9", + "//antlir/antlir2/os:eln": "eln", + "DEFAULT": "default", + }), visibility = [], ), rpm( - name = "test-rpm-" + level + "." + f, + name = "test-rpm-" + level, arch = "noarch", epoch = 0, release = "1", - rpm = ":rpm." + level + "." + f + "--package", + rpm = ":rpm." + level + "--package", rpm_name = "test-rpm-" + level, sha256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef", - version = f, + version = select({ + "//antlir/antlir2/os:centos8": "centos8", + "//antlir/antlir2/os:centos9": "centos9", + "//antlir/antlir2/os:eln": "eln", + "DEFAULT": "default", + }), visibility = [ ], ), - all_rpms.append(":test-rpm-" + level + "." + f), ] - for (f, requires) in [ - # Can't know what the exact version is, so do a >= on the major and < on - # major+1 to match things like 8.6 for c8 - ( - "centos8", - [ - "centos-stream-release >= 8", - "centos-stream-release < 9", - ], - ), - ( - "centos9", - [ - "centos-stream-release >= 9", - "centos-stream-release < 10", - ], - ), - ( - "eln", - [ - "fedora-release-eln", - ], + for level in [ + "root", + "intermediate", + "leaf", + ] +] + +all_rpms = [] + +[ + [ + antlir2_configured_alias( + name = "test-rpm-" + level + "." + os, + actual = ":test-rpm-" + level, + default_os = os, ), + all_rpms.append(":test-rpm-" + level + "." + os), + ] + for os in [ + "centos8", + "centos9", + "eln", ] for level in [ "root",