• varnish-4.x VTL--varnishtest


    varnish-4.x VTL--varnishtest

    The Varnish Test Case (VTC) Language
    • Test against simulated or real backends
    • Starts real instance of varnishd
    • Simulates clients
    • Asserts using expect

    如下:是一个测试例子,保存为foo.vtc
    varnishtest "Varnish as Proxy"

    server s1 {
        rxreq
        txresp
    } -start
    server s2 {
        rxreq
        txresp
    }
    server s2 start

    varnish v1 -arg "-b 192.168.192.10:8080" -start
    varnish v2 -arg "-b ${s1_addr}:${s1_port}" -start

    client c1 {
        txreq
        rxresp
        expect resp.http.via ~ "varnish"
    } -run
    client c2 {
        txreq
        rxresp
        expect resp.http.via ~ "varnish"
    } -run
    client c3 {
        txreq
        rxresp
        expect resp.http.via ~ "varnish"
    }
    client c3 run


    1.VTC程序都以test命名开头
    varnishtest "Varnish as Proxy"

    2.定义模拟若干真实的后端origin server

    s1,s2等命名都必须以s开头,字面意思上就可以看出,s1,s2接受一个请求rxreq,传输应答txresp,${s1_addr}:${s1_port}定义后端server的地址和端口,可以是真实的后端地址及端口,server启动可简写可新行完整申明

    3.定义模拟若干varnish server

    4.定义模拟若干client
    varnish是完全为现代硬件架构和操作系统设计,多线程,所以几个角色(server,varnish,client)可能启动先后顺序会有一定影响,所以又提供了-wait参数
    -run
    -start
    -wait
    有兴趣的朋友可以试下如下,VTL
    示例2
    varnishtest "Synchronized"

    server s1 {
        rxreq
        txresp
    }
    server s1 -start

    client c1 -connect ${s1_sock} {
        txreq
        rxresp
    }
    # -run: -start - wait
    client c1 -run
    server s1 -wait

    示例3
    varnishtest "Unsynchronized"

    server s1 {
        rxreq
        txresp
    }
    server s1 -start -wait

    client c1 -connect ${s1_sock} {
        txreq
        rxresp
    }
    client c1 -run

    root@config-p:~#varnishtest t2.vtc 
    **** top   0.0 macro def varnishd=varnishd
    **** top   0.0 macro def varnishadm=varnishadm
    **** top   0.0 macro def varnishstat=varnishstat
    **** top   0.0 macro def varnishhist=varnishhist
    **** top   0.0 macro def varnishlog=varnishlog
    **** top   0.0 macro def varnishncsa=varnishncsa
    **** top   0.0 macro def vmod_std=std
    **** top   0.0 macro def vmod_debug=debug
    **** top   0.0 macro def vmod_directors=directors
    **** top   0.0 macro def pwd=/root
    **** top   0.0 macro def bad_ip=192.0.2.255
    **** top   0.0 macro def tmpdir=/tmp/vtc.84399.1a833cf5
    *    top   0.0 TEST t2.vtc starting
    ***  top   0.0 varnishtest
    *    top   0.0 TEST Unsynchronized
    ***  top   0.0 server
    ***  top   0.0 server
    **   s1    0.0 Starting server
    **** s1    0.0 macro def s1_addr=127.0.0.1
    **** s1    0.0 macro def s1_port=36877
    **** s1    0.0 macro def s1_sock=127.0.0.1 36877
    *    s1    0.0 Listen on 127.0.0.1 36877
    **   s1    0.0 Waiting for server
    **   s1    0.0 Started on 127.0.0.1 36877

    #     top  TEST t2.vtc FAILED (60.007) signal=9 exit=0
    失败是因为等待s1返回超时

    测试命令
    varnishtest foo.vtc [-v]
  • 相关阅读:
    TabControl 切换 内嵌web页面直接响应滚动事件
    进程、应用程序域和对象上下文
    CSharp中的多线程——线程同步基础
    CSharp中的多线程——入门
    注重实效的程序员之快速参考指南
    学习语言技术快速入门——五步骤
    利用jQuery选择将被操作的元素
    CSharp中的多线程——使用多线程
    android开发文件介绍
    三角函数公式
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814209.html
Copyright © 2020-2023  润新知