Skip to content

Commit

Permalink
update tests with http calls; fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
dearing committed Aug 4, 2015
1 parent c6383b4 commit e3f52d1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 34 deletions.
12 changes: 1 addition & 11 deletions templates/default/logstash/logstash.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ input {
}

filter {
if [type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
syslog_pri { }
date {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
## ADD FILTERS HERE
}

# TODO: logstash doesn't convert 1:1 with ruby or json, hash passing will have to wait
Expand Down
6 changes: 3 additions & 3 deletions test/cookbooks/ellktest/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
packages = %w( tar nano htop )
packages = %w( tar nano htop jq )

case node[:platform_family]
when 'debian'
Expand Down Expand Up @@ -33,7 +33,7 @@
content logstash_crt
end

## ELASTICSEARCH
## ELASTICSEARCH
elasticsearch 'default' do
datadir '/tmp/es_datadir'
version '1.7.1'
Expand All @@ -60,7 +60,7 @@
files [{ 'paths' => ['/var/log/messages', '/var/log/*log', '/var/log/kibana/current'], 'fields' => { 'type' => 'syslog' } }]
end

## KIBANA
## KIBANA
kibana 'default' do
port 8080
end
26 changes: 15 additions & 11 deletions test/integration/helpers/serverspec/elasticsearch.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
shared_examples 'elasticsearch' do
describe command('sv status elasticsearch') do
its(:stdout) { should match 'run: elasticsearch' }
its(:stdout) { should contain 'run: elasticsearch' }
end

# TODO: unreliable
# describe command('curl http://localhost:9200/') do
# its(:stdout) { should match '"status" : 200,' }
# end
# describe command('curl http://localhost:9200/_cat/health') do
# its(:stdout) { should match 'elasticsearch' } # node name
# end
describe command('curl http://localhost:9200/') do
its(:stdout) { should contain '"status" : 200,' }
end
describe command('curl -s http://localhost:9200/_cluster/state|jq .cluster_name') do
its(:stdout) { should contain 'elasticsearch' } # node name
end

describe file('/etc/service/elasticsearch/env/ES_USER') do
it { should be_file }
its(:content) { should match 'elasticsearch' }
its(:content) { should contain 'elasticsearch' }
end

describe file('/opt/elasticsearch/elasticsearch-1.7.1/config/elasticsearch.yml') do
it { should be_file }
its(:content) { should match '# This file was generated by Chef' }
its(:content) { should contain '# This file was generated by Chef' }
end

describe file('/opt/elasticsearch/elasticsearch-1.7.1/config/logging.yml') do
it { should be_file }
its(:content) { should match '# This file was generated by Chef' }
its(:content) { should contain '# This file was generated by Chef' }
end

describe file('/var/log/elasticsearch/current') do
it { should be_file }
its(:content) { should contain 'bound_address' }
end
end
11 changes: 9 additions & 2 deletions test/integration/helpers/serverspec/kibana.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
shared_examples 'kibana' do
describe command('sv status kibana') do
its(:stdout) { should match 'run: kibana' }
its(:stdout) { should contain 'run: kibana' }
end
describe file('/opt/kibana/kibana-4.1.1/config/kibana.yml') do
it { should be_file }
its(:content) { should match '# This file was generated by Chef' }
its(:content) { should contain '# This file was generated by Chef' }
end
describe command('curl http://localhost:8080') do
its(:stdout) { should contain 'Kibana 4' }
end
describe file('/var/log/kibana/current') do
it { should be_file }
its(:content) { should contain 'Listening on 0.0.0.0:8080' }
end
end
15 changes: 10 additions & 5 deletions test/integration/helpers/serverspec/logstash.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
shared_examples 'logstash' do
describe command('sv status logstash') do
its(:stdout) { should match 'run: logstash' }
its(:stdout) { should contain 'run: logstash' }
end

describe file('/etc/service/logstash/env/LS_USER') do
it { should be_file }
its(:content) { should match 'kibana' } # <= not a typo; testing hash merge
its(:content) { should contain 'kibana' } # <= not a typo; testing hash merge
end

describe file('/etc/service/logstash/env/HELLO') do
it { should be_file }
its(:content) { should match 'WORLD' }
its(:content) { should contain 'WORLD' }
end

describe file('/opt/logstash/logstash-1.5.3/config/logging.yml') do
it { should be_file }
its(:content) { should match '# This file was generated by ELKTEST' }
its(:content) { should contain '# This file was generated by ELKTEST' }
end

describe file('/opt/logstash/logstash-1.5.3/config/logstash.conf') do
it { should be_file }
its(:content) { should match '# This file was generated by merged hash from a recipe!' }
its(:content) { should contain '# This file was generated by merged hash from a recipe!' }
end

describe file('/var/log/logstash/current') do
it { should be_file }
its(:content) { should contain 'detected_master' }
end
end
12 changes: 10 additions & 2 deletions test/integration/helpers/serverspec/logstash_forwarder.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
shared_examples 'logstash_forwarder' do
describe command('sv status logstash-forwarder') do
its(:stdout) { should match 'run: logstash-forwarder' }
its(:stdout) { should contain 'run: logstash-forwarder' }
end

describe file('/opt/logstash-forwarder/logstash-forwarder-0.4.0/logstash-forwarder.conf') do
it { should be_file }
its(:content) { should match '# This file was generated by Chef' }
its(:content) { should contain '# This file was generated by Chef' }
end

describe file('/var/log/logstash-forwarder/current') do
it { should be_file }
its(:content) { should contain 'Connected to' }
its(:content) { should contain 'Registrar: processing' }
its(:content) { should contain 'Launching harvester on new file:' }
end
end

0 comments on commit e3f52d1

Please sign in to comment.