← ClaudeAtlas

varnish-test-vtc-syntaxlisted

Use when a Varnish caching layer or VCL change needs tests: varnishtest VTC files with server, client and varnish blocks, grace and saint modes, PURGE handlers with ACLs, and surrogate-key invalidation with the xkey vmod.
testland/qa · ★ 13 · Testing & QA · score 80
Install: claude install-skill testland/qa
# varnish-test-vtc-syntax ## Overview `varnishtest` (CLI) executes `.vtc` (Varnish Test Case) files that spin up a Varnish instance + a mock backend + a mock client in-process. Per [varnish-cache.org/docs](https://varnish-cache.org/docs/), VTC is the canonical way to test VCL - Varnish's configuration language - without a real network. ## When to use - Authoring or modifying VCL. - Testing PURGE handlers, grace/saint mode, surrogate-key logic. - Regression-testing VCL after Varnish version bump. - CI gate before a VCL deploy. ## Authoring ### Install Varnish ships `varnishtest` in the standard distribution: ```bash apt install varnish # Debian/Ubuntu brew install varnish # macOS varnishtest -v # verify ``` ### Anatomy of a VTC ``` varnishtest "basic cache hit test" server s1 { rxreq txresp -hdr "Cache-Control: max-age=60" -body "hello" } -start varnish v1 -vcl+backend { // VCL goes here } -start client c1 { txreq -url "/" rxresp expect resp.status == 200 expect resp.body == "hello" txreq -url "/" rxresp expect resp.http.x-cache == "HIT" // assumes vcl_deliver sets this } -run varnish v1 -expect cache_hit == 1 ``` Per Varnish docs, the VTC file has four block types: | Block | Purpose | |---|---| | `server sN` | Mock origin | | `varnish vN` | Varnish instance with VCL | | `client cN` | Send requests, assert responses | | `barrier`, `delay`, `shell` | Synchronisation + setup | ### Testing PURGE The canonical patte