From 155c7e4b2de0ce969fdfcb40b95a1df41ea70cdf Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Thu, 6 Jun 2024 13:17:08 -0700 Subject: [PATCH 1/9] Initial conformance testing setup Signed-off-by: Kate Goldenring --- Cargo.lock | 1109 ++++++++++++++++++++++++++++----- Cargo.toml | 5 +- conformance-tests/Cargo.toml | 13 + conformance-tests/README.md | 39 ++ conformance-tests/src/main.rs | 88 +++ 5 files changed, 1091 insertions(+), 163 deletions(-) create mode 100644 conformance-tests/Cargo.toml create mode 100644 conformance-tests/README.md create mode 100644 conformance-tests/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 436dcef..d184f20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1261,6 +1261,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cargo_toml" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a969e13a7589e9e3e4207e153bae624ade2b5622fb4684a4923b23ec3d57719" +dependencies = [ + "serde 1.0.203", + "toml 0.8.12", +] + [[package]] name = "cbc" version = "0.1.2" @@ -1505,6 +1515,30 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "conformance-tests" +version = "0.1.0" +source = "git+https://github.com/fermyon/conformance-tests#c19e5cf54b7586829e923bd2091314e4d473f4f5" +dependencies = [ + "anyhow", + "flate2", + "json5", + "libtest-mimic", + "reqwest 0.12.4", + "serde 1.0.203", + "tar", + "test-environment", +] + +[[package]] +name = "conformance-tests" +version = "0.14.1" +dependencies = [ + "anyhow", + "conformance-tests 0.1.0", + "testing-framework", +] + [[package]] name = "console" version = "0.15.8" @@ -1618,17 +1652,17 @@ dependencies = [ "openssl", "serde 1.0.203", "serde_json", - "spin-app", - "spin-common", - "spin-componentize", - "spin-core", - "spin-expressions", - "spin-loader", - "spin-manifest", + "spin-app 2.6.0", + "spin-common 2.6.0", + "spin-componentize 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-loader 2.6.0", + "spin-manifest 2.6.0", "spin-oci", - "spin-telemetry", - "spin-trigger", - "spin-trigger-http", + "spin-telemetry 2.6.0", + "spin-trigger 2.6.0", + "spin-trigger-http 2.6.0", "spin-trigger-redis", "tokio", "trigger-command", @@ -2438,6 +2472,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d817e038c30374a4bcb22f94d0a8a0e216958d4c3dcde369b1439fec4bdda6e6" +[[package]] +name = "escape8259" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" + [[package]] name = "event-listener" version = "2.5.3" @@ -2659,6 +2699,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "fslock" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "futures" version = "0.3.30" @@ -3602,6 +3652,17 @@ dependencies = [ "treediff", ] +[[package]] +name = "json5" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde 1.0.203", +] + [[package]] name = "jsonpath-rust" version = "0.3.5" @@ -4015,6 +4076,18 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "libtest-mimic" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc0bda45ed5b3a2904262c1bb91e526127aa70e7ef3758aba2ef93cf896b9b58" +dependencies = [ + "clap 4.5.7", + "escape8259", + "termcolor", + "threadpool", +] + [[package]] name = "libz-sys" version = "1.1.16" @@ -5077,6 +5150,26 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "outbound-http" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "http 0.2.12", + "reqwest 0.11.27", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-locked-app 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-telemetry 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "terminal 2.6.0-pre0", + "tracing", + "url", +] + [[package]] name = "outbound-http" version = "2.6.0" @@ -5085,18 +5178,35 @@ dependencies = [ "anyhow", "http 0.2.12", "reqwest 0.11.27", - "spin-app", - "spin-core", - "spin-expressions", - "spin-locked-app", - "spin-outbound-networking", - "spin-telemetry", - "spin-world", - "terminal", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-locked-app 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-telemetry 2.6.0", + "spin-world 2.6.0", + "terminal 2.6.0", "tracing", "url", ] +[[package]] +name = "outbound-mqtt" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "rumqttc", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", + "tokio", + "tracing", +] + [[package]] name = "outbound-mqtt" version = "2.6.0" @@ -5104,14 +5214,34 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "rumqttc", - "spin-app", - "spin-core", - "spin-expressions", - "spin-outbound-networking", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", + "tokio", + "tracing", +] + +[[package]] +name = "outbound-mysql" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "flate2", + "mysql_async", + "mysql_common", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", "tokio", "tracing", + "url", ] [[package]] @@ -5123,17 +5253,36 @@ dependencies = [ "flate2", "mysql_async", "mysql_common", - "spin-app", - "spin-core", - "spin-expressions", - "spin-outbound-networking", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", "tokio", "tracing", "url", ] +[[package]] +name = "outbound-pg" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "native-tls", + "postgres-native-tls", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", + "tokio", + "tokio-postgres", + "tracing", +] + [[package]] name = "outbound-pg" version = "2.6.0" @@ -5142,17 +5291,34 @@ dependencies = [ "anyhow", "native-tls", "postgres-native-tls", - "spin-app", - "spin-core", - "spin-expressions", - "spin-outbound-networking", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", "tokio", "tokio-postgres", "tracing", ] +[[package]] +name = "outbound-redis" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "redis 0.21.7", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", + "tokio", + "tracing", +] + [[package]] name = "outbound-redis" version = "2.6.0" @@ -5160,12 +5326,12 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "redis 0.21.7", - "spin-app", - "spin-core", - "spin-expressions", - "spin-outbound-networking", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", "tokio", "tracing", ] @@ -6270,6 +6436,7 @@ dependencies = [ "base64 0.22.0", "bytes", "encoding_rs", + "futures-channel", "futures-core", "futures-util", "h2 0.4.4", @@ -7200,6 +7367,22 @@ dependencies = [ "lock_api", ] +[[package]] +name = "spin-app" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "ouroboros", + "serde 1.0.203", + "serde_json", + "spin-core 2.6.0-pre0", + "spin-locked-app 2.6.0-pre0", + "spin-serde 2.6.0-pre0", + "thiserror", +] + [[package]] name = "spin-app" version = "2.6.0" @@ -7210,12 +7393,25 @@ dependencies = [ "ouroboros", "serde 1.0.203", "serde_json", - "spin-core", - "spin-locked-app", - "spin-serde", + "spin-core 2.6.0", + "spin-locked-app 2.6.0", + "spin-serde 2.6.0", "thiserror", ] +[[package]] +name = "spin-common" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "dirs 4.0.0", + "sha2", + "tempfile", + "tokio", + "url", +] + [[package]] name = "spin-common" version = "2.6.0" @@ -7229,6 +7425,18 @@ dependencies = [ "url", ] +[[package]] +name = "spin-componentize" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "wasm-encoder 0.200.0", + "wasmparser 0.200.0", + "wit-component 0.200.0", + "wit-parser 0.200.0", +] + [[package]] name = "spin-componentize" version = "2.6.0" @@ -7237,12 +7445,36 @@ dependencies = [ "anyhow", "tracing", "wasm-encoder 0.200.0", - "wasm-metadata", + "wasm-metadata 0.200.0", "wasmparser 0.200.0", - "wit-component", + "wit-component 0.200.0", "wit-parser 0.200.0", ] +[[package]] +name = "spin-core" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "cap-primitives", + "cap-std", + "crossbeam-channel", + "http 1.1.0", + "io-extras", + "rustix 0.37.27", + "spin-telemetry 2.6.0-pre0", + "system-interface", + "tokio", + "tracing", + "wasi-common", + "wasmtime", + "wasmtime-wasi", + "wasmtime-wasi-http", +] + [[package]] name = "spin-core" version = "2.6.0" @@ -7257,7 +7489,7 @@ dependencies = [ "http 1.1.0", "io-extras", "rustix 0.37.27", - "spin-telemetry", + "spin-telemetry 2.6.0", "system-interface", "tokio", "tracing", @@ -7267,6 +7499,20 @@ dependencies = [ "wasmtime-wasi-http", ] +[[package]] +name = "spin-expressions" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "dotenvy", + "once_cell", + "serde 1.0.203", + "spin-locked-app 2.6.0-pre0", + "thiserror", +] + [[package]] name = "spin-expressions" version = "2.6.0" @@ -7277,10 +7523,29 @@ dependencies = [ "dotenvy", "once_cell", "serde 1.0.203", - "spin-locked-app", + "spin-locked-app 2.6.0", "thiserror", ] +[[package]] +name = "spin-http" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "http 1.1.0", + "http-body-util", + "hyper 1.3.1", + "indexmap 1.9.3", + "percent-encoding", + "routefinder", + "serde 1.0.203", + "spin-app 2.6.0-pre0", + "spin-locked-app 2.6.0-pre0", + "tracing", + "wasmtime-wasi-http", +] + [[package]] name = "spin-http" version = "2.6.0" @@ -7294,12 +7559,27 @@ dependencies = [ "percent-encoding", "routefinder", "serde 1.0.203", - "spin-app", - "spin-locked-app", + "spin-app 2.6.0", + "spin-locked-app 2.6.0", "tracing", "wasmtime-wasi-http", ] +[[package]] +name = "spin-key-value" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "lru 0.9.0", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", + "tokio", + "tracing", +] + [[package]] name = "spin-key-value" version = "2.6.0" @@ -7307,12 +7587,28 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "lru 0.9.0", - "spin-app", - "spin-core", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", + "tokio", + "tracing", +] + +[[package]] +name = "spin-key-value-azure" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "azure_data_cosmos", + "futures", + "serde 1.0.203", + "spin-core 2.6.0-pre0", + "spin-key-value 2.6.0-pre0", "tokio", "tracing", + "url", ] [[package]] @@ -7324,8 +7620,23 @@ dependencies = [ "azure_data_cosmos", "futures", "serde 1.0.203", - "spin-core", - "spin-key-value", + "spin-core 2.6.0", + "spin-key-value 2.6.0", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "spin-key-value-redis" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "redis 0.21.7", + "spin-core 2.6.0-pre0", + "spin-key-value 2.6.0-pre0", + "spin-world 2.6.0-pre0", "tokio", "tracing", "url", @@ -7338,14 +7649,29 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "redis 0.21.7", - "spin-core", - "spin-key-value", - "spin-world", + "spin-core 2.6.0", + "spin-key-value 2.6.0", + "spin-world 2.6.0", "tokio", "tracing", "url", ] +[[package]] +name = "spin-key-value-sqlite" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "once_cell", + "rusqlite", + "spin-core 2.6.0-pre0", + "spin-key-value 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "tokio", + "tracing", +] + [[package]] name = "spin-key-value-sqlite" version = "2.6.0" @@ -7354,13 +7680,26 @@ dependencies = [ "anyhow", "once_cell", "rusqlite", - "spin-core", - "spin-key-value", - "spin-world", + "spin-core 2.6.0", + "spin-key-value 2.6.0", + "spin-world 2.6.0", "tokio", "tracing", ] +[[package]] +name = "spin-llm" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "bytesize", + "llm", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-world 2.6.0-pre0", +] + [[package]] name = "spin-llm" version = "2.6.0" @@ -7369,9 +7708,27 @@ dependencies = [ "anyhow", "bytesize", "llm", - "spin-app", - "spin-core", - "spin-world", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-world 2.6.0", +] + +[[package]] +name = "spin-llm-remote-http" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "http 0.2.12", + "llm", + "reqwest 0.11.27", + "serde 1.0.203", + "serde_json", + "spin-core 2.6.0-pre0", + "spin-llm 2.6.0-pre0", + "spin-telemetry 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "tracing", ] [[package]] @@ -7385,17 +7742,17 @@ dependencies = [ "reqwest 0.11.27", "serde 1.0.203", "serde_json", - "spin-core", - "spin-llm", - "spin-telemetry", - "spin-world", + "spin-core 2.6.0", + "spin-llm 2.6.0", + "spin-telemetry 2.6.0", + "spin-world 2.6.0", "tracing", ] [[package]] name = "spin-loader" -version = "2.6.0" -source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d694774858408e918f3e5cec60" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" dependencies = [ "anyhow", "async-trait", @@ -7408,7 +7765,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static 1.4.0", "mime_guess", - "outbound-http", + "outbound-http 2.6.0-pre0", "path-absolutize", "regex", "reqwest 0.11.27", @@ -7417,12 +7774,12 @@ dependencies = [ "serde_json", "sha2", "shellexpand 3.1.0", - "spin-common", - "spin-locked-app", - "spin-manifest", - "spin-outbound-networking", + "spin-common 2.6.0-pre0", + "spin-locked-app 2.6.0-pre0", + "spin-manifest 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", "tempfile", - "terminal", + "terminal 2.6.0-pre0", "thiserror", "tokio", "tokio-util 0.6.10", @@ -7433,30 +7790,100 @@ dependencies = [ ] [[package]] -name = "spin-locked-app" +name = "spin-loader" version = "2.6.0" source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d694774858408e918f3e5cec60" dependencies = [ "anyhow", "async-trait", - "ouroboros", - "serde 1.0.203", - "serde_json", - "spin-serde", - "thiserror", -] - -[[package]] -name = "spin-manifest" -version = "2.6.0" + "bytes", + "dirs 4.0.0", + "dunce", + "futures", + "glob", + "indexmap 1.9.3", + "itertools 0.10.5", + "lazy_static 1.4.0", + "mime_guess", + "outbound-http 2.6.0", + "path-absolutize", + "regex", + "reqwest 0.11.27", + "semver", + "serde 1.0.203", + "serde_json", + "sha2", + "shellexpand 3.1.0", + "spin-common 2.6.0", + "spin-locked-app 2.6.0", + "spin-manifest 2.6.0", + "spin-outbound-networking 2.6.0", + "tempfile", + "terminal 2.6.0", + "thiserror", + "tokio", + "tokio-util 0.6.10", + "toml 0.8.12", + "tracing", + "walkdir", + "wasm-pkg-loader", +] + +[[package]] +name = "spin-locked-app" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "ouroboros", + "serde 1.0.203", + "serde_json", + "spin-serde 2.6.0-pre0", + "thiserror", +] + +[[package]] +name = "spin-locked-app" +version = "2.6.0" +source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d694774858408e918f3e5cec60" +dependencies = [ + "anyhow", + "async-trait", + "ouroboros", + "serde 1.0.203", + "serde_json", + "spin-serde 2.6.0", + "thiserror", +] + +[[package]] +name = "spin-manifest" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "indexmap 1.9.3", + "semver", + "serde 1.0.203", + "spin-serde 2.6.0-pre0", + "terminal 2.6.0-pre0", + "thiserror", + "toml 0.8.12", + "url", +] + +[[package]] +name = "spin-manifest" +version = "2.6.0" source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d694774858408e918f3e5cec60" dependencies = [ "anyhow", "indexmap 1.9.3", "semver", "serde 1.0.203", - "spin-serde", - "terminal", + "spin-serde 2.6.0", + "terminal 2.6.0", "thiserror", "toml 0.8.12", "url", @@ -7480,10 +7907,10 @@ dependencies = [ "reqwest 0.11.27", "serde 1.0.203", "serde_json", - "spin-common", - "spin-loader", - "spin-locked-app", - "spin-manifest", + "spin-common 2.6.0", + "spin-loader 2.6.0", + "spin-locked-app 2.6.0", + "spin-manifest 2.6.0", "tempfile", "tokio", "tokio-util 0.7.10", @@ -7491,6 +7918,21 @@ dependencies = [ "walkdir", ] +[[package]] +name = "spin-outbound-networking" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "http 1.1.0", + "ipnet", + "spin-expressions 2.6.0-pre0", + "spin-locked-app 2.6.0-pre0", + "terminal 2.6.0-pre0", + "url", + "urlencoding", +] + [[package]] name = "spin-outbound-networking" version = "2.6.0" @@ -7499,13 +7941,22 @@ dependencies = [ "anyhow", "http 1.1.0", "ipnet", - "spin-expressions", - "spin-locked-app", - "terminal", + "spin-expressions 2.6.0", + "spin-locked-app 2.6.0", + "terminal 2.6.0", "url", "urlencoding", ] +[[package]] +name = "spin-serde" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "base64 0.21.7", + "serde 1.0.203", +] + [[package]] name = "spin-serde" version = "2.6.0" @@ -7515,6 +7966,21 @@ dependencies = [ "serde 1.0.203", ] +[[package]] +name = "spin-sqlite" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "table 2.6.0-pre0", + "tokio", + "tracing", +] + [[package]] name = "spin-sqlite" version = "2.6.0" @@ -7522,10 +7988,26 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "async-trait", - "spin-app", - "spin-core", - "spin-world", - "table", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-world 2.6.0", + "table 2.6.0", + "tokio", + "tracing", +] + +[[package]] +name = "spin-sqlite-inproc" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "once_cell", + "rand 0.8.5", + "rusqlite", + "spin-sqlite 2.6.0-pre0", + "spin-world 2.6.0-pre0", "tokio", "tracing", ] @@ -7540,8 +8022,24 @@ dependencies = [ "once_cell", "rand 0.8.5", "rusqlite", - "spin-sqlite", - "spin-world", + "spin-sqlite 2.6.0", + "spin-world 2.6.0", + "tokio", + "tracing", +] + +[[package]] +name = "spin-sqlite-libsql" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "libsql", + "rusqlite", + "spin-sqlite 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "sqlparser", "tokio", "tracing", ] @@ -7555,13 +8053,33 @@ dependencies = [ "async-trait", "libsql", "rusqlite", - "spin-sqlite", - "spin-world", + "spin-sqlite 2.6.0", + "spin-world 2.6.0", "sqlparser", "tokio", "tracing", ] +[[package]] +name = "spin-telemetry" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "http 0.2.12", + "http 1.1.0", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "opentelemetry_sdk", + "terminal 2.6.0-pre0", + "tracing", + "tracing-appender", + "tracing-opentelemetry", + "tracing-subscriber", + "url", +] + [[package]] name = "spin-telemetry" version = "2.6.0" @@ -7574,7 +8092,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "terminal", + "terminal 2.6.0", "tracing", "tracing-appender", "tracing-opentelemetry", @@ -7582,6 +8100,57 @@ dependencies = [ "url", ] +[[package]] +name = "spin-trigger" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "clap 3.2.25", + "ctrlc", + "dirs 4.0.0", + "futures", + "indexmap 1.9.3", + "ipnet", + "outbound-http 2.6.0-pre0", + "outbound-mqtt 2.6.0-pre0", + "outbound-mysql 2.6.0-pre0", + "outbound-pg 2.6.0-pre0", + "outbound-redis 2.6.0-pre0", + "sanitize-filename", + "serde 1.0.203", + "serde_json", + "spin-app 2.6.0-pre0", + "spin-common 2.6.0-pre0", + "spin-componentize 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-key-value 2.6.0-pre0", + "spin-key-value-azure 2.6.0-pre0", + "spin-key-value-redis 2.6.0-pre0", + "spin-key-value-sqlite 2.6.0-pre0", + "spin-llm 2.6.0-pre0", + "spin-llm-remote-http 2.6.0-pre0", + "spin-loader 2.6.0-pre0", + "spin-manifest 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-sqlite 2.6.0-pre0", + "spin-sqlite-inproc 2.6.0-pre0", + "spin-sqlite-libsql 2.6.0-pre0", + "spin-telemetry 2.6.0-pre0", + "spin-variables 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "terminal 2.6.0-pre0", + "tokio", + "toml 0.5.11", + "tracing", + "url", + "wasmtime", + "wasmtime-wasi", + "wasmtime-wasi-http", +] + [[package]] name = "spin-trigger" version = "2.6.0" @@ -7595,35 +8164,35 @@ dependencies = [ "futures", "indexmap 1.9.3", "ipnet", - "outbound-http", - "outbound-mqtt", - "outbound-mysql", - "outbound-pg", - "outbound-redis", + "outbound-http 2.6.0", + "outbound-mqtt 2.6.0", + "outbound-mysql 2.6.0", + "outbound-pg 2.6.0", + "outbound-redis 2.6.0", "sanitize-filename", "serde 1.0.203", "serde_json", - "spin-app", - "spin-common", - "spin-componentize", - "spin-core", - "spin-expressions", - "spin-key-value", - "spin-key-value-azure", - "spin-key-value-redis", - "spin-key-value-sqlite", - "spin-llm", - "spin-llm-remote-http", - "spin-loader", - "spin-manifest", - "spin-outbound-networking", - "spin-sqlite", - "spin-sqlite-inproc", - "spin-sqlite-libsql", - "spin-telemetry", - "spin-variables", - "spin-world", - "terminal", + "spin-app 2.6.0", + "spin-common 2.6.0", + "spin-componentize 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-key-value 2.6.0", + "spin-key-value-azure 2.6.0", + "spin-key-value-redis 2.6.0", + "spin-key-value-sqlite 2.6.0", + "spin-llm 2.6.0", + "spin-llm-remote-http 2.6.0", + "spin-loader 2.6.0", + "spin-manifest 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-sqlite 2.6.0", + "spin-sqlite-inproc 2.6.0", + "spin-sqlite-libsql 2.6.0", + "spin-telemetry 2.6.0", + "spin-variables 2.6.0", + "spin-world 2.6.0", + "terminal 2.6.0", "tokio", "toml 0.5.11", "tracing", @@ -7633,6 +8202,45 @@ dependencies = [ "wasmtime-wasi-http", ] +[[package]] +name = "spin-trigger-http" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "clap 3.2.25", + "futures", + "futures-util", + "http 1.1.0", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "indexmap 1.9.3", + "outbound-http 2.6.0-pre0", + "percent-encoding", + "rustls-pemfile 0.3.0", + "serde 1.0.203", + "serde_json", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-http 2.6.0-pre0", + "spin-outbound-networking 2.6.0-pre0", + "spin-telemetry 2.6.0-pre0", + "spin-trigger 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "terminal 2.6.0-pre0", + "tls-listener", + "tokio", + "tokio-rustls 0.23.4", + "tracing", + "url", + "wasi-common", + "wasmtime", + "wasmtime-wasi", + "wasmtime-wasi-http", +] + [[package]] name = "spin-trigger-http" version = "2.6.0" @@ -7648,19 +8256,19 @@ dependencies = [ "hyper 1.3.1", "hyper-util", "indexmap 1.9.3", - "outbound-http", + "outbound-http 2.6.0", "percent-encoding", "rustls-pemfile 0.3.0", "serde 1.0.203", "serde_json", - "spin-app", - "spin-core", - "spin-http", - "spin-outbound-networking", - "spin-telemetry", - "spin-trigger", - "spin-world", - "terminal", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-http 2.6.0", + "spin-outbound-networking 2.6.0", + "spin-telemetry 2.6.0", + "spin-trigger 2.6.0", + "spin-world 2.6.0", + "terminal 2.6.0", "tls-listener", "tokio", "tokio-rustls 0.23.4", @@ -7682,17 +8290,40 @@ dependencies = [ "futures", "redis 0.21.7", "serde 1.0.203", - "spin-app", - "spin-common", - "spin-core", - "spin-expressions", - "spin-telemetry", - "spin-trigger", - "spin-world", + "spin-app 2.6.0", + "spin-common 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-telemetry 2.6.0", + "spin-trigger 2.6.0", + "spin-world 2.6.0", "tokio", "tracing", ] +[[package]] +name = "spin-variables" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "async-trait", + "azure_core 0.20.0", + "azure_identity", + "azure_security_keyvault", + "dotenvy", + "once_cell", + "serde 1.0.203", + "spin-app 2.6.0-pre0", + "spin-core 2.6.0-pre0", + "spin-expressions 2.6.0-pre0", + "spin-world 2.6.0-pre0", + "thiserror", + "tokio", + "tracing", + "vaultrs", +] + [[package]] name = "spin-variables" version = "2.6.0" @@ -7706,16 +8337,24 @@ dependencies = [ "dotenvy", "once_cell", "serde 1.0.203", - "spin-app", - "spin-core", - "spin-expressions", - "spin-world", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-expressions 2.6.0", + "spin-world 2.6.0", "thiserror", "tokio", "tracing", "vaultrs", ] +[[package]] +name = "spin-world" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "wasmtime", +] + [[package]] name = "spin-world" version = "2.6.0" @@ -7908,6 +8547,11 @@ dependencies = [ "winx", ] +[[package]] +name = "table" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" + [[package]] name = "table" version = "2.6.0" @@ -7930,6 +8574,12 @@ version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +[[package]] +name = "temp-dir" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f227968ec00f0e5322f9b8173c7a0cbcff6181a0a5b28e9892491c286277231" + [[package]] name = "tempfile" version = "3.10.1" @@ -7951,6 +8601,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal" +version = "2.6.0-pre0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "atty", + "once_cell", + "termcolor", +] + [[package]] name = "terminal" version = "2.6.0" @@ -7961,6 +8621,52 @@ dependencies = [ "termcolor", ] +[[package]] +name = "test-components" +version = "0.1.0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "cargo_toml", + "wit-component 0.19.1", +] + +[[package]] +name = "test-environment" +version = "0.1.0" +source = "git+https://github.com/fermyon/conformance-tests#c19e5cf54b7586829e923bd2091314e4d473f4f5" +dependencies = [ + "anyhow", + "fslock", + "regex", + "reqwest 0.12.4", + "temp-dir", + "tokio", +] + +[[package]] +name = "testing-framework" +version = "0.1.0" +source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" +dependencies = [ + "anyhow", + "fslock", + "http 1.1.0", + "http-body-util", + "log", + "nix 0.26.4", + "regex", + "reqwest 0.11.27", + "spin-http 2.6.0-pre0", + "spin-loader 2.6.0-pre0", + "spin-trigger 2.6.0-pre0", + "spin-trigger-http 2.6.0-pre0", + "temp-dir", + "test-components", + "tokio", + "toml 0.8.12", + "wasmtime-wasi-http", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -7997,6 +8703,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.34" @@ -8544,10 +9259,10 @@ dependencies = [ "clap 3.2.25", "openssl", "serde 1.0.203", - "spin-app", - "spin-core", - "spin-telemetry", - "spin-trigger", + "spin-app 2.6.0", + "spin-core 2.6.0", + "spin-telemetry 2.6.0", + "spin-trigger 2.6.0", "tokio", "tracing", "wasmtime-wasi", @@ -8566,9 +9281,9 @@ dependencies = [ "futures", "openssl", "serde 1.0.203", - "spin-core", - "spin-telemetry", - "spin-trigger", + "spin-core 2.6.0", + "spin-telemetry 2.6.0", + "spin-trigger 2.6.0", "tokio", "tokio-scoped", "tracing", @@ -9155,6 +9870,15 @@ dependencies = [ "wat", ] +[[package]] +name = "wasm-encoder" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111495d6204760238512f57a9af162f45086504da332af210f2f75dd80b34f1d" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-encoder" version = "0.41.2" @@ -9192,6 +9916,22 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-metadata" +version = "0.10.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18ebaa7bd0f9e7a5e5dd29b9a998acf21c4abed74265524dd7e85934597bfb10" +dependencies = [ + "anyhow", + "indexmap 2.2.6", + "serde 1.0.203", + "serde_derive", + "serde_json", + "spdx", + "wasm-encoder 0.41.2", + "wasmparser 0.121.2", +] + [[package]] name = "wasm-metadata" version = "0.200.0" @@ -9251,6 +9991,17 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmparser" +version = "0.119.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c35daf77afb4f9b14016625144a391085ec2ca99ca9cc53ed291bb53ab5278d" +dependencies = [ + "bitflags 2.5.0", + "indexmap 2.2.6", + "semver", +] + [[package]] name = "wasmparser" version = "0.121.2" @@ -10014,6 +10765,25 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "wit-component" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "429e3c06fba3a7566aab724ae3ffff3152ede5399d44789e7dd11f5421292859" +dependencies = [ + "anyhow", + "bitflags 2.5.0", + "indexmap 2.2.6", + "log", + "serde 1.0.203", + "serde_derive", + "serde_json", + "wasm-encoder 0.39.0", + "wasm-metadata 0.10.20", + "wasmparser 0.119.0", + "wit-parser 0.13.2", +] + [[package]] name = "wit-component" version = "0.200.0" @@ -10028,11 +10798,28 @@ dependencies = [ "serde_derive", "serde_json", "wasm-encoder 0.200.0", - "wasm-metadata", + "wasm-metadata 0.200.0", "wasmparser 0.200.0", "wit-parser 0.200.0", ] +[[package]] +name = "wit-parser" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.2.6", + "log", + "semver", + "serde 1.0.203", + "serde_derive", + "serde_json", + "unicode-xid", +] + [[package]] name = "wit-parser" version = "0.200.0" diff --git a/Cargo.toml b/Cargo.toml index 839fb46..76227aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,5 +11,6 @@ homepage = "https://github.com/spinkube/containerd-shim-spin" resolver = "2" members = [ "tests", - "containerd-shim-spin" -] \ No newline at end of file + "containerd-shim-spin", + "conformance-tests" +] diff --git a/conformance-tests/Cargo.toml b/conformance-tests/Cargo.toml new file mode 100644 index 0000000..6cab302 --- /dev/null +++ b/conformance-tests/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "conformance-tests" +version.workspace = true +edition.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +homepage.workspace = true + +[dependencies] +anyhow = "1.0" +testing-framework = { git = "https://github.com/kate-goldenring/spin", branch = "shim-test-environment" } +conformance-tests = { git = "https://github.com/fermyon/conformance-tests" } diff --git a/conformance-tests/README.md b/conformance-tests/README.md new file mode 100644 index 0000000..85f4dfb --- /dev/null +++ b/conformance-tests/README.md @@ -0,0 +1,39 @@ +# Spin Conformance Tests + +A set of Spin [conformance tests](https://github.com/fermyon/conformance-tests) that ensures that this shim is a compliant runtime. + +## Prerequisites +The following must be installed: +- `containerd` +- `ctr` +- `containerd-shim-spin` + +Containerd must be configured to access the `containerd-shim-spin`: + +1. Build the shim and add it to `$PATH`: + ```sh + cargo build --release + sudo cp target/release/containerd-shim-spin-v2 /usr/bin/ + ``` +2. Configure containerd to add the Spin shim as a runtime by adding the following to `/etc/containerd/config.toml`: + ```toml + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.spin] + runtime_type = "io.containerd.spin.v2" + ``` +3. Restart containerd if it is running as a service + ```sh + systemctl restart containerd + ``` + +## Running tests +Containerd can only be executed as a root user. Choose one of the following options +1. Build the `conformance-tests` bin and excute it as sudo user: + ```sh + cargo build + sudo ../target/debug/conformance-tests + ``` +2. Run cargo as root by passing in the environment from the user's context and full path to cargo: + ```sh + sudo -E $HOME/.cargo/bin/cargo run + ``` +3. Follow the [containerd instructions](https://github.com/containerd/containerd/blob/main/docs/rootless.md) to configure it to be runnable as a non-root user \ No newline at end of file diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs new file mode 100644 index 0000000..35d282f --- /dev/null +++ b/conformance-tests/src/main.rs @@ -0,0 +1,88 @@ +use testing_framework::runtimes::spin_containerd_shim::SpinShim; + +fn main() { + let tests_dir = conformance_tests::download_tests().unwrap(); + + for test in conformance_tests::tests(&tests_dir).unwrap() { + let spin_binary = std::path::Path::new("/home/kagold/projects/temp/spin"); + let ctr_binary = "/usr/bin/ctr".into(); + // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) + let oci_image = format!("ttl.sh/{}:72h", test.name); + let env_config = testing_framework::TestEnvironmentConfig::containerd_shim( + ctr_binary, + oci_image.clone(), + move |e| { + // TODO: consider doing this outside the test environment since it is not a part of the runtime execution + e.copy_into(&test.manifest, "spin.toml")?; + e.copy_into(&test.component, test.component.file_name().unwrap())?; + SpinShim::regisry_push(spin_binary, &oci_image, e).unwrap(); + Ok(()) + }, + testing_framework::ServicesConfig::none(), + ); + std::thread::sleep(std::time::Duration::from_secs(60)); + let mut env = testing_framework::TestEnvironment::up(env_config, |_| Ok(())).unwrap(); + let spin = env.runtime_mut(); + for invocation in test.config.invocations { + let conformance_tests::config::Invocation::Http(invocation) = invocation; + let headers = invocation + .request + .headers + .iter() + .map(|h| (h.name.as_str(), h.value.as_str())) + .collect::>(); + let request = testing_framework::http::Request::full( + match invocation.request.method { + conformance_tests::config::Method::GET => testing_framework::http::Method::GET, + conformance_tests::config::Method::POST => { + testing_framework::http::Method::POST + } + }, + &invocation.request.path, + &headers, + invocation.request.body, + ); + let response = spin.make_http_request(request).unwrap(); + let stderr = spin.stderr(); + let body = String::from_utf8(response.body()) + .unwrap_or_else(|_| String::from("invalid utf-8")); + assert_eq!( + response.status(), + invocation.response.status, + "request to Spin failed\nstderr:\n{stderr}\nbody:\n{body}", + ); + + let mut actual_headers = response + .headers() + .iter() + .map(|(k, v)| (k.to_lowercase(), v.to_lowercase())) + .collect::>(); + for expected_header in invocation.response.headers { + let expected_name = expected_header.name.to_lowercase(); + let expected_value = expected_header.value.map(|v| v.to_lowercase()); + let actual_value = actual_headers.remove(&expected_name); + let Some(actual_value) = actual_value.as_deref() else { + if expected_header.optional { + continue; + } else { + panic!( + "expected header {name} not found in response", + name = expected_header.name + ) + } + }; + if let Some(expected_value) = expected_value { + assert_eq!(actual_value, expected_value); + } + } + if !actual_headers.is_empty() { + panic!("unexpected headers: {actual_headers:?}"); + } + + if let Some(expected_body) = invocation.response.body { + assert_eq!(body, expected_body); + } + } + println!("test passed: {}", test.name); + } +} From 82a3fda7ce980f5a32b2910eef87c4e870091490 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Wed, 12 Jun 2024 16:57:23 +0200 Subject: [PATCH 2/9] Move to new test-environment crate Signed-off-by: Ryan Levick --- conformance-tests/Cargo.toml | 6 +- conformance-tests/README.md | 2 +- conformance-tests/src/main.rs | 276 ++++++++++++++++++++++++++-------- 3 files changed, 221 insertions(+), 63 deletions(-) diff --git a/conformance-tests/Cargo.toml b/conformance-tests/Cargo.toml index 6cab302..3abcebd 100644 --- a/conformance-tests/Cargo.toml +++ b/conformance-tests/Cargo.toml @@ -9,5 +9,7 @@ homepage.workspace = true [dependencies] anyhow = "1.0" -testing-framework = { git = "https://github.com/kate-goldenring/spin", branch = "shim-test-environment" } -conformance-tests = { git = "https://github.com/fermyon/conformance-tests" } +conformance-tests = { git = "https://github.com/fermyon/conformance-tests", branch = "testing-environment" } +log = "0.4" +nix = "0.26" +test-environment = { git = "https://github.com/fermyon/conformance-tests", branch = "testing-environment" } diff --git a/conformance-tests/README.md b/conformance-tests/README.md index 85f4dfb..6547013 100644 --- a/conformance-tests/README.md +++ b/conformance-tests/README.md @@ -18,7 +18,7 @@ Containerd must be configured to access the `containerd-shim-spin`: 2. Configure containerd to add the Spin shim as a runtime by adding the following to `/etc/containerd/config.toml`: ```toml [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.spin] - runtime_type = "io.containerd.spin.v2" + runtime_type = "/usr/bin/containerd-shim-spin-v2" ``` 3. Restart containerd if it is running as a service ```sh diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index 35d282f..cfbb593 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -1,88 +1,244 @@ -use testing_framework::runtimes::spin_containerd_shim::SpinShim; +use std::{ + path::{Path, PathBuf}, + process::{Command, Stdio}, +}; + +use anyhow::Context as _; +use test_environment::{ + http::{Request, Response}, + io::OutputStream, + services::ServicesConfig, + Runtime, TestEnvironment, TestEnvironmentConfig, +}; fn main() { let tests_dir = conformance_tests::download_tests().unwrap(); + let mut args = std::env::args().skip(1); + let spin_binary = args + .next() + .expect("expected first arg to be path to Spin binary"); + let ctr_binary = args + .next() + .expect("expected second arg to be path to ctr binary"); + let ctr_binary = Path::new(&ctr_binary); for test in conformance_tests::tests(&tests_dir).unwrap() { - let spin_binary = std::path::Path::new("/home/kagold/projects/temp/spin"); - let ctr_binary = "/usr/bin/ctr".into(); + let spin_binary = PathBuf::from(spin_binary.clone()); // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) let oci_image = format!("ttl.sh/{}:72h", test.name); - let env_config = testing_framework::TestEnvironmentConfig::containerd_shim( - ctr_binary, + let env_config = SpinShim::config( + ctr_binary.into(), oci_image.clone(), move |e| { // TODO: consider doing this outside the test environment since it is not a part of the runtime execution e.copy_into(&test.manifest, "spin.toml")?; e.copy_into(&test.component, test.component.file_name().unwrap())?; - SpinShim::regisry_push(spin_binary, &oci_image, e).unwrap(); + SpinShim::regisry_push(&spin_binary, &oci_image, e).unwrap(); Ok(()) }, - testing_framework::ServicesConfig::none(), + test_environment::services::ServicesConfig::none(), ); - std::thread::sleep(std::time::Duration::from_secs(60)); - let mut env = testing_framework::TestEnvironment::up(env_config, |_| Ok(())).unwrap(); + let mut env = TestEnvironment::up(env_config, |_| Ok(())).unwrap(); let spin = env.runtime_mut(); for invocation in test.config.invocations { let conformance_tests::config::Invocation::Http(invocation) = invocation; - let headers = invocation + invocation .request - .headers - .iter() - .map(|h| (h.name.as_str(), h.value.as_str())) - .collect::>(); - let request = testing_framework::http::Request::full( - match invocation.request.method { - conformance_tests::config::Method::GET => testing_framework::http::Method::GET, - conformance_tests::config::Method::POST => { - testing_framework::http::Method::POST - } - }, - &invocation.request.path, - &headers, - invocation.request.body, - ); - let response = spin.make_http_request(request).unwrap(); - let stderr = spin.stderr(); - let body = String::from_utf8(response.body()) - .unwrap_or_else(|_| String::from("invalid utf-8")); - assert_eq!( - response.status(), - invocation.response.status, - "request to Spin failed\nstderr:\n{stderr}\nbody:\n{body}", - ); + .send(|request| spin.make_http_request(request)) + .unwrap(); + } + println!("test passed: {}", test.name); + } +} + +struct SpinShim { + process: std::process::Child, + #[allow(dead_code)] + stdout: OutputStream, + stderr: OutputStream, + io_mode: IoMode, +} + +/// `ctr run` invocations require an ID that is unique to all currently running instances. Since +/// only one test runs at a time, we can reuse a constant ID. +const CTR_RUN_ID: &str = "run-id"; + +impl SpinShim { + pub fn config( + ctr_binary: PathBuf, + oci_image: String, + preboot: impl FnOnce(&mut TestEnvironment) -> anyhow::Result<()> + 'static, + services_config: ServicesConfig, + ) -> TestEnvironmentConfig { + TestEnvironmentConfig { + services_config, + create_runtime: Box::new(move |env| { + preboot(env)?; + SpinShim::image_pull(&ctr_binary, &oci_image)?; + SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID) + }), + } + } + + pub fn regisry_push( + spin_binary_path: &Path, + image: &str, + env: &mut TestEnvironment, + ) -> anyhow::Result<()> { + // TODO: consider enabling configuring a port + Command::new(spin_binary_path) + .args(["registry", "push"]) + .arg(image) + .current_dir(env.path()) + .output() + .context("failed to push spin app to registry with 'spin'")?; + // TODO: assess output + Ok(()) + } + + pub fn image_pull(ctr_binary_path: &Path, image: &str) -> anyhow::Result<()> { + // TODO: consider enabling configuring a port + Command::new(ctr_binary_path) + .args(["image", "pull"]) + .arg(image) + .output() + .context("failed to pull spin app with 'ctr'")?; + // TODO: assess output + Ok(()) + } - let mut actual_headers = response - .headers() - .iter() - .map(|(k, v)| (k.to_lowercase(), v.to_lowercase())) - .collect::>(); - for expected_header in invocation.response.headers { - let expected_name = expected_header.name.to_lowercase(); - let expected_value = expected_header.value.map(|v| v.to_lowercase()); - let actual_value = actual_headers.remove(&expected_name); - let Some(actual_value) = actual_value.as_deref() else { - if expected_header.optional { - continue; - } else { - panic!( - "expected header {name} not found in response", - name = expected_header.name - ) - } - }; - if let Some(expected_value) = expected_value { - assert_eq!(actual_value, expected_value); + /// Start the Spin app using `ctr run` + /// Equivalent of `sudo ctr run --rm --net-host --runtime io.containerd.spin.v2 ttl.sh/myapp:48h ctr-run-id bogus-arg` for image `ttl.sh/myapp:48h` and run id `ctr-run-id` + pub fn start( + ctr_binary_path: &Path, + env: &mut TestEnvironment, + image: &str, + ctr_run_id: &str, + ) -> anyhow::Result { + let port = 80; + let mut ctr_cmd = std::process::Command::new(ctr_binary_path); + let child = ctr_cmd + .arg("run") + .args([ + "--memory-limit", + "10000", + "--rm", + "--net-host", + "--runtime", + "io.containerd.spin.v2", + ]) + .arg(image) + .arg(ctr_run_id) + .arg("bogus-arg") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()); + for (key, value) in env.env_vars() { + child.env(key, value); + } + let mut child = child.spawn()?; + let stdout = OutputStream::new(child.stdout.take().unwrap()); + let stderr = OutputStream::new(child.stderr.take().unwrap()); + log::debug!("Awaiting shim binary to start up on port {port}..."); + let mut spin = Self { + process: child, + stdout, + stderr, + io_mode: IoMode::Http(port), + }; + let start = std::time::Instant::now(); + loop { + match std::net::TcpStream::connect(format!("127.0.0.1:{port}")) { + Ok(_) => { + log::debug!("Spin shim started on port {port}."); + return Ok(spin); + } + Err(e) => { + let stderr = spin.stderr.output_as_str().unwrap_or(""); + log::trace!("Checking that the Spin server started returned an error: {e}"); + log::trace!("Current spin stderr = '{stderr}'"); } } - if !actual_headers.is_empty() { - panic!("unexpected headers: {actual_headers:?}"); + if let Some(status) = spin.try_wait()? { + anyhow::bail!( + "Shim exited early with status code {:?}\n{}{}", + status.code(), + spin.stdout.output_as_str().unwrap_or(""), + spin.stderr.output_as_str().unwrap_or("") + ); } - if let Some(expected_body) = invocation.response.body { - assert_eq!(body, expected_body); + if start.elapsed() > std::time::Duration::from_secs(2 * 60) { + break; } + std::thread::sleep(std::time::Duration::from_millis(50)); } - println!("test passed: {}", test.name); + anyhow::bail!( + "`ctr run` did not start server or error after two minutes. stderr:\n\t{}", + spin.stderr.output_as_str().unwrap_or("") + ) + } + + /// Make an HTTP request against Spin + /// + /// Will fail if Spin has already exited or if the io mode is not HTTP + pub fn make_http_request(&mut self, request: Request<'_, String>) -> anyhow::Result { + let IoMode::Http(port) = self.io_mode; + if let Some(status) = self.try_wait()? { + anyhow::bail!( + "make_http_request - shim exited early with status code {:?}", + status.code() + ); + } + log::debug!("Connecting to HTTP server on port {port}..."); + let response = request.send("localhost", port).unwrap(); + log::debug!("Awaiting response from server"); + if let Some(status) = self.try_wait()? { + anyhow::bail!("Spin exited early with status code {:?}", status.code()); + } + println!("Response: {}", response.status()); + Ok(response) + } + + pub fn stderr(&mut self) -> &str { + self.stderr.output_as_str().unwrap_or("") + } + + fn try_wait(&mut self) -> std::io::Result> { + self.process.try_wait() + } +} + +impl Drop for SpinShim { + fn drop(&mut self) { + kill_process(&mut self.process); + } +} + +impl Runtime for SpinShim { + fn error(&mut self) -> anyhow::Result<()> { + if self.try_wait()?.is_some() { + anyhow::bail!("Containerd shim spin exited early: {}", self.stderr()); + } + + Ok(()) + } +} + +/// How this instance is communicating with the outside world +pub enum IoMode { + /// An http server is running on this port + Http(u16), +} + +/// Helper function to kill a process +fn kill_process(process: &mut std::process::Child) { + #[cfg(windows)] + { + let _ = process.kill(); + } + #[cfg(not(windows))] + { + let pid = nix::unistd::Pid::from_raw(process.id() as i32); + let _ = nix::sys::signal::kill(pid, nix::sys::signal::SIGTERM); } } From f2e1752664f62b4784707c6c037693c811262415 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Thu, 13 Jun 2024 13:28:17 +0200 Subject: [PATCH 3/9] Small refactorings Signed-off-by: Ryan Levick --- Cargo.lock | 997 ++++++---------------------------- conformance-tests/Cargo.toml | 4 +- conformance-tests/src/main.rs | 52 +- 3 files changed, 173 insertions(+), 880 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d184f20..bd50e67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1261,16 +1261,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cargo_toml" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a969e13a7589e9e3e4207e153bae624ade2b5622fb4684a4923b23ec3d57719" -dependencies = [ - "serde 1.0.203", - "toml 0.8.12", -] - [[package]] name = "cbc" version = "0.1.2" @@ -1536,7 +1526,9 @@ version = "0.14.1" dependencies = [ "anyhow", "conformance-tests 0.1.0", - "testing-framework", + "log", + "nix 0.26.4", + "test-environment", ] [[package]] @@ -1652,17 +1644,17 @@ dependencies = [ "openssl", "serde 1.0.203", "serde_json", - "spin-app 2.6.0", - "spin-common 2.6.0", - "spin-componentize 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-loader 2.6.0", - "spin-manifest 2.6.0", + "spin-app", + "spin-common", + "spin-componentize", + "spin-core", + "spin-expressions", + "spin-loader", + "spin-manifest", "spin-oci", - "spin-telemetry 2.6.0", - "spin-trigger 2.6.0", - "spin-trigger-http 2.6.0", + "spin-telemetry", + "spin-trigger", + "spin-trigger-http", "spin-trigger-redis", "tokio", "trigger-command", @@ -5150,26 +5142,6 @@ dependencies = [ "syn 2.0.58", ] -[[package]] -name = "outbound-http" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "http 0.2.12", - "reqwest 0.11.27", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-locked-app 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-telemetry 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "terminal 2.6.0-pre0", - "tracing", - "url", -] - [[package]] name = "outbound-http" version = "2.6.0" @@ -5178,35 +5150,18 @@ dependencies = [ "anyhow", "http 0.2.12", "reqwest 0.11.27", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-locked-app 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-telemetry 2.6.0", - "spin-world 2.6.0", - "terminal 2.6.0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-locked-app", + "spin-outbound-networking", + "spin-telemetry", + "spin-world", + "terminal", "tracing", "url", ] -[[package]] -name = "outbound-mqtt" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "rumqttc", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", - "tokio", - "tracing", -] - [[package]] name = "outbound-mqtt" version = "2.6.0" @@ -5214,34 +5169,14 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "rumqttc", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", - "tokio", - "tracing", -] - -[[package]] -name = "outbound-mysql" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "flate2", - "mysql_async", - "mysql_common", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-outbound-networking", + "spin-world", + "table", "tokio", "tracing", - "url", ] [[package]] @@ -5253,36 +5188,17 @@ dependencies = [ "flate2", "mysql_async", "mysql_common", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-outbound-networking", + "spin-world", + "table", "tokio", "tracing", "url", ] -[[package]] -name = "outbound-pg" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "native-tls", - "postgres-native-tls", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", - "tokio", - "tokio-postgres", - "tracing", -] - [[package]] name = "outbound-pg" version = "2.6.0" @@ -5291,34 +5207,17 @@ dependencies = [ "anyhow", "native-tls", "postgres-native-tls", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-outbound-networking", + "spin-world", + "table", "tokio", "tokio-postgres", "tracing", ] -[[package]] -name = "outbound-redis" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "redis 0.21.7", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", - "tokio", - "tracing", -] - [[package]] name = "outbound-redis" version = "2.6.0" @@ -5326,12 +5225,12 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "redis 0.21.7", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-outbound-networking", + "spin-world", + "table", "tokio", "tracing", ] @@ -7367,22 +7266,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "spin-app" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "ouroboros", - "serde 1.0.203", - "serde_json", - "spin-core 2.6.0-pre0", - "spin-locked-app 2.6.0-pre0", - "spin-serde 2.6.0-pre0", - "thiserror", -] - [[package]] name = "spin-app" version = "2.6.0" @@ -7393,25 +7276,12 @@ dependencies = [ "ouroboros", "serde 1.0.203", "serde_json", - "spin-core 2.6.0", - "spin-locked-app 2.6.0", - "spin-serde 2.6.0", + "spin-core", + "spin-locked-app", + "spin-serde", "thiserror", ] -[[package]] -name = "spin-common" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "dirs 4.0.0", - "sha2", - "tempfile", - "tokio", - "url", -] - [[package]] name = "spin-common" version = "2.6.0" @@ -7425,18 +7295,6 @@ dependencies = [ "url", ] -[[package]] -name = "spin-componentize" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "wasm-encoder 0.200.0", - "wasmparser 0.200.0", - "wit-component 0.200.0", - "wit-parser 0.200.0", -] - [[package]] name = "spin-componentize" version = "2.6.0" @@ -7445,36 +7303,12 @@ dependencies = [ "anyhow", "tracing", "wasm-encoder 0.200.0", - "wasm-metadata 0.200.0", + "wasm-metadata", "wasmparser 0.200.0", - "wit-component 0.200.0", + "wit-component", "wit-parser 0.200.0", ] -[[package]] -name = "spin-core" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "bytes", - "cap-primitives", - "cap-std", - "crossbeam-channel", - "http 1.1.0", - "io-extras", - "rustix 0.37.27", - "spin-telemetry 2.6.0-pre0", - "system-interface", - "tokio", - "tracing", - "wasi-common", - "wasmtime", - "wasmtime-wasi", - "wasmtime-wasi-http", -] - [[package]] name = "spin-core" version = "2.6.0" @@ -7489,7 +7323,7 @@ dependencies = [ "http 1.1.0", "io-extras", "rustix 0.37.27", - "spin-telemetry 2.6.0", + "spin-telemetry", "system-interface", "tokio", "tracing", @@ -7499,20 +7333,6 @@ dependencies = [ "wasmtime-wasi-http", ] -[[package]] -name = "spin-expressions" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "dotenvy", - "once_cell", - "serde 1.0.203", - "spin-locked-app 2.6.0-pre0", - "thiserror", -] - [[package]] name = "spin-expressions" version = "2.6.0" @@ -7523,29 +7343,10 @@ dependencies = [ "dotenvy", "once_cell", "serde 1.0.203", - "spin-locked-app 2.6.0", + "spin-locked-app", "thiserror", ] -[[package]] -name = "spin-http" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "http 1.1.0", - "http-body-util", - "hyper 1.3.1", - "indexmap 1.9.3", - "percent-encoding", - "routefinder", - "serde 1.0.203", - "spin-app 2.6.0-pre0", - "spin-locked-app 2.6.0-pre0", - "tracing", - "wasmtime-wasi-http", -] - [[package]] name = "spin-http" version = "2.6.0" @@ -7559,27 +7360,12 @@ dependencies = [ "percent-encoding", "routefinder", "serde 1.0.203", - "spin-app 2.6.0", - "spin-locked-app 2.6.0", + "spin-app", + "spin-locked-app", "tracing", "wasmtime-wasi-http", ] -[[package]] -name = "spin-key-value" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "lru 0.9.0", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", - "tokio", - "tracing", -] - [[package]] name = "spin-key-value" version = "2.6.0" @@ -7587,30 +7373,14 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "lru 0.9.0", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", + "spin-app", + "spin-core", + "spin-world", + "table", "tokio", "tracing", ] -[[package]] -name = "spin-key-value-azure" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "azure_data_cosmos", - "futures", - "serde 1.0.203", - "spin-core 2.6.0-pre0", - "spin-key-value 2.6.0-pre0", - "tokio", - "tracing", - "url", -] - [[package]] name = "spin-key-value-azure" version = "2.6.0" @@ -7620,23 +7390,8 @@ dependencies = [ "azure_data_cosmos", "futures", "serde 1.0.203", - "spin-core 2.6.0", - "spin-key-value 2.6.0", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "spin-key-value-redis" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "redis 0.21.7", - "spin-core 2.6.0-pre0", - "spin-key-value 2.6.0-pre0", - "spin-world 2.6.0-pre0", + "spin-core", + "spin-key-value", "tokio", "tracing", "url", @@ -7649,29 +7404,14 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "redis 0.21.7", - "spin-core 2.6.0", - "spin-key-value 2.6.0", - "spin-world 2.6.0", + "spin-core", + "spin-key-value", + "spin-world", "tokio", "tracing", "url", ] -[[package]] -name = "spin-key-value-sqlite" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "once_cell", - "rusqlite", - "spin-core 2.6.0-pre0", - "spin-key-value 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "tokio", - "tracing", -] - [[package]] name = "spin-key-value-sqlite" version = "2.6.0" @@ -7680,26 +7420,13 @@ dependencies = [ "anyhow", "once_cell", "rusqlite", - "spin-core 2.6.0", - "spin-key-value 2.6.0", - "spin-world 2.6.0", + "spin-core", + "spin-key-value", + "spin-world", "tokio", "tracing", ] -[[package]] -name = "spin-llm" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "bytesize", - "llm", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-world 2.6.0-pre0", -] - [[package]] name = "spin-llm" version = "2.6.0" @@ -7708,27 +7435,9 @@ dependencies = [ "anyhow", "bytesize", "llm", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-world 2.6.0", -] - -[[package]] -name = "spin-llm-remote-http" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "http 0.2.12", - "llm", - "reqwest 0.11.27", - "serde 1.0.203", - "serde_json", - "spin-core 2.6.0-pre0", - "spin-llm 2.6.0-pre0", - "spin-telemetry 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "tracing", + "spin-app", + "spin-core", + "spin-world", ] [[package]] @@ -7742,53 +7451,13 @@ dependencies = [ "reqwest 0.11.27", "serde 1.0.203", "serde_json", - "spin-core 2.6.0", - "spin-llm 2.6.0", - "spin-telemetry 2.6.0", - "spin-world 2.6.0", + "spin-core", + "spin-llm", + "spin-telemetry", + "spin-world", "tracing", ] -[[package]] -name = "spin-loader" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "bytes", - "dirs 4.0.0", - "dunce", - "futures", - "glob", - "indexmap 1.9.3", - "itertools 0.10.5", - "lazy_static 1.4.0", - "mime_guess", - "outbound-http 2.6.0-pre0", - "path-absolutize", - "regex", - "reqwest 0.11.27", - "semver", - "serde 1.0.203", - "serde_json", - "sha2", - "shellexpand 3.1.0", - "spin-common 2.6.0-pre0", - "spin-locked-app 2.6.0-pre0", - "spin-manifest 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "tempfile", - "terminal 2.6.0-pre0", - "thiserror", - "tokio", - "tokio-util 0.6.10", - "toml 0.8.12", - "tracing", - "walkdir", - "wasm-pkg-loader", -] - [[package]] name = "spin-loader" version = "2.6.0" @@ -7805,7 +7474,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static 1.4.0", "mime_guess", - "outbound-http 2.6.0", + "outbound-http", "path-absolutize", "regex", "reqwest 0.11.27", @@ -7814,12 +7483,12 @@ dependencies = [ "serde_json", "sha2", "shellexpand 3.1.0", - "spin-common 2.6.0", - "spin-locked-app 2.6.0", - "spin-manifest 2.6.0", - "spin-outbound-networking 2.6.0", + "spin-common", + "spin-locked-app", + "spin-manifest", + "spin-outbound-networking", "tempfile", - "terminal 2.6.0", + "terminal", "thiserror", "tokio", "tokio-util 0.6.10", @@ -7829,20 +7498,6 @@ dependencies = [ "wasm-pkg-loader", ] -[[package]] -name = "spin-locked-app" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "ouroboros", - "serde 1.0.203", - "serde_json", - "spin-serde 2.6.0-pre0", - "thiserror", -] - [[package]] name = "spin-locked-app" version = "2.6.0" @@ -7853,26 +7508,10 @@ dependencies = [ "ouroboros", "serde 1.0.203", "serde_json", - "spin-serde 2.6.0", + "spin-serde", "thiserror", ] -[[package]] -name = "spin-manifest" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "indexmap 1.9.3", - "semver", - "serde 1.0.203", - "spin-serde 2.6.0-pre0", - "terminal 2.6.0-pre0", - "thiserror", - "toml 0.8.12", - "url", -] - [[package]] name = "spin-manifest" version = "2.6.0" @@ -7882,8 +7521,8 @@ dependencies = [ "indexmap 1.9.3", "semver", "serde 1.0.203", - "spin-serde 2.6.0", - "terminal 2.6.0", + "spin-serde", + "terminal", "thiserror", "toml 0.8.12", "url", @@ -7907,10 +7546,10 @@ dependencies = [ "reqwest 0.11.27", "serde 1.0.203", "serde_json", - "spin-common 2.6.0", - "spin-loader 2.6.0", - "spin-locked-app 2.6.0", - "spin-manifest 2.6.0", + "spin-common", + "spin-loader", + "spin-locked-app", + "spin-manifest", "tempfile", "tokio", "tokio-util 0.7.10", @@ -7918,21 +7557,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "spin-outbound-networking" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "http 1.1.0", - "ipnet", - "spin-expressions 2.6.0-pre0", - "spin-locked-app 2.6.0-pre0", - "terminal 2.6.0-pre0", - "url", - "urlencoding", -] - [[package]] name = "spin-outbound-networking" version = "2.6.0" @@ -7941,22 +7565,13 @@ dependencies = [ "anyhow", "http 1.1.0", "ipnet", - "spin-expressions 2.6.0", - "spin-locked-app 2.6.0", - "terminal 2.6.0", + "spin-expressions", + "spin-locked-app", + "terminal", "url", "urlencoding", ] -[[package]] -name = "spin-serde" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "base64 0.21.7", - "serde 1.0.203", -] - [[package]] name = "spin-serde" version = "2.6.0" @@ -7966,21 +7581,6 @@ dependencies = [ "serde 1.0.203", ] -[[package]] -name = "spin-sqlite" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "table 2.6.0-pre0", - "tokio", - "tracing", -] - [[package]] name = "spin-sqlite" version = "2.6.0" @@ -7988,26 +7588,10 @@ source = "git+https://github.com/fermyon/spin?tag=v2.6.0#a4ddd3921d9ea3d69477485 dependencies = [ "anyhow", "async-trait", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-world 2.6.0", - "table 2.6.0", - "tokio", - "tracing", -] - -[[package]] -name = "spin-sqlite-inproc" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "once_cell", - "rand 0.8.5", - "rusqlite", - "spin-sqlite 2.6.0-pre0", - "spin-world 2.6.0-pre0", + "spin-app", + "spin-core", + "spin-world", + "table", "tokio", "tracing", ] @@ -8022,24 +7606,8 @@ dependencies = [ "once_cell", "rand 0.8.5", "rusqlite", - "spin-sqlite 2.6.0", - "spin-world 2.6.0", - "tokio", - "tracing", -] - -[[package]] -name = "spin-sqlite-libsql" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "libsql", - "rusqlite", - "spin-sqlite 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "sqlparser", + "spin-sqlite", + "spin-world", "tokio", "tracing", ] @@ -8053,33 +7621,13 @@ dependencies = [ "async-trait", "libsql", "rusqlite", - "spin-sqlite 2.6.0", - "spin-world 2.6.0", + "spin-sqlite", + "spin-world", "sqlparser", "tokio", "tracing", ] -[[package]] -name = "spin-telemetry" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "http 0.2.12", - "http 1.1.0", - "opentelemetry", - "opentelemetry-otlp", - "opentelemetry-semantic-conventions", - "opentelemetry_sdk", - "terminal 2.6.0-pre0", - "tracing", - "tracing-appender", - "tracing-opentelemetry", - "tracing-subscriber", - "url", -] - [[package]] name = "spin-telemetry" version = "2.6.0" @@ -8092,7 +7640,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry_sdk", - "terminal 2.6.0", + "terminal", "tracing", "tracing-appender", "tracing-opentelemetry", @@ -8100,57 +7648,6 @@ dependencies = [ "url", ] -[[package]] -name = "spin-trigger" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "clap 3.2.25", - "ctrlc", - "dirs 4.0.0", - "futures", - "indexmap 1.9.3", - "ipnet", - "outbound-http 2.6.0-pre0", - "outbound-mqtt 2.6.0-pre0", - "outbound-mysql 2.6.0-pre0", - "outbound-pg 2.6.0-pre0", - "outbound-redis 2.6.0-pre0", - "sanitize-filename", - "serde 1.0.203", - "serde_json", - "spin-app 2.6.0-pre0", - "spin-common 2.6.0-pre0", - "spin-componentize 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-key-value 2.6.0-pre0", - "spin-key-value-azure 2.6.0-pre0", - "spin-key-value-redis 2.6.0-pre0", - "spin-key-value-sqlite 2.6.0-pre0", - "spin-llm 2.6.0-pre0", - "spin-llm-remote-http 2.6.0-pre0", - "spin-loader 2.6.0-pre0", - "spin-manifest 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-sqlite 2.6.0-pre0", - "spin-sqlite-inproc 2.6.0-pre0", - "spin-sqlite-libsql 2.6.0-pre0", - "spin-telemetry 2.6.0-pre0", - "spin-variables 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "terminal 2.6.0-pre0", - "tokio", - "toml 0.5.11", - "tracing", - "url", - "wasmtime", - "wasmtime-wasi", - "wasmtime-wasi-http", -] - [[package]] name = "spin-trigger" version = "2.6.0" @@ -8164,35 +7661,35 @@ dependencies = [ "futures", "indexmap 1.9.3", "ipnet", - "outbound-http 2.6.0", - "outbound-mqtt 2.6.0", - "outbound-mysql 2.6.0", - "outbound-pg 2.6.0", - "outbound-redis 2.6.0", + "outbound-http", + "outbound-mqtt", + "outbound-mysql", + "outbound-pg", + "outbound-redis", "sanitize-filename", "serde 1.0.203", "serde_json", - "spin-app 2.6.0", - "spin-common 2.6.0", - "spin-componentize 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-key-value 2.6.0", - "spin-key-value-azure 2.6.0", - "spin-key-value-redis 2.6.0", - "spin-key-value-sqlite 2.6.0", - "spin-llm 2.6.0", - "spin-llm-remote-http 2.6.0", - "spin-loader 2.6.0", - "spin-manifest 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-sqlite 2.6.0", - "spin-sqlite-inproc 2.6.0", - "spin-sqlite-libsql 2.6.0", - "spin-telemetry 2.6.0", - "spin-variables 2.6.0", - "spin-world 2.6.0", - "terminal 2.6.0", + "spin-app", + "spin-common", + "spin-componentize", + "spin-core", + "spin-expressions", + "spin-key-value", + "spin-key-value-azure", + "spin-key-value-redis", + "spin-key-value-sqlite", + "spin-llm", + "spin-llm-remote-http", + "spin-loader", + "spin-manifest", + "spin-outbound-networking", + "spin-sqlite", + "spin-sqlite-inproc", + "spin-sqlite-libsql", + "spin-telemetry", + "spin-variables", + "spin-world", + "terminal", "tokio", "toml 0.5.11", "tracing", @@ -8202,45 +7699,6 @@ dependencies = [ "wasmtime-wasi-http", ] -[[package]] -name = "spin-trigger-http" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "clap 3.2.25", - "futures", - "futures-util", - "http 1.1.0", - "http-body-util", - "hyper 1.3.1", - "hyper-util", - "indexmap 1.9.3", - "outbound-http 2.6.0-pre0", - "percent-encoding", - "rustls-pemfile 0.3.0", - "serde 1.0.203", - "serde_json", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-http 2.6.0-pre0", - "spin-outbound-networking 2.6.0-pre0", - "spin-telemetry 2.6.0-pre0", - "spin-trigger 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "terminal 2.6.0-pre0", - "tls-listener", - "tokio", - "tokio-rustls 0.23.4", - "tracing", - "url", - "wasi-common", - "wasmtime", - "wasmtime-wasi", - "wasmtime-wasi-http", -] - [[package]] name = "spin-trigger-http" version = "2.6.0" @@ -8256,19 +7714,19 @@ dependencies = [ "hyper 1.3.1", "hyper-util", "indexmap 1.9.3", - "outbound-http 2.6.0", + "outbound-http", "percent-encoding", "rustls-pemfile 0.3.0", "serde 1.0.203", "serde_json", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-http 2.6.0", - "spin-outbound-networking 2.6.0", - "spin-telemetry 2.6.0", - "spin-trigger 2.6.0", - "spin-world 2.6.0", - "terminal 2.6.0", + "spin-app", + "spin-core", + "spin-http", + "spin-outbound-networking", + "spin-telemetry", + "spin-trigger", + "spin-world", + "terminal", "tls-listener", "tokio", "tokio-rustls 0.23.4", @@ -8290,40 +7748,17 @@ dependencies = [ "futures", "redis 0.21.7", "serde 1.0.203", - "spin-app 2.6.0", - "spin-common 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-telemetry 2.6.0", - "spin-trigger 2.6.0", - "spin-world 2.6.0", + "spin-app", + "spin-common", + "spin-core", + "spin-expressions", + "spin-telemetry", + "spin-trigger", + "spin-world", "tokio", "tracing", ] -[[package]] -name = "spin-variables" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "async-trait", - "azure_core 0.20.0", - "azure_identity", - "azure_security_keyvault", - "dotenvy", - "once_cell", - "serde 1.0.203", - "spin-app 2.6.0-pre0", - "spin-core 2.6.0-pre0", - "spin-expressions 2.6.0-pre0", - "spin-world 2.6.0-pre0", - "thiserror", - "tokio", - "tracing", - "vaultrs", -] - [[package]] name = "spin-variables" version = "2.6.0" @@ -8337,24 +7772,16 @@ dependencies = [ "dotenvy", "once_cell", "serde 1.0.203", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-expressions 2.6.0", - "spin-world 2.6.0", + "spin-app", + "spin-core", + "spin-expressions", + "spin-world", "thiserror", "tokio", "tracing", "vaultrs", ] -[[package]] -name = "spin-world" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "wasmtime", -] - [[package]] name = "spin-world" version = "2.6.0" @@ -8547,11 +7974,6 @@ dependencies = [ "winx", ] -[[package]] -name = "table" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" - [[package]] name = "table" version = "2.6.0" @@ -8601,16 +8023,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "terminal" -version = "2.6.0-pre0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "atty", - "once_cell", - "termcolor", -] - [[package]] name = "terminal" version = "2.6.0" @@ -8621,15 +8033,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "test-components" -version = "0.1.0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "cargo_toml", - "wit-component 0.19.1", -] - [[package]] name = "test-environment" version = "0.1.0" @@ -8643,30 +8046,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "testing-framework" -version = "0.1.0" -source = "git+https://github.com/kate-goldenring/spin?branch=shim-test-environment#c5045631ec52b019f36e1988fe05c8bef4002199" -dependencies = [ - "anyhow", - "fslock", - "http 1.1.0", - "http-body-util", - "log", - "nix 0.26.4", - "regex", - "reqwest 0.11.27", - "spin-http 2.6.0-pre0", - "spin-loader 2.6.0-pre0", - "spin-trigger 2.6.0-pre0", - "spin-trigger-http 2.6.0-pre0", - "temp-dir", - "test-components", - "tokio", - "toml 0.8.12", - "wasmtime-wasi-http", -] - [[package]] name = "textwrap" version = "0.16.1" @@ -9259,10 +8638,10 @@ dependencies = [ "clap 3.2.25", "openssl", "serde 1.0.203", - "spin-app 2.6.0", - "spin-core 2.6.0", - "spin-telemetry 2.6.0", - "spin-trigger 2.6.0", + "spin-app", + "spin-core", + "spin-telemetry", + "spin-trigger", "tokio", "tracing", "wasmtime-wasi", @@ -9281,9 +8660,9 @@ dependencies = [ "futures", "openssl", "serde 1.0.203", - "spin-core 2.6.0", - "spin-telemetry 2.6.0", - "spin-trigger 2.6.0", + "spin-core", + "spin-telemetry", + "spin-trigger", "tokio", "tokio-scoped", "tracing", @@ -9870,15 +9249,6 @@ dependencies = [ "wat", ] -[[package]] -name = "wasm-encoder" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111495d6204760238512f57a9af162f45086504da332af210f2f75dd80b34f1d" -dependencies = [ - "leb128", -] - [[package]] name = "wasm-encoder" version = "0.41.2" @@ -9916,22 +9286,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasm-metadata" -version = "0.10.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18ebaa7bd0f9e7a5e5dd29b9a998acf21c4abed74265524dd7e85934597bfb10" -dependencies = [ - "anyhow", - "indexmap 2.2.6", - "serde 1.0.203", - "serde_derive", - "serde_json", - "spdx", - "wasm-encoder 0.41.2", - "wasmparser 0.121.2", -] - [[package]] name = "wasm-metadata" version = "0.200.0" @@ -9991,17 +9345,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmparser" -version = "0.119.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c35daf77afb4f9b14016625144a391085ec2ca99ca9cc53ed291bb53ab5278d" -dependencies = [ - "bitflags 2.5.0", - "indexmap 2.2.6", - "semver", -] - [[package]] name = "wasmparser" version = "0.121.2" @@ -10765,25 +10108,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "wit-component" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "429e3c06fba3a7566aab724ae3ffff3152ede5399d44789e7dd11f5421292859" -dependencies = [ - "anyhow", - "bitflags 2.5.0", - "indexmap 2.2.6", - "log", - "serde 1.0.203", - "serde_derive", - "serde_json", - "wasm-encoder 0.39.0", - "wasm-metadata 0.10.20", - "wasmparser 0.119.0", - "wit-parser 0.13.2", -] - [[package]] name = "wit-component" version = "0.200.0" @@ -10798,28 +10122,11 @@ dependencies = [ "serde_derive", "serde_json", "wasm-encoder 0.200.0", - "wasm-metadata 0.200.0", + "wasm-metadata", "wasmparser 0.200.0", "wit-parser 0.200.0", ] -[[package]] -name = "wit-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "316b36a9f0005f5aa4b03c39bc3728d045df136f8c13a73b7db4510dec725e08" -dependencies = [ - "anyhow", - "id-arena", - "indexmap 2.2.6", - "log", - "semver", - "serde 1.0.203", - "serde_derive", - "serde_json", - "unicode-xid", -] - [[package]] name = "wit-parser" version = "0.200.0" diff --git a/conformance-tests/Cargo.toml b/conformance-tests/Cargo.toml index 3abcebd..e4bcca3 100644 --- a/conformance-tests/Cargo.toml +++ b/conformance-tests/Cargo.toml @@ -9,7 +9,7 @@ homepage.workspace = true [dependencies] anyhow = "1.0" -conformance-tests = { git = "https://github.com/fermyon/conformance-tests", branch = "testing-environment" } +conformance-tests = { git = "https://github.com/fermyon/conformance-tests" } log = "0.4" nix = "0.26" -test-environment = { git = "https://github.com/fermyon/conformance-tests", branch = "testing-environment" } +test-environment = { git = "https://github.com/fermyon/conformance-tests" } diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index cfbb593..c50bb2c 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -14,37 +14,33 @@ use test_environment::{ fn main() { let tests_dir = conformance_tests::download_tests().unwrap(); let mut args = std::env::args().skip(1); - let spin_binary = args + let spin_binary = &args .next() .expect("expected first arg to be path to Spin binary"); - let ctr_binary = args + let ctr_binary = &args .next() .expect("expected second arg to be path to ctr binary"); - let ctr_binary = Path::new(&ctr_binary); for test in conformance_tests::tests(&tests_dir).unwrap() { - let spin_binary = PathBuf::from(spin_binary.clone()); // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) let oci_image = format!("ttl.sh/{}:72h", test.name); let env_config = SpinShim::config( ctr_binary.into(), + spin_binary.into(), oci_image.clone(), - move |e| { - // TODO: consider doing this outside the test environment since it is not a part of the runtime execution - e.copy_into(&test.manifest, "spin.toml")?; - e.copy_into(&test.component, test.component.file_name().unwrap())?; - SpinShim::regisry_push(&spin_binary, &oci_image, e).unwrap(); - Ok(()) - }, test_environment::services::ServicesConfig::none(), ); - let mut env = TestEnvironment::up(env_config, |_| Ok(())).unwrap(); - let spin = env.runtime_mut(); + let mut env = TestEnvironment::up(env_config, move |e| { + e.copy_into(&test.manifest, "spin.toml")?; + e.copy_into(&test.component, test.component.file_name().unwrap())?; + Ok(()) + }) + .unwrap(); + let shim = env.runtime_mut(); for invocation in test.config.invocations { let conformance_tests::config::Invocation::Http(invocation) = invocation; invocation - .request - .send(|request| spin.make_http_request(request)) + .run(|request| shim.make_http_request(request)) .unwrap(); } println!("test passed: {}", test.name); @@ -66,14 +62,14 @@ const CTR_RUN_ID: &str = "run-id"; impl SpinShim { pub fn config( ctr_binary: PathBuf, + spin_binary: PathBuf, oci_image: String, - preboot: impl FnOnce(&mut TestEnvironment) -> anyhow::Result<()> + 'static, services_config: ServicesConfig, ) -> TestEnvironmentConfig { TestEnvironmentConfig { services_config, create_runtime: Box::new(move |env| { - preboot(env)?; + SpinShim::regisry_push(&spin_binary, &oci_image, env)?; SpinShim::image_pull(&ctr_binary, &oci_image)?; SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID) }), @@ -86,13 +82,10 @@ impl SpinShim { env: &mut TestEnvironment, ) -> anyhow::Result<()> { // TODO: consider enabling configuring a port - Command::new(spin_binary_path) - .args(["registry", "push"]) - .arg(image) - .current_dir(env.path()) - .output() + let mut cmd = Command::new(spin_binary_path); + cmd.args(["registry", "push"]).arg(image); + env.run_in(&mut cmd) .context("failed to push spin app to registry with 'spin'")?; - // TODO: assess output Ok(()) } @@ -119,14 +112,7 @@ impl SpinShim { let mut ctr_cmd = std::process::Command::new(ctr_binary_path); let child = ctr_cmd .arg("run") - .args([ - "--memory-limit", - "10000", - "--rm", - "--net-host", - "--runtime", - "io.containerd.spin.v2", - ]) + .args(["--rm", "--net-host", "--runtime", "io.containerd.spin.v2"]) .arg(image) .arg(ctr_run_id) .arg("bogus-arg") @@ -154,7 +140,7 @@ impl SpinShim { } Err(e) => { let stderr = spin.stderr.output_as_str().unwrap_or(""); - log::trace!("Checking that the Spin server started returned an error: {e}"); + log::trace!("Checking that the shim server started returned an error: {e}"); log::trace!("Current spin stderr = '{stderr}'"); } } @@ -190,7 +176,7 @@ impl SpinShim { ); } log::debug!("Connecting to HTTP server on port {port}..."); - let response = request.send("localhost", port).unwrap(); + let response = request.send("localhost", port)?; log::debug!("Awaiting response from server"); if let Some(status) = self.try_wait()? { anyhow::bail!("Spin exited early with status code {:?}", status.code()); From ace71956226a0ca32be2cad096a0e2eb8e58ae5e Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Fri, 14 Jun 2024 16:29:45 +0200 Subject: [PATCH 4/9] Update to latest tests Signed-off-by: Ryan Levick --- conformance-tests/src/main.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index c50bb2c..af8991a 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -21,29 +21,41 @@ fn main() { .next() .expect("expected second arg to be path to ctr binary"); - for test in conformance_tests::tests(&tests_dir).unwrap() { + 'test: for test in conformance_tests::tests(&tests_dir).unwrap() { + println!("running test: {}", test.name); // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) let oci_image = format!("ttl.sh/{}:72h", test.name); let env_config = SpinShim::config( ctr_binary.into(), spin_binary.into(), oci_image.clone(), - test_environment::services::ServicesConfig::none(), + test_environment::services::ServicesConfig::new(test.config.services).unwrap(), ); let mut env = TestEnvironment::up(env_config, move |e| { - e.copy_into(&test.manifest, "spin.toml")?; + let mut manifest = + test_environment::manifest_template::EnvTemplate::from_file(&test.manifest) + .unwrap(); + manifest.substitute(e, |_| None).unwrap(); + e.write_file("spin.toml", manifest.contents())?; e.copy_into(&test.component, test.component.file_name().unwrap())?; Ok(()) }) .unwrap(); - let shim = env.runtime_mut(); for invocation in test.config.invocations { - let conformance_tests::config::Invocation::Http(invocation) = invocation; - invocation - .run(|request| shim.make_http_request(request)) - .unwrap(); + let conformance_tests::config::Invocation::Http(mut invocation) = invocation; + invocation.request.substitute_from_env(&mut env).unwrap(); + let shim = env.runtime_mut(); + if let Err(e) = invocation.run(|request| shim.make_http_request(request)) { + println!("❌ test failed: {}", test.name); + println!("error: {}", e); + for e in e.chain() { + println!("\t{}", e); + } + + continue 'test; + } } - println!("test passed: {}", test.name); + println!("✅ test passed: {}", test.name); } } @@ -181,7 +193,6 @@ impl SpinShim { if let Some(status) = self.try_wait()? { anyhow::bail!("Spin exited early with status code {:?}", status.code()); } - println!("Response: {}", response.status()); Ok(response) } From 70cad6ec8dc5574a95d5972d860754929cebf3d8 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 18 Jun 2024 12:46:28 +0200 Subject: [PATCH 5/9] Update conformance tests Signed-off-by: Ryan Levick --- conformance-tests/src/main.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index af8991a..daee57e 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -23,13 +23,26 @@ fn main() { 'test: for test in conformance_tests::tests(&tests_dir).unwrap() { println!("running test: {}", test.name); + let mut services = Vec::new(); + for precondition in &test.config.preconditions { + match precondition { + conformance_tests::config::Precondition::HttpEcho => { + services.push("http-echo".into()); + } + conformance_tests::config::Precondition::KeyValueStore(k) => { + if k.label != "default" { + panic!("unsupported label: {}", k.label); + } + } + } + } // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) let oci_image = format!("ttl.sh/{}:72h", test.name); let env_config = SpinShim::config( ctr_binary.into(), spin_binary.into(), oci_image.clone(), - test_environment::services::ServicesConfig::new(test.config.services).unwrap(), + test_environment::services::ServicesConfig::new(services).unwrap(), ); let mut env = TestEnvironment::up(env_config, move |e| { let mut manifest = From 7cacbc5a91db658d7bcfc4b4521455cc4293c29d Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 18 Jun 2024 14:37:57 +0200 Subject: [PATCH 6/9] Use local registry Signed-off-by: Ryan Levick --- conformance-tests/src/main.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index daee57e..179ace3 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -23,7 +23,7 @@ fn main() { 'test: for test in conformance_tests::tests(&tests_dir).unwrap() { println!("running test: {}", test.name); - let mut services = Vec::new(); + let mut services = vec!["registry".into()]; for precondition in &test.config.preconditions { match precondition { conformance_tests::config::Precondition::HttpEcho => { @@ -36,12 +36,10 @@ fn main() { } } } - // Just using TTL.sh until we decide where to host these (local registry, ghcr, etc) - let oci_image = format!("ttl.sh/{}:72h", test.name); let env_config = SpinShim::config( ctr_binary.into(), spin_binary.into(), - oci_image.clone(), + test.name.clone(), test_environment::services::ServicesConfig::new(services).unwrap(), ); let mut env = TestEnvironment::up(env_config, move |e| { @@ -94,6 +92,12 @@ impl SpinShim { TestEnvironmentConfig { services_config, create_runtime: Box::new(move |env| { + let oci_image = format!( + "localhost:{port}/{oci_image}:latest", + port = env + .get_port(5000)? + .context("environment doesn't expose port for OCI registry")? + ); SpinShim::regisry_push(&spin_binary, &oci_image, env)?; SpinShim::image_pull(&ctr_binary, &oci_image)?; SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID) @@ -108,7 +112,7 @@ impl SpinShim { ) -> anyhow::Result<()> { // TODO: consider enabling configuring a port let mut cmd = Command::new(spin_binary_path); - cmd.args(["registry", "push"]).arg(image); + cmd.args(["registry", "push", "-k"]).arg(image); env.run_in(&mut cmd) .context("failed to push spin app to registry with 'spin'")?; Ok(()) @@ -126,7 +130,6 @@ impl SpinShim { } /// Start the Spin app using `ctr run` - /// Equivalent of `sudo ctr run --rm --net-host --runtime io.containerd.spin.v2 ttl.sh/myapp:48h ctr-run-id bogus-arg` for image `ttl.sh/myapp:48h` and run id `ctr-run-id` pub fn start( ctr_binary_path: &Path, env: &mut TestEnvironment, From 0a67bbbd1a40b10b06f57f84564fbf7d6085e924 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Tue, 25 Jun 2024 08:39:20 -0700 Subject: [PATCH 7/9] Update inline commenting Signed-off-by: Kate Goldenring --- conformance-tests/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index 179ace3..f84083b 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -110,7 +110,6 @@ impl SpinShim { image: &str, env: &mut TestEnvironment, ) -> anyhow::Result<()> { - // TODO: consider enabling configuring a port let mut cmd = Command::new(spin_binary_path); cmd.args(["registry", "push", "-k"]).arg(image); env.run_in(&mut cmd) @@ -119,7 +118,6 @@ impl SpinShim { } pub fn image_pull(ctr_binary_path: &Path, image: &str) -> anyhow::Result<()> { - // TODO: consider enabling configuring a port Command::new(ctr_binary_path) .args(["image", "pull"]) .arg(image) @@ -136,6 +134,7 @@ impl SpinShim { image: &str, ctr_run_id: &str, ) -> anyhow::Result { + // TODO: consider enabling configuring a port let port = 80; let mut ctr_cmd = std::process::Command::new(ctr_binary_path); let child = ctr_cmd @@ -143,6 +142,7 @@ impl SpinShim { .args(["--rm", "--net-host", "--runtime", "io.containerd.spin.v2"]) .arg(image) .arg(ctr_run_id) + // The container runtime expects at least one argument to the container .arg("bogus-arg") .stdout(Stdio::piped()) .stderr(Stdio::piped()); From cecce6ca9ddcee5de88a25871251b373ab0ca232 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Tue, 25 Jun 2024 10:20:41 -0700 Subject: [PATCH 8/9] Use latest conformance tests structure and tests Signed-off-by: Kate Goldenring --- conformance-tests/Cargo.toml | 4 ++-- conformance-tests/README.md | 6 +++--- conformance-tests/src/main.rs | 13 ++++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/conformance-tests/Cargo.toml b/conformance-tests/Cargo.toml index e4bcca3..aa3b9cc 100644 --- a/conformance-tests/Cargo.toml +++ b/conformance-tests/Cargo.toml @@ -9,7 +9,7 @@ homepage.workspace = true [dependencies] anyhow = "1.0" -conformance-tests = { git = "https://github.com/fermyon/conformance-tests" } +conformance-tests = { git = "https://github.com/fermyon/conformance-tests", ref = "c19e5cf54b7586829e923bd2091314e4d473f4f5" } log = "0.4" nix = "0.26" -test-environment = { git = "https://github.com/fermyon/conformance-tests" } +test-environment = { git = "https://github.com/fermyon/conformance-tests", ref = "c19e5cf54b7586829e923bd2091314e4d473f4f5" } diff --git a/conformance-tests/README.md b/conformance-tests/README.md index 6547013..b097ce0 100644 --- a/conformance-tests/README.md +++ b/conformance-tests/README.md @@ -26,14 +26,14 @@ Containerd must be configured to access the `containerd-shim-spin`: ``` ## Running tests -Containerd can only be executed as a root user. Choose one of the following options +Containerd can only be executed as a root user. Choose one of the following option, being sure to pass the path to the Spin and `ctr` binaries as arguments. 1. Build the `conformance-tests` bin and excute it as sudo user: ```sh cargo build - sudo ../target/debug/conformance-tests + sudo ../target/debug/conformance-tests /path/to/spin /path/to/ctr ``` 2. Run cargo as root by passing in the environment from the user's context and full path to cargo: ```sh - sudo -E $HOME/.cargo/bin/cargo run + sudo -E $HOME/.cargo/bin/cargo run /path/to/spin /path/to/ctr ``` 3. Follow the [containerd instructions](https://github.com/containerd/containerd/blob/main/docs/rootless.md) to configure it to be runnable as a non-root user \ No newline at end of file diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index f84083b..3463ac1 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -21,7 +21,11 @@ fn main() { .next() .expect("expected second arg to be path to ctr binary"); - 'test: for test in conformance_tests::tests(&tests_dir).unwrap() { + 'test: for test in conformance_tests::tests_iter(&tests_dir).unwrap() { + if test.name.starts_with("tcp") { + // Skip TCP tests for now as shim cannot create sockets + continue; + } println!("running test: {}", test.name); let mut services = vec!["registry".into()]; for precondition in &test.config.preconditions { @@ -34,6 +38,9 @@ fn main() { panic!("unsupported label: {}", k.label); } } + conformance_tests::config::Precondition::TcpEcho => { + services.push("tcp-echo".into()); + } } } let env_config = SpinShim::config( @@ -98,14 +105,14 @@ impl SpinShim { .get_port(5000)? .context("environment doesn't expose port for OCI registry")? ); - SpinShim::regisry_push(&spin_binary, &oci_image, env)?; + SpinShim::registry_push(&spin_binary, &oci_image, env)?; SpinShim::image_pull(&ctr_binary, &oci_image)?; SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID) }), } } - pub fn regisry_push( + pub fn registry_push( spin_binary_path: &Path, image: &str, env: &mut TestEnvironment, From 5e4ac59dad2ce3984c7252454408778487939c4e Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Wed, 26 Jun 2024 16:20:02 -0700 Subject: [PATCH 9/9] Use latest conformance-tests to leverage libtest-mimic and run in parallel - Set unique port for each run - Set unique ctr run ID for each run Signed-off-by: Kate Goldenring --- Cargo.lock | 4 +- conformance-tests/Cargo.toml | 4 +- conformance-tests/src/main.rs | 151 +++++++++++++++++++--------------- 3 files changed, 90 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd50e67..95d973a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1508,7 +1508,7 @@ dependencies = [ [[package]] name = "conformance-tests" version = "0.1.0" -source = "git+https://github.com/fermyon/conformance-tests#c19e5cf54b7586829e923bd2091314e4d473f4f5" +source = "git+https://github.com/fermyon/conformance-tests#db0ee32a825561d35f884a246e1d390134d78823" dependencies = [ "anyhow", "flate2", @@ -8036,7 +8036,7 @@ dependencies = [ [[package]] name = "test-environment" version = "0.1.0" -source = "git+https://github.com/fermyon/conformance-tests#c19e5cf54b7586829e923bd2091314e4d473f4f5" +source = "git+https://github.com/fermyon/conformance-tests#db0ee32a825561d35f884a246e1d390134d78823" dependencies = [ "anyhow", "fslock", diff --git a/conformance-tests/Cargo.toml b/conformance-tests/Cargo.toml index aa3b9cc..02e05ad 100644 --- a/conformance-tests/Cargo.toml +++ b/conformance-tests/Cargo.toml @@ -9,7 +9,7 @@ homepage.workspace = true [dependencies] anyhow = "1.0" -conformance-tests = { git = "https://github.com/fermyon/conformance-tests", ref = "c19e5cf54b7586829e923bd2091314e4d473f4f5" } +conformance-tests = { git = "https://github.com/fermyon/conformance-tests", ref = "db0ee32a825561d35f884a246e1d390134d78823" } log = "0.4" nix = "0.26" -test-environment = { git = "https://github.com/fermyon/conformance-tests", ref = "c19e5cf54b7586829e923bd2091314e4d473f4f5" } +test-environment = { git = "https://github.com/fermyon/conformance-tests", ref = "db0ee32a825561d35f884a246e1d390134d78823" } diff --git a/conformance-tests/src/main.rs b/conformance-tests/src/main.rs index 3463ac1..6782e78 100644 --- a/conformance-tests/src/main.rs +++ b/conformance-tests/src/main.rs @@ -1,4 +1,5 @@ use std::{ + hash::{DefaultHasher, Hash, Hasher}, path::{Path, PathBuf}, process::{Command, Stdio}, }; @@ -12,69 +13,67 @@ use test_environment::{ }; fn main() { - let tests_dir = conformance_tests::download_tests().unwrap(); let mut args = std::env::args().skip(1); - let spin_binary = &args + let spin_binary: std::path::PathBuf = args .next() - .expect("expected first arg to be path to Spin binary"); - let ctr_binary = &args + .expect("expected first arg to be path to Spin binary") + .into(); + let ctr_binary: std::path::PathBuf = args .next() - .expect("expected second arg to be path to ctr binary"); + .expect("expected second arg to be path to ctr binary") + .into(); + conformance_tests::run_tests(move |test| run_test(test, &spin_binary, &ctr_binary)).unwrap(); +} - 'test: for test in conformance_tests::tests_iter(&tests_dir).unwrap() { - if test.name.starts_with("tcp") { - // Skip TCP tests for now as shim cannot create sockets - continue; - } - println!("running test: {}", test.name); - let mut services = vec!["registry".into()]; - for precondition in &test.config.preconditions { - match precondition { - conformance_tests::config::Precondition::HttpEcho => { - services.push("http-echo".into()); - } - conformance_tests::config::Precondition::KeyValueStore(k) => { - if k.label != "default" { - panic!("unsupported label: {}", k.label); - } - } - conformance_tests::config::Precondition::TcpEcho => { - services.push("tcp-echo".into()); - } +fn run_test( + test: conformance_tests::Test, + spin_binary: &std::path::Path, + ctr_binary: &std::path::Path, +) -> anyhow::Result<()> { + println!("running test: {}", test.name); + let mut services = vec!["registry".into()]; + for precondition in &test.config.preconditions { + match precondition { + conformance_tests::config::Precondition::HttpEcho => { + services.push("http-echo".into()); } - } - let env_config = SpinShim::config( - ctr_binary.into(), - spin_binary.into(), - test.name.clone(), - test_environment::services::ServicesConfig::new(services).unwrap(), - ); - let mut env = TestEnvironment::up(env_config, move |e| { - let mut manifest = - test_environment::manifest_template::EnvTemplate::from_file(&test.manifest) - .unwrap(); - manifest.substitute(e, |_| None).unwrap(); - e.write_file("spin.toml", manifest.contents())?; - e.copy_into(&test.component, test.component.file_name().unwrap())?; - Ok(()) - }) - .unwrap(); - for invocation in test.config.invocations { - let conformance_tests::config::Invocation::Http(mut invocation) = invocation; - invocation.request.substitute_from_env(&mut env).unwrap(); - let shim = env.runtime_mut(); - if let Err(e) = invocation.run(|request| shim.make_http_request(request)) { - println!("❌ test failed: {}", test.name); - println!("error: {}", e); - for e in e.chain() { - println!("\t{}", e); + conformance_tests::config::Precondition::KeyValueStore(k) => { + if k.label != "default" { + panic!("unsupported label: {}", k.label); } - - continue 'test; + } + conformance_tests::config::Precondition::TcpEcho => { + services.push("tcp-echo".into()); + } + conformance_tests::config::Precondition::Sqlite => {} + conformance_tests::config::Precondition::Redis => { + services.push("redis".into()); } } - println!("✅ test passed: {}", test.name); } + let env_config = SpinShim::config( + ctr_binary.into(), + spin_binary.into(), + test.name.clone(), + test_environment::services::ServicesConfig::new(services).unwrap(), + &test.name, + ); + let mut env = TestEnvironment::up(env_config, move |e| { + let mut manifest = + test_environment::manifest_template::EnvTemplate::from_file(&test.manifest).unwrap(); + manifest.substitute(e, |_| None).unwrap(); + e.write_file("spin.toml", manifest.contents())?; + e.copy_into(&test.component, test.component.file_name().unwrap())?; + Ok(()) + }) + .unwrap(); + for invocation in test.config.invocations { + let conformance_tests::config::Invocation::Http(mut invocation) = invocation; + invocation.request.substitute_from_env(&mut env).unwrap(); + let shim = env.runtime_mut(); + invocation.run(|request| shim.make_http_request(request))?; + } + Ok(()) } struct SpinShim { @@ -85,9 +84,21 @@ struct SpinShim { io_mode: IoMode, } -/// `ctr run` invocations require an ID that is unique to all currently running instances. Since -/// only one test runs at a time, we can reuse a constant ID. -const CTR_RUN_ID: &str = "run-id"; +fn hash(obj: T) -> u64 +where + T: Hash, +{ + let mut hasher = DefaultHasher::new(); + obj.hash(&mut hasher); + hasher.finish() +} + +/// Uses a track to get a random unused port +fn get_available_port() -> anyhow::Result { + Ok(std::net::TcpListener::bind("localhost:0")? + .local_addr()? + .port()) +} impl SpinShim { pub fn config( @@ -95,7 +106,9 @@ impl SpinShim { spin_binary: PathBuf, oci_image: String, services_config: ServicesConfig, + test_id: &str, ) -> TestEnvironmentConfig { + let ctr_run_id = hash(test_id).to_string(); TestEnvironmentConfig { services_config, create_runtime: Box::new(move |env| { @@ -107,7 +120,7 @@ impl SpinShim { ); SpinShim::registry_push(&spin_binary, &oci_image, env)?; SpinShim::image_pull(&ctr_binary, &oci_image)?; - SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID) + SpinShim::start(&ctr_binary, env, &oci_image, &ctr_run_id) }), } } @@ -125,12 +138,12 @@ impl SpinShim { } pub fn image_pull(ctr_binary_path: &Path, image: &str) -> anyhow::Result<()> { - Command::new(ctr_binary_path) + let output = Command::new(ctr_binary_path) .args(["image", "pull"]) .arg(image) .output() .context("failed to pull spin app with 'ctr'")?; - // TODO: assess output + anyhow::ensure!(output.status.success(), "pulling image failed"); Ok(()) } @@ -141,13 +154,21 @@ impl SpinShim { image: &str, ctr_run_id: &str, ) -> anyhow::Result { - // TODO: consider enabling configuring a port - let port = 80; + let port = get_available_port().context("no available port")?; + let listen_adress_env = format!("SPIN_HTTP_LISTEN_ADDR=0.0.0.0:{}", port); let mut ctr_cmd = std::process::Command::new(ctr_binary_path); let child = ctr_cmd .arg("run") - .args(["--rm", "--net-host", "--runtime", "io.containerd.spin.v2"]) + .args([ + "--rm", + "--net-host", + "--runtime", + "io.containerd.spin.v2", + "--env", + ]) + .arg(listen_adress_env) .arg(image) + // `ctr run` invocations require an ID that is unique to all currently running instances .arg(ctr_run_id) // The container runtime expects at least one argument to the container .arg("bogus-arg") @@ -199,9 +220,9 @@ impl SpinShim { ) } - /// Make an HTTP request against Spin + /// Make an HTTP request against the shim. /// - /// Will fail if Spin has already exited or if the io mode is not HTTP + /// Will fail if the shim has already exited. pub fn make_http_request(&mut self, request: Request<'_, String>) -> anyhow::Result { let IoMode::Http(port) = self.io_mode; if let Some(status) = self.try_wait()? {