class Urushiol::VarnishTestBase

Public Class Methods

new(name,vcl_file_ref=nil) click to toggle source
# File lib/urushiol.rb, line 9
def initialize (name,vcl_file_ref=nil)
  @vtc_obj    = Vtc.new(name)
  @vcl_source = vcl_file_ref
end

Public Instance Methods

cleanup() click to toggle source
# File lib/urushiol.rb, line 85
def cleanup
  #system("rm /tmp/test.vtc")
end
client_testcase(name="c",config="") { |test| ... } click to toggle source
# File lib/urushiol.rb, line 38
def client_testcase(name="c",config="",&block)
  test = ClientTestBase.new(name,config)
  yield test if block_given?
  @vtc_obj.append_config(test.test_source)
end
create_test_file(vtc) click to toggle source
# File lib/urushiol.rb, line 50
def create_test_file(vtc)
  File.open('/tmp/test.vtc', "wb") { |f| f.write(vtc.get_spec) }
end
define_tests(tests) click to toggle source
# File lib/urushiol.rb, line 34
def define_tests(tests)
  @vtc_obj.mock_clients_and_tests(tests)
end
delay(time) click to toggle source
# File lib/urushiol.rb, line 62
def delay(time)
  @vtc_obj.append_config("\ndelay #{time}")
end
get_vcl() click to toggle source
# File lib/urushiol.rb, line 58
def get_vcl
  @vcl_source
end
mock_backends(source=@vcl_source) click to toggle source
# File lib/urushiol.rb, line 20
def mock_backends(source=@vcl_source)
  if source != nil
    @vtc_obj.mock_backends(Vcl.new(source).get_conf)
  else
    puts "\nCan't mock backends if no VCL file is specified.\n"
  end
end
mock_server(name) { |server| ... } click to toggle source
# File lib/urushiol.rb, line 44
def mock_server(name,&block)
  server = Server.new(name)
  yield server if block_given?
  @vtc_obj.append_config(server.server_source)
end
mock_varnish(name) { |varnish| ... } click to toggle source
# File lib/urushiol.rb, line 14
def mock_varnish(name)
  varnish = Varnish.new(name)
  yield varnish if block_given?
  @vtc_obj.append_config(varnish.varnish_source)
end
override_vcl_file(vcl_file) click to toggle source
# File lib/urushiol.rb, line 54
def override_vcl_file(vcl_file)
  File.open('/tmp/test.vcl', "wb") { |f| f.write(Vcl.new(vcl_file).get_conf) }
end
run() click to toggle source
# File lib/urushiol.rb, line 66
def run
  create_test_file(@vtc_obj)
  varnishd_check = `which varnishd` ;  result=$?.success?
  if result == true
    output=`varnishtest /tmp/test.vtc` ;  result=$?.success?
    if result == false
      puts output
      puts "\nVarnishtests returned errors, see stack trace above."
      exit 1
    else
      puts "Test completed successfully without errors."
    end
    cleanup
  else
    puts "Varnish does not seem to be installed on your computer. Urushiol can't run without Varnish"
  end

end
server() { |Server)| ... } click to toggle source
# File lib/urushiol.rb, line 28
def server(&block)
  if block_given?
    @vtc_obj.append_config(yield Server)
  end
end