[master] cf3c9d9 varnishtest: change varnish -expect to accept PATTERN and update SMA checks

Nils Goroll nils.goroll at uplex.de
Wed Sep 27 12:11:05 UTC 2017


commit cf3c9d9213c12e3c58a391b068398f8fd1d1c17c
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Sep 27 14:06:59 2017 +0200

    varnishtest: change varnish -expect to accept PATTERN and update SMA checks
    
    In varnishtest, varnish checks now use -expect PATTERN OP NUMBER
    PATTERN being a glob pattern (see fnmatch(3)).
    
    Make all vtc checking for SMA counters stevedore-type agnostic by matching
    on SM?

diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc
index d0f3cc6..f56fae0 100644
--- a/bin/varnishtest/tests/b00002.vtc
+++ b/bin/varnishtest/tests/b00002.vtc
@@ -35,7 +35,7 @@ client c1 {
 delay .1
 
 varnish v1 -expect n_object == 0
-varnish v1 -expect SMA.Transient.g_alloc == 0
+varnish v1 -expect SM?.Transient.g_alloc == 0
 varnish v1 -expect sess_conn == 1
 varnish v1 -expect client_req == 1
 varnish v1 -expect s_sess == 1
diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc
index 2c0cf66..f9ebad6 100644
--- a/bin/varnishtest/tests/c00044.vtc
+++ b/bin/varnishtest/tests/c00044.vtc
@@ -37,13 +37,13 @@ client c1 {
 	expect resp.bodylen == 1048290
 } -run
 
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes == 0
-varnish v1 -expect SMA.s0.g_space > 1000000
-varnish v1 -expect SMA.s1.g_bytes > 1000000
-varnish v1 -expect SMA.s1.g_space < 200
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes == 0
+varnish v1 -expect SM?.s0.g_space > 1000000
+varnish v1 -expect SM?.s1.g_bytes > 1000000
+varnish v1 -expect SM?.s1.g_space < 200
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
 
 client c1 {
 	txreq -url /bar
@@ -52,13 +52,13 @@ client c1 {
 	expect resp.bodylen == 1048291
 } -run
 
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes == 0
-varnish v1 -expect SMA.s0.g_space > 1000000
-varnish v1 -expect SMA.s1.g_bytes > 1000000
-varnish v1 -expect SMA.s1.g_space < 200
-varnish v1 -expect SMA.s2.g_bytes > 1000000
-varnish v1 -expect SMA.s2.g_space < 200
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes == 0
+varnish v1 -expect SM?.s0.g_space > 1000000
+varnish v1 -expect SM?.s1.g_bytes > 1000000
+varnish v1 -expect SM?.s1.g_space < 200
+varnish v1 -expect SM?.s2.g_bytes > 1000000
+varnish v1 -expect SM?.s2.g_space < 200
 
 client c1 {
 	txreq -url /burp
@@ -67,13 +67,13 @@ client c1 {
 	expect resp.bodylen == 1048292
 } -run
 
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 200
-varnish v1 -expect SMA.s1.g_bytes > 1000000
-varnish v1 -expect SMA.s1.g_space < 200
-varnish v1 -expect SMA.s2.g_bytes > 1000000
-varnish v1 -expect SMA.s2.g_space < 200
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 200
+varnish v1 -expect SM?.s1.g_bytes > 1000000
+varnish v1 -expect SM?.s1.g_space < 200
+varnish v1 -expect SM?.s2.g_bytes > 1000000
+varnish v1 -expect SM?.s2.g_space < 200
 
 client c1 {
 	txreq -url /foo1
diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc
index 4d3850f..96fb58a 100644
--- a/bin/varnishtest/tests/c00045.vtc
+++ b/bin/varnishtest/tests/c00045.vtc
@@ -30,13 +30,13 @@ client c1 {
 	expect resp.bodylen == 1048288
 } -run
 
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 193
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 193
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
 
 client c1 {
 	txreq -url /bar
@@ -46,13 +46,13 @@ client c1 {
 } -run
 
 varnish v1 -expect n_lru_nuked == 1
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 1192
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 1192
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
 
 client c1 {
 	txreq -url /foo
@@ -62,10 +62,10 @@ client c1 {
 } -run
 
 varnish v1 -expect n_lru_nuked == 2
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 1194
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 1194
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc
index 9a3dfec..3666ed8 100644
--- a/bin/varnishtest/tests/c00046.vtc
+++ b/bin/varnishtest/tests/c00046.vtc
@@ -23,13 +23,13 @@ client c1 {
 	expect resp.bodylen == 1000000
 } -run
 
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 100000
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 100000
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
 
 server s1 -wait {
 	rxreq
@@ -45,13 +45,13 @@ client c1 {
 } -run
 
 varnish v1 -expect n_lru_nuked == 1
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 100000
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 100000
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
 
 server s1 -wait {
 	rxreq
@@ -67,10 +67,10 @@ client c1 {
 } -run
 
 varnish v1 -expect n_lru_nuked == 2
-varnish v1 -expect SMA.Transient.g_bytes == 0
-varnish v1 -expect SMA.s0.g_bytes > 1000000
-varnish v1 -expect SMA.s0.g_space < 100000
-varnish v1 -expect SMA.s1.g_bytes == 0
-varnish v1 -expect SMA.s1.g_space > 1000000
-varnish v1 -expect SMA.s2.g_bytes == 0
-varnish v1 -expect SMA.s2.g_space > 1000000
+varnish v1 -expect SM?.Transient.g_bytes == 0
+varnish v1 -expect SM?.s0.g_bytes > 1000000
+varnish v1 -expect SM?.s0.g_space < 100000
+varnish v1 -expect SM?.s1.g_bytes == 0
+varnish v1 -expect SM?.s1.g_space > 1000000
+varnish v1 -expect SM?.s2.g_bytes == 0
+varnish v1 -expect SM?.s2.g_space > 1000000
diff --git a/bin/varnishtest/tests/c00073.vtc b/bin/varnishtest/tests/c00073.vtc
index de94671..78cfabb 100644
--- a/bin/varnishtest/tests/c00073.vtc
+++ b/bin/varnishtest/tests/c00073.vtc
@@ -22,9 +22,9 @@ client c1 {
 } -start
 
 barrier b1 sync
-varnish v1 -expect SMA.s0.g_bytes > 10000
+varnish v1 -expect SM?.s0.g_bytes > 10000
 
 barrier b2 sync
 
 client c1 -wait
-varnish v1 -expect SMA.s0.g_bytes < 6000
+varnish v1 -expect SM?.s0.g_bytes < 6000
diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc
index b722617..c440a23 100644
--- a/bin/varnishtest/tests/g00002.vtc
+++ b/bin/varnishtest/tests/g00002.vtc
@@ -34,7 +34,7 @@ client c1 {
 } -run
 
 # If this fails, the multiple storage allocations did not happen
-varnish v1 -expect SMA.s0.c_req > 2
+varnish v1 -expect SM?.s0.c_req > 2
 
 client c1 {
 	# See varnish can gunzip it.
diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc
index 098a653..994107c 100644
--- a/bin/varnishtest/tests/r01140.vtc
+++ b/bin/varnishtest/tests/r01140.vtc
@@ -36,7 +36,7 @@ client c1 {
 
 delay .1
 
-varnish v1 -expect SMA.s0.g_space < 1000
+varnish v1 -expect SM?.s0.g_space < 1000
 
 client c1 {
 	txreq -url /url2
diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc
index 42a87a3..72661d9 100644
--- a/bin/varnishtest/tests/r01175.vtc
+++ b/bin/varnishtest/tests/r01175.vtc
@@ -18,4 +18,4 @@ client c1 {
 	expect resp.status == 503
 } -run
 
-varnish v1 -expect SMA.test.c_fail < 5
+varnish v1 -expect SM?.test.c_fail < 5
diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc
index dd8c65f..f4d5efb 100644
--- a/bin/varnishtest/tests/r01284.vtc
+++ b/bin/varnishtest/tests/r01284.vtc
@@ -34,8 +34,8 @@ client c1 {
 
 delay .1
 
-varnish v1 -expect SMA.Transient.g_bytes > 1048000
-varnish v1 -expect SMA.Transient.g_space < 200
+varnish v1 -expect SM?.Transient.g_bytes > 1048000
+varnish v1 -expect SM?.Transient.g_space < 200
 
 client c1 {
 	# No space for this object (more than 256 bytes in headers). Don't wait
@@ -45,7 +45,7 @@ client c1 {
 } -run
 
 # Three failures, one for obj2, one for vcl_backend_error{}, one for synth objcore
-varnish v1 -expect SMA.Transient.c_fail == 3
+varnish v1 -expect SM?.Transient.c_fail == 3
 
 client c1 {
 	# Check that Varnish is still alive
diff --git a/bin/varnishtest/tests/r01821.vtc b/bin/varnishtest/tests/r01821.vtc
index bdeeb5f..3c7c02c 100644
--- a/bin/varnishtest/tests/r01821.vtc
+++ b/bin/varnishtest/tests/r01821.vtc
@@ -22,5 +22,5 @@ client c1 {
 
 logexpect l1 -wait
 
-varnish v1 -expect SMA.Transient.c_bytes != 0
-varnish v1 -expect SMA.Transient.g_bytes < 65536
+varnish v1 -expect SM?.Transient.c_bytes != 0
+varnish v1 -expect SM?.Transient.g_bytes < 65536
diff --git a/bin/varnishtest/tests/r01914.vtc b/bin/varnishtest/tests/r01914.vtc
index a14f053..b6a9269 100644
--- a/bin/varnishtest/tests/r01914.vtc
+++ b/bin/varnishtest/tests/r01914.vtc
@@ -30,15 +30,15 @@ client c1 {
 	rxresp
 } -run
 
-varnish v1 -expect SMA.s0.c_bytes > 0
-varnish v1 -expect SMA.s1.c_bytes == 0
-varnish v1 -expect SMA.Transient.c_bytes > 0
+varnish v1 -expect SM?.s0.c_bytes > 0
+varnish v1 -expect SM?.s1.c_bytes == 0
+varnish v1 -expect SM?.Transient.c_bytes > 0
 
 client c1 {
 	txreq -url /1 -bodylen 100
 	rxresp
 } -run
 
-varnish v1 -expect SMA.s0.c_bytes > 0
-varnish v1 -expect SMA.s1.c_bytes > 0
-varnish v1 -expect SMA.Transient.c_bytes > 0
+varnish v1 -expect SM?.s0.c_bytes > 0
+varnish v1 -expect SM?.s1.c_bytes > 0
+varnish v1 -expect SM?.Transient.c_bytes > 0
diff --git a/bin/varnishtest/tests/r02406.vtc b/bin/varnishtest/tests/r02406.vtc
index 3f3d018..05ad838 100644
--- a/bin/varnishtest/tests/r02406.vtc
+++ b/bin/varnishtest/tests/r02406.vtc
@@ -8,5 +8,5 @@ varnish v1 -vcl {
 	}
 } -start
 
-varnish v1 -expect SMA.acme_example_com_static_assets_malloc_storage.c_req == 0
+varnish v1 -expect SM?.acme_example_com_static_assets_malloc_storage.c_req == 0
 varnish v1 -expect VBE.vcl1.be_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789.req == 0
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 9f97f46..5a5951a 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -851,7 +851,7 @@ varnish_vsc(const struct varnish *v, const char *arg)
  */
 
 struct stat_priv {
-	char target_name[256];
+	char target_pattern[256];
 	uintmax_t val;
 	const struct varnish *v;
 };
@@ -864,7 +864,7 @@ do_expect_cb(void *priv, const struct VSC_point * const pt)
 	if (pt == NULL)
 		return(0);
 
-	if (strcmp(pt->name, sp->target_name))
+	if (fnmatch(sp->target_pattern, pt->name, 0))
 		return(0);
 
 	AZ(strcmp(pt->ctype, "uint64_t"));
@@ -897,9 +897,9 @@ varnish_expect(const struct varnish *v, char * const *av)
 	}
 	p = strrchr(r, '.');
 	if (p == NULL) {
-		bprintf(sp.target_name, "MAIN.%s", r);
+		bprintf(sp.target_pattern, "MAIN.%s", r);
 	} else {
-		bprintf(sp.target_name, "%s", r);
+		bprintf(sp.target_pattern, "%s", r);
 	}
 
 	sp.val = 0;
@@ -965,7 +965,13 @@ varnish_expect(const struct varnish *v, char * const *av)
  * process in the background, waiting for the ``-start`` switch to actually
  * start the child.
  *
- * With:
+ * Types used in the description below:
+ *
+ * PATTERN
+ *         is a 'glob' style pattern (ie: fnmatch(3)) as used in shell filename
+ *         expansion.
+ *
+ * Arguments:
  *
  * vNAME
  *	   Identify the Varnish server with a string, it must starts with 'v'.
@@ -1030,17 +1036,15 @@ varnish_expect(const struct varnish *v, char * const *av)
  *         anything, -cliok expects 200, -clierr expects STATUS, and
  *         -cliexpect expects the REGEXP to match the returned response.
  *
- * \-expect STRING OP NUMBER
- *         Look into the VSM and make sure the counter identified by STRING has
- *         a correct value. OP can be ==, >, >=, <, <=. For example::
+ * \-expect PATTERN OP NUMBER
+ *         Look into the VSM and make sure the first VSC counter identified by
+ *         PATTERN has a correct value. OP can be ==, >, >=, <, <=. For
+ *         example::
  *
- *                 varnish v1 -expect SMA.s1.g_space > 1000000
+ *                 varnish v1 -expect SM?.s1.g_space > 1000000
  *
  * \-vsc PATTERN
- *         Dump VSC counters matching PATTERN.  The PATTERN is a 'glob'
- *         style pattern (ie: fnmatch(3)) as used in shell filename expansion.
- *         To see all counters use pattern "*", to see all counters about
- *         requests use "*req*".
+ *         Dump VSC counters matching PATTERN.
  *
  * \-vsl_catchup
  *         Wait until the logging thread has idled to make sure that all


More information about the varnish-commit mailing list