vtest "Test -h critbit for digest edges"

server s1 {
	rxreq
	expect req.url == "/1"
	txresp -body "\n"
	rxreq
	expect req.url == "/2"
	txresp -body "x\n"
	rxreq
	expect req.url == "/3"
	txresp -body "xx\n"
	rxreq
	expect req.url == "/4"
	txresp -body "xxx\n"
	rxreq
	expect req.url == "/5"
	txresp -body "xxxx\n"
	rxreq
	expect req.url == "/6"
	txresp -body "xxxxx\n"
	rxreq
	expect req.url == "/7"
	txresp -body "xxxxxx\n"
	rxreq
	expect req.url == "/8"
	txresp -body "xxxxxxx\n"
	rxreq
	expect req.url == "/9"
	txresp -body "xxxxxxxx\n"
} -start

vinyl v1 -arg "-hcritbit" -vcl+backend { } -start
vinyl v1 -cliok "param.set debug +hashedge"

client c1 {
	txreq -url "/1"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1
	expect resp.http.X-Vinyl == "1001"

	txreq -url "/2"
	rxresp
	expect resp.bodylen == 2
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1003"

	txreq -url "/3"
	rxresp
	expect resp.bodylen == 3
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1005"

	txreq -url "/4"
	rxresp
	expect resp.bodylen == 4
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1007"

	txreq -url "/5"
	rxresp
	expect resp.bodylen == 5
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1009"

	txreq -url "/6"
	rxresp
	expect resp.bodylen == 6
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1011"

	txreq -url "/7"
	rxresp
	expect resp.bodylen == 7
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1013"

	txreq -url "/8"
	rxresp
	expect resp.bodylen == 8
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1015"

	txreq -url "/9"
	rxresp
	expect resp.bodylen == 9
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1017"
} -run


client c1 {
	txreq -url "/1"
	rxresp
	expect resp.status == 200
	expect resp.bodylen == 1
	expect resp.http.X-Vinyl == "1020 1002"

	txreq -url "/2"
	rxresp
	expect resp.bodylen == 2
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1021 1004"

	txreq -url "/3"
	rxresp
	expect resp.bodylen == 3
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1022 1006"

	txreq -url "/4"
	rxresp
	expect resp.bodylen == 4
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1023 1008"

	txreq -url "/5"
	rxresp
	expect resp.bodylen == 5
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1024 1010"

	txreq -url "/6"
	rxresp
	expect resp.bodylen == 6
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1025 1012"

	txreq -url "/7"
	rxresp
	expect resp.bodylen == 7
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1026 1014"

	txreq -url "/8"
	rxresp
	expect resp.bodylen == 8
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1027 1016"

	txreq -url "/9"
	rxresp
	expect resp.bodylen == 9
	expect resp.status == 200
	expect resp.http.X-Vinyl == "1028 1018"
} -run

vinyl v1 -expect sess_conn == 2
vinyl v1 -expect cache_hit == 9
vinyl v1 -expect cache_miss == 9
vinyl v1 -expect client_req == 18
