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 nextest_profile: NextestProfile,
91        pub repetitions: std::num::NonZeroU64,
92        pub done: WriteVar<SideEffect>,
93    }
94}
95
96new_simple_flow_node!(struct Node);
97
98impl SimpleFlowNode for Node {
99    type Request = Params;
100
101    fn imports(ctx: &mut ImportCtx<'_>) {
102        ctx.import::<crate::download_vmm_tests_built_artifacts::Node>();
103        ctx.import::<crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Node>();
104    }
105
106    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
107        let Params {
108            label,
109            profile,
110            nextest_profile,
111            repetitions,
112            done,
113        } = request;
114
115        let VmmTestsParameters {
116            target,
117            nextest_filter_expr,
118            built_artifacts,
119            built_artifacts_write,
120            downloaded_artifacts,
121            prep_steps_variants,
122            external_deps,
123        } = profile.parameters(ctx);
124
125        ctx.req(crate::download_vmm_tests_built_artifacts::Request {
126            built_artifacts_write,
127        });
128
129        ctx.req(
130            crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Params {
131                junit_test_label: format!("{label}-vmm-tests"),
132                target: target.as_triple(),
133                nextest_profile,
134                nextest_filter_expr: Some(nextest_filter_expr),
135                test_content_config: TestContentConfig::Uninitialized {
136                    test_content_dir: None,
137                    built_artifacts,
138                    prebuilt_artifacts: VmmTestsPreBuiltArtifactsSelections {
139                        // TODO: figure out which are actually needed
140                        test_linux_initrd_x64: true,
141                        test_linux_kernel_x64: true,
142                        test_linux_initrd_aarch64: true,
143                        test_linux_kernel_aarch64: true,
144                        test_linux_kernel_cca_aarch64: true,
145                        test_linux_bzimage_x64: true,
146                        uefi_x64: true,
147                        uefi_aarch64: false,
148                        qemu_system_aarch64_linux_x64: false,
149                    },
150                    uefi_firmware_flavor: None,
151                    needs_virtio_win_drivers: true,
152                    needs_release_igvm: true,
153                },
154                downloaded_artifacts,
155                prep_steps_variants,
156                external_deps,
157                upload_logs_on_success: false,
158                fail_job_on_test_fail: true,
159                repetitions,
160                // TODO
161                petri_params: PetriParams {
162                    disable_remote_artifacts: true,
163                    reuse_prepped_vhds: false,
164                    require_2mb_hugetlb: false,
165                },
166                test_content_dir_as_repo_root: false,
167                done,
168            },
169        );
170
171        Ok(())
172    }
173}