VTC·续2

-all keep waiting for DATA frame until one sets the END_STREAM flag -some INT retrieve INT DATA frames.

Receive a frame, any frame.

sendhex#

Push bytes directly on the wire. sendhex takes exactly one argument: a string describing the bytes, in hex notation, with possible whitespaces between them. Here’s an example:

sendhex "00 00 08 00 0900       8d"
rxgoaway#

Receive a GOAWAY frame.

txgoaway#

Possible options include:

-err STRING|INT set the error code to explain the termination. The second argument can be a integer or the string version of the error code as found in rfc7540#7. -laststream INT the id of the “highest-numbered stream identifier for which the sender of the GOAWAY frame might have taken some action on or might yet take action on”. -debug specify the debug data, if any to append to the frame.

gunzip#

Same as the gunzip command for HTTP/1.

rxping#

Receive a PING frame.

txping#

Send PING frame.

-data STRING specify the payload of the frame, with STRING being an 8-char string. -ack set the ACK flag.

rxprio#

Receive a PRIORITY frame.

txprio#

Send a PRIORITY frame

-stream INT indicate the id of the stream the sender stream depends on. -ex the dependency should be made exclusive (only this streams depends on the parent stream). -weight INT an 8-bits integer is used to balance priority between streams depending on the same streams.

rxrst#

Receive a RST_STREAM frame.

txrst#

Send a RST_STREAM frame. By default, txrst will send a 0 error code (NO_ERROR).

-err STRING|INT Sets the error code to be sent. The argument can be an integer or a string describing the error, such as NO_ERROR, or CANCEL (see rfc7540#11.4 for more strings).

rxsettings#

Receive a SETTINGS frame.

txsettings#

SETTINGS frames must be acknowledge, arguments are as follow (most of them are from rfc7540#6.5.2):

-hdrtbl INT headers table size -push BOOL whether push frames are accepted or not -maxstreams INT maximum concurrent streams allowed -winsize INT sender’s initial window size -framesize INT largest frame size authorized -hdrsize INT maximum size of the header list authorized -0xHH[HH] INT tx arbitraty settings with tag xx -ack set the ack bit

rxwinup#

Receive a WINDOW_UPDATE frame.

txwinup#

Transmit a WINDOW_UPDATE frame, increasing the amount of credit of the connection (from stream 0) or of the stream (any other stream).

-size INT give INT credits to the peer.

write_body STRING Same as the write_body command for HTTP/1.

expect#

expect in stream works as it does in client or server, except that the elements compared will be different.

Most of these elements will be frame specific, meaning that the last frame received on that stream must of the correct type.

Here the list of keywords you can look at.

# GOAWAY specific

goaway.err The error code (as integer) of the GOAWAY frame. goaway.laststream Last-Stream-ID goaway.debug Debug data, if any.

# PING specific

ping.data The 8-bytes string of the PING frame payload. ping.ack (PING) “true” if the ACK flag was set, “false” otherwise.

# PRIORITY specific

prio.stream The stream ID announced. prio.exclusive “true” if the priority is exclusive, else “false”. prio.weight The dependency weight.

# PUSH_PROMISE specific

push.id The id of the promised stream.

# RESET_STREAM specific

rst.err The error code (as integer) of the RESET_STREAM frame.

# SETTINGS specific

settings.ack “true” if the ACK flag was set, else “false”. settings.push “true” if the push settings was set to yes, “false” if set to no, and if not present. settings.hdrtbl Value of HEADER_TABLE_SIZE if set, otherwise. settings.maxstreams Value of MAX_CONCURRENT_STREAMS if set, otherwise. settings.winsize Value of INITIAL_WINDOW_SIZE if set, otherwise. setting.framesize Value of MAX_FRAME_SIZE if set, otherwise. settings.hdrsize Value of MAX_HEADER_LIST_SIZE if set, otherwise.

# WINDOW_UPDATE specific

winup.size The size of the upgrade given by the WINDOW_UPDATE frame.

# Generic frame

frame.data Payload of the last frame frame.type Type of the frame, as integer. frame.size Size of the frame. frame.stream Stream of the frame (correspond to the one you are executing this from, obviously). frame.padding (for DATA, HEADERS, PUSH_PROMISE frames) Number of padded bytes.

# Request and response

Note: it’s possible to inspect a request or response while it is still being construct (in-between two frames for example).

req.bodylen / resp.bodylen Length in bytes of the request/response so far. req.body / resp.body Body of the request/response so far. req.http.STRING / resp.http.STRING Value of the header STRING in the request/response. req.status / resp.status :status pseudo-header’s value. req.url / resp.url :path pseudo-header’s value. req.method / resp.method :method pseudo-header’s value. req.authority / resp.authority :method pseudo-header’s value. req.scheme / resp.scheme :method pseudo-header’s value.

# Stream

stream.window The current local window size of the stream, or, if on stream 0, of the connection. stream.peer_window The current peer window size of the stream, or, if on stream 0, of the connection. stream.weight Weight of the stream stream.dependency Id of the stream this one depends on.

# Index tables

tbl.dec.size / tbl.enc.size Size (bytes) of the decoding/encoding table. tbl.dec.size / tbl.enc.maxsize Maximum size (bytes) of the decoding/encoding table. tbl.dec.length / tbl.enc.length Number of headers in decoding/encoding table. tbl.dec[INT].key / tbl.enc[INT].key Name of the header at index INT of the decoding/encoding table. tbl.dec[INT].value / tbl.enc[INT].value Value of the header at index INT of the decoding/encoding table.

syslog#

Define and interact with syslog instances (for use with haproxy)

To define a syslog server, you’ll use this syntax:

syslog SNAME

Arguments:

SNAME Identify the syslog server with a string which must start with ‘S’. -level STRING Set the default syslog priority level used by any subsequent “recv” command. Any syslog dgram with a different level will be skipped by “recv” command. This default level value may be superseded by “recv” command if supplied as first argument: “recv ”. -start Start the syslog server thread in the background. -repeat

Instead of processing the specification only once, do it NUMBER times. -bind Bind the syslog socket to a local address. -wait Wait for that thread to terminate. -stop Stop the syslog server thread.

tunnel#

The goal of a tunnel is to help control the data transfer between two parties, for example to trigger socket timeouts in the middle of protocol frames, without the need to change how both parties are implemented.

A tunnel accepts a connection and then connects on behalf of the source to the desired destination. Once both connections are established the tunnel will transfer bytes unchanged between the source and destination. Transfer can be interrupted, usually with the help of synchronization methods like barriers. Once the transfer is paused, it is possible to let a specific amount of bytes move in either direction.

Arguments#

-start Start the tunnel in background, processing the last given specification. -start+pause Start the tunnel, but already paused. -wait Block until the thread finishes. -listen STRING Dictate the listening socket for the server. STRING is of the form “IP PORT”, or “HOST PORT”.
Listens by defaults to a local random port. -connect STRING Indicate the server to connect to. STRING is also of the form “IP PORT”, or “HOST PORT”.
Connects by default to a varnish instance called v1.

Specification#

The specification contains a list of tunnel commands that can be combined with barriers and delays. For example:

tunnel t1 {
    barrier b1 sync
    pause
    delay 1
    send 42
    barrier b2 sync
    resume
} -start

If one end of the tunnel is closed before the end of the specification the test case will fail. A specification that ends in a paused state will implicitly resume the tunnel.

pause Wait for in-flight bytes to be transferred and pause the tunnel.
The tunnel must be running.

recv NUMBER Wait until NUMBER bytes are transferred from destination to source.
The tunnel must be paused, it remains paused afterwards.

resume Resume the transfer of bytes in both directions.
The tunnel must be paused.

send NUMBER Wait until NUMBER bytes are transferred from source to destination.
The tunnel must be paused, it remains paused afterwards.

varnish#

Define and interact with varnish instances.

To define a Varnish server, you’ll use this syntax:

varnish vNAME [-arg STRING] [-vcl STRING] [-vcl+backend STRING]
        [-errvcl STRING STRING] [-jail STRING] [-proto PROXY]

The first varnish vNAME invocation will start the varnishd master process in the background, waiting for the -start switch to actually start the child.

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’. -arg STRING Pass an argument to varnishd, for example “-h simple_list”.
If the ${varnishd_args_prepend} or ${varnishd_args_append} macros are defined, they are expanded and inserted before / appended to the varnishd command line as constructed by varnishtest, before the command line itself is expanded. This enables tweaks to the varnishd command line without editing test cases. This macros can be defined using the -D option for varnishtest. -vcl STRING Specify the VCL to load on this Varnish instance. You’ll probably want to use multi-lines strings for this ({…}). -vcl+backend STRING Do the exact same thing as -vcl, but adds the definition block of known backends (ie. already defined). -errvcl STRING1 STRING2 Load STRING2 as VCL, expecting it to fail, and Varnish to send an error string matching STRING1 -jail STRING Look at man varnishd (-j) for more information. -proto PROXY Have Varnish use the proxy protocol. Note that PROXY here is the actual string.

You can decide to start the Varnish instance and/or wait for several events:

varnish vNAME [-start] [-wait] [-wait-running] [-wait-stopped]

-start Start the child process.
Once successfully started, the following macros are available for the default listen address: ${vNAME_addr}, ${vNAME_port} and ${vNAME_sock}. Additional macros are available, including the listen address name for each address vNAME listens to, like for example: ${vNAME_a0_addr}. -stop Stop the child process. -syntax Set the VCL syntax level for this command (default: 4.1) -wait Wait for that instance to terminate. -wait-running Wait for the Varnish child process to be started. -wait-stopped Wait for the Varnish child process to stop. -cleanup Once Varnish is stopped, clean everything after it. This is only used in very few tests and you should never need it. -expectexit NUMBER Expect varnishd to exit(3) with this value

Once Varnish is started, you can talk to it (as you would through varnishadm) with these additional switches:

varnish vNAME [-cli STRING] [-cliok STRING] [-clierr STRING]
              [-clijson STRING]

-cli STRING|-cliok STRING|-clierr STATUS STRING|-cliexpect [!] REGEXP STRING All four of these will send STRING to the CLI, the only difference is what they expect the result to be. -cli doesn’t expect anything, -cliok expects 200, -clierr expects STATUS, and -cliexpect expects the REGEXP to match the returned response. -cliexpect ! … negates the match -clijson STRING Send STRING to the CLI, expect success (CLIS_OK/200) and check that the response is parsable JSON.

It is also possible to interact with its shared memory (as you would through tools like varnishstat) with additional switches:

-expect !PATTERN|PATTERN OP NUMBER|PATTERN OP PATTERN 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 SM?.s1.g_space > 1000000 varnish v1 -expect cache_hit >= cache_hit_grace

In the ! form the test fails if a counter matches PATTERN.
The MAIN. namespace can be omitted from PATTERN.
The test takes up to 5 seconds before timing out. -vsc PATTERN Dump VSC counters matching PATTERN. -vsl_catchup Wait until the logging thread has idled to make sure that all the generated log is flushed

varnishtest#

Alternate name for ‘vtest’, see above.

vsm#

Interact with the shared memory of a varnish instance.

To define a VSM consumer, use this syntax:

vsm mNAME [-n STRING]

Arguments:

mNAME Identify the VSM consumer, it must starts with ‘m’. -n STRING Choose the working directory of the varnish instance. By default a VSM consumer connects to ${v1_name}. -attach Attach to a new varnish instance. Implicitly detach from the current varnish instance if applicable. -detach Detach from the current varnish instance. -expect-status STRING Check that the status of VSM matches the list of status flags from STRING. The expected status is represented as a comma-separated list of flags. The list of flags in STRING is not sensitive to the order of flags.
The available flags are:

  • mgt-running
  • mgt-changed
  • mgt-restarted
  • wrk-running
  • wrk-changed
  • wrk-restarted
    Expecting a status automatically attaches to the varnish instance if that was not already the case.

vtest#

This should be the first command in your vtc as it will identify the test case with a short yet descriptive sentence. It takes exactly one argument, a string, eg:

vtest "Check that vtest is actually a valid command"

It will also print that string in the log.

HISTORY#

This document has been written by Guillaume Quintard.

SEE ALSO#

This document is licensed under the same licence as Varnish itself. See LICENCE for details.

  • Copyright (c) 2006-2016 Varnish Software AS