Alexandros Kosiaris has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363186 )

Change subject: WIP monitoring: provide basic Rspec
......................................................................

WIP monitoring: provide basic Rspec

Add RSpec for monitoring module.

Change-Id: I04db8fe2051dc9f667da0e4e557c740174c352a1
---
A modules/monitoring/.fixtures.yml
A modules/monitoring/.rspec
A modules/monitoring/Rakefile
A modules/monitoring/spec/defines/monitoring_host_spec.rb
A modules/monitoring/spec/fixtures/modules/bacula
A modules/monitoring/spec/fixtures/modules/base
A modules/monitoring/spec/fixtures/modules/stdlib
A modules/monitoring/spec/fixtures/modules/wmflib
A modules/monitoring/spec/spec_helper.rb
9 files changed, 133 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/86/363186/1

diff --git a/modules/monitoring/.fixtures.yml b/modules/monitoring/.fixtures.yml
new file mode 100644
index 0000000..ef1bcbf
--- /dev/null
+++ b/modules/monitoring/.fixtures.yml
@@ -0,0 +1,8 @@
+fixtures:
+    symlinks:
+        monitoring: "#{source_dir}"
+        icinga: "../../../../icinga"
+        nagios_common: "../../../../nagios_common"
+        wmflib: "../../../../wmflib"
+        logrotate: "../../../../logrotate"
+        secret: "../../../../../../labs/private/modules/secret"
diff --git a/modules/monitoring/.rspec b/modules/monitoring/.rspec
new file mode 100644
index 0000000..f449dae
--- /dev/null
+++ b/modules/monitoring/.rspec
@@ -0,0 +1,2 @@
+--format doc
+--color
diff --git a/modules/monitoring/Rakefile b/modules/monitoring/Rakefile
new file mode 100644
index 0000000..cd3d379
--- /dev/null
+++ b/modules/monitoring/Rakefile
@@ -0,0 +1 @@
+require 'puppetlabs_spec_helper/rake_tasks'
diff --git a/modules/monitoring/spec/defines/monitoring_host_spec.rb 
b/modules/monitoring/spec/defines/monitoring_host_spec.rb
new file mode 100644
index 0000000..f863008
--- /dev/null
+++ b/modules/monitoring/spec/defines/monitoring_host_spec.rb
@@ -0,0 +1,109 @@
+require 'spec_helper'
+
+describe 'monitoring::host' do
+  context 'with a standard physical host' do
+    let(:facts) {
+      {
+        :hostname        => 'ahost',
+        :operatingsystem => 'Debian',
+        :ipaddress       => '1.2.3.4',
+        :is_virtual      => false,
+        :lldp_parent     => 'ahosts_parent',
+      }
+    }
+    let(:title) { 'ahost' }
+    it { should compile }
+    describe 'with no parameters' do
+      subject { exported_resources }
+      it do
+        should contain_nagios_host('ahost').with(
+          'host_name'  => 'ahost',
+          'parents'    => 'ahosts_parent',
+          'icon_image' => 'vendors/debian.png',
+          'address'    => '1.2.3.4',
+        )
+    end
+    end
+    describe 'with a parents parameters' do
+      let(:params) {
+        {
+          :parents => 'aparent',
+        }
+      }
+      subject { exported_resources }
+      it do
+        should contain_nagios_host('ahost').with(
+          'host_name'  => 'ahost',
+          'parents'    => 'aparent',
+          'icon_image' => 'vendors/debian.png',
+          'address'    => '1.2.3.4',
+        )
+      end
+    end
+  end
+  context 'with a standard virtual host' do
+    let(:facts) {
+      {
+        :hostname        => 'ahost',
+        :operatingsystem => 'Debian',
+        :ipaddress       => '1.2.3.4',
+        :is_virtual      => true,
+        :lldp_parent     => 'ahosts_parent',
+      }
+    }
+    let(:title) { 'ahost' }
+    it { should compile }
+    describe 'with no parameters' do
+      subject { exported_resources }
+      it do
+        should contain_nagios_host('ahost').with(
+          'host_name'  => 'ahost',
+          'parents'    => nil,
+          'icon_image' => 'vendors/debian.png',
+          'address'    => '1.2.3.4',
+        )
+      end
+    end
+    describe 'with a parents parameters' do
+      let(:params) {
+        {
+          :parents => 'aparent',
+        }
+      }
+      subject { exported_resources }
+      it do
+        should contain_nagios_host('ahost').with(
+          'host_name'  => 'ahost',
+          'parents'    => 'aparent',
+          'icon_image' => 'vendors/debian.png',
+          'address'    => '1.2.3.4',
+        )
+      end
+    end
+  end
+  context 'with an icinga host monitoring itself' do
+    let(:facts) {
+      {
+        :hostname        => 'ahost',
+        :operatingsystem => 'Debian',
+        :ipaddress       => '1.2.3.4',
+        :is_virtual      => false,
+        :lldp_parent     => 'ahosts_parent',
+      }
+    }
+    let(:title) { 'ahost' }
+    let(:pre_condition) { 'include icinga'}
+    it { should compile }
+    describe 'with no parameters' do
+      subject { exported_resources }
+      it do
+        should contain_nagios_host('ahost').with(
+          'host_name'  => 'ahost',
+          'parents'    => 'ahosts_parent',
+          'icon_image' => 'vendors/debian.png',
+          'address'    => '1.2.3.4',
+        )
+      end
+    end
+  end
+end
diff --git a/modules/monitoring/spec/fixtures/modules/bacula 
b/modules/monitoring/spec/fixtures/modules/bacula
new file mode 120000
index 0000000..5531cdb
--- /dev/null
+++ b/modules/monitoring/spec/fixtures/modules/bacula
@@ -0,0 +1 @@
+/home/alex/wikimedia/gerrit/puppet/production/modules/monitoring
\ No newline at end of file
diff --git a/modules/monitoring/spec/fixtures/modules/base 
b/modules/monitoring/spec/fixtures/modules/base
new file mode 120000
index 0000000..393ad7f
--- /dev/null
+++ b/modules/monitoring/spec/fixtures/modules/base
@@ -0,0 +1 @@
+../../../../base
\ No newline at end of file
diff --git a/modules/monitoring/spec/fixtures/modules/stdlib 
b/modules/monitoring/spec/fixtures/modules/stdlib
new file mode 120000
index 0000000..1aafa4d
--- /dev/null
+++ b/modules/monitoring/spec/fixtures/modules/stdlib
@@ -0,0 +1 @@
+../../../../stdlib
\ No newline at end of file
diff --git a/modules/monitoring/spec/fixtures/modules/wmflib 
b/modules/monitoring/spec/fixtures/modules/wmflib
new file mode 120000
index 0000000..639468d
--- /dev/null
+++ b/modules/monitoring/spec/fixtures/modules/wmflib
@@ -0,0 +1 @@
+../../../../wmflib
\ No newline at end of file
diff --git a/modules/monitoring/spec/spec_helper.rb 
b/modules/monitoring/spec/spec_helper.rb
new file mode 100644
index 0000000..421fd71
--- /dev/null
+++ b/modules/monitoring/spec/spec_helper.rb
@@ -0,0 +1,9 @@
+require 'rspec-puppet'
+require 'puppetlabs_spec_helper/module_spec_helper'
+
+fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
+
+RSpec.configure do |c|
+  c.module_path = File.join(fixture_path, 'modules')
+  c.manifest_dir = File.join(fixture_path, 'manifests')
+end

-- 
To view, visit https://gerrit.wikimedia.org/r/363186
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04db8fe2051dc9f667da0e4e557c740174c352a1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to