vtest "h2 reset interrupt"

barrier b1 sock 2
barrier b2 sock 2

vinyl v1 -cliok "param.set feature +http2"
vinyl v1 -cliok "param.set debug +syncvsl"
vinyl 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

vinyl v1 -vsl_catchup
vinyl v1 -expect req_reset == 1

# NB: The vinylncsa 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" {
	vinylncsa -n ${v1_name} -d \
		-q 'Timestamp:Reset[2] < 1.0' -F '%{VSL:Begin[2]}x %h %s'
}
