Enhance Makefile and documentation for validation workflow
- Added new targets in the Makefile for validation, including `run-validation`, `validate-check`, and `validate-kill`, to streamline the testing process with external tools like SteamPrefill. - Introduced a `setcap` target to manage necessary capabilities for running the server on port 80 without root access. - Updated README.md to include detailed instructions for validating functionality, including quick start guides and troubleshooting tips. - Improved .gitignore to exclude validation artifacts and logs, ensuring a cleaner repository.
This commit is contained in:
@@ -61,6 +61,113 @@ Run `make help` to see the full list of available commands.
|
||||
|
||||
This is the preferred approach for day-to-day development. Avoid running raw `go test`, `go run`, or `golangci-lint` commands directly for routine tasks.
|
||||
|
||||
### Validating Full Functionality with external tools
|
||||
|
||||
steamcache2 provides a convenient small-cache configuration and helper targets so you can easily validate behavior using external tools such as [SteamPrefill (tpill90/steam-lancache-prefill)](https://github.com/tpill90/steam-lancache-prefill).
|
||||
|
||||
This gives you:
|
||||
- Real Steam manifest + chunk traffic (no reinventing the wheel)
|
||||
- Excellent `benchmark setup` / `benchmark run` workflow with warmup, randomization, and mixed chunk sizes
|
||||
- The ability to validate a **just-built binary** end-to-end (caching, coalescing, Range support, memory+disk tiers, GC/eviction, metrics, special endpoints, startup validation, etc.)
|
||||
|
||||
#### Quick Start
|
||||
|
||||
```bash
|
||||
# 1. Build the binary (this also runs short tests)
|
||||
make build
|
||||
|
||||
# 2. Start a validation-oriented instance (small caches so disk tier + GC get exercised)
|
||||
# Uses port 80 by default; the script will automatically set the needed
|
||||
# capability on the binary via sudo setcap if it is missing.
|
||||
./scripts/validate-with-prefill.sh
|
||||
|
||||
# 3. In another terminal (or on another machine), create a workload once if you haven't already,
|
||||
# then drive it through your local steamcache2.
|
||||
# Note: when using a non-80 port you may need to give SteamPrefill the full address.
|
||||
./scripts/validate-with-prefill.sh # (shows the exact commands with the correct port)
|
||||
```
|
||||
|
||||
When the benchmark finishes, press Ctrl-C in the first terminal to cleanly stop the server.
|
||||
|
||||
#### Simple validation server (recommended for manual testing)
|
||||
|
||||
For easy validation with external tools (SteamPrefill, etc.), use:
|
||||
|
||||
```bash
|
||||
make run-validation
|
||||
# or
|
||||
make validate
|
||||
```
|
||||
|
||||
This starts `steamcache2` on port 80 using a deliberately small memory + disk configuration (good for exercising the disk tier, GC, coalescing, promotions, etc.).
|
||||
|
||||
`make run-validation` (and `make validate`) will automatically ensure the `cap_net_bind_service` capability is set on the binary it just built (one sudo prompt the first time after each rebuild). This keeps the server running as your normal user so the disk cache directory stays owned by you.
|
||||
|
||||
If you want the capability on the binary for other workflows (e.g. `make run`, or running the binary directly on port 80), use the explicit target:
|
||||
|
||||
```bash
|
||||
make setcap
|
||||
```
|
||||
|
||||
When the server is running, point your external SteamPrefill (or other load generator) at it:
|
||||
|
||||
```bash
|
||||
./SteamPrefill benchmark run ...
|
||||
```
|
||||
|
||||
When finished, you can get a quick metrics summary with:
|
||||
|
||||
```bash
|
||||
make validate-check
|
||||
```
|
||||
|
||||
This is the recommended simple workflow. No automatic downloading or running of external tools.
|
||||
|
||||
#### Inspecting the Result
|
||||
|
||||
After a benchmark run you can ask for a quick report:
|
||||
|
||||
```bash
|
||||
make validate-check
|
||||
# or manually:
|
||||
curl -s http://localhost/metrics
|
||||
```
|
||||
|
||||
Look for:
|
||||
- High cache hit rate after the warmup pass
|
||||
- Non-zero `coalesced` and `disk` activity
|
||||
- Zero unexpected errors
|
||||
|
||||
#### The Validation Config
|
||||
|
||||
The script uses [docs/examples/validate-config.yaml](docs/examples/validate-config.yaml). It enables both memory and disk tiers at modest sizes (128 MB / 512 MB) with conservative concurrency. Edit or copy it if you need larger caches for bigger workloads.
|
||||
|
||||
#### What Gets Validated
|
||||
|
||||
Running a realistic SteamPrefill benchmark workload through a built steamcache2 exercises the complete public surface that matters for production use:
|
||||
- Steam User-Agent detection and depot/manifest/chunk URL patterns
|
||||
- Full MISS → cache write → HIT (and HIT-COALESCED) paths
|
||||
- Range request handling from cached full responses
|
||||
- Request coalescing under concurrent load
|
||||
- Memory tier + disk tier interaction (including async disk attach)
|
||||
- Garbage collection and eviction under pressure
|
||||
- Metrics and special endpoints (`/`, `/lancache-heartbeat`, `/metrics`)
|
||||
- Per-client and global rate limiting (with trusted proxy handling)
|
||||
- Startup configuration validation and upstream behavior
|
||||
- Clean shutdown hygiene
|
||||
|
||||
This is the closest practical equivalent to "run the thing real clients will run and make sure nothing is broken."
|
||||
|
||||
#### Troubleshooting
|
||||
|
||||
- **Low hit rate on first run**: Normal. The first `benchmark run` is the warmup that populates the cache.
|
||||
- **Want to test real disk I/O (not RAM cache)**: Make sure your workload size (shown by `benchmark setup`) is larger than the total RAM on the machine running steamcache2.
|
||||
- **Server won't start or bind on port 80 as non-root**: `make run-validation` and `make validate` automatically run `setcap` on the binary they just built. If it still fails, run `make setcap` explicitly and retry. The server always runs as your normal user (no root) so the disk cache directory ownership stays correct.
|
||||
- **SteamPrefill not found**: Install it yourself from its GitHub releases. Then use `make validate` to start the server with small caches and point SteamPrefill at it manually.
|
||||
- **SteamPrefill won't use server as cache properly**: SteamPrefill has some bad autodetectiong functions sometimes it works when the server is resolvable from localhost or 127.0.0.1 other times you have to fully override the dns for the proper dns name lancache.steamcontent.com to point to 127.0.0.1 i don't recommend doing it unless your okay with having to undo and redo it depending on if your running the server or not its a pain.
|
||||
|
||||
See also the SteamPrefill documentation for `benchmark setup` and `benchmark run` options.
|
||||
|
||||
### Command Line Flags
|
||||
|
||||
While most configuration is done via the YAML file, some runtime options are still available as command-line flags:
|
||||
|
||||
Reference in New Issue
Block a user