Commit df7f4aa7 authored by Nils Goroll's avatar Nils Goroll

pull in shard director tests from varnish-cache

parent c9b0da17
varnishtest "shard director regression to vslp v01000"
server s1 {
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
txresp -body "xiuFi3Pe"
} -start
# VSLP:
# picked preferred backend 0 for key 68b902f8
# picked preferred backend 1 for key 39dc4614
# picked preferred backend 2 for key c7793506
#
# shard:
varnish v1 -vcl+backend {
import std;
import directors;
sub vcl_init {
new vd = directors.shard();
vd.debug(3);
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 {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(req.url, CRC32));
return(pass);
}
} -start
# check that the hashcircle points are decremented by one compared to vslp
#
# generated from vslp test output
# perl -ne </tmp/vslp_v0.log 'if (/VSLP hashcircle/) { my @f=split; $f[9] =~ s/\]/./; $f[13] =~ s/,//; $f[13]=hex($f[13]) - 1; $f[16] =~ s/\}//; printf ("\texpect 0 = Debug {^shard: hashcircle.* %s = .point = %8x, host = %2d.}\n", $f[9], $f[13], $f[16]); }' >/tmp/regression.logexp
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI "^Rd vcl.load"
expect 0 = Debug {^shard: hashcircle.* 0. = .point = 3b6b56a, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 1. = .point = 66986a7, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 2. = .point = 7e41e30, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 3. = .point = b749e7b, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 4. = .point = e543430, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 5. = .point = 10136c05, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 6. = .point = 102d847f, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 7. = .point = 1112f910, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 8. = .point = 1119a7c7, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 9. = .point = 22464ee9, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 10. = .point = 22b35675, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 11. = .point = 2363bebb, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 12. = .point = 259eeccf, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 13. = .point = 26f0c3e7, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 14. = .point = 28340f35, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 15. = .point = 285e8475, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 16. = .point = 28ec7a6f, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 17. = .point = 2da0e37b, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 18. = .point = 3392487a, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 19. = .point = 37597c4c, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 20. = .point = 4b1f5b22, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 21. = .point = 523723f2, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 22. = .point = 539234db, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 23. = .point = 564ca84f, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 24. = .point = 5d2df428, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 25. = .point = 5fa294ee, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 26. = .point = 60dded53, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 27. = .point = 6257bc27, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 28. = .point = 64014b25, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 29. = .point = 6bfd5a2d, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 30. = .point = 6e040182, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 31. = .point = 6e3819f7, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 32. = .point = 7232b381, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 33. = .point = 74c384ad, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 34. = .point = 83ce71ce, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 35. = .point = 888b6447, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 36. = .point = 8997c018, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 37. = .point = 8aa6b5b4, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 38. = .point = 8b47e6ac, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 39. = .point = 8bc8bc11, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 40. = .point = 8e2d3849, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 41. = .point = 8e7e012c, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 42. = .point = 99892987, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 43. = .point = 9a6f2f00, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 44. = .point = 9ef9125d, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 45. = .point = 9f33cd30, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 46. = .point = 9fc69b51, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 47. = .point = a19f99eb, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 48. = .point = a28b9595, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 49. = .point = a8afe9c4, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 50. = .point = ad923ad3, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 51. = .point = ae8946c6, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 52. = .point = b197e339, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 53. = .point = b3c305e6, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 54. = .point = b6bf43ea, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 55. = .point = b9004d3d, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 56. = .point = bbcc0bad, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 57. = .point = c2542a5d, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 58. = .point = c6c43fa7, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 59. = .point = c945958a, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 60. = .point = cbd9198a, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 61. = .point = d4c93105, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 62. = .point = d7de63b6, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 63. = .point = d937a7df, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 64. = .point = dac52229, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 65. = .point = db7840f0, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 66. = .point = dd5c6bef, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 67. = .point = dfd5333b, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 68. = .point = e991584c, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 69. = .point = ec8891c5, host = 1.}
expect 0 = Debug {^shard: hashcircle.* 70. = .point = ef6b4ab5, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 71. = .point = f08ad325, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 72. = .point = f3325ba2, host = 2.}
expect 0 = Debug {^shard: hashcircle.* 73. = .point = f6530dd1, host = 0.}
expect 0 = Debug {^shard: hashcircle.* 74. = .point = fc28e8d2, host = 2.}
expect 0 = CLI Loaded
expect * = Debug {^shard: lookup key 68b902f7 idx 29 host 0}
expect * = Debug {^shard: lookup key 39dc4613 idx 20 host 1}
expect * = Debug {^shard: lookup key c7793505 idx 59 host 2}
} -start
client c1 {
txreq -url /eishoSu2
rxresp
expect resp.body == "ech3Ooj"
txreq -url /Zainao9d
rxresp
expect resp.body == "ieQu2qua"
txreq -url /Aunah3uo
rxresp
expect resp.body == "xiuFi3Pe"
} -run
logexpect l1 -wait
varnishtest "shard director RS"
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 directors;
sub vcl_init {
new vd = directors.shard();
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.reconfigure(replicas=25);
}
sub vcl_recv {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(req.url, alg=RS));
return(pass);
}
} -start
client c1 {
txreq -url /we0eeTho
rxresp
expect resp.body == "ech3Ooj"
txreq -url /mae8ooNu
rxresp
expect resp.body == "ieQu2qua"
txreq -url /oob3dahS
rxresp
expect resp.body == "xiuFi3Pe"
} -run
varnishtest "shard director key function"
server s1 {
rxreq
txresp -body "ech3Ooj"
rxreq
txresp -body "ech3Ooj"
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
import directors;
sub vcl_init {
new vd = directors.shard();
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.reconfigure(25);
}
sub recv_sub {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(req.http.X-Hash, RS));
}
sub vcl_recv {
if (req.url == "/1") {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(alg=CRC32, string="/eishoSu2"));
} else if (req.url == "/2") {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key("/eishoSu2"));
} else if (req.url == "/3") {
set req.http.X-Hash = "/oob3dahS";
call recv_sub;
} else if (req.url == "/null_by_string") {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(req.http.NonExistent));
} else if (req.url == "/null_by_string_hash") {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(req.http.NonExistent, SHA256));
}
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"
txreq -url /null_by_string
rxresp
expect resp.body == "ech3Ooj"
txreq -url /null_by_string_hash
rxresp
expect resp.body == "ech3Ooj"
} -run
varnishtest "shard director Restarts"
server s1 {
rxreq
txresp -body "ech3Ooj"
rxreq
txresp -body "ech3Ooj"
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
txresp -body "ieQu2qua"
rxreq
txresp -body "ieQu2qua"
rxreq
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
txresp -body "xiuFi3Pe"
rxreq
txresp -body "xiuFi3Pe"
rxreq
txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
import directors;
sub vcl_init {
new vd = directors.shard();
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.reconfigure(25);
}
sub vcl_recv {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key("/eishoSu2", CRC32),
alt=req.restarts,
healthy=ALL);
if (req.url == "/2" && req.restarts > 0) {
unset req.http.vrstart;
}
if (req.url == "/3" && req.restarts > 1) {
unset req.http.vrstart;
}
return(pass);
}
sub vcl_deliver {
if (req.http.vrstart) {
return(restart);
}
}
} -start
client c1 {
txreq -url /1
rxresp
expect resp.body == "ech3Ooj"
txreq -url /2 -hdr "vrstart: 1"
rxresp
expect resp.body == "ieQu2qua"
txreq -url /3 -hdr "vrstart: 1"
rxresp
expect resp.body == "xiuFi3Pe"
} -run
varnishtest "shard director Unhealthy"
server s1 {
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
expect req.http.healthy == "true"
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
expect req.http.healthy == "true"
txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
import std;
import directors;
sub vcl_init {
new vd = directors.shard();
vd.debug(3);
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.reconfigure(25);
}
sub vcl_recv {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key("/eishoSu2", CRC32));
set req.http.healthy = std.healthy(req.backend_hint);
return(pass);
}
} -start
varnish v1 -cliok "backend.set_health s1 sick"
client c1 {
txreq
rxresp
expect resp.body == "ieQu2qua"
} -run
varnish v1 -cliok "backend.set_health s2 sick"
client c1 {
txreq
rxresp
expect resp.body == "xiuFi3Pe"
} -run
varnishtest "shard director Rampup Time"
# NOTE: this test is timing sensitive by nature
server s1 {
rxreq
txresp -body "ech3Ooj"
} -start
server s2 {
rxreq
txresp -body "ieQu2qua"
rxreq
txresp -body "ieQu2qua"
} -start
server s3 {
rxreq
txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
import directors;
sub vcl_init {
new vd = directors.shard();
vd.debug(4);
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.set_rampup(15s);
vd.reconfigure(25);
}
sub vcl_recv {
set req.backend_hint = vd.backend(by=KEY,
key=vd.key(alg=CRC32, string="/eishoSu2"));
return(pass);
}
} -start
varnish v1 -cliok "debug.srandom"
delay 8
varnish v1 -cliok "backend.set_health s1 sick"
# s1 down, s2 and s3 both in rampup - s2 chosen
client c1 {
txreq -url /1
rxresp
expect resp.body == "ieQu2qua"
} -run
delay 8
varnish v1 -cliok "backend.set_health s1 healthy"
# s1 just came up, s2 chosen for ramup
client c1 {
txreq -url /2
rxresp
expect resp.body == "ieQu2qua"
} -run
delay 16
# s1 out of ramup
client c1 {
txreq -url /3
rxresp
expect resp.body == "ech3Ooj"
} -run
varnishtest "shard director - same as v01000.vtc but setting backend in fetch"
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 directors;
sub vcl_init {
new vd = directors.shard();
vd.add_backend(s1);
vd.add_backend(s2);
vd.add_backend(s3);
vd.reconfigure(25);
}
sub vcl_backend_fetch {
set bereq.backend = vd.backend(by=KEY,
key=vd.key(bereq.url, CRC32));
return(fetch);
}
} -start
client c1 {
txreq -url /eishoSu2
rxresp
expect resp.body == "ech3Ooj"
txreq -url /Zainao9d
rxresp
expect resp.body == "ieQu2qua"
txreq -url /Aunah3uo
rxresp
expect resp.body == "xiuFi3Pe"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment