Skip to content

Instantly share code, notes, and snippets.

[pivotal@Toemang vcl (master)]$ varnishtest get_is_cached.vtc
# top TEST get_is_cached.vtc starting
# TEST GET is cached
## s Starting server
### s listen on 127.0.0.1:9080 (fd 3)
## v Launch
### v CMD: cd ../varnishd && ./varnishd -d -d -n /tmp/__v -a '127.0.0.1:9081' -T 127.0.0.1:9001 -P /tmp/__v/varnishd.pid
### v opening CLI connection
## s Started on 127.0.0.1:9080
connect(): Connection refused
test "Authorization tokens are cached"
server s {
rxreq
expect req.url == "/"
expect req.http.Authorization == "Basic foo"
txresp -status 200
rxreq
expect req.url == "/"
test "Authorization tokens are cached"
server s {
rxreq
expect req.url == "/"
expect req.http.Authorization == "foo"
txresp -status 200
} -start
varnish v -vcl+backend {
C{
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
typedef int twitter_is_fresh_t(char *, char *);
static twitter_is_fresh_t *twitter_is_fresh_ptr = NULL;
9 RxRequest c GET
9 RxURL c /statuses/user_timeline.xml
9 RxProtocol c HTTP/1.1
9 RxHeader c Authorization: Basic amFjazoxMjM0
9 RxHeader c User-Agent: curl/7.18.1 (i386-apple-darwin9.2.2) libcurl/7.18.1 zlib/1.2.3
9 RxHeader c Host: localhost
9 RxHeader c Accept: */*
9 VCL_call c recv
9 VCL_return c lookup
9 VCL_call c hash
test "Test restarts in vcl_hit"
server s {
rxreq
expect req.url == "/foo"
txresp -status 200
rxreq
expect req.url == "/foo"
txresp -status 200
} -start
test "Test restarts in vcl_hit"
server s {
rxreq
expect req.url == "/foo"
txresp -status 200
} -start
varnish v -vcl+backend {
sub vcl_hit {
#include <stdio.h>
#include <pthread.h>
#include "config.h"
#include "memcached.h"
void make_thread_local_connection_key();
void memcached_destroy(void *connection);
void make_prototypical_connection();
void initialize_process();
[pivot1@twitter-web029 ~]$ curl -H "Host: twitter.com" http://pivot4:pivots2pandas@localhost:81/statuses/user_timeline.xml -vvvvv
* About to connect() to localhost port 81
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 81
* Server auth using Basic with user 'pivot4'
> GET /statuses/user_timeline.xml HTTP/1.1
> Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Accept: */*
> Host: twitter.com
0 Backend_health - mongrels Still healthy 4--X-S-RH 5 2 5 0.000773 0.000849 HTTP/1.1 200 OK
0 Backend_health - mongrels[1] Still healthy 4--X-S-RH 5 2 5 0.000702 0.000825 HTTP/1.1 200 OK
0 Backend_health - mongrels Still healthy 4--X-S-RH 5 2 5 0.000780 0.000831 HTTP/1.1 200 OK
0 Backend_health - mongrels[1] Still healthy 4--X-S-RH 5 2 5 0.000765 0.000810 HTTP/1.1 200 OK
0 CLI - Rd ping
0 CLI - Wr 0 200 PONG 1226357087 1.0
0 Backend_health - mongrels Still healthy 4--X-S-RH 5 2 5 0.000760 0.000814 HTTP/1.1 200 OK
0 Backend_health - mongrels[1] Still healthy 4--X-S-RH 5 2 5 0.000755 0.000796 HTTP/1.1 200 OK
0 Backend_health - mongrels Still healthy 4--X-S-RH 5 2 5 0.000758 0.000800 HTTP/1.1 200 OK
0 Backend_health - mongrels[1] Still healthy 4--X-S-RH 5 2 5 0.000727 0.000779 HTTP/1.1 200 OK