Skip to content

Commit 5d028fb

Browse files
authored
Merge pull request #2671 from fermyon/revert-2663-run-conformance
Revert "Run conformance tests as part of runtime tests"
2 parents 67f189f + 889d768 commit 5d028fb

File tree

32 files changed

+302
-74
lines changed

32 files changed

+302
-74
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ runtime-tests = { path = "tests/runtime-tests" }
100100
test-components = { path = "tests/test-components" }
101101
test-codegen-macro = { path = "crates/test-codegen-macro" }
102102
test-environment = { git = "https://github.com/fermyon/conformance-tests", rev = "d2129a3fd73140a76c77f15a030a5273b37cbd11" }
103-
conformance-tests = { git = "https://github.com/fermyon/conformance-tests", rev = "d2129a3fd73140a76c77f15a030a5273b37cbd11" }
104-
conformance = { path = "tests/conformance-tests" }
105103

106104
[build-dependencies]
107105
cargo-target-dep = { git = "https://github.com/fermyon/cargo-target-dep", rev = "482f269eceb7b1a7e8fc618bf8c082dd24979cf1" }

tests/conformance-tests/src/lib.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/conformance-tests/src/main.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,63 @@
1+
use anyhow::Context as _;
2+
use testing_framework::runtimes::spin_cli::{SpinCli, SpinConfig};
3+
14
fn main() {
25
let spin_binary: std::path::PathBuf = std::env::args()
36
.nth(1)
47
.expect("expected first argument to be path to spin binary")
58
.into();
6-
conformance_tests::run_tests(move |test| conformance::run_test(test, &spin_binary)).unwrap();
9+
conformance_tests::run_tests(move |test| run_test(test, &spin_binary)).unwrap();
10+
}
11+
12+
fn run_test(test: conformance_tests::Test, spin_binary: &std::path::Path) -> anyhow::Result<()> {
13+
let mut services = Vec::new();
14+
for precondition in test.config.preconditions {
15+
match precondition {
16+
conformance_tests::config::Precondition::HttpEcho => {
17+
services.push("http-echo");
18+
}
19+
conformance_tests::config::Precondition::TcpEcho => {
20+
services.push("tcp-echo");
21+
}
22+
conformance_tests::config::Precondition::Redis => services.push("redis"),
23+
conformance_tests::config::Precondition::Mqtt => services.push("mqtt"),
24+
conformance_tests::config::Precondition::KeyValueStore(_) => {}
25+
conformance_tests::config::Precondition::Sqlite => {}
26+
}
27+
}
28+
let env_config = SpinCli::config(
29+
SpinConfig {
30+
binary_path: spin_binary.to_owned(),
31+
spin_up_args: Vec::new(),
32+
app_type: testing_framework::runtimes::SpinAppType::Http,
33+
},
34+
test_environment::services::ServicesConfig::new(services)?,
35+
move |e| {
36+
let mut manifest =
37+
test_environment::manifest_template::EnvTemplate::from_file(&test.manifest)?;
38+
manifest.substitute(e, |_| None)?;
39+
e.write_file("spin.toml", manifest.contents())?;
40+
e.copy_into(&test.component, test.component.file_name().unwrap())?;
41+
Ok(())
42+
},
43+
);
44+
let mut env = test_environment::TestEnvironment::up(env_config, |_| Ok(()))?;
45+
for invocation in test.config.invocations {
46+
let conformance_tests::config::Invocation::Http(mut invocation) = invocation;
47+
invocation.request.substitute_from_env(&mut env)?;
48+
let spin = env.runtime_mut();
49+
let actual = invocation
50+
.request
51+
.send(|request| spin.make_http_request(request))?;
52+
53+
conformance_tests::assertions::assert_response(&invocation.response, &actual)
54+
.with_context(|| {
55+
format!(
56+
"Failed assertion.\nstdout: {}\nstderr: {}",
57+
spin.stdout().to_owned(),
58+
spin.stderr()
59+
)
60+
})?;
61+
}
62+
Ok(())
763
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Error::AccessDenied
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
spin_manifest_version = 2
2+
3+
[application]
4+
name = "key-value"
5+
authors = ["Fermyon Engineering <[email protected]>"]
6+
version = "0.1.0"
7+
8+
[[trigger.http]]
9+
route = "/"
10+
component = "test"
11+
12+
[component.test]
13+
source = "%{source=key-value}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spin_manifest_version = 2
2+
3+
[application]
4+
name = "key-value"
5+
authors = ["Fermyon Engineering <[email protected]>"]
6+
version = "0.1.0"
7+
8+
[[trigger.http]]
9+
route = "/"
10+
component = "test"
11+
12+
[component.test]
13+
source = "%{source=key-value}"
14+
key_value_stores = ["default"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mqtt
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
spin_manifest_version = 2
2+
3+
[application]
4+
name = "outbound-mqtt"
5+
authors = ["Suneet Nangia <[email protected]>"]
6+
version = "0.1.0"
7+
8+
[variables]
9+
mqtt_server = { default = "localhost" }
10+
11+
[[trigger.http]]
12+
route = "/"
13+
component = "test"
14+
15+
[component.test]
16+
source = "%{source=outbound-mqtt}"
17+
allowed_outbound_hosts = ["mqtt://{{ mqtt_server }}:%{port=1883}"]
18+
# To test anonymous MQTT authentication, remove the values from MQTT_USERNAME and MQTT_PASSWORD env variables.
19+
environment = { MQTT_ADDRESS = "mqtt://localhost:%{port=1883}?client_id=spintest", MQTT_USERNAME = "user", MQTT_PASSWORD = "password", MQTT_KEEP_ALIVE_INTERVAL = "30" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mqtt

0 commit comments

Comments
 (0)