class Urushiol::Vtc
Public Class Methods
new(name)
click to toggle source
# File lib/vtc.rb, line 4 def initialize(name) @vtc = "" end
Public Instance Methods
append_config(tests)
click to toggle source
# File lib/vtc.rb, line 32 def append_config(tests) @vtc << tests end
get_spec()
click to toggle source
# File lib/vtc.rb, line 41 def get_spec @vtc end
mock_backends(vcl)
click to toggle source
# File lib/vtc.rb, line 8 def mock_backends(vcl) if vcl != nil backends = vcl.scan(/^backend (\w*)\W+/).flatten #Mock servers in vtc-file backends.each do |backend| index = backends.index(backend) @vtc << "server s#{index} -repeat 10000 { # Receive a request rxreq # Send a standard response txresp -hdr \"Connection: close\" -body \"#{backend}\" } -start \n" #mock backends in vcl-file vcl.gsub!(/(?m)backend #{backend} \{(.*?)\}/, "backend #{backend} {\n .host = \"${s#{index}_addr}\";\n .port = \"${s#{index}_port}\";\n}") end @test_vcl = vcl else puts("no vcl-file given") end end
mock_varnish()
click to toggle source
# File lib/vtc.rb, line 36 def mock_varnish @vtc << "# Start a varnish instance called \"v1\" from vcl and override backends with mock server adresses varnish v1 -arg \"-f /tmp/test.vcl\" -start \n" end