Skip to main content

flowey_lib_hvlite/_jobs/
local_run_nextest_vmm_tests.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! A local-only job that runs the VMM tests out of a directory populated
5//! by local_build_and_run_nextest_vmm_tests with the build_only option.
6
7use crate::_jobs::consume_and_test_nextest_vmm_tests_archive::TestContentConfig;
8use crate::_jobs::local_build_and_run_nextest_vmm_tests::build_test_label;
9use crate::_jobs::local_build_and_run_nextest_vmm_tests::init_artifacts_dir;
10use crate::build_incubator::IncubatorProfileNameOrPath;
11use crate::common::CommonTriple;
12use crate::init_vmm_tests_env::PetriParams;
13use crate::install_vmm_tests_external_deps::VmmTestsExternalDeps;
14use flowey::node::prelude::*;
15use std::num::NonZeroU64;
16use vmm_test_images::KnownTestArtifacts;
17
18flowey_request! {
19    pub struct Params {
20        pub target: CommonTriple,
21
22        /// Test content dir with all artifacts and repo root
23        pub test_content_dir: PathBuf,
24
25        // Subset of `VmmTestSelections`
26        pub filter: String,
27        pub downloaded_artifacts: Vec<KnownTestArtifacts>,
28        pub external_deps: VmmTestsExternalDeps,
29        pub prep_steps_variants: Vec<String>,
30        pub needs_test_igvm_agent_rpc_server: bool,
31
32        /// Skip the interactive VHD download prompt
33        pub skip_vhd_prompt: bool,
34
35        pub nextest_profile: crate::run_cargo_nextest_run::NextestProfile,
36
37        pub petri_params: PetriParams,
38
39        pub repetitions: NonZeroU64,
40
41        /// Optional: incubator profile path. When set, tests run inside
42        /// an emulated VM instead of on the host.
43        pub incubator_profile: Option<IncubatorProfileNameOrPath>,
44
45        pub done: WriteVar<SideEffect>,
46    }
47}
48
49new_simple_flow_node!(struct Node);
50
51impl SimpleFlowNode for Node {
52    type Request = Params;
53
54    fn imports(ctx: &mut ImportCtx<'_>) {
55        ctx.import::<crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Node>();
56        ctx.import::<crate::download_openvmm_vmm_tests_artifacts::Node>();
57    }
58
59    fn process_request(request: Self::Request, ctx: &mut NodeCtx<'_>) -> anyhow::Result<()> {
60        let Params {
61            target,
62            test_content_dir,
63            filter,
64            downloaded_artifacts,
65            external_deps,
66            prep_steps_variants,
67            needs_test_igvm_agent_rpc_server,
68            skip_vhd_prompt,
69            nextest_profile,
70            petri_params,
71            repetitions,
72            incubator_profile,
73            done,
74        } = request;
75
76        let test_content_dir = test_content_dir.absolute()?;
77
78        let target_triple = target.as_triple();
79        let test_label = build_test_label(&target_triple);
80
81        init_artifacts_dir(ctx, &test_content_dir, skip_vhd_prompt)?;
82
83        ctx.req(
84            crate::_jobs::consume_and_test_nextest_vmm_tests_archive::Params {
85                junit_test_label: test_label,
86                target: target_triple,
87                nextest_profile,
88                nextest_filter_expr: Some(filter),
89                test_content_config: TestContentConfig::Initialized {
90                    test_content_dir: ReadVar::from_static(test_content_dir),
91                    needs_test_igvm_agent_rpc_server,
92                },
93                downloaded_artifacts,
94                prep_steps_variants,
95                external_deps,
96                incubator_profile,
97                upload_logs_on_success: true,
98                fail_job_on_test_fail: true,
99                repetitions,
100                petri_params,
101                test_content_dir_as_repo_root: true,
102                done,
103            },
104        );
105
106        Ok(())
107    }
108}