varnishtest "h2 reset interrupt"

barrier b1 sock 2
barrier b2 sock 2

varnish v1 -cliok "param.set feature +http2"
varnish v1 -cliok "param.set debug +syncvsl"
varnish v1 -vcl {
	import vtc;

	backend be none;

	sub vcl_recv {
		vtc.barrier_sync("${b1_sock}");
		vtc.barrier_sync("${b2_sock}");
	}

	sub vcl_miss {
		vtc.panic("unreachable");
	}
} -start

logexpect l1 -v v1 -g raw -i Debug {
	expect * * Debug "^H2RXF RST_STREAM"
} -start

client c1 {
	stream 0 {
		rxgoaway
		expect goaway.err == NO_ERROR
		expect goaway.laststream == 1
	} -start
	stream 1 {
		txreq
		barrier b1 sync
		txrst
	} -run
	stream 0 -wait
} -start

logexpect l1 -wait
barrier b2 sync

client c1 -wait

varnish v1 -vsl_catchup
varnish v1 -expect req_reset == 1

# NB: The varnishncsa command below shows a minimal pattern to collect
# "rapid reset" suspects per session, with the IP address. Here rapid
# is interpreted as before a second elapsed. Session VXIDs showing up
# numerous times become increasingly more suspicious. The format can of
# course be extended to add anything else useful for data mining.
shell -expect "1000 ${localhost} 408" {
	varnishncsa -n ${v1_name} -d \
		-q 'Timestamp:Reset[2] < 1.0' -F '%{VSL:Begin[2]}x %h %s'
}
