[3.0] ea964eb This test is much to brittle due to dependence on random timing. Tighten it up with use of semaphores and collapse s1/s2/s3 using "accept" keyword.

Tollef Fog Heen tfheen at varnish-cache.org
Thu Oct 6 11:25:23 CEST 2011


commit ea964eb04d60bc1004026e19ae3b09c28dd1cd47
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Sep 30 18:24:34 2011 +0000

    This test is much to brittle due to dependence on random timing.
    Tighten it up with use of semaphores and collapse s1/s2/s3 using
    "accept" keyword.

diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc
index ff2ecd3..46bcca8 100644
--- a/bin/varnishtest/tests/v00036.vtc
+++ b/bin/varnishtest/tests/v00036.vtc
@@ -4,12 +4,46 @@ server s1 {
 	rxreq
 	expect req.url == "/"
 	txresp -body "slash"
+	accept
+
+	sema r1 sync 3
+
+	rxreq
+	expect req.url == "/"
+	txresp -body "slash"
+	accept
+
+	rxreq
+	expect req.url == "/"
+	txresp -body "slash"
+
+	sema r3 sync 2
+	accept
+
+	rxreq
+	expect req.url == "/foo"
+	txresp -hdr "Foo: 1" -body "foobar"
+
 } -start
 
 server s2 {
 	rxreq
 	expect req.url == "/"
 	txresp -body "slash"
+	accept
+
+	sema r1 sync 3
+
+	rxreq
+	expect req.url == "/"
+	txresp -body "slash"
+
+	sema r2 sync 2
+	accept
+
+	rxreq
+	expect req.url == "/foo"
+	txresp -hdr "Foo: 2" -body "foobar"
 } -start
 
 server s3 {
@@ -65,66 +99,23 @@ varnish v1 -vcl {
 	}
 } -start
 
-# s1 & s2 have both had 1 probe, so both are unhealthy
 
 client c1 {
+	# s1 & s2 are both sick, expect response from s3
 	txreq -url "/foo"
 	rxresp
 	expect resp.http.foo == "3"
-} -run
-
-# setup for probe #2
-
-server s1 {
-	rxreq
-	expect req.url == "/"
-	txresp -body "slash"
-} -start
-
-server s2 {
-	rxreq
-	expect req.url == "/"
-	txresp -body "slash"
-} -start
 
-# if we muck with a running server, the test will wait until it's done,
-# which will be after probe #2 completes. b2 will then be healthy.
+	sema r1 sync 3
 
-server s2 {
-	rxreq
-	expect req.url == "/foo"
-	txresp -hdr "Foo: 2" -body "foobar"
-} -start
-
-client c1 {
+	# wait for s2 to become healthy
+	sema r2 sync 2
 	txreq -url "/foo"
 	rxresp
 	expect resp.http.foo == "2"
-} -run
 
-# setup for probe #3
-
-server s1 {
-        rxreq
-        expect req.url == "/"
-        txresp -body "slash"
-} -start
-
-server s2 {
-        rxreq
-        expect req.url == "/"
-        txresp -body "slash"
-} -start
-
-# after probe #3 b1 should be healthy.
-
-server s1 {
-	rxreq
-	expect req.url == "/foo"
-	txresp -hdr "Foo: 1" -body "foobar"
-} -start
-
-client c1 {
+	# wait for s1 to become healthy
+	sema r3 sync 2
 	txreq -url "/foo"
 	rxresp
 	expect resp.http.foo == "1"



More information about the varnish-commit mailing list