Skip to main content

flowey_lib_hvlite/_jobs/
download_and_run_nextest_vmm_tests.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Download pre-built artifacts and run cargo-nextest based VMM tests.
5//
6// Unfortunately, this follows a different pattern than the normal VMM tests
7// flow where VmmTestsBuiltArtifacts is constructed at the pipeline level.
8// This is necessary because flowey does not yet support dependencies within
9// a job.
10// TODO: unify these two paths for running VMM tests in CI.
11
12use crate::_jobs::consume_and_test_nextest_vmm_tests_archive::TestContentConfig;
13use crate::common::CommonTriple;
14use crate::init_vmm_tests_content_dir::VmmTestsBuiltArtifacts;
15use crate::init_vmm_tests_content_dir::VmmTestsBuiltArtifactsWrite;
16use crate::init_vmm_tests_content_dir::VmmTestsPreBuiltArtifactsSelections;
17use crate::init_vmm_tests_content_dir::vmm_tests_artifact_builders::VmmTestsArtifactsBuilderWindowsX86;
18use crate::init_vmm_tests_env::PetriParams;
19use crate::install_vmm_tests_external_deps::VmmTestsExternalDeps;
20use crate::install_vmm_tests_external_deps::VmmTestsExternalDepsWindows;
21use crate::run_cargo_nextest_run::NextestProfile;
22use flowey::node::prelude::*;
23use petri_artifacts_vmm_test::ErasedVmmTestImage;
24use petri_artifacts_vmm_test::artifacts::test_iso;
25use petri_artifacts_vmm_test::artifacts::test_vhd;
26use petri_artifacts_vmm_test::artifacts::test_vmgs;
27
28#[derive(Serialize, Deserialize)]
29pub enum VmmTestsProfile {
30    X64WindowsAll,
31}
32
33struct VmmTestsParameters {
34    target: CommonTriple,
35    nextest_filter_expr: String,
36    built_artifacts: VmmTestsBuiltArtifacts,
37    built_artifacts_write: VmmTestsBuiltArtifactsWrite,
38    downloaded_artifacts: Vec<ErasedVmmTestImage>,
39    prep_steps_variants: Vec<String>,
40    external_deps: VmmTestsExternalDeps,
41}
42
43impl VmmTestsProfile {
44    fn parameters(&self, ctx: &mut NodeCtx<'_>) -> VmmTestsParameters {
45        match self {
46            VmmTestsProfile::X64WindowsAll => {
47                let (built_artifacts, built_artifacts_write) =
48                    VmmTestsArtifactsBuilderWindowsX86::selections().new_var_set(ctx);
49                let mut nextest_filter_expr = "all()".to_string();
50                // self-hosted runners don't have HvlDeviceHost installed
51                // TODO: configure runners and remove this exclusion
52                nextest_filter_expr.push_str(" & !test(storvsp_nvme_hyperv)");
53                // self-hosted runners don't have a Hyper-V switch configured
54                // TODO: configure runners and remove this exclusion
55                nextest_filter_expr.push_str(" & !test(dio_nic)");
56
57                VmmTestsParameters {
58                    target: CommonTriple::X86_64_WINDOWS_MSVC,
59                    nextest_filter_expr,
60                    built_artifacts,
61                    built_artifacts_write,
62                    downloaded_artifacts: vec![
63                        test_vhd::ALPINE_3_23_X64.into(),
64                        test_vhd::FREE_BSD_13_2_X64.into(),
65                        test_iso::FREE_BSD_13_2_X64.into(),
66                        test_vhd::GEN1_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
67                        test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2022_X64.into(),
68                        test_vhd::GEN2_WINDOWS_DATA_CENTER_CORE2025_X64.into(),
69                        test_vhd::UBUNTU_2404_SERVER_X64.into(),
70                        test_vhd::UBUNTU_2504_SERVER_X64.into(),
71                        test_vmgs::VMGS_WITH_BOOT_ENTRY.into(),
72                        test_vmgs::VMGS_WITH_16K_TPM.into(),
73                    ],
74                    prep_steps_variants: vec!["standard".into(), "no-vmbus".into()],
75                    external_deps: VmmTestsExternalDeps::Windows(VmmTestsExternalDepsWindows {
76                        hyperv: true,
77                        whp: true,
78                        hardware_isolation: true,
79                    }),
80                }
81            }
82        }
83    }
84}
85
86flowey_request! {
87    pub struct Params {
88        pub label: String,
89        pub profile: VmmTestsProfile,
90        pub repetitions: std::num::NonZeroU64,
91        pub done: WriteVar<SideEffect>,
92    }
93}
94
95new_simple_flow_node!(struct Node);
96
97impl SimpleFlowNode for Node {
98    type Request = Params;
99
100    fn imports(ctx: &mut ImportCtx<'_>) {
101        ctx.import::<crate::download_vmm_tests_built_artifacts::Node>();
102        ctx.import::<crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Node>();
103    }
104
105    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
106        let Params {
107            label,
108            profile,
109            repetitions,
110            done,
111        } = request;
112
113        let VmmTestsParameters {
114            target,
115            nextest_filter_expr,
116            built_artifacts,
117            built_artifacts_write,
118            downloaded_artifacts,
119            prep_steps_variants,
120            external_deps,
121        } = profile.parameters(ctx);
122
123        ctx.req(crate::download_vmm_tests_built_artifacts::Request {
124            built_artifacts_write,
125        });
126
127        ctx.req(
128            crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Params {
129                junit_test_label: format!("{label}-vmm-tests"),
130                target: target.as_triple(),
131                nextest_profile: NextestProfile::Ci,
132                nextest_filter_expr: Some(nextest_filter_expr),
133                test_content_config: TestContentConfig::Uninitialized {
134                    test_content_dir: None,
135                    built_artifacts,
136                    prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
137                        // TODO: figure out which are actually needed
138                        test_linux_initrd_x64: true,
139                        test_linux_kernel_x64: true,
140                        test_linux_initrd_aarch64: true,
141                        test_linux_kernel_aarch64: true,
142                        test_linux_kernel_cca_aarch64: true,
143                        test_linux_bzimage_x64: true,
144                        uefi_x64: true,
145                        uefi_aarch64: false,
146                        qemu_system_aarch64_linux_x64: false,
147                    },
148                    uefi_firmware_flavor: None,
149                    needs_virtio_win_drivers: true,
150                    needs_release_igvm: true,
151                },
152                downloaded_artifacts,
153                prep_steps_variants,
154                external_deps,
155                upload_logs_on_success: false,
156                fail_job_on_test_fail: true,
157                repetitions,
158                // TODO
159                petri_params: PetriParams {
160                    disable_remote_artifacts: true,
161                    reuse_prepped_vhds: false,
162                    require_2mb_hugetlb: false,
163                },
164                test_content_dir_as_repo_root: false,
165                done,
166            },
167        );
168
169        Ok(())
170    }
171}