vtest "test logexpect"

server s1 {
	rxreq
	txresp
} -start

vinyl v1 -vcl+backend {
} -start

logexpect l1 -v v1 -g session {
	expect 0 1000	Begin		sess
	expect 0 =	SessOpen
	expect * =	Link		"req 1001"
	expect 0 =	SessClose
	expect 0 =	End

	expect 0 *	Begin		"req 1000"
	expect * =	ReqStart
	expect 0 =	ReqMethod	GET
	expect 0 =	ReqURL		/
	expect 0 =	ReqProtocol	HTTP/1.1
	expect * =	ReqHeader	"Foo: bar"
	expect * =	Link		bereq
	expect * =	End

	expect 0 1002	Begin		"bereq 1001"
	expect * =	End
} -start

# Check with a query (this selects only the backend request)
logexpect l2 -v v1 -g vxid -q "Begin ~ 'bereq 1001'" {
	expect 0 1002	Begin
	expect * =	End
} -start

client c1 {
	txreq -hdr "Foo: bar"
	rxresp
	expect resp.status == 200
} -run

logexpect l1 -wait
logexpect l2 -wait

# Check -d arg
logexpect l1 -d 1 {
	expect 0 1000	Begin		sess
	expect * =	SessClose
} -run
