1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

integration test command

This commit is contained in:
Robin Appelman 2021-07-02 19:36:04 +02:00
commit 2fc3e5ed93
4 changed files with 39 additions and 1 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh
cd $WEBROOT/build/integration
sudo -u www-data ./run.sh "$@"
./run.sh "$@"

View file

@ -45,6 +45,10 @@ pub enum HazeArgs {
Fmt {
path: String,
},
Integration {
options: CloudOptions,
args: Vec<String>,
},
}
#[derive(Debug, Clone, Eq, PartialEq)]
@ -103,6 +107,12 @@ impl HazeArgs {
let args = args.map(S::into).collect();
Ok(HazeArgs::Test { options, args })
}
HazeCommand::Integration => {
let mut args = args.peekable();
let options = CloudOptions::parse(&mut args)?;
let args = args.map(S::into).collect();
Ok(HazeArgs::Integration { options, args })
}
HazeCommand::Exec => {
let mut args = args.peekable();
@ -171,6 +181,7 @@ pub enum HazeCommand {
Logs,
Open,
Fmt,
Integration,
}
impl FromStr for HazeCommand {
@ -190,6 +201,7 @@ impl FromStr for HazeCommand {
"open" => Ok(HazeCommand::Open),
"fmt" => Ok(HazeCommand::Fmt),
"format" => Ok(HazeCommand::Fmt),
"integration" => Ok(HazeCommand::Integration),
_ => Err(Report::msg(format!("Unknown command: {}", s))),
}
}
@ -209,6 +221,7 @@ impl HazeCommand {
HazeCommand::Logs => true,
HazeCommand::Open => true,
HazeCommand::Fmt => false,
HazeCommand::Integration => false,
}
}
}

View file

@ -108,6 +108,7 @@ pub async fn exec<S1: AsRef<str>, S2: Into<String>>(
attach_stdout: Some(true),
attach_stderr: Some(true),
env: Some(env),
tty: Some(true),
..Default::default()
};
let message = docker

View file

@ -214,6 +214,30 @@ async fn main() -> Result<()> {
cloud.exec(&mut docker, args, false).await?;
cloud.destroy(&mut docker).await?;
}
HazeArgs::Integration { options, mut args } => {
let cloud = Cloud::create(&mut docker, options, &config).await?;
println!("Waiting for servers to start");
cloud.wait_for_start(&mut docker).await?;
println!("Installing");
if let Err(e) = cloud
.exec(
&mut docker,
vec![
"install",
&config.auto_setup.username,
&config.auto_setup.password,
],
false,
)
.await
{
cloud.destroy(&mut docker).await?;
return Err(e);
}
args.insert(0, "integration".to_string());
cloud.exec(&mut docker, args, false).await?;
cloud.destroy(&mut docker).await?;
}
HazeArgs::Fmt { path } => {
let cloud = Cloud::create(&mut docker, CloudOptions::default(), &config).await?;
let mut out_buffer = Vec::<u8>::with_capacity(1024);