Skip to content

Commit

Permalink
[antlir2][os] simplify os tests with configured aliases
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vmagro authored and facebook-github-bot committed Oct 31, 2023
1 parent 183c5f6 commit 0438c03
Showing 1 changed file with 61 additions and 34 deletions.
95 changes: 61 additions & 34 deletions antlir/antlir2/test_images/cfg/os/BUCK
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 0438c03

Please sign in to comment.