r3535 - branches/2.0/varnish-cache/bin/varnishtest/tests

tfheen at projects.linpro.no tfheen at projects.linpro.no
Mon Jan 19 15:24:04 CET 2009


Author: tfheen
Date: 2009-01-19 15:24:03 +0100 (Mon, 19 Jan 2009)
New Revision: 3535

Added:
   branches/2.0/varnish-cache/bin/varnishtest/tests/v00022.vtc
Log:
Merge r3368:

Add a test of the random director that uses actual randomness.

This will be skipped on platforms where srandom(1) does not result
in the same deterministic sequence of random numbers as on FreeBSD
and Linux.



Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/v00022.vtc (from rev 3368, trunk/varnish-cache/bin/varnishtest/tests/v00022.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00022.vtc	                        (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00022.vtc	2009-01-19 14:24:03 UTC (rev 3535)
@@ -0,0 +1,86 @@
+# $Id$
+
+test "Deeper test of random director"
+
+random
+
+server s1 {
+	rxreq
+	txresp -body "1"
+} -start
+server s2 -listen 127.0.0.1:9180 {
+	rxreq
+	txresp -body "22"
+	rxreq
+	txresp -body "22"
+	rxreq
+	txresp -body "22"
+} -start
+server s3 -listen 127.0.0.1:9181 {
+	rxreq
+	txresp -body "333"
+} -start
+server s4 -listen 127.0.0.1:9182 {
+	rxreq
+	txresp -body "4444"
+	rxreq
+	txresp -body "4444"
+	rxreq
+	txresp -body "4444"
+	rxreq
+	txresp -body "4444"
+	rxreq
+	txresp -body "4444"
+} -start
+
+varnish v1 -vcl+backend {
+	director foo random {
+		{ .backend = s1; .weight = 1; }
+		{ .backend = s2; .weight = 1; }
+		{ .backend = s3; .weight = 1; }
+		{ .backend = s4; .weight = 1; }
+	}
+
+	sub vcl_recv {
+		set req.backend = foo;
+		pass;
+	}
+} -start
+
+# NB: Do not change the number 1
+# NB: Only srandom(1) is standardized as deterministic.
+
+varnish v1 -cliok "debug.srandom 1"
+
+client c1 {
+	txreq 
+	rxresp
+	expect resp.bodylen == 4
+	txreq 
+	rxresp
+	expect resp.bodylen == 2
+	txreq 
+	rxresp
+	expect resp.bodylen == 4
+	txreq 
+	rxresp
+	expect resp.bodylen == 4
+	txreq 
+	rxresp
+	expect resp.bodylen == 4
+	txreq 
+	rxresp
+	expect resp.bodylen == 1
+	txreq 
+	rxresp
+	expect resp.bodylen == 2
+	txreq 
+	rxresp
+	expect resp.bodylen == 4
+	txreq 
+	rxresp
+	expect resp.bodylen == 2
+	txreq 
+	rxresp
+	expect resp.bodylen == 3
+} -run



More information about the varnish-commit mailing list