[icinga-checkins] icinga.org: chef-icinga2/master: Update integration testing

git at icinga.org git at icinga.org
Fri Aug 5 16:26:33 CEST 2016


Module: chef-icinga2
Branch: master
Commit: d5e8a00c8f6ca52b2b4c645580f55e0ab11da8bc
URL:    https://git.icinga.org/?p=chef-icinga2.git;a=commit;h=d5e8a00c8f6ca52b2b4c645580f55e0ab11da8bc

Author: Blerim Sheqa <blerim.sheqa at netways.de>
Date:   Wed Aug  3 11:06:50 2016 +0200

Update integration testing

---

 .kitchen.yml                                      |   26 +++++++++++++----
 test/cookbooks/icinga2-test/recipes/default.rb    |    2 +-
 test/integration/client/serverspec/client_spec.rb |   14 +++++++++
 test/integration/client/serverspec/spec_helper.rb |    6 ++++
 test/integration/server/serverspec/server_spec.rb |   32 +++++++++++++++++++++
 test/integration/server/serverspec/spec_helper.rb |    6 ++++
 test/integration/web2/serverspec/spec_helper.rb   |    6 ++++
 test/integration/web2/serverspec/web2_spec.rb     |   27 +++++++----------
 8 files changed, 96 insertions(+), 23 deletions(-)

diff --git a/.kitchen.yml b/.kitchen.yml
index c9ab345..2f9db02 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -3,19 +3,32 @@ driver:
   name: vagrant
 
 provisioner:
-  name: chef_solo
+  name: chef_zero
 
 platforms:
-  - name: ubuntu-12.04
-  - name: centos-6.4
-  - name: debian-7.8
+  - name: ubuntu-14.04
 
 suites:
-  - name: default
+  - name: server
+    driver:
+      network:
+        - ["forwarded_port", {guest: 80, host: 8080, auto_correct: true}]
     run_list:
-      - recipe[icinga2::default]
+      - recipe[icinga2::server]
+      - recipe[icinga2-test::default]
     attributes:
+      icinga2:
+        version: '2.4.10-1'
+        classic_ui:
+          version: '2.4.10-1'
 
+  - name: client
+    run_list:
+      - recipe[icinga2::client]
+    attributes:
+      icinga2:
+        version: '2.4.10-1'
+    
   - name: web2
     driver:
       network:
@@ -27,6 +40,7 @@ suites:
       - recipe[icinga2-test::default]
     attributes:
      icinga2:
+      version: '2.4.10-1'
       web2:
         enable: true
       classic_ui:
diff --git a/test/cookbooks/icinga2-test/recipes/default.rb b/test/cookbooks/icinga2-test/recipes/default.rb
index c664289..3d4f3a7 100644
--- a/test/cookbooks/icinga2-test/recipes/default.rb
+++ b/test/cookbooks/icinga2-test/recipes/default.rb
@@ -1 +1 @@
-package 'curl' # minimal ubuntu precies does not come with curl
+package 'curl' # minimal ubuntu/debian does not come with curl
diff --git a/test/integration/client/serverspec/client_spec.rb b/test/integration/client/serverspec/client_spec.rb
new file mode 100644
index 0000000..69aae01
--- /dev/null
+++ b/test/integration/client/serverspec/client_spec.rb
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+%w(
+  icinga2
+).each do |pkg|
+  describe package(pkg) do
+    it { should be_installed }
+  end
+end
+
+describe service('icinga2') do
+  it { should be_running }
+  it { should be_enabled }
+end
diff --git a/test/integration/client/serverspec/spec_helper.rb b/test/integration/client/serverspec/spec_helper.rb
new file mode 100644
index 0000000..0970d19
--- /dev/null
+++ b/test/integration/client/serverspec/spec_helper.rb
@@ -0,0 +1,6 @@
+require 'serverspec'
+require 'pathname'
+
+set :backend, :exec
+
+set :path, '/bin:/usr/local/bin:$PATH'
diff --git a/test/integration/server/serverspec/server_spec.rb b/test/integration/server/serverspec/server_spec.rb
new file mode 100644
index 0000000..1305932
--- /dev/null
+++ b/test/integration/server/serverspec/server_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper'
+
+%w(
+  icinga2
+).each do |pkg|
+  describe package(pkg) do
+    it { should be_installed }
+  end
+end
+
+describe service('icinga2') do
+  it { should be_running }
+  it { should be_enabled }
+end
+
+case os[:family]
+  when 'centos'
+    webserver = 'httpd'
+  when 'debian'
+    webserver = 'apache2'
+  when 'ubuntu'
+    webserver = 'apache2'
+end
+
+describe service(webserver) do
+  it { should be_running }
+  it { should be_enabled }
+end
+
+describe command('curl -IL -u icingaadmin:icingaadmin localhost/icinga2-classicui') do
+  its(:stdout) { should match(%r{HTTP/1.1 200 OK}) }
+end
diff --git a/test/integration/server/serverspec/spec_helper.rb b/test/integration/server/serverspec/spec_helper.rb
new file mode 100644
index 0000000..0970d19
--- /dev/null
+++ b/test/integration/server/serverspec/spec_helper.rb
@@ -0,0 +1,6 @@
+require 'serverspec'
+require 'pathname'
+
+set :backend, :exec
+
+set :path, '/bin:/usr/local/bin:$PATH'
diff --git a/test/integration/web2/serverspec/spec_helper.rb b/test/integration/web2/serverspec/spec_helper.rb
new file mode 100644
index 0000000..0970d19
--- /dev/null
+++ b/test/integration/web2/serverspec/spec_helper.rb
@@ -0,0 +1,6 @@
+require 'serverspec'
+require 'pathname'
+
+set :backend, :exec
+
+set :path, '/bin:/usr/local/bin:$PATH'
diff --git a/test/integration/web2/serverspec/web2_spec.rb b/test/integration/web2/serverspec/web2_spec.rb
index ee3b62d..7af470b 100644
--- a/test/integration/web2/serverspec/web2_spec.rb
+++ b/test/integration/web2/serverspec/web2_spec.rb
@@ -1,7 +1,4 @@
-require 'serverspec'
-
-set :backend, :exec
-set :path, '$PATH:/sbin:/usr/local/sbin'
+require 'spec_helper'
 
 %w(
   icinga2
@@ -13,18 +10,16 @@ set :path, '$PATH:/sbin:/usr/local/sbin'
 end
 
 case os[:family]
-when 'centos'
-  describe file('/etc/httpd/conf-enabled/icinga2-web2.conf') do
-    it { should be_file }
-  end
-when 'debian'
-  describe file('/etc/apache2/conf-enabled/icinga2-web2.conf') do
-    it { should be_file }
-  end
-when 'ubuntu'
-  describe file('/etc/apache2/conf-enabled/icinga2-web2.conf') do
-    it { should be_file }
-  end
+  when 'centos'
+    webserver_config = '/etc/httpd/conf-enabled/icinga2-web2.conf'
+  when 'debian'
+    webserver_config = '/etc/apache2/conf-enabled/icinga2-web2.conf'
+  when 'ubuntu'
+    webserver_config = '/etc/apache2/conf-enabled/icinga2-web2.conf'
+end
+
+describe file(webserver_config) do
+  it { should be_file }
 end
 
 describe command('curl -IL localhost/icingaweb2/setup') do



More information about the icinga-checkins mailing list