Skip to content

Commit 42d73ee

Browse files
Felixoidsylvestre
andauthored
Integration tests (#2564)
--------- Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
1 parent a46b26b commit 42d73ee

File tree

14 files changed

+892
-700
lines changed

14 files changed

+892
-700
lines changed

.github/workflows/integration-tests.yml

Lines changed: 10 additions & 672 deletions
Large diffs are not rendered by default.

tests/integration/Makefile

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
.PHONY: help clean $(addprefix test-,$(BACKENDS)) $(addprefix clean-,$(BACKENDS)) test-backends
2+
3+
export UID := $(shell id -u)
4+
export GID := $(shell id -g)
5+
6+
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)
7+
SCCACHE_BIN := $(PROJECT_ROOT)/target/debug/sccache
8+
9+
BACKENDS := redis redis-deprecated memcached memcached-deprecated s3 azblob webdav
10+
TOOLS := gcc clang cmake autotools coverage zstd
11+
12+
# Map backends to their compose profiles
13+
PROFILE_redis := redis
14+
PROFILE_redis-deprecated := redis
15+
PROFILE_memcached := memcached
16+
PROFILE_memcached-deprecated := memcached
17+
PROFILE_s3 := s3
18+
PROFILE_azblob := azblob
19+
PROFILE_webdav := webdav
20+
PROFILE_gcc := gcc
21+
PROFILE_clang := clang
22+
PROFILE_cmake := cmake
23+
PROFILE_autotools := autotools
24+
PROFILE_coverage := coverage
25+
PROFILE_zstd := zstd
26+
27+
# Map backends to their services
28+
SERVICES_redis := redis
29+
SERVICES_redis-deprecated := redis
30+
SERVICES_memcached := memcached
31+
SERVICES_memcached-deprecated := memcached
32+
SERVICES_s3 := minio minio-setup
33+
SERVICES_azblob := azurite azurite-setup
34+
SERVICES_webdav := webdav
35+
SERVICES_gcc :=
36+
SERVICES_clang :=
37+
SERVICES_cmake :=
38+
SERVICES_autotools :=
39+
SERVICES_coverage :=
40+
SERVICES_zstd :=
41+
42+
help:
43+
@echo "sccache Integration Tests"
44+
@echo ""
45+
@echo "Available targets:"
46+
@echo " make build Build sccache binary"
47+
@echo ""
48+
@echo "Backend Storage Tests:"
49+
@echo " make test-redis Run Redis (new endpoint) test"
50+
@echo " make test-redis-deprecated Run Redis (deprecated) test"
51+
@echo " make test-memcached Run Memcached (new endpoint) test"
52+
@echo " make test-memcached-deprecated Run Memcached (deprecated) test"
53+
@echo " make test-s3 Run S3/MinIO test"
54+
@echo " make test-azblob Run Azure Blob Storage test"
55+
@echo " make test-webdav Run WebDAV test"
56+
@echo ""
57+
@echo "Compiler Integration Tests:"
58+
@echo " make test-gcc Run GCC compiler test"
59+
@echo " make test-clang Run Clang compiler test"
60+
@echo ""
61+
@echo "Build System Tests:"
62+
@echo " make test-cmake Run CMake integration test"
63+
@echo " make test-autotools Run Autotools integration test"
64+
@echo ""
65+
@echo "Advanced Tests:"
66+
@echo " make test-coverage Run Rust coverage instrumentation test"
67+
@echo " make test-zstd Run ZSTD compression levels test"
68+
@echo ""
69+
@echo " make test-backends Run all backend tests"
70+
@echo " make clean Stop all services and clean up"
71+
@echo " make help Show this help"
72+
73+
build: $(SCCACHE_BIN) $(PROJECT_ROOT)/target/integration-cargo-cache
74+
75+
# Create a persistent cargo cache for integration tests, used to avoid re-downloading dependencies
76+
$(PROJECT_ROOT)/target/integration-cargo-cache:
77+
@mkdir -p $@
78+
79+
$(SCCACHE_BIN): $(PROJECT_ROOT)/Cargo.toml $(PROJECT_ROOT)/Cargo.lock
80+
@echo "Building sccache in Docker..."
81+
@docker run --rm \
82+
-v $(PROJECT_ROOT):/sccache \
83+
-v integration-cargo-cache:/usr/local/cargo/registry \
84+
-w /sccache \
85+
-e OPENSSL_NO_VENDOR=1 \
86+
rust:latest \
87+
bash -c "apt-get update -qq && apt-get install -y -qq libssl-dev pkg-config && \
88+
cargo build --all-features && \
89+
chown -R $(UID):$(GID) target"
90+
@echo "Binary built: $(SCCACHE_BIN)"
91+
@ls -lh $(SCCACHE_BIN)
92+
93+
# Pattern rule for cleaning backends
94+
clean-%:
95+
@docker compose --profile $(PROFILE_$*) down -v
96+
97+
# Pattern rule for testing backends
98+
test-%: build clean-%
99+
@echo "Testing $* backend..."
100+
@docker compose --profile $(PROFILE_$*) up --quiet-pull -d $(SERVICES_$*)
101+
@docker compose --profile $(PROFILE_$*) run --quiet-pull --rm test-$*
102+
@docker compose --profile $(PROFILE_$*) down
103+
@echo "$* test completed"
104+
105+
test-backends: $(addprefix test-,$(BACKENDS))
106+
@echo "All backend tests completed"
107+
108+
test-tools: $(addprefix test-,$(TOOLS))
109+
@echo "All backend tests completed"
110+
111+
test: test-backends test-tools
112+
@echo "All tests completed"
113+
114+
clean:
115+
@docker compose --profile '*' down -v
116+
@echo "Cleanup complete"

tests/integration/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# sccache Integration Tests
2+
3+
Docker Compose-based integration tests for sccache backends and compilers.
4+
5+
## Prerequisites
6+
7+
- Docker and Docker Compose
8+
- Make (optional, for convenience)
9+
10+
## Quick Start
11+
12+
```bash
13+
cd tests/integration
14+
15+
# Run a specific test
16+
make test-redis
17+
18+
# Run all backend tests
19+
make test-backends
20+
21+
# Run all tools tests
22+
make test-tools
23+
24+
# Clean up
25+
make clean
26+
```
27+
28+
## Binary Management
29+
30+
Tests will automatically use existing `target/debug/sccache` binary if present.
31+
If not found, it will build in Docker automatically.
32+
33+
To pre-build manually:
34+
```bash
35+
cargo build --all-features
36+
```
37+
38+
## Test Pattern
39+
40+
Each backend test follows this pattern:
41+
42+
1. Start required service (redis, memcached, etc.)
43+
2. Run cargo build (cache miss expected)
44+
3. Verify backend is used via JSON stats
45+
4. Run cargo build again (cache hit expected)
46+
5. Verify cache hits > 0 via JSON stats
47+
6. Clean up service state
48+
7. Stop services
49+
50+
### Cleanup
51+
- `make clean` - Stop all services and remove volumes
52+
53+
## Debugging
54+
55+
Run test manually:
56+
```bash
57+
docker compose --profile redis up -d redis
58+
docker compose --profile redis run --rm test-redis
59+
```
60+
61+
Check service logs:
62+
```bash
63+
docker compose logs redis
64+
```
65+
66+
Manual cleanup:
67+
```bash
68+
docker compose --profile cleanup run --rm cleanup-redis
69+
```

0 commit comments

Comments
 (0)