Skip to content

Commit 3266094

Browse files
tmt: Introduce skip_for_ostree
So we don't spawn VMs for tests like "composefs-gc" just to do nothing and exit Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent df41589 commit 3266094

5 files changed

Lines changed: 60 additions & 7 deletions

File tree

crates/xtask/src/tmt.rs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const FIELD_ADJUST: &str = "adjust";
2828
const FIELD_FIXME_SKIP_IF_COMPOSEFS: &str = "fixme_skip_if_composefs";
2929
const FIELD_FIXME_SKIP_IF_UKI: &str = "fixme_skip_if_uki";
3030

31+
/// For tests that should only run for composefs systems
32+
/// Ex. composefs-gc
33+
const FIELD_SKIP_IF_OSTREE: &str = "skip_if_ostree";
34+
3135
// bcvk options
3236
const BCVK_OPT_BIND_STORAGE_RO: &str = "--bind-storage-ro";
3337
const ENV_BOOTC_UPGRADE_IMAGE: &str = "BOOTC_upgrade_image";
@@ -210,10 +214,11 @@ fn verify_ssh_connectivity(sh: &Shell, port: u16, key_path: &Utf8Path) -> Result
210214
)
211215
}
212216

213-
#[derive(Debug)]
217+
#[derive(Debug, Default)]
214218
struct PlanMetadata {
215219
try_bind_storage: bool,
216220
skip_if_composefs: bool,
221+
skip_if_ostree: bool,
217222
skip_if_uki: bool,
218223
}
219224

@@ -255,8 +260,7 @@ fn parse_plan_metadata(
255260
.and_modify(|m| m.try_bind_storage = b)
256261
.or_insert(PlanMetadata {
257262
try_bind_storage: b,
258-
skip_if_uki: false,
259-
skip_if_composefs: false,
263+
..Default::default()
260264
});
261265
}
262266
}
@@ -271,8 +275,7 @@ fn parse_plan_metadata(
271275
.and_modify(|m| m.skip_if_composefs = b)
272276
.or_insert(PlanMetadata {
273277
skip_if_composefs: b,
274-
skip_if_uki: false,
275-
try_bind_storage: false,
278+
..Default::default()
276279
});
277280
}
278281
}
@@ -287,8 +290,22 @@ fn parse_plan_metadata(
287290
.and_modify(|m| m.skip_if_uki = b)
288291
.or_insert(PlanMetadata {
289292
skip_if_uki: b,
290-
skip_if_composefs: false,
291-
try_bind_storage: false,
293+
..Default::default()
294+
});
295+
}
296+
}
297+
298+
if let Some(skip_if_ostree) = plan_data.get(&serde_yaml::Value::String(format!(
299+
"extra-{}",
300+
FIELD_SKIP_IF_OSTREE
301+
))) {
302+
if let Some(b) = skip_if_ostree.as_bool() {
303+
plan_metadata
304+
.entry(plan_name.to_string())
305+
.and_modify(|m| m.skip_if_ostree = b)
306+
.or_insert(PlanMetadata {
307+
skip_if_ostree: b,
308+
..Default::default()
292309
});
293310
}
294311
}
@@ -602,6 +619,14 @@ pub(crate) fn run_tmt(sh: &Shell, args: &RunTmtArgs) -> Result<()> {
602619
.map(|(_, v)| v.skip_if_composefs)
603620
.unwrap_or(false)
604621
});
622+
} else {
623+
plans.retain(|plan| {
624+
!plan_metadata
625+
.iter()
626+
.find(|(key, _)| plan.ends_with(key.as_str()))
627+
.map(|(_, v)| v.skip_if_ostree)
628+
.unwrap_or(false)
629+
});
605630
}
606631

607632
if matches!(args.boot_type, crate::BootType::Uki) {
@@ -1068,6 +1093,8 @@ struct TestDef {
10681093
try_bind_storage: bool,
10691094
/// Whether to skip this test for composefs backend
10701095
skip_if_composefs: bool,
1096+
/// Whether to skip this test for ostree backend
1097+
skip_if_ostree: bool,
10711098
/// Whether to skip this test for images with UKI
10721099
skip_if_uki: bool,
10731100
/// TMT fmf attributes to pass through (summary, duration, adjust, etc.)
@@ -1239,6 +1266,13 @@ fn generate_integration() -> Result<(String, String)> {
12391266
.and_then(|v| v.as_bool())
12401267
.unwrap_or(false);
12411268

1269+
let skip_if_ostree = metadata
1270+
.extra
1271+
.as_mapping()
1272+
.and_then(|m| m.get(&serde_yaml::Value::String(FIELD_SKIP_IF_OSTREE.to_string())))
1273+
.and_then(|v| v.as_bool())
1274+
.unwrap_or(false);
1275+
12421276
let skip_if_uki = metadata
12431277
.extra
12441278
.as_mapping()
@@ -1256,6 +1290,7 @@ fn generate_integration() -> Result<(String, String)> {
12561290
test_command,
12571291
try_bind_storage,
12581292
skip_if_composefs,
1293+
skip_if_ostree,
12591294
skip_if_uki,
12601295
tmt: metadata.tmt,
12611296
});
@@ -1379,6 +1414,13 @@ fn generate_integration() -> Result<(String, String)> {
13791414
);
13801415
}
13811416

1417+
if test.skip_if_ostree {
1418+
plan_value.insert(
1419+
serde_yaml::Value::String(format!("extra-{}", FIELD_SKIP_IF_OSTREE)),
1420+
serde_yaml::Value::Bool(true),
1421+
);
1422+
}
1423+
13821424
if test.skip_if_uki {
13831425
plan_value.insert(
13841426
serde_yaml::Value::String(format!("extra-{}", FIELD_FIXME_SKIP_IF_UKI)),

tmt/plans/integration.fmf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ execute:
196196
how: fmf
197197
test:
198198
- /tmt/tests/tests/test-35-composefs-gc
199+
extra-skip_if_ostree: true
200+
extra-fixme_skip_if_uki: true
199201

200202
/plan-35-upgrade-preflight-disk-check:
201203
summary: Verify pre-flight disk space check rejects images with inflated layer sizes
@@ -254,6 +256,7 @@ execute:
254256
how: fmf
255257
test:
256258
- /tmt/tests/tests/test-41-composefs-gc-uki
259+
extra-skip_if_ostree: true
257260

258261
/plan-42-loader-entries-source:
259262
summary: Test bootc loader-entries set-options-for-source
@@ -269,4 +272,5 @@ execute:
269272
how: fmf
270273
test:
271274
- /tmt/tests/tests/test-43-switch-same-digest
275+
extra-skip_if_ostree: true
272276
# END GENERATED PLANS

tmt/tests/booted/test-composefs-gc-uki.nu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# tmt:
33
# summary: Test composefs garbage collection for UKI
44
# duration: 30m
5+
# extra:
6+
# skip_if_ostree: true
57

68
use std assert
79
use tap.nu

tmt/tests/booted/test-composefs-gc.nu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# tmt:
33
# summary: Test composefs garbage collection with same and different kernel+initrd
44
# duration: 30m
5+
# extra:
6+
# skip_if_ostree: true
7+
# fixme_skip_if_uki: true
58

69
use std assert
710
use tap.nu

tmt/tests/booted/test-switch-same-digest.nu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# tmt:
33
# summary: Error on bootc switch to image with identical fs-verity digest
44
# duration: 10m
5+
# extra:
6+
# skip_if_ostree: true
57
#
68
# Verify that `bootc switch` errors out when the target image produces the
79
# same composefs fs-verity digest as an existing deployment. The simplest

0 commit comments

Comments
 (0)