-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2671 from fermyon/revert-2663-run-conformance
Revert "Run conformance tests as part of runtime tests"
- Loading branch information
Showing
32 changed files
with
302 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,63 @@ | ||
use anyhow::Context as _; | ||
use testing_framework::runtimes::spin_cli::{SpinCli, SpinConfig}; | ||
|
||
fn main() { | ||
let spin_binary: std::path::PathBuf = std::env::args() | ||
.nth(1) | ||
.expect("expected first argument to be path to spin binary") | ||
.into(); | ||
conformance_tests::run_tests(move |test| conformance::run_test(test, &spin_binary)).unwrap(); | ||
conformance_tests::run_tests(move |test| run_test(test, &spin_binary)).unwrap(); | ||
} | ||
|
||
fn run_test(test: conformance_tests::Test, spin_binary: &std::path::Path) -> anyhow::Result<()> { | ||
let mut services = Vec::new(); | ||
for precondition in test.config.preconditions { | ||
match precondition { | ||
conformance_tests::config::Precondition::HttpEcho => { | ||
services.push("http-echo"); | ||
} | ||
conformance_tests::config::Precondition::TcpEcho => { | ||
services.push("tcp-echo"); | ||
} | ||
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 => {} | ||
} | ||
} | ||
let env_config = SpinCli::config( | ||
SpinConfig { | ||
binary_path: spin_binary.to_owned(), | ||
spin_up_args: Vec::new(), | ||
app_type: testing_framework::runtimes::SpinAppType::Http, | ||
}, | ||
test_environment::services::ServicesConfig::new(services)?, | ||
move |e| { | ||
let mut manifest = | ||
test_environment::manifest_template::EnvTemplate::from_file(&test.manifest)?; | ||
manifest.substitute(e, |_| None)?; | ||
e.write_file("spin.toml", manifest.contents())?; | ||
e.copy_into(&test.component, test.component.file_name().unwrap())?; | ||
Ok(()) | ||
}, | ||
); | ||
let mut env = test_environment::TestEnvironment::up(env_config, |_| Ok(()))?; | ||
for invocation in test.config.invocations { | ||
let conformance_tests::config::Invocation::Http(mut invocation) = invocation; | ||
invocation.request.substitute_from_env(&mut env)?; | ||
let spin = env.runtime_mut(); | ||
let actual = invocation | ||
.request | ||
.send(|request| spin.make_http_request(request))?; | ||
|
||
conformance_tests::assertions::assert_response(&invocation.response, &actual) | ||
.with_context(|| { | ||
format!( | ||
"Failed assertion.\nstdout: {}\nstderr: {}", | ||
spin.stdout().to_owned(), | ||
spin.stderr() | ||
) | ||
})?; | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Error::AccessDenied |
13 changes: 13 additions & 0 deletions
13
tests/runtime-tests/tests/key-value-no-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "key-value" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=key-value}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "key-value" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=key-value}" | ||
key_value_stores = ["default"] |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/outbound-mqtt-variable-permission/services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mqtt |
19 changes: 19 additions & 0 deletions
19
tests/runtime-tests/tests/outbound-mqtt-variable-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "outbound-mqtt" | ||
authors = ["Suneet Nangia <suneetnangia@gmail.com>"] | ||
version = "0.1.0" | ||
|
||
[variables] | ||
mqtt_server = { default = "localhost" } | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=outbound-mqtt}" | ||
allowed_outbound_hosts = ["mqtt://{{ mqtt_server }}:%{port=1883}"] | ||
# To test anonymous MQTT authentication, remove the values from MQTT_USERNAME and MQTT_PASSWORD env variables. | ||
environment = { MQTT_ADDRESS = "mqtt://localhost:%{port=1883}?client_id=spintest", MQTT_USERNAME = "user", MQTT_PASSWORD = "password", MQTT_KEEP_ALIVE_INTERVAL = "30" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mqtt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "outbound-mqtt" | ||
authors = ["Suneet Nangia <suneetnangia@gmail.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=outbound-mqtt}" | ||
allowed_outbound_hosts = ["mqtt://localhost:%{port=1883}"] | ||
# To test anonymous MQTT authentication, remove the values from MQTT_USERNAME and MQTT_PASSWORD env variables. | ||
environment = { MQTT_ADDRESS = "mqtt://localhost:%{port=1883}?client_id=spintest", MQTT_USERNAME = "user", MQTT_PASSWORD = "password", MQTT_KEEP_ALIVE_INTERVAL = "30" } |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/outbound-redis-no-permission/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Error::InvalidAddress |
14 changes: 14 additions & 0 deletions
14
tests/runtime-tests/tests/outbound-redis-no-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "outbound-redis" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=outbound-redis}" | ||
environment = { REDIS_ADDRESS = "redis://localhost:6379" } |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/outbound-redis-variable-permission/services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
redis |
18 changes: 18 additions & 0 deletions
18
tests/runtime-tests/tests/outbound-redis-variable-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "outbound-redis" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[variables] | ||
redis_host = { default = "localhost" } | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=outbound-redis}" | ||
environment = { REDIS_ADDRESS = "redis://localhost:%{port=6379}" } | ||
allowed_outbound_hosts = ["redis://{{ redis_host }}:%{port=6379}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "outbound-redis" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=outbound-redis}" | ||
environment = { REDIS_ADDRESS = "redis://localhost:%{port=6379}" } | ||
allowed_outbound_hosts = ["redis://localhost:%{port=6379}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Error::AccessDenied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "sqlite" | ||
authors = ["Ryan Levick <ryan.levick@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=sqlite}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "sqlite" | ||
authors = ["Ryan Levick <ryan.levick@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=sqlite}" | ||
sqlite_databases = ["default"] |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/tcp-sockets-ip-range-variable-permission/services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tcp-echo |
19 changes: 19 additions & 0 deletions
19
tests/runtime-tests/tests/tcp-sockets-ip-range-variable-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "tcp-sockets" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[variables] | ||
addr_prefix = { default = "127.0.0.0" } | ||
prefix_len = { default = "24" } | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=tcp-sockets}" | ||
environment = { ADDRESS = "127.0.0.1:%{port=7}" } | ||
allowed_outbound_hosts = ["*://{{ addr_prefix }}/{{ prefix_len }}:%{port=7}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tcp-echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "tcp-sockets" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=tcp-sockets}" | ||
environment = { ADDRESS = "127.0.0.1:%{port=7}" } | ||
allowed_outbound_hosts = ["*://127.0.0.0/24:%{port=7}"] |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/tcp-sockets-no-ip-permission/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
access-denied |
16 changes: 16 additions & 0 deletions
16
tests/runtime-tests/tests/tcp-sockets-no-ip-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "tcp-sockets" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=tcp-sockets}" | ||
environment = { ADDRESS = "127.0.0.1:6001" } | ||
# Component expects 127.0.0.1 but we only allow 127.0.0.2 | ||
allowed_outbound_hosts = ["*://127.0.0.2:6001"] |
1 change: 1 addition & 0 deletions
1
tests/runtime-tests/tests/tcp-sockets-no-port-permission/error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
access-denied |
16 changes: 16 additions & 0 deletions
16
tests/runtime-tests/tests/tcp-sockets-no-port-permission/spin.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "tcp-sockets" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "%{source=tcp-sockets}" | ||
environment = { ADDRESS = "127.0.0.1:6001" } | ||
# Component expects port 6001 but we allow 6002 | ||
allowed_outbound_hosts = ["*://127.0.0.1:6002"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tcp-echo |
Oops, something went wrong.