1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2024-12-16 13:20:35 +00:00

Merge pull request #19 from wywy/use_rspec_puppet_facts

Use rspec puppet facts
This commit is contained in:
Max Wilhelm 2017-08-17 14:08:11 +02:00 committed by GitHub
commit d6231c3b13
14 changed files with 350 additions and 389 deletions

View File

@ -7,6 +7,7 @@ gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0' gem 'facter', '>= 1.7.0'
gem 'beaker-puppet_install_helper' gem 'beaker-puppet_install_helper'
gem 'metadata-json-lint' gem 'metadata-json-lint'
gem 'rspec-puppet-facts', '~> 1.7'
beakerrspec = '> 0' beakerrspec = '> 0'
platforms [:ruby_19, :ruby_21] do platforms [:ruby_19, :ruby_21] do

View File

@ -1,7 +1,14 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::config', :type => :class do describe 'fluentd::config', :type => :class do
shared_examples 'when called with no parameters' do on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
describe 'when called with no parameters' do
it { it {
should contain_file('/etc/td-agent/td-agent.conf').with({ should contain_file('/etc/td-agent/td-agent.conf').with({
'ensure' => 'file', 'ensure' => 'file',
@ -19,28 +26,6 @@ describe 'fluentd::config', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
include_examples 'when called with no parameters'
end end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,8 +1,13 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::install', :type => :class do describe 'fluentd::install', :type => :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
shared_examples 'when called with no parameters' do describe 'when called with no parameters' do
it { it {
should contain_package('fluentd').with({ should contain_package('fluentd').with({
'ensure' => 'installed', 'ensure' => 'installed',
@ -11,28 +16,6 @@ describe 'fluentd::install', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
include_examples 'when called with no parameters'
end end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,23 +1,18 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::repo::apt', :type => :class do describe 'fluentd::repo::apt', :type => :class do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'Debian', let :facts do
:lsbdistid => 'Ubuntu', facts
:operatingsystem => 'Ubuntu', end
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
describe 'when called with no parameters on Ubuntu' do case facts[:osfamily]
when 'Debian'
it { it {
should contain_class('apt') should contain_class('apt')
should contain_apt__source('treasure-data').with({ should contain_apt__source('treasure-data').with({
'ensure' => 'present', 'ensure' => 'present',
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
'release' => 'precise',
'repos' => 'contrib', 'repos' => 'contrib',
'architecture' => 'amd64', 'architecture' => 'amd64',
'key' => { 'key' => {
@ -30,5 +25,57 @@ describe 'fluentd::repo::apt', :type => :class do
} }
}) })
} }
case facts[:operatingsystem]
when 'Ubuntu'
case facts[:lsbdistcodename]
when 'precise'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/ubuntu/precise',
'release' => 'precise'
})
}
when 'trusty'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/ubuntu/trusty',
'release' => 'trusty'
})
}
when 'xenial'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/ubuntu/xenial',
'release' => 'xenial'
})
}
end
when 'Debian'
case facts[:lsbdistcodename]
when 'jessie'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/debian/jessie',
'release' => 'jessie'
})
}
when 'squeeze'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/debian/squeeze',
'release' => 'squeeze'
})
}
when 'wheezy'
it {
should contain_apt__source('treasure-data').with({
'location' => 'http://packages.treasuredata.com/2/debian/wheezy',
'release' => 'wheezy'
})
}
end
end
end
end
end end
end end

View File

@ -1,30 +1,21 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::repo', :type => :class do describe 'fluentd::repo', :type => :class do
on_supported_os.each do |os, facts|
context 'when called with no parameters on osfamily Debian' do context "on #{os}" do
let(:facts) { let :facts do
{ facts
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
it {
should contain_class('fluentd::repo::apt')
}
end end
context 'when called with no parameters on osfamily RedHat' do describe 'when called with no parameters' do
let(:facts) { case facts[:osfamily]
{ when 'Debian'
:osfamily => 'RedHat', it { is_expected.to contain_class('fluentd::repo::apt') }
} when 'RedHat'
} it { is_expected.to contain_class('fluentd::repo::yum') }
it { end
should contain_class('fluentd::repo::yum') end
} end
end end
end end

View File

@ -1,13 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::repo::yum', :type => :class do describe 'fluentd::repo::yum', :type => :class do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'RedHat', let :facts do
} facts
} end
describe 'when called with no parameters on RedHat' do describe 'when called with no parameters' do
case facts[:osfamily]
when 'RedHat'
it { it {
should contain_yumrepo('treasure-data').with({ should contain_yumrepo('treasure-data').with({
'ensure' => 'present', 'ensure' => 'present',
@ -24,4 +26,7 @@ describe 'fluentd::repo::yum', :type => :class do
}) })
} }
end end
end
end
end
end end

View File

@ -1,7 +1,13 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::config', :type => :class do describe 'fluentd::config', :type => :class do
shared_examples 'when called with no parameters' do on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
describe 'when called with no parameters' do
it { it {
should contain_service('fluentd').with({ should contain_service('fluentd').with({
'name' => 'td-agent', 'name' => 'td-agent',
@ -12,28 +18,6 @@ describe 'fluentd::config', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
include_examples 'when called with no parameters'
end end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,7 +1,13 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd', :type => :class do describe 'fluentd', :type => :class do
shared_examples 'when called with no parameters' do on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
describe 'when called with no parameters' do
it { it {
should contain_class('fluentd::repo') should contain_class('fluentd::repo')
should contain_class('fluentd::install') should contain_class('fluentd::install')
@ -9,29 +15,6 @@ describe 'fluentd', :type => :class do
should contain_class('fluentd::service') should contain_class('fluentd::service')
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
include_examples 'when called with no parameters'
end end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,7 +1,13 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::user', :type => :class do describe 'fluentd::user', :type => :class do
shared_examples 'when called with no parameters' do on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
describe 'when called with no parameters' do
it { it {
should contain_user('fluentd').with({ should contain_user('fluentd').with({
'name' => 'td-agent', 'name' => 'td-agent',
@ -10,28 +16,6 @@ describe 'fluentd::user', :type => :class do
}) })
} }
end end
context 'when osfamily is Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
include_examples 'when called with no parameters'
end end
context 'when osfamily is RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
}
}
include_examples 'when called with no parameters'
end end
end end

View File

@ -1,18 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::filter' do describe 'fluentd::filter' do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'Debian', let :facts do
:lsbdistid => 'Ubuntu', facts
:operatingsystem => 'Ubuntu', end
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' } let(:pre_condition) { 'include fluentd' }
context 'basic filter' do describe 'basic filter' do
let(:title) { 'test' } let(:title) { 'test' }
let(:params) do let(:params) do
{ {
@ -32,4 +29,6 @@ describe 'fluentd::filter' do
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/filter_record_transformer.conf'))) with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/filter_record_transformer.conf')))
end end
end end
end
end
end end

View File

@ -1,18 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::match' do describe 'fluentd::match' do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'Debian', let :facts do
:lsbdistid => 'Ubuntu', facts
:operatingsystem => 'Ubuntu', end
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' } let(:pre_condition) { 'include fluentd' }
context 'basic match' do describe 'basic match' do
let(:title) { 'test' } let(:title) { 'test' }
let(:params) do let(:params) do
{ {
@ -40,7 +37,7 @@ describe 'fluentd::match' do
end end
end end
context 'multiple store' do describe 'multiple store' do
let(:title) { 'test' } let(:title) { 'test' }
let(:params) do let(:params) do
{ {
@ -69,4 +66,6 @@ describe 'fluentd::match' do
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf'))) with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf')))
end end
end end
end
end
end end

View File

@ -1,18 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::plugin' do describe 'fluentd::plugin' do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'Debian', let :facts do
:lsbdistid => 'Ubuntu', facts
:operatingsystem => 'Ubuntu', end
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' } let(:pre_condition) { 'include fluentd' }
context 'gem plugin' do describe 'gem plugin' do
let(:title) { 'fluent-plugin-elasticsearch' } let(:title) { 'fluent-plugin-elasticsearch' }
let(:params) do let(:params) do
{ {
@ -29,7 +26,7 @@ describe 'fluentd::plugin' do
end end
end end
context 'file plugin' do describe 'file plugin' do
let(:title) { 'fluent-plugin-test' } let(:title) { 'fluent-plugin-test' }
let(:params) do let(:params) do
{ {
@ -49,4 +46,6 @@ describe 'fluentd::plugin' do
}) })
end end
end end
end
end
end end

View File

@ -1,18 +1,15 @@
require 'spec_helper' require 'spec_helper'
describe 'fluentd::source' do describe 'fluentd::source' do
let(:facts) { on_supported_os.each do |os, facts|
{ context "on #{os}" do
:osfamily => 'Debian', let :facts do
:lsbdistid => 'Ubuntu', facts
:operatingsystem => 'Ubuntu', end
:lsbdistcodename => 'precise',
:architecture => 'amd64',
}
}
let(:pre_condition) { 'include fluentd' } let(:pre_condition) { 'include fluentd' }
context 'basic source' do describe 'basic source' do
let(:title) { 'test' } let(:title) { 'test' }
let(:params) do let(:params) do
{ {
@ -31,4 +28,6 @@ describe 'fluentd::source' do
with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/source_tail.conf'))) with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/source_tail.conf')))
end end
end end
end
end
end end

View File

@ -1 +1,3 @@
require 'puppetlabs_spec_helper/module_spec_helper' require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts