Skip to content

Commit aedc2b8

Browse files
authored
Merge pull request #2542 from fermyon/conformance-tests
Run conformance tests
2 parents 637a9a3 + 2d4e070 commit aedc2b8

30 files changed

+492
-1460
lines changed

Cargo.lock

Lines changed: 55 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ spin-locked-app = { path = "crates/locked-app" }
6161
spin-manifest = { path = "crates/manifest" }
6262
spin-oci = { path = "crates/oci" }
6363
spin-plugins = { path = "crates/plugins" }
64-
spin-telemetry = { path = "crates/telemetry", features = ["tracing-log-compat"] }
64+
spin-telemetry = { path = "crates/telemetry", features = [
65+
"tracing-log-compat",
66+
] }
6567
spin-templates = { path = "crates/templates" }
6668
spin-trigger = { path = "crates/trigger" }
6769
spin-trigger-http = { path = "crates/trigger-http" }
@@ -97,6 +99,7 @@ redis = "0.24"
9799
runtime-tests = { path = "tests/runtime-tests" }
98100
test-components = { path = "tests/test-components" }
99101
test-codegen-macro = { path = "crates/test-codegen-macro" }
102+
test-environment = { git = "https://github.com/fermyon/conformance-tests" }
100103

101104
[build-dependencies]
102105
cargo-target-dep = { git = "https://github.com/fermyon/cargo-target-dep", rev = "482f269eceb7b1a7e8fc618bf8c082dd24979cf1" }
@@ -117,16 +120,23 @@ llm-metal = ["llm", "spin-trigger-http/llm-metal"]
117120
llm-cublas = ["llm", "spin-trigger-http/llm-cublas"]
118121

119122
[workspace]
120-
members = ["crates/*", "tests/runtime-tests", "tests/testing-framework"]
123+
members = [
124+
"crates/*",
125+
"tests/conformance-tests",
126+
"tests/runtime-tests",
127+
"tests/testing-framework",
128+
]
121129

122130
[workspace.dependencies]
123131
anyhow = "1.0.75"
124132
http-body-util = "0.1.0"
125133
hyper = { version = "1.0.0", features = ["full"] }
126-
reqwest = { version = "0.11", features = ["stream", "blocking"] }
134+
reqwest = { version = "0.12", features = ["stream", "blocking"] }
127135
tracing = { version = "0.1", features = ["log"] }
128136

129-
wasi-common-preview1 = { version = "21.0.1", package = "wasi-common", features = ["tokio"] }
137+
wasi-common-preview1 = { version = "21.0.1", package = "wasi-common", features = [
138+
"tokio",
139+
] }
130140
wasmtime = "21.0.1"
131141
wasmtime-wasi = "21.0.1"
132142
wasmtime-wasi-http = "21.0.1"

tests/conformance-tests/Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "conformance"
3+
version.workspace = true
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
rust-version.workspace = true
10+
11+
[dependencies]
12+
anyhow = "1.0"
13+
testing-framework = { path = "../testing-framework" }
14+
conformance-tests = { git = "https://github.com/fermyon/conformance-tests" }
15+
test-environment = { git = "https://github.com/fermyon/conformance-tests" }
16+
17+
[lints]
18+
workspace = true

tests/conformance-tests/src/main.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use testing_framework::runtimes::spin_cli::{SpinCli, SpinConfig};
2+
3+
fn main() {
4+
let spin_binary: std::path::PathBuf = std::env::args()
5+
.nth(1)
6+
.expect("expected first argument to be path to spin binary")
7+
.into();
8+
let tests_dir = conformance_tests::download_tests().unwrap();
9+
10+
for test in conformance_tests::tests(&tests_dir).unwrap() {
11+
let env_config = SpinCli::config(
12+
SpinConfig {
13+
binary_path: spin_binary.clone(),
14+
spin_up_args: Vec::new(),
15+
app_type: testing_framework::runtimes::SpinAppType::Http,
16+
},
17+
test_environment::services::ServicesConfig::none(),
18+
move |e| {
19+
e.copy_into(&test.manifest, "spin.toml")?;
20+
e.copy_into(&test.component, test.component.file_name().unwrap())?;
21+
Ok(())
22+
},
23+
);
24+
let mut env = test_environment::TestEnvironment::up(env_config, |_| Ok(())).unwrap();
25+
let spin = env.runtime_mut();
26+
for invocation in test.config.invocations {
27+
let conformance_tests::config::Invocation::Http(invocation) = invocation;
28+
let actual = invocation
29+
.request
30+
.send(|request| spin.make_http_request(request))
31+
.unwrap();
32+
if let Err(e) =
33+
conformance_tests::assertions::assert_response(&invocation.response, &actual)
34+
{
35+
eprintln!("Test failed: {e}");
36+
eprintln!("stderr: {}", spin.stderr());
37+
std::process::exit(1);
38+
}
39+
}
40+
}
41+
println!("All tests passed!")
42+
}

0 commit comments

Comments
 (0)