Skip to content

Commit

Permalink
Merge pull request #2615 from fermyon/conformance-test-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rylev authored Jul 18, 2024
2 parents fe52a61 + bd6aaa6 commit 286cf43
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions tests/conformance-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ fn run_test(test: conformance_tests::Test, spin_binary: &std::path::Path) -> any
for precondition in test.config.preconditions {
match precondition {
conformance_tests::config::Precondition::HttpEcho => {
services.push("http-echo".into());
services.push("http-echo");
}
conformance_tests::config::Precondition::TcpEcho => {
services.push("tcp-echo".into());
services.push("tcp-echo");
}
conformance_tests::config::Precondition::Redis => services.push("redis".into()),
conformance_tests::config::Precondition::Redis => services.push("redis"),
conformance_tests::config::Precondition::Mqtt => services.push("mqtt"),
conformance_tests::config::Precondition::KeyValueStore(_) => {}
conformance_tests::config::Precondition::Sqlite => {}
}
Expand Down
26 changes: 13 additions & 13 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ mod integration_tests {
spin_up_args: Vec::new(),
app_type: SpinAppType::Redis,
},
ServicesConfig::new(vec!["redis".into()])?,
ServicesConfig::new(vec!["redis"])?,
move |env| {
let redis_port = env
.services_mut()
Expand Down Expand Up @@ -167,7 +167,7 @@ mod integration_tests {
spin_up_args: Vec::new(),
app_type: SpinAppType::Http,
},
ServicesConfig::new(vec!["jaeger".into()])?,
ServicesConfig::new(vec!["jaeger"])?,
|env| {
let otel_port = env
.services_mut()
Expand Down Expand Up @@ -480,7 +480,7 @@ Caused by:
spin_up_args: vec!["--runtime-config-file".into(), "runtime_config.toml".into()],
app_type: SpinAppType::Http,
},
ServicesConfig::new(vec!["vault".into()])?,
ServicesConfig::new(vec!["vault"])?,
|env| {
// Vault can take a few moments to be ready
std::thread::sleep(std::time::Duration::from_secs(2));
Expand Down Expand Up @@ -730,7 +730,7 @@ Caused by:
#[test]
#[cfg(feature = "extern-dependencies-tests")]
fn registry_works() -> anyhow::Result<()> {
let services = ServicesConfig::new(vec!["registry".into()])?;
let services = ServicesConfig::new(vec!["registry"])?;
let spin_up_args = |env: &mut test_environment::TestEnvironment<()>| {
let registry_url = format!(
"localhost:{}/spin-e2e-tests/registry-works/v1",
Expand All @@ -747,7 +747,7 @@ Caused by:
])
};
let mut env = super::testcases::bootstrap_smoke_test(
&services,
services,
None,
None,
&[],
Expand Down Expand Up @@ -786,7 +786,7 @@ Caused by:
spin_up_args: Vec::new(),
app_type: SpinAppType::Http,
},
ServicesConfig::new(vec!["http-echo".into()])?,
ServicesConfig::new(vec!["http-echo"])?,
move |env| {
let port = env
.get_port(80)?
Expand All @@ -810,7 +810,7 @@ Caused by:

#[test]
fn spin_up_gives_help_on_new_app() -> anyhow::Result<()> {
let mut env = test_environment::TestEnvironment::<()>::boot(&ServicesConfig::none())?;
let mut env = test_environment::TestEnvironment::<()>::boot(ServicesConfig::none())?;

// We still don't see full help if there are no components.
let toml_text = r#"spin_version = "1"
Expand Down Expand Up @@ -848,7 +848,7 @@ route = "/..."

#[test]
fn spin_up_help_build_does_not_build() -> anyhow::Result<()> {
let mut env = test_environment::TestEnvironment::<()>::boot(&ServicesConfig::none())?;
let mut env = test_environment::TestEnvironment::<()>::boot(ServicesConfig::none())?;

// We still don't see full help if there are no components.
let toml_text = r#"spin_version = "1"
Expand Down Expand Up @@ -891,7 +891,7 @@ route = "/..."
#[cfg(not(target_os = "windows"))]
#[test]
fn test_spin_plugin_install_command() -> anyhow::Result<()> {
let env = test_environment::TestEnvironment::<()>::boot(&ServicesConfig::none())?;
let env = test_environment::TestEnvironment::<()>::boot(ServicesConfig::none())?;

let path_to_test_dir = std::env::current_dir()?;
let file_url = format!(
Expand Down Expand Up @@ -1011,7 +1011,7 @@ route = "/..."
#[cfg(not(target_os = "windows"))]
#[test]
fn test_cloud_plugin_autoinstall() -> anyhow::Result<()> {
let env = test_environment::TestEnvironment::<()>::boot(&ServicesConfig::none())?;
let env = test_environment::TestEnvironment::<()>::boot(ServicesConfig::none())?;

let mut login = std::process::Command::new(spin_binary());
login
Expand Down Expand Up @@ -1065,7 +1065,7 @@ route = "/..."
})
.collect::<std::collections::HashMap<_, _>>();

let env = test_environment::TestEnvironment::<()>::boot(&ServicesConfig::none())?;
let env = test_environment::TestEnvironment::<()>::boot(ServicesConfig::none())?;
env.copy_into(dir, ".")?;

let mut build = std::process::Command::new(spin_binary());
Expand Down Expand Up @@ -1178,7 +1178,7 @@ route = "/..."
spin_up_args: Vec::new(),
app_type: SpinAppType::Http,
},
ServicesConfig::new(vec!["http-responses-from-file".into()])?,
ServicesConfig::new(vec!["http-responses-from-file"])?,
move |env| {
let service_url = format!(
"http://localhost:{}",
Expand Down Expand Up @@ -1366,7 +1366,7 @@ route = "/..."
spin_up_args: Vec::new(),
app_type: SpinAppType::Http,
},
ServicesConfig::new(vec!["http-echo".into()])?,
ServicesConfig::new(vec!["http-echo"])?,
move |env| {
let service_url = format!(
"http://localhost:{}",
Expand Down
7 changes: 6 additions & 1 deletion tests/runtime-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ impl<R> RuntimeTest<R> {

fn services_config<R>(config: &RuntimeTestConfig<R>) -> anyhow::Result<ServicesConfig> {
let required_services = required_services(&config.test_path)?;
let services_config = ServicesConfig::new(required_services)?;
let services_config = ServicesConfig::new(
required_services
.iter()
.map(String::as_str)
.collect::<Vec<_>>(),
)?;
Ok(services_config)
}

Expand Down
7 changes: 4 additions & 3 deletions tests/testcases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn http_smoke_test_template_with_route(
expected_body: &str,
) -> anyhow::Result<()> {
let mut env = bootstrap_smoke_test(
&ServicesConfig::none(),
ServicesConfig::none(),
template_url,
template_branch,
plugins,
Expand Down Expand Up @@ -214,7 +214,7 @@ pub fn redis_smoke_test_template(
) -> anyhow::Result<()> {
use redis::Commands;
let mut env = bootstrap_smoke_test(
&test_environment::services::ServicesConfig::new(vec!["redis".into()])?,
test_environment::services::ServicesConfig::new(vec!["redis"])?,
template_url,
template_branch,
plugins,
Expand Down Expand Up @@ -257,7 +257,7 @@ static TEMPLATE_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(());
// TODO: refactor this function to not take so many arguments
#[allow(clippy::too_many_arguments)]
pub fn bootstrap_smoke_test(
services: &ServicesConfig,
services: ServicesConfig,
template_url: Option<&str>,
template_branch: Option<&str>,
plugins: &[&str],
Expand Down Expand Up @@ -310,6 +310,7 @@ pub fn bootstrap_smoke_test(
"-o",
".",
"--accept-defaults",
"--allow-overwrite",
])
.args(new_app_args(&mut env)?);
env.run_in(&mut new_app)?;
Expand Down

0 comments on commit 286cf43

Please sign in to comment.