feat: use actual values test sutie containers
This commit is contained in:
parent
cccbbba24d
commit
67f9d5f7cf
1 changed files with 21 additions and 13 deletions
|
@ -5,13 +5,11 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use tokio::sync::mpsc::{self, Receiver};
|
||||
use url::Url;
|
||||
|
||||
use super::results::*;
|
||||
use crate::complaince::result::Result as CResult;
|
||||
use crate::complaince::suite::Suite;
|
||||
use crate::docker::Docker;
|
||||
use crate::docker::DockerLike;
|
||||
use crate::utils::get_random;
|
||||
|
||||
pub struct SuiteRunnerState {
|
||||
suite: Suite,
|
||||
|
@ -25,22 +23,31 @@ pub struct TestRunnerState {
|
|||
|
||||
impl SuiteRunnerState {
|
||||
pub async fn run(
|
||||
container_host: &Url,
|
||||
suite: &crate::complaince::suite::Suite,
|
||||
auth: &str,
|
||||
ctx: &crate::ctx::ArcCtx,
|
||||
) -> ArchivableSuiteResult {
|
||||
let state = Self::launch_suite(suite, &ctx);
|
||||
let state = Self::launch_suite(container_host, suite, auth, &ctx);
|
||||
state.collect_results(&ctx).await
|
||||
}
|
||||
|
||||
fn launch_suite(suite: &crate::complaince::suite::Suite, ctx: &crate::ctx::ArcCtx) -> Self {
|
||||
fn launch_suite(
|
||||
container_host: &Url,
|
||||
suite: &crate::complaince::suite::Suite,
|
||||
auth: &str,
|
||||
ctx: &crate::ctx::ArcCtx,
|
||||
) -> Self {
|
||||
let mut tests = HashMap::with_capacity(suite.tests.len());
|
||||
for test in suite.tests.iter() {
|
||||
let mut env = HashMap::new();
|
||||
let auth = get_random(32);
|
||||
env.insert("FTEST_AUTH".into(), auth.clone());
|
||||
env.insert("FTEST_HOST".into(), get_random(32));
|
||||
env.insert("FTEST_TARGET_HOST".into(), get_random(32));
|
||||
env.insert("FTEST_USER".into(), get_random(32));
|
||||
env.insert("FTEST_AUTH".into(), auth.to_owned());
|
||||
env.insert(
|
||||
"FTEST_HOST".into(),
|
||||
format!("http://ftest:{}", ctx.settings.server.port),
|
||||
);
|
||||
env.insert("FTEST_TARGET_HOST".into(), container_host.to_string());
|
||||
env.insert("FTEST_USER".into(), "alice".into());
|
||||
if let Some(custom_vars) = test.env_vars.clone() {
|
||||
env.extend(custom_vars);
|
||||
}
|
||||
|
@ -58,10 +65,10 @@ impl SuiteRunnerState {
|
|||
let (tx, rx) = mpsc::channel(1);
|
||||
{
|
||||
let mut w = ctx.results.write().unwrap();
|
||||
w.insert(auth.clone(), tx);
|
||||
w.insert(auth.to_owned(), tx);
|
||||
}
|
||||
tests.insert(
|
||||
auth.clone(),
|
||||
auth.to_owned(),
|
||||
TestRunnerState {
|
||||
container_name: name,
|
||||
rx,
|
||||
|
@ -186,6 +193,7 @@ mod tests {
|
|||
#[actix_rt::test]
|
||||
async fn suite_runner_works() {
|
||||
const LOGS: &str = "SUITE RUNNER LOG STRING";
|
||||
const AUTH: &str = "asdfasdfasdfadsf";
|
||||
|
||||
let settings = Settings::new().unwrap();
|
||||
let ctx = Ctx::new(settings.clone()).await;
|
||||
|
@ -216,7 +224,7 @@ mod tests {
|
|||
tests: vec![dummy_test.clone(), dummy_test2.clone()],
|
||||
};
|
||||
|
||||
let state = SuiteRunnerState::launch_suite(&suite, &ctx);
|
||||
let state = SuiteRunnerState::launch_suite(&suite, AUTH, &ctx);
|
||||
assert_eq!(state.tests.len(), 2);
|
||||
std::thread::sleep(std::time::Duration::new(13, 0));
|
||||
|
||||
|
|
Loading…
Reference in a new issue