Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 81d2443

Browse files
authored
test(spin): add more integration tests (#181)
* test(spin): add more integration tests This commit adds an integration test for spin-keyvalue using dynamic config file that was introduced by #179 and an integraion test for outbound redis introduced by #117 Signed-off-by: jiaxiao zhou <[email protected]>
1 parent 1e5c06f commit 81d2443

File tree

21 files changed

+1454
-520
lines changed

21 files changed

+1454
-520
lines changed

Cargo.lock

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

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ To build the shims in this project, run `make build`.
4141

4242
To run the integration tests, run `make integration-tests`.
4343

44-
### Cleaning up
45-
4644
To clean up, run `make tests/clean`.
4745

4846
## Example Kubernetes Cluster Deployments

containerd-shim-spin/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl SpinEngine {
223223
let mut runtime_config = RuntimeConfig::new(PathBuf::from("/").into());
224224
// Load in runtime config if one exists at expected location
225225
if Path::new(RUNTIME_CONFIG_PATH).exists() {
226-
runtime_config.merge_config_file(RUNTIME_CONFIG_PATH);
226+
runtime_config.merge_config_file(RUNTIME_CONFIG_PATH)?;
227227
}
228228
let mut builder = TriggerExecutorBuilder::new(loader);
229229
builder
Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
spin_version = "1"
1+
spin_manifest_version = 2
2+
3+
[application]
24
authors = ["Suneet Nangia <[email protected]>"]
3-
name = "spin-hello"
4-
trigger = { type = "redis", address = "redis:/localhost:6379" }
5+
name = "spin-inbound-redis"
56
version = "1.0.0"
67

7-
[[component]]
8-
environment = { REDIS_ADDRESS = "redis://localhost:6379", REDIS_CHANNEL = "messages-out" }
9-
id = "hello"
8+
[variables]
9+
redis_address = { required = true }
10+
redis_channel = { required = true }
11+
12+
[[trigger.redis]]
13+
address = "redis://redis-service.default.svc.cluster.local:6379"
14+
component = "hello"
15+
16+
[component.hello]
1017
source = "spin_inbound_redis.wasm"
11-
allowed_http_hosts = []
12-
[component.trigger]
13-
channel = "messages-in"
18+
allowed_outbound_hosts = ["redis://*:*"]
19+
20+
[component.hello.variables]
21+
redis_address = "{{ redis_address }}"
22+
redis_channel = "{{ redis_channel }}"
23+

images/spin-inbound-redis/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ use anyhow::Result;
22
use bytes::Bytes;
33
use spin_sdk::redis_component;
44
use std::str::from_utf8;
5-
use spin_sdk::redis;
6-
7-
const REDIS_ADDRESS_ENV: &str = "REDIS_ADDRESS";
8-
const REDIS_CHANNEL_ENV: &str = "REDIS_CHANNEL";
5+
use spin_sdk::{redis, variables};
96

107
/// A simple Spin Redis component.
118
#[redis_component]
129
fn on_message(message: Bytes) -> Result<()> {
1310

14-
let address = std::env::var(REDIS_ADDRESS_ENV)?;
15-
let channel = std::env::var(REDIS_CHANNEL_ENV)?;
16-
11+
let address = variables::get("redis_address").expect("could not get variable");
12+
let channel = variables::get("redis_channel").expect("could not get variable");
1713
let conn = redis::Connection::open(&address)?;
1814

1915
println!("{}", from_utf8(&message)?);

0 commit comments

Comments
 (0)