Skip to content

Commit

Permalink
haproxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skriebel authored and jordansissel committed Jul 28, 2015
1 parent cb26b57 commit bead5a5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions spec/patterns/haproxy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# encoding: utf-8
require "spec_helper"
require "logstash/patterns/core"

describe "HAPROXY" do

let(:haproxyhttp_pattern) { "HAPROXYHTTP" }

context "Parsing HAPROXY log line from raw syslog line" do

let(:value) { 'Dec 9 13:01:26 localhost haproxy[28029]: 127.0.0.1:39759 [09/Dec/2013:12:59:46.633] loadbalancer default/instance8 0/51536/1/48082/99627 200 83285 - - ---- 87/87/87/1/0 0/67 {77.24.148.74} "GET /path/to/image HTTP/1.1"' }
subject { grok_match(haproxyhttp_pattern, value) }

it { should include("program" => "haproxy") }
it { should include("client_ip" => "127.0.0.1") }
it { should include("http_verb" => "GET") }
it { should include("server_name" => "instance8") }

it "generates a message field" do
expect(subject["message"]).to include("loadbalancer default/instance8")
end

end

let(:haproxyhttpbase_pattern) { "HAPROXYHTTPBASE" }

context "Parsing HAPROXY log line without syslog specific enteries. This mimics an event coming from a syslog input." do

let(:value) { '127.0.0.1:39759 [09/Dec/2013:12:59:46.633] loadbalancer default/instance8 0/51536/1/48082/99627 200 83285 - - ---- 87/87/87/1/0 0/67 {77.24.148.74} "GET /path/to/image HTTP/1.1"' }
subject { grok_match(haproxyhttpbase_pattern, value) }

# Assume 'program' would be matched by the syslog input.
it { should include("client_ip" => "127.0.0.1") }
it { should include("http_verb" => "GET") }
it { should include("server_name" => "instance8") }

it "generates a message field" do
expect(subject["message"]).to include("loadbalancer default/instance8")
end

end

end

0 comments on commit bead5a5

Please sign in to comment.