vtest "Test priv_call discard"

vinyl v1 -cliok "param.set thread_pools 1"
vinyl v1 -vcl {
	import cookie;
	backend be none;
	sub vcl_recv { return (synth(200)); }
	sub vcl_synth {
		cookie.set("cookie1", "value1");
		cookie.set("cookie2", "value2");
		cookie.set("cookie3", "value3");

		cookie.filter_re("noop");
		cookie.keep_re("cook");
		set resp.http.get = cookie.get_re("cookie");
	}
} -start

client c1 {
	txreq -url "/"
	rxresp
	expect resp.http.get == value1
} -run

# load a new VCL to discard the first one
vinyl v1 -vcl {backend be none;}
vinyl v1 -cliok {vcl.discard vcl1}

# tickle the CLI to trigger the effective VCL discard
vinyl v1 -cliok ping
vinyl v1 -expect n_vcl_avail == 1
vinyl v1 -expect n_vcl_discard == 0

# tickle again, check we survived discard-time assertions
vinyl v1 -cliok ping
