zoukankan      html  css  js  c++  java
  • 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]
  • 相关阅读:
    【mysql5.6】数据类型
    【leetcode】Multiply Strings(middle)
    创建JDBC模板简化代码、JDBC应用的事务管理以及连接池的作用
    IE8.0登录Oracle EBS后报Oracle error 1403错
    三联动 支持ie6,ie7 省,市,区
    任正非最新訪谈: 假设企业收留这类人, 距离死亡就不远了
    向量空间模型实现文档查询(Vector Space Model to realize document query)
    前端开发的经验
    《大话操作系统——做坚实的project实践派》(7)
    【整理】nand相关
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814209.html
Copyright © 2011-2022 走看看