Skip to content

Commit

Permalink
Fix failing specs (#44)
Browse files Browse the repository at this point in the history
* Fix fact-related telegraf::input specs

These failures appear to have been caused by additional fact requirements
added since the specs were first written. Additionally, the my_snmp
check was failing due to a change that causes integers to be written to
the config as bare numerals, not as strings.

* Bump Travis ruby version

Required for newer versions of beaker.
  • Loading branch information
cosmopetrich authored and yankcrime committed Jan 16, 2017
1 parent 1c8f30f commit d11bfa2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
script:
- bundle exec rake validate lint beaker
rvm:
- 2.1.6
- 2.2.6
env:
- BEAKER_set="default"
- BEAKER_set="default" PUPPET_INSTALL_TYPE="agent" PUPPET_INSTALL_VERSION="1.6.1"
8 changes: 2 additions & 6 deletions spec/classes/telegraf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
[6,7].each do |releasenum|
context "RedHat #{releasenum} release specifics" do
let(:facts) {{
:osfamily => 'RedHat',
:architecture => 'x86_64',
:kernel => 'Linux',
:operatingsystem => osfamily,
:operatingsystemrelease => releasenum,
:operatingsystemmajrelease => releasenum,
:role => 'telegraf'
}}
it { should compile.with_all_deps }
it { should contain_class('telegraf::config') }
Expand Down Expand Up @@ -81,15 +77,15 @@
it { should contain_service('telegraf') }
it { should contain_yumrepo('influxdata')
.with(
:baseurl => "https://repos.influxdata.com/rhel/#{facts[:operatingsystemmajrelease]}/#{facts[:architecture]}/stable",
:baseurl => "https://repos.influxdata.com/rhel/#{releasenum}/x86_64/stable",
)
}

describe 'allow custom repo_type' do
let(:params) { {:repo_type => 'unstable' } }
it { should contain_yumrepo('influxdata')
.with(
:baseurl => "https://repos.influxdata.com/rhel/#{facts[:operatingsystemmajrelease]}/#{facts[:architecture]}/unstable",
:baseurl => "https://repos.influxdata.com/rhel/#{releasenum}/x86_64/unstable",
)
}
end
Expand Down
5 changes: 1 addition & 4 deletions spec/defines/input_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"urls" => ["http://localhost:8086",],
},
}}
let(:facts) { { :osfamily => 'RedHat' } }
let(:filename) { "/etc/telegraf/telegraf.d/#{title}.conf" }

describe "configuration file /etc/telegraf/telegraf.d/my_influxdb.conf input" do
Expand Down Expand Up @@ -43,7 +42,6 @@
},
},
}}
let(:facts) { { :osfamily => 'RedHat' } }
let(:filename) { "/etc/telegraf/telegraf.d/#{title}.conf" }

describe 'configuration file /etc/telegraf/telegraf.d/my_snmp.conf input with sections' do
Expand All @@ -54,7 +52,7 @@
should contain_file(filename).with_content(/ address = "snmp_host1:161"/)
should contain_file(filename).with_content(/ community = "read_only"/)
should contain_file(filename).with_content(/ get_oids = \["1.3.6.1.2.1.1.5"\]/)
should contain_file(filename).with_content(/ version = "2"/)
should contain_file(filename).with_content(/ version = 2/)
end

it 'requires telegraf to be installed' do
Expand All @@ -72,7 +70,6 @@
let(:params) {{
:plugin_type => 'haproxy',
}}
let(:facts) { { :osfamily => 'RedHat' } }
let(:filename) { "/etc/telegraf/telegraf.d/#{title}.conf" }

describe 'configuration file /etc/telegraf/telegraf.d/my_haproxy.conf input with no options or sections' do
Expand Down
10 changes: 10 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
Puppet.features.stubs(:root? => true)
end

c.default_facts = {
:osfamily => 'RedHat',
:architecture => 'x86_64',
:kernel => 'Linux',
:operatingsystem => 'RedHat',
:operatingsystemrelease => 7,
:operatingsystemmajrelease => 7,
:role => 'telegraf'
}

c.hiera_config = 'spec/hiera.yaml'

end

0 comments on commit d11bfa2

Please sign in to comment.