vdev/commands/e2e/
test.rs

1use anyhow::Result;
2use clap::Args;
3
4use crate::testing::integration::ComposeTestLocalConfig;
5
6/// Execute end-to-end 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 e2e test
18    e2e_test: String,
19
20    /// The desired environment (optional)
21    environment: Option<String>,
22
23    /// Number of retries to allow on each integration test case.
24    #[arg(short = 'r', long)]
25    retries: Option<u8>,
26
27    /// Extra test command arguments
28    args: Vec<String>,
29}
30
31impl Cli {
32    pub fn exec(self) -> Result<()> {
33        crate::commands::compose_tests::test::exec(
34            ComposeTestLocalConfig::e2e(),
35            &self.e2e_test,
36            self.environment.as_ref(),
37            self.retries.unwrap_or_default(),
38            &self.args,
39        )
40    }
41}