varnishtest "shard director/int key"

server s1 {
	rxreq
	txresp -body "ech3Ooj"
} -start

server s2 {
	rxreq
	txresp -body "ieQu2qua"
} -start

server s3 {
	rxreq
	txresp -body "xiuFi3Pe"
} -start

varnish v1 -vcl+backend {
	import std;
	import directors;

	sub vcl_init {
		new vd = directors.shard();
		if (!vd.add_backend(s1)) {
			std.log("add s1 failed");
		}
		if (!vd.add_backend(s2)) {
			std.log("add s2 failed");
		}
		if (!vd.add_backend(s3)) {
			std.log("add s3 failed");
		}
		if (!vd.reconfigure(replicas=25)) {
			std.log("reconfigure failed");
		}
	}

	sub vcl_recv {
		if (req.url == "/1") {
			set req.backend_hint = vd.backend(by=KEY, key=1);
		}
		if (req.url == "/2") {
			set req.backend_hint = vd.backend(by=KEY, key=2147483647);
		}
		if (req.url == "/3") {
			set req.backend_hint = vd.backend(by=KEY, key=4294967295);
		}
		return(pass);
	}

} -start


client c1 {
	txreq -url /1
	rxresp
	expect resp.body == "ech3Ooj"

	txreq -url /2
	rxresp
	expect resp.body == "ieQu2qua"

	txreq -url /3
	rxresp
	expect resp.body == "xiuFi3Pe"
} -run
