vdev/commands/integration/test.rs
1use anyhow::Result;
2use clap::Args;
3
4use crate::testing::integration::ComposeTestLocalConfig;
5
6/// Execute integration tests
7///
8/// If an environment is named, it is used to run the test. If the environment was not previously started,
9/// it is started before the test is run and stopped afterwards.
10///
11/// If no environment is named, but one has been started already, that environment is used for the test.
12///
13/// Otherwise, all environments are started, the test run, and then stopped, one by one.
14#[derive(Args, Debug)]
15#[command()]
16pub struct Cli {
17 /// The desired integration
18 integration: String,
19
20 /// The desired environment (optional)
21 environment: Option<String>,
22
23 /// Whether to compile the test runner with all integration test features
24 #[arg(short = 'a', long)]
25 build_all: bool,
26
27 /// Reuse existing test runner image instead of rebuilding (useful in CI)
28 #[arg(long)]
29 reuse_image: bool,
30
31 /// Number of retries to allow on each integration test case.
32 #[arg(short = 'r', long)]
33 retries: Option<u8>,
34
35 /// Extra test command arguments
36 args: Vec<String>,
37}
38
39impl Cli {
40 pub fn exec(self) -> Result<()> {
41 crate::commands::compose_tests::test::exec(
42 ComposeTestLocalConfig::integration(),
43 &self.integration,
44 self.environment.as_ref(),
45 self.build_all,
46 self.reuse_image,
47 self.retries.unwrap_or_default(),
48 &self.args,
49 )
50 }
51}