Skip to content

Commit

Permalink
Merge pull request #60 from coi-gov-pl/feature/enh-45-add-puppet-rspe…
Browse files Browse the repository at this point in the history
…c-tests

Feature for #45: Rspec cover tests for puppet-jboss resources.
Rspec cover tests for puppet-jboss resources refers to #45.
  • Loading branch information
frodoslaw committed Feb 9, 2016
2 parents 9177949 + 7e171d5 commit 04290e1
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 365 deletions.
45 changes: 45 additions & 0 deletions spec/classes/internal/augeas_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper_puppet'

describe 'jboss::internal::augeas', :type => :class do

shared_examples 'completly working define' do
it { is_expected.to contain_class 'jboss::internal::lenses' }
it { is_expected.to contain_class 'jboss::internal::augeas' }
it { is_expected.to contain_file("/usr/lib/wildfly-8.2.0.Final/lenses/jbxml.aug") }
end

context 'On RedHat os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-augeas' }
let(:facts) do
{
:operatingsystem => 'OracleLinux',
:osfamily => 'RedHat',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation

end

context 'On Debian os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-augeas' }
let(:facts) do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:lsbdistcodename => 'trusty',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation

end
end
81 changes: 81 additions & 0 deletions spec/classes/internal/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
require 'spec_helper_puppet'

describe 'jboss::internal::configuration', :type => :class do
shared_examples 'completly working define' do
it { is_expected.to contain_class 'jboss::internal::configuration' }
it { is_expected.to contain_class 'jboss::internal::configure::interfaces' }
it { is_expected.to contain_class 'jboss::internal::quirks::etc_initd_functions' }
it { is_expected.to contain_file('/etc/profile.d/jboss.sh').with({
:ensure => 'file',
:mode => '0644'
}) }

it { is_expected.to contain_file('/var/log/wildfly/console.log').with({
:ensure => 'file',
:alias => 'jboss::logfile',
:owner => 'root',
:group => 'jboss',
:mode => '0660'
}) }

it { is_expected.to contain_file('/etc/jboss-as').with({
:ensure => 'directory',
:mode => '2770',
:owner => 'jboss',
:group => 'jboss'
}) }

it { is_expected.to contain_file('/etc/jboss-as/jboss-as.conf').
with_ensure('link').
that_comes_before('Anchor[jboss::configuration::end]') }

it { is_expected.to contain_file('/etc/default').with_ensure('directory') }

it { is_expected.to contain_file('/etc/default/wildfly.conf').
with_ensure('link').
that_comes_before('Anchor[jboss::configuration::end]') }

it { is_expected.to contain_concat('/etc/wildfly/wildfly.conf').with({
:alias => 'jboss::jboss-as.conf',
:mode => '0644'
}) }
it { is_expected.to contain_concat__fragment('jboss::jboss-as.conf::defaults').with({
:order => '000'
}) }
end

context 'On RedHat os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-configuration' }
let(:facts) do
{
:operatingsystem => 'OracleLinux',
:osfamily => 'RedHat',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
it { is_expected.to contain_file('/etc/sysconfig/wildfly.conf') }
end

context 'On Debian os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-configuration' }
let(:facts) do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:lsbdistcodename => 'trusty',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
it { is_expected.to contain_file('/etc/default/wildfly') }
end
end
61 changes: 5 additions & 56 deletions spec/classes/internal/configure/interfaces_spec.rb
Original file line number Diff line number Diff line change
@@ -1,67 +1,13 @@
require 'spec_helper_puppet'

describe 'jboss::internal::configure::interfaces', :type => :define do
bind_variables_list = [
"inet-address", "link-local-address",
"loopback", "loopback-address", "multicast",
"nic", "nic-match", "point-to-point", "public-address",
"site-local-address", "subnet-match", "up", "virtual",
"any-ipv4-address", "any-ipv6-address" ]

anchor_list = [
"begin", "end", "configuration::begin", "configuration::end",
"installed", "package::begin", "package::end",
"service::begin", "service::end", "service::started"].map {|item| "jboss::#{item}"}

shared_examples 'completly working define' do
it { is_expected.to compile }
it { is_expected.to contain_user 'jboss' }
it { is_expected.to contain_class 'jboss' }
it { is_expected.to contain_group 'jboss' }
it { is_expected.to contain_class 'jboss::params' }
it { is_expected.to contain_class 'jboss::internal::runtime::dc' }
it { is_expected.to contain_class 'jboss::internal::configure::interfaces' }
it { is_expected.to contain_jboss__interface('public').with({
:ensure => 'present',
:inet_address => nil
}) }
it { is_expected.to contain_augeas('ensure present interface public').with({
:context => '/files/usr/lib/wildfly-8.2.0.Final/standalone/configuration/standalone-full.xml/',
:changes => "set server/interfaces/interface[last()+1]/#attribute/name public",
:onlyif => "match server/interfaces/interface[#attribute/name='public'] size == 0"
}) }
it { is_expected.to contain_augeas('interface public set any-address').with({
:context => '/files/usr/lib/wildfly-8.2.0.Final/standalone/configuration/standalone-full.xml/',
:changes => "set server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value 'true'",
:onlyif => "get server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value != 'true'"
}) }
it { is_expected.to contain_jboss__internal__interface__foreach("public:any-address").with({
:cfg_file => '/usr/lib/wildfly-8.2.0.Final/standalone/configuration/standalone-full.xml',
:path => 'server/interfaces'
}) }

anchor_list.each do |item|
it { is_expected.to contain_anchor("#{item}") }
end
bind_variables_list.each do |var|
it { is_expected.to contain_augeas("interface public rm #{var}").with({
:context => '/files/usr/lib/wildfly-8.2.0.Final/standalone/configuration/standalone-full.xml/',
:changes => "rm server/interfaces/interface[#attribute/name='public']/#{var}",
:onlyif => "match server/interfaces/interface[#attribute/name='public']/#{var} size != 0"
}) }
it { is_expected.to contain_jboss__internal__interface__foreach("public:#{var}").with({
:cfg_file => '/usr/lib/wildfly-8.2.0.Final/standalone/configuration/standalone-full.xml',
:path => 'server/interfaces'
}) }
end
it { is_expected.to contain_service('wildfly').with({
:ensure => 'running',
:enable => true
}) }
end

context 'On RedHat os family' do
let(:title) { 'test-conf-interfaces' }
extend Testing::JBoss::SharedExamples
let(:facts) do
{
:operatingsystem => 'OracleLinux',
Expand All @@ -72,10 +18,12 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
end

context 'On Debian os family' do
let(:title) { 'test-module' }
extend Testing::JBoss::SharedExamples
let(:title) { 'test-conf-interfaces' }
let(:facts) do
{
:operatingsystem => 'Ubuntu',
Expand All @@ -87,5 +35,6 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
end
end
51 changes: 51 additions & 0 deletions spec/classes/internal/lenses_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'spec_helper_puppet'

describe 'jboss::internal::lenses', :type => :class do
shared_examples 'completly working define' do
it { is_expected.to contain_class 'jboss::internal::lenses' }
it { is_expected.to contain_class 'jboss' }
it { is_expected.to contain_file('/usr/lib/wildfly-8.2.0.Final/lenses/jbxml.aug').with({
:ensure => 'file',
:source => 'puppet:///modules/jboss/jbxml.aug',
}) }
it { is_expected.to contain_file('/usr/lib/wildfly-8.2.0.Final/lenses/jbxml.aug').that_requires(
'File[/usr/lib/wildfly-8.2.0.Final/lenses/]'
)}
it { is_expected.to contain_file('/usr/lib/wildfly-8.2.0.Final/lenses').with({
:ensure => 'directory',
:owner => 'jboss',
}) }
it { is_expected.to contain_file('/usr/lib/wildfly-8.2.0.Final/lenses').that_requires(
'Anchor[jboss::configuration::begin]'
)}
end

context 'On RedHat os family' do
let(:title) { 'test-lenses' }
let(:facts) do
{
:operatingsystem => 'OracleLinux',
:osfamily => 'RedHat',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
end

context 'On Debian os family' do
let(:title) { 'test-lenses' }
let(:facts) do
{
:operatingsystem => 'Ubuntu',
:osfamily => 'Debian',
:ipaddress => '192.168.0.1',
:concat_basedir => '/root/concat',
:lsbdistcodename => 'trusty',
:puppetversion => Puppet.version
}
end
it_behaves_like 'completly working define'
end
end
12 changes: 7 additions & 5 deletions spec/classes/internal/quirks/etc_initd_functions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

describe 'jboss::internal::quirks::etc_initd_functions', :type => :define do
shared_examples 'completly working define' do
it { is_expected.to compile }
it { is_expected.to contain_class 'jboss::internal::quirks::etc_initd_functions' }
it { is_expected.to contain_class 'jboss' }
it { is_expected.to contain_class 'jboss::internal::service' }
it { is_expected.to contain_class 'jboss::internal::compatibility' }
end

context 'On RedHat os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-etc_initd_functions' }
let(:facts) do
{
Expand All @@ -21,10 +18,13 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation

end

context 'On Debian os family' do
let(:title) { 'test-module' }
extend Testing::JBoss::SharedExamples
let(:title) { 'test-etc_initd_functions' }
let(:facts) do
{
:operatingsystem => 'Ubuntu',
Expand All @@ -36,5 +36,7 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation

end
end
37 changes: 4 additions & 33 deletions spec/classes/internal/service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
require 'spec_helper_puppet'

describe 'jboss::internal::service', :type => :define do
bind_variables_list = [
"inet-address", "link-local-address",
"loopback", "loopback-address", "multicast",
"nic", "nic-match", "point-to-point", "public-address",
"site-local-address", "subnet-match", "up", "virtual",
"any-ipv4-address", "any-ipv6-address" ]

anchor_list = [
"begin", "end", "configuration::begin", "configuration::end",
"installed", "package::begin", "package::end",
"service::begin", "service::end", "service::started"].map {|item| "jboss::#{item}"}

shared_examples 'completly working define' do
it { is_expected.to compile }
it { is_expected.to contain_class 'jboss::internal::service' }
it { is_expected.to contain_class 'jboss' }
it { is_expected.to contain_group 'jboss' }
it { is_expected.to contain_user 'jboss' }
it { is_expected.to contain_class 'jboss::params' }
it { is_expected.to contain_class 'jboss::internal::configuration' }
it { is_expected.to contain_jboss__interface('public') }
it { is_expected.to contain_augeas('ensure present interface public') }
it { is_expected.to contain_augeas('interface public set any-address') }

anchor_list.each do |item|
it { is_expected.to contain_anchor("#{item}") }
end
bind_variables_list.each do |var|
it { is_expected.to contain_augeas("interface public rm #{var}") }
it { is_expected.to contain_jboss__internal__interface__foreach("public:#{var}") }
end
it { is_expected.to contain_service('wildfly').with({
:ensure => 'running',
:enable => true
})}
it { is_expected.to contain_exec('jboss::move-unzipped') }
end

context 'On RedHat os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-service' }
let(:facts) do
{
Expand All @@ -51,9 +19,11 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
end

context 'On Debian os family' do
extend Testing::JBoss::SharedExamples
let(:title) { 'test-module' }
let(:facts) do
{
Expand All @@ -66,5 +36,6 @@
}
end
it_behaves_like 'completly working define'
it_behaves_like_full_working_jboss_installation
end
end
Loading

0 comments on commit 04290e1

Please sign in to comment.