Skip to content

Commit 8decd49

Browse files
committed
add e2e tests
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent ca8d9f0 commit 8decd49

10 files changed

Lines changed: 579 additions & 26 deletions

File tree

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
22
# Ignore build and test binaries.
33
bin/
4+
target/
5+
.venv/
6+
.pytest_cache/
7+
.ruff_cache/
8+
.git/
9+
.github/
10+
*.egg-info/
11+
__pycache__/
12+
*.pyc
13+
*.pyo
14+
.DS_Store
15+
.env
16+
docker-compose*.yml
17+
docs/
18+
examples/
19+
python/tests/

.github/workflows/rust-ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ jobs:
3636
with:
3737
toolchain: stable
3838

39-
- name: Run tests
39+
- name: Run Unit tests
4040
run: make test
41+
42+
- name: Run E2E tests
43+
run: make e2e-test

Cargo.lock

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

Dockerfile

Whitespace-only changes.

Dockerfile.e2e

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Multi-stage build for SandD daemon
2+
# Use latest Rust for building
3+
FROM rust:1.85-slim as builder
4+
5+
WORKDIR /app
6+
7+
# Install build dependencies
8+
RUN apt-get update && apt-get install -y \
9+
pkg-config \
10+
libssl-dev \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Copy workspace files
14+
COPY Cargo.toml Cargo.lock ./
15+
COPY sandd/ ./sandd/
16+
COPY server/ ./server/
17+
18+
# Build the daemon binary in release mode
19+
RUN cargo build --package sandd --release
20+
21+
# Runtime stage - use trixie for newer glibc
22+
FROM debian:trixie-slim
23+
24+
# Install runtime dependencies
25+
RUN apt-get update && apt-get install -y \
26+
ca-certificates \
27+
libssl3 \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
# Copy the binary from builder
31+
COPY --from=builder /app/target/release/sandd /usr/local/bin/sandd
32+
33+
# Set working directory
34+
WORKDIR /workspace
35+
36+
# Default command - can be overridden
37+
ENTRYPOINT ["/usr/local/bin/sandd"]
38+
CMD ["--help"]

Makefile

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ RUFF := .venv/bin/ruff
22
PYTEST := .venv/bin/pytest
33
MATURIN := .venv/bin/maturin
44

5-
.PHONY: help build install dev test clean daemon-build daemon-release
5+
.PHONY: help build install dev test clean daemon-build daemon-release test-e2e docker-build docker-down
66

77
help:
88
@echo "SandD - Sandbox Daemon - Build Commands"
99
@echo ""
1010
@echo " make build - Build Python package (debug mode)"
1111
@echo " make install - Install Python package locally"
1212
@echo " make dev - Install in development mode with hot reload"
13-
@echo " make test - Run tests"
13+
@echo " make test - Run unit and integration tests"
14+
@echo " make test-e2e - Run end-to-end tests with Docker"
1415
@echo " make daemon-build - Build daemon binary (debug)"
1516
@echo " make daemon-release - Build daemon binary (release)"
17+
@echo " make docker-build - Build Docker image for daemon"
18+
@echo " make docker-down - Stop and remove Docker containers"
1619
@echo " make clean - Clean build artifacts"
1720

1821
build: $(MATURIN)
@@ -48,6 +51,25 @@ clean:
4851
rm -rf python/sandd.egg-info/
4952
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
5053

54+
test-e2e: $(PYTEST) dev
55+
@echo "Building Docker images..."
56+
docker compose -f docker-compose.e2e.yml build
57+
@echo ""
58+
@echo "Running E2E tests with Docker..."
59+
$(PYTEST) python/tests/test_e2e.py -v -s
60+
@echo ""
61+
@echo "Cleaning up containers..."
62+
docker compose -f docker-compose.e2e.yml down
63+
64+
docker-build:
65+
docker compose -f docker-compose.e2e.yml build
66+
67+
docker-down:
68+
docker compose -f docker-compose.e2e.yml down
69+
70+
test-all: test test-e2e
71+
@echo "All tests completed successfully"
72+
5173
.PHONY: lint
5274
lint: $(RUFF)
5375
$(RUFF) check .

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# SandD
44

5-
**Sandbox Daemon for Secure Remote Command Execution**
5+
**A Lightweight Sandbox Daemon for Secure Agent Execution in Isolated Environments.**
66

7-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
87
[![Rust](https://img.shields.io/badge/rust-1.70+-orange.svg)](https://www.rust-lang.org/)
98
[![Python](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/)
9+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1010

1111
Rust-powered WebSocket server with Python API for secure command execution in isolated environments.
1212

docker-compose.e2e.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
version: '3.8'
2+
3+
services:
4+
# The daemon running in a container
5+
daemon1:
6+
build:
7+
context: .
8+
dockerfile: Dockerfile.e2e
9+
container_name: sandd-daemon-1
10+
command: >
11+
--server-url ws://host.docker.internal:8765/ws
12+
--daemon-id daemon-1
13+
--label env=test
14+
--label region=us-east
15+
networks:
16+
- sandd-network
17+
extra_hosts:
18+
- "host.docker.internal:host-gateway"
19+
restart: unless-stopped
20+
healthcheck:
21+
test: ["CMD", "pgrep", "-f", "sandd"]
22+
interval: 5s
23+
timeout: 3s
24+
retries: 3
25+
26+
daemon2:
27+
build:
28+
context: .
29+
dockerfile: Dockerfile.e2e
30+
container_name: sandd-daemon-2
31+
command: >
32+
--server-url ws://host.docker.internal:8765/ws
33+
--daemon-id daemon-2
34+
--label env=test
35+
--label region=us-west
36+
networks:
37+
- sandd-network
38+
extra_hosts:
39+
- "host.docker.internal:host-gateway"
40+
restart: unless-stopped
41+
healthcheck:
42+
test: ["CMD", "pgrep", "-f", "sandd"]
43+
interval: 5s
44+
timeout: 3s
45+
retries: 3
46+
47+
daemon3:
48+
build:
49+
context: .
50+
dockerfile: Dockerfile.e2e
51+
container_name: sandd-daemon-3
52+
command: >
53+
--server-url ws://host.docker.internal:8765/ws
54+
--daemon-id daemon-3
55+
--label env=prod
56+
--label region=eu-west
57+
networks:
58+
- sandd-network
59+
extra_hosts:
60+
- "host.docker.internal:host-gateway"
61+
restart: unless-stopped
62+
healthcheck:
63+
test: ["CMD", "pgrep", "-f", "sandd"]
64+
interval: 5s
65+
timeout: 3s
66+
retries: 3
67+
68+
networks:
69+
sandd-network:
70+
driver: bridge

0 commit comments

Comments
 (0)