varnishtester is minimally functional

Poul-Henning Kamp phk at
Tue Jul 11 23:48:00 CEST 2006

The varnishtester is minimally functional now, and understands the
following commands:

		start varnishd

	serve string [...]
		Send these strings when port 8081 is contacted and we
		see a blank line.  If multiple strings specified, all
		but the last one are sent only once, the last (or only)
		one is sent as many times as requested.  If first char
		of string is '!' close connection afterwards.

		Open request connection to port 8080

		Close request connection to port 8080

	req	string
		Send string as request (open if not explicitly done already)
		if first char is '!' close connection afterwards.

	cli	string
		Send string via varnishd CLI connection

	vcl	name vcl_prog
		Load VCL program as named.

		exit test program.

My minimal test-the-tester script looks like this:

	serve "!HTTP/1.0 200 OK\nContent Length: 11\n\n0123456789\n"
	req   "!GET / HTTP/1.1\nHost: localhost\n\n"
	cli ping

And the output looks like this:

	]: <<start>>
	X: Pause
	V: <<Forked>>
	V: <<file /tmp//varnish.8jwTdm (unlinked) size 10485760 bytes (5120 fs-blocks, 2
	560 pages)>>
	V: <<Acceptfilter(5, httpready): -1 No such file or directory>>
	V: <<Acceptfilter(6, httpready): -1 No such file or directory>>
	V: <<start child pid 88131>>
	V: <<Child said <Child starts>>>
	V: <<Child said <Loaded "/tmp/vcl.0lYCJi6Q" as "boot">>>
	V: <<Child said <managed to mmap 10485760 bytes of 10485760>>>
	V: <<Child said <Ready>>>
	X: Resume
	]: <<serve "!HTTP/1.0 200 OK\nContent Length: 11\n\n0123456789\n">>
	]: <<open>>
	]: <<req   "!GET / HTTP/1.1\nHost: localhost\n\n">>
	X: Pause
	B: <<GET / HTTP/1.1>>
	B: <<Host: localhost>>
	B: <<>>
	R: <<HTTP/1.0 200 OK>>
	R: <<Content Length: 11>>
	R: <<Content-Length: 11>>
	R: <<Age: 0>>
	R: <<Via: 1.1 varnish>>
	R: <<X-Varnish: xid 1205698085>>
	R: <<>>
	R: <<0123456789>>
	ex_req(0x82a0320, 0x11, 0x0)
	X: Resume
	]: <<close>>
	]: <<cli ping>>
	X: Pause
	V: <<PONG 1152653743>>
	V: <<OK>>
	X: Resume
	]: <<exit>>

Prefix indicator:
	]:	read from script file
	X:	execution information (pause/resume)
	V:	received from Varnish stdout/stderr
	B:	requests received by synth backend
	R:	response received by syntg client


For automated testing I plan to add a hash facility so that one can
say things like:

	hash serve 283838383...
	hash req 229292929...
	hash cli 229292929...

And it will croak if what has been received until then on the relevant
connection does not generate the expected hash.

Alternatively one can compare to a string:

	compare serve "GET / HTTP/1.1\nHost: localhost\n\n"
	compare req "HTTP/1.0 200 OK\nContent-Length: 11..."


Hopefully this will be workable to generate test cases for all
relevant flows in the state-machine.

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

More information about the varnish-dev mailing list