vtest "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:

vinyl v1 -vcl+backend {
	import std;
	import directors;
	import blob;

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

	sub vcl_recv {
		set req.backend_hint = vd.backend(by=BLOB,
		    key_blob=blob.decode(HEX, encoded=
			regsub(req.url, "^/", "")));
		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 {^vmod_directors: 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 {^vmod_directors: shard: hashcircle.* 0. = .point =  3b6b56a, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 1. = .point =  66986a7, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 2. = .point =  7e41e30, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 3. = .point =  b749e7b, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 4. = .point =  e543430, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 5. = .point = 10136c05, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 6. = .point = 102d847f, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 7. = .point = 1112f910, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 8. = .point = 1119a7c7, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 9. = .point = 22464ee9, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 10. = .point = 22b35675, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 11. = .point = 2363bebb, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 12. = .point = 259eeccf, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 13. = .point = 26f0c3e7, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 14. = .point = 28340f35, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 15. = .point = 285e8475, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 16. = .point = 28ec7a6f, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 17. = .point = 2da0e37b, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 18. = .point = 3392487a, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 19. = .point = 37597c4c, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 20. = .point = 4b1f5b22, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 21. = .point = 523723f2, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 22. = .point = 539234db, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 23. = .point = 564ca84f, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 24. = .point = 5d2df428, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 25. = .point = 5fa294ee, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 26. = .point = 60dded53, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 27. = .point = 6257bc27, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 28. = .point = 64014b25, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 29. = .point = 6bfd5a2d, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 30. = .point = 6e040182, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 31. = .point = 6e3819f7, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 32. = .point = 7232b381, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 33. = .point = 74c384ad, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 34. = .point = 83ce71ce, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 35. = .point = 888b6447, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 36. = .point = 8997c018, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 37. = .point = 8aa6b5b4, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 38. = .point = 8b47e6ac, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 39. = .point = 8bc8bc11, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 40. = .point = 8e2d3849, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 41. = .point = 8e7e012c, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 42. = .point = 99892987, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 43. = .point = 9a6f2f00, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 44. = .point = 9ef9125d, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 45. = .point = 9f33cd30, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 46. = .point = 9fc69b51, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 47. = .point = a19f99eb, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 48. = .point = a28b9595, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 49. = .point = a8afe9c4, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 50. = .point = ad923ad3, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 51. = .point = ae8946c6, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 52. = .point = b197e339, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 53. = .point = b3c305e6, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 54. = .point = b6bf43ea, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 55. = .point = b9004d3d, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 56. = .point = bbcc0bad, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 57. = .point = c2542a5d, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 58. = .point = c6c43fa7, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 59. = .point = c945958a, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 60. = .point = cbd9198a, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 61. = .point = d4c93105, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 62. = .point = d7de63b6, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 63. = .point = d937a7df, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 64. = .point = dac52229, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 65. = .point = db7840f0, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 66. = .point = dd5c6bef, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 67. = .point = dfd5333b, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 68. = .point = e991584c, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 69. = .point = ec8891c5, host =  1.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 70. = .point = ef6b4ab5, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 71. = .point = f08ad325, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 72. = .point = f3325ba2, host =  2.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 73. = .point = f6530dd1, host =  0.}
	expect 0 =    Debug {^vmod_directors: shard: hashcircle.* 74. = .point = fc28e8d2, host =  2.}

	expect 0 =    CLI   Loaded

	expect * =    Debug {^vmod_directors: shard: lookup key 68b902f7 idx 29 host 0}
	expect * =    Debug {^vmod_directors: shard: lookup key 39dc4613 idx 20 host 1}
	expect * =    Debug {^vmod_directors: shard: lookup key c7793505 idx 59 host 2}
} -start

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

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

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

logexpect l1 -wait
