From e5a50f4d3c629f9b80910b538ba2bd23fc4c8f87 Mon Sep 17 00:00:00 2001 From: David Gurtner Date: Tue, 20 May 2014 01:43:58 +0200 Subject: [PATCH] Support for RedHat in ceph::mon Support for RedHat in ceph::mon and in ceph::mon, ceph::keys CI tests. Yumrepo isn't propperly removed but only disabled. This leads to a need to ensure => absent on the ceph::repo whenever a switch to a different ceph version happens. Therefore it's refactored run tests ordered by release Change-Id: I51150c1e3316bdab20c4458e79c4aeeb15fe4bd2 Closes-Bug: #1264916 Closes-Bug: #1323841 --- manifests/mon.pp | 15 +- spec/classes/ceph_mons_spec.rb | 74 ++++-- spec/defines/ceph_mon_spec.rb | 37 ++- spec/spec_helper.rb | 21 ++ spec/spec_helper_system.rb | 11 + spec/system/ceph_key_spec.rb | 117 ++++++--- spec/system/ceph_mon_spec.rb | 442 ++++++++++++++++++--------------- spec/system/ceph_repo_spec.rb | 7 +- 8 files changed, 443 insertions(+), 281 deletions(-) diff --git a/manifests/mon.pp b/manifests/mon.pp index 67dab96b..43c35d7e 100644 --- a/manifests/mon.pp +++ b/manifests/mon.pp @@ -1,6 +1,7 @@ # # Copyright (C) 2013 Cloudwatt # Copyright (C) iWeb Technologies Inc. +# Copyright (C) 2014 Nine Internet Solutions AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ # # Author: Loic Dachary # Author: David Moreau Simard +# Author: David Gurtner # # Installs and configures MONs (ceph monitors) ### == Parameters @@ -74,7 +76,7 @@ define ceph::mon ( stop => "stop ceph-mon id=${id}", status => "status ceph-mon id=${id}", } - } elsif $::operatingsystem == 'Debian' { + } elsif ($::operatingsystem == 'Debian') or ($::osfamily == 'RedHat') { $init = 'sysvinit' Service { name => "ceph-mon-${id}", @@ -83,10 +85,9 @@ define ceph::mon ( status => "service ceph status mon.${id}", } } else { - # - # TODO: create [mon.$id] in ceph.conf for init scripts that require it - # - fail("operatingsystem = ${::operatingsystem} is not supported") + if ! $public_addr { + fail("operatingsystem = ${::operatingsystem} is not supported") + } } $mon_service = "ceph-mon-${id}" @@ -146,7 +147,9 @@ fi -> # prevent automatic creation of the client.admin key by ceph-create-keys exec { "ceph-mon-${cluster_name}.client.admin.keyring-${id}": - command => "/usr/bin/touch /etc/ceph/${cluster_name}.client.admin.keyring", + command => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +touch /etc/ceph/${cluster_name}.client.admin.keyring", } -> service { $mon_service: diff --git a/spec/classes/ceph_mons_spec.rb b/spec/classes/ceph_mons_spec.rb index e0cae4dc..a40594ea 100644 --- a/spec/classes/ceph_mons_spec.rb +++ b/spec/classes/ceph_mons_spec.rb @@ -1,5 +1,6 @@ # # Copyright (C) 2013 Cloudwatt +# Copyright (C) 2014 Nine Internet Solutions AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,41 +15,66 @@ # limitations under the License. # # Author: Loic Dachary +# Author: David Gurtner # require 'spec_helper' describe 'ceph::mons' do - let :facts do - { - :operatingsystem => 'Ubuntu', + shared_examples_for 'ceph mons' do + let :params do + { + :args => { + 'A' => { + 'public_addr' => '1.2.3.4', + 'authentication_type' => 'none', + }, + 'B' => { + 'public_addr' => '1.2.3.4', + 'authentication_type' => 'none', + }, + }, + :defaults => { + 'cluster' => 'CLUSTER', + }, + } + end + + it { + should contain_service('ceph-mon-A').with('ensure' => "running") + should contain_service('ceph-mon-B').with('ensure' => "running") } end - let :params do - { - :args => { - 'A' => { - 'public_addr' => '1.2.3.4', - 'authentication_type' => 'none', - }, - 'B' => { - 'public_addr' => '1.2.3.4', - 'authentication_type' => 'none', - }, - }, - :defaults => { - 'cluster' => 'CLUSTER', - }, - } + describe 'Ubuntu' do + let :facts do + { + :operatingsystem => 'Ubuntu', + } + end + + it_configures 'ceph mons' end - it { - should contain_service('ceph-mon-A').with('ensure' => "running") - should contain_service('ceph-mon-B').with('ensure' => "running") - } + describe 'Debian' do + let :facts do + { + :operatingsystem => 'Debian', + } + end -# it { p subject.resources } + it_configures 'ceph mons' + end + + describe 'RedHat' do + let :facts do + { + :operatingsystem => 'RedHat', + } + end + + it_configures 'ceph mons' + end end diff --git a/spec/defines/ceph_mon_spec.rb b/spec/defines/ceph_mon_spec.rb index e4961955..f421a17b 100644 --- a/spec/defines/ceph_mon_spec.rb +++ b/spec/defines/ceph_mon_spec.rb @@ -1,5 +1,6 @@ # Copyright (C) 2013 Cloudwatt # Copyright (C) iWeb Technologies Inc. +# Copyright (C) 2014 Nine Internet Solutions AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +16,8 @@ # # Author: Loic Dachary # Author: David Moreau Simard - +# Author: David Gurtner +# require 'spec_helper' describe 'ceph::mon' do @@ -43,9 +45,40 @@ describe 'ceph::mon' do it { should contain_service('ceph-mon-A').with('ensure' => "running") } it { should contain_exec('ceph-mon-ceph.client.admin.keyring-A').with( - 'command' => "/usr/bin/touch /etc/ceph/ceph.client.admin.keyring" + 'command' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +touch /etc/ceph/ceph.client.admin.keyring" ) } +# it { p subject.resources } + + end + end + + describe 'Redhat Family' do + + describe "with custom params" do + + let :facts do + { + :operatingsystem => 'RHEL6', + :hostname => 'first', + } + end + + let :title do + 'A' + end + + let :params do + { + :public_addr => '127.0.0.1', + :authentication_type => 'none', + } + end + + it { should contain_service('ceph-mon-A').with('ensure' => "running") } + # it { p subject.resources } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c6f5664..9d0c281a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1 +1,22 @@ +# +# Copyright (C) 2014 Nine Internet Solutions AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Author: David Gurtner +# require 'puppetlabs_spec_helper/module_spec_helper' + +RSpec.configure do |c| + c.alias_it_should_behave_like_to(:it_configures, 'configures') +end diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 7fd2059f..4b3fa445 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -1,7 +1,9 @@ # # Copyright 2013 Cloudwatt +# Copyright (C) 2014 Nine Internet Solutions AG # # Author: Loic Dachary +# Author: David Gurtner # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -42,6 +44,15 @@ RSpec.configure do |c| :node => vm) shell(:command => 'puppet module install --version 1.4.0 puppetlabs/apt', :node => vm) + # Flush the firewall + flushfw = <<-EOS + iptables -F + iptables -X + iptables -P INPUT ACCEPT + iptables -P OUTPUT ACCEPT + iptables -P FORWARD ACCEPT + EOS + shell(:node => vm, :command => flushfw) end end end diff --git a/spec/system/ceph_key_spec.rb b/spec/system/ceph_key_spec.rb index 01ea0fb3..81c5ce04 100644 --- a/spec/system/ceph_key_spec.rb +++ b/spec/system/ceph_key_spec.rb @@ -1,6 +1,7 @@ # # Copyright (C) 2014 Catalyst IT Limited. # Copyright (C) 2014 Cloudwatt +# Copyright (C) 2014 Nine Internet Solutions AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,50 +17,84 @@ # # Author: Ricardo Rocha # Author: Loic Dachary +# Author: David Gurtner # require 'spec_helper_system' describe 'ceph::key' do - purge = <<-EOS - ceph::mon { 'a': ensure => absent } - -> - file { [ - '/var/lib/ceph/bootstrap-osd/ceph.keyring', - '/etc/ceph/ceph.client.admin.keyring', - ]: - ensure => absent - } - -> - package { [ - 'python-ceph', - 'ceph-common', - 'librados2', - 'librbd1', - ]: - ensure => purged - } - EOS - releases = ENV['RELEASES'] ? ENV['RELEASES'].split : [ 'cuttlefish', 'dumpling', 'emperor' ] + machines = ENV['MACHINES'] ? ENV['MACHINES'].split : [ 'first', 'second' ] fsid = 'a4807c9a-e76f-4666-a297-6d6cbc922e3a' mon_key = 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw==' admin_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRsg==' volume_key = 'AQAMTVRTSOHmHBAAH5d1ukHrAnxuSbrWSv9KGA==' - something_key = 'AQD44lJTqGB4LhAA3zV8mKlO9UKFNLwg2f3lvQ==' + mon_host = '$::ipaddress_eth1' + # passing it directly as unqoted array is not supported everywhere + packages = "[ 'python-ceph', 'ceph-common', 'librados2', 'librbd1', 'libcephfs1' ]" releases.each do |release| + purge = <<-EOS + ceph::mon { 'a': ensure => absent } + -> + file { [ + '/var/lib/ceph/bootstrap-osd/ceph.keyring', + '/etc/ceph/ceph.client.admin.keyring', + '/etc/ceph/ceph.client.volume', + ]: + ensure => absent + } + -> + package { [ + 'python-ceph', + 'ceph-common', + 'librados2', + 'librbd1', + 'libcephfs1', + ]: + ensure => purged + } + EOS + describe release do - it 'should install and not inject client.admin key' do + before(:all) do pp = <<-EOS class { 'ceph::repo': release => '#{release}', } - -> + EOS + + machines.each do |mon| + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + end + end + end + + after(:all) do + pp = <<-EOS + package { #{packages}: + ensure => purged + } + class { 'ceph::repo': + release => '#{release}', + ensure => absent, + } + EOS + + machines.each do |mon| + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + end + end + end + + it 'should install and not inject client.admin key' do + pp = <<-EOS class { 'ceph': fsid => '#{fsid}', - mon_host => $::ipaddress_eth0, + mon_host => #{mon_host}, authentication_type => 'none', } -> @@ -75,7 +110,7 @@ describe 'ceph::key' do } -> ceph::mon { 'a': - public_addr => $::ipaddress_eth0, + public_addr => #{mon_host}, authentication_type => 'none', } EOS @@ -110,24 +145,26 @@ describe 'ceph::key' do r.exit_code.should_not == 1 end end - end - end - releases.each do |release| - describe release do it 'should install and inject client.volumes key' do + osfamily = facter.facts['osfamily'] + operatingsystem = facter.facts['operatingsystem'] + + if osfamily == 'Debian' && operatingsystem == 'Ubuntu' + nogroup = 'nogroup' + end + if osfamily == 'RedHat' + nogroup = 'nobody' + end + pp = <<-EOS - class { 'ceph::repo': - release => '#{release}', - } - -> class { 'ceph': fsid => '#{fsid}', - mon_host => $::ipaddress_eth0, + mon_host => #{mon_host}, } -> ceph::mon { 'a': - public_addr => $::ipaddress_eth0, + public_addr => #{mon_host}, key => '#{mon_key}', } -> @@ -148,7 +185,7 @@ describe 'ceph::key' do cap_osd => 'allow rw', mode => 0600, user => 'nobody', - group => 'nogroup', + group => '#{nogroup}', inject => true, } EOS @@ -166,7 +203,7 @@ describe 'ceph::key' do end shell 'ls -l /etc/ceph/ceph.client.volumes.keyring' do |r| - r.stdout.should =~ /.*-rw-------.*nobody\snogroup.*/m + r.stdout.should =~ /.*-rw-------.*nobody\s#{nogroup}.*/m r.stderr.should be_empty r.exit_code.should be_zero end @@ -176,7 +213,6 @@ describe 'ceph::key' do r.stderr.should be_empty r.exit_code.should be_zero end - end it 'should uninstall one monitor and all packages' do @@ -186,12 +222,11 @@ describe 'ceph::key' do end end end - end # Local Variables: # compile-command: "cd ../.. # ( -# cd .rspec_system/vagrant_projects/two-ubuntu-server-12042-x64 +# cd .rspec_system/vagrant_projects/one-ubuntu-server-12042-x64 # vagrant destroy --force # ) # cp -a Gemfile-rspec-system Gemfile @@ -199,7 +234,7 @@ end # MACHINES=first \ # RELEASES=cuttlefish \ # RS_DESTROY=no \ -# RS_SET=two-ubuntu-server-12042-x64 \ +# RS_SET=one-centos-64-x64 \ # BUNDLE_PATH=/tmp/vendor \ # bundle exec rake spec:system SPEC=spec/system/ceph_key_spec.rb && # git checkout Gemfile diff --git a/spec/system/ceph_mon_spec.rb b/spec/system/ceph_mon_spec.rb index 7c9e46c5..302c04bc 100644 --- a/spec/system/ceph_mon_spec.rb +++ b/spec/system/ceph_mon_spec.rb @@ -1,7 +1,9 @@ # # Copyright 2013,2014 Cloudwatt +# Copyright (C) Nine Internet Solutions AG # # Author: Loic Dachary +# Author: David Gurtner # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,262 +21,292 @@ require 'spec_helper_system' describe 'ceph::mon' do - purge = <<-EOS - package { [ - 'python-ceph', - 'ceph-common', - 'librados2', - 'librbd1', - ]: - ensure => purged - } - EOS - releases = ENV['RELEASES'] ? ENV['RELEASES'].split : [ 'cuttlefish', 'dumpling', 'emperor' ] + machines = ENV['MACHINES'] ? ENV['MACHINES'].split : [ 'first', 'second' ] fsid = 'a4807c9a-e76f-4666-a297-6d6cbc922e3a' + mon_host = '$::ipaddress_eth1' + # passing it directly as unqoted array is not supported everywhere + packages = "[ 'python-ceph', 'ceph-common', 'librados2', 'librbd1', 'libcephfs1' ]" releases.each do |release| - describe release, :cephx do - it 'should install one monitor with cephx and key' do + + describe release do + before(:all) do pp = <<-EOS class { 'ceph::repo': release => '#{release}', } - -> - class { 'ceph': - fsid => '#{fsid}', - mon_host => $::ipaddress_eth0, - } - -> - ceph::mon { 'a': - public_addr => $::ipaddress_eth0, - key => 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw==', - } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - r.refresh - r.exit_code.should_not == 1 - end - - shell 'test -z "$(cat /etc/ceph/ceph.client.admin.keyring)"' do |r| - r.exit_code.should be_zero + machines.each do |mon| + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + end end end - it 'should uninstall one monitor' do + after(:all) do pp = <<-EOS - ceph::mon { 'a': - ensure => absent, + package { #{packages}: + ensure => purged } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end - - shell 'status ceph-mon id=a' do |r| - r.stdout.should be_empty - r.stderr.should =~ /Unknown instance: ceph.a/ - r.exit_code.should_not be_zero - end - end - it 'should purge all packages' do - puppet_apply(purge) do |r| - r.exit_code.should_not == 1 - end - end - end - end - - releases.each do |release| - describe release do - it 'should install one monitor with cephx and keyring' do - - key = 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw==' - keyring = "[mon.]\\n\\tkey = #{key}\\n\\tcaps mon = \"allow *\"" - keyring_path = "/tmp/keyring" - shell "echo -e '#{keyring}' > #{keyring_path}" - - pp = <<-EOS class { 'ceph::repo': release => '#{release}', - } - -> - class { 'ceph': - fsid => '#{fsid}', - mon_host => $::ipaddress_eth0, - } - -> - ceph::mon { 'a': - public_addr => $::ipaddress_eth0, - keyring => '#{keyring_path}', + ensure => absent, } EOS - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - r.refresh - r.exit_code.should_not == 1 - end - - shell 'test -f /etc/ceph/ceph.client.admin.keyring' do |r| - r.exit_code.should be_zero + machines.each do |mon| + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + end end end - it 'should uninstall one monitor' do - pp = <<-EOS - ceph::mon { 'a': - ensure => absent, - } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end - - shell 'status ceph-mon id=a' do |r| - r.stdout.should be_empty - r.stderr.should =~ /Unknown instance: ceph.a/ - r.exit_code.should_not be_zero - end - end - it 'should purge all packages' do - puppet_apply(purge) do |r| - r.exit_code.should_not == 1 - end - end - end - end - - releases.each do |release| - describe release do - it 'should install one monitor no cephx' do - pp = <<-EOS - class { 'ceph::repo': - release => '#{release}', - } - -> - class { 'ceph': - fsid => '#{fsid}', - mon_host => $::ipaddress_eth0, - authentication_type => 'none', - } - -> - ceph::mon { 'a': - public_addr => $::ipaddress_eth0, - authentication_type => 'none', - } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - r.refresh - r.exit_code.should_not == 1 - end - - shell 'ceph -s' do |r| - r.stdout.should =~ /1 mons at/ - r.stderr.should be_empty - r.exit_code.should be_zero - end - - end - - it 'should uninstall one monitor' do - pp = <<-EOS - ceph::mon { 'a': - ensure => absent, - } - EOS - - puppet_apply(pp) do |r| - r.exit_code.should_not == 1 - end - - shell 'status ceph-mon id=a' do |r| - r.stdout.should be_empty - r.stderr.should =~ /Unknown instance: ceph.a/ - r.exit_code.should_not be_zero - end - end - it 'should purge all packages' do - puppet_apply(purge) do |r| - r.exit_code.should_not == 1 - end - end - end - end - - releases.each do |release| - describe release do - it 'should install two monitors, two hosts, no cephx' do - [ 'first', 'second' ].each do |mon| + describe 'on one host' do + it 'should install one monitor' do pp = <<-EOS - class { 'ceph::repo': - release => '#{release}', - } - -> - class { 'ceph': - fsid => '#{fsid}', - mon_host => '10.11.12.2,10.11.12.3', - public_network => '10.11.12.0/24', - authentication_type => 'none', - } - -> - ceph::mon { '#{mon}': - authentication_type => 'none', - } + class { 'ceph': + fsid => '#{fsid}', + mon_host => #{mon_host}, + authentication_type => 'none', + } + -> + ceph::mon { 'a': + public_addr => #{mon_host}, + authentication_type => 'none', + } EOS - puppet_apply(:node => "#{mon}", :code => pp) do |r| + puppet_apply(pp) do |r| r.exit_code.should_not == 1 r.refresh r.exit_code.should_not == 1 end + + shell 'ceph -s' do |r| + r.stdout.should =~ /1 mons at/ + r.stderr.should be_empty + r.exit_code.should be_zero + end end - shell 'ceph -s' do |r| - r.stdout.should =~ /2 mons .* quorum 0,1 first,second/ - r.stderr.should be_empty - r.exit_code.should be_zero - end - - end - - it 'should uninstall two monitors' do - [ 'first', 'second' ].each do |mon| + it 'should uninstall one monitor' do pp = <<-EOS - ceph::mon { '#{mon}': + ceph::mon { 'a': ensure => absent, } EOS - puppet_apply(:node => "#{mon}", :code => pp) do |r| + puppet_apply(pp) do |r| r.exit_code.should_not == 1 end - shell "status ceph-mon id=#{mon}" do |r| - r.stdout.should be_empty - r.stderr.should =~ /Unknown instance: ceph.#{mon}/ - r.exit_code.should_not be_zero + osfamily = facter.facts['osfamily'] + operatingsystem = facter.facts['operatingsystem'] + + if osfamily == 'Debian' && operatingsystem == 'Ubuntu' + shell 'status ceph-mon id=a' do |r| + r.stdout.should be_empty + r.stderr.should =~ /Unknown instance: ceph.a/ + r.exit_code.should_not be_zero + end + end + if osfamily == 'RedHat' + shell 'service ceph status mon.a' do |r| + r.stdout.should =~ /mon.a not found/ + r.stderr.should be_empty + r.exit_code.should_not be_zero + end end end end - it 'should purge all packages' do - [ 'first', 'second' ].each do |mon| - puppet_apply(:node => "#{mon}", :code => purge) do |r| + describe 'on one host', :cephx do + it 'should install one monitor with key' do + pp = <<-EOS + class { 'ceph': + fsid => '#{fsid}', + mon_host => #{mon_host}, + } + -> + ceph::mon { 'a': + public_addr => #{mon_host}, + key => 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw==', + } + EOS + + puppet_apply(pp) do |r| r.exit_code.should_not == 1 + r.refresh + r.exit_code.should_not == 1 + end + + shell 'test -z "$(cat /etc/ceph/ceph.client.admin.keyring)"' do |r| + r.exit_code.should be_zero + end + end + + it 'should uninstall one monitor' do + pp = <<-EOS + ceph::mon { 'a': + ensure => absent, + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + + osfamily = facter.facts['osfamily'] + operatingsystem = facter.facts['operatingsystem'] + + if osfamily == 'Debian' && operatingsystem == 'Ubuntu' + shell 'status ceph-mon id=a' do |r| + r.stdout.should be_empty + r.stderr.should =~ /Unknown instance: ceph.a/ + r.exit_code.should_not be_zero + end + end + if osfamily == 'RedHat' + shell 'service ceph status mon.a' do |r| + r.stdout.should =~ /mon.a not found/ + r.stderr.should be_empty + r.exit_code.should_not be_zero + end + end + end + + it 'should install one monitor with keyring' do + + key = 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw==' + keyring = "[mon.]\\n\\tkey = #{key}\\n\\tcaps mon = \"allow *\"" + keyring_path = "/tmp/keyring" + shell "echo -e '#{keyring}' > #{keyring_path}" + + pp = <<-EOS + class { 'ceph': + fsid => '#{fsid}', + mon_host => #{mon_host}, + } + -> + ceph::mon { 'a': + public_addr => #{mon_host}, + keyring => '#{keyring_path}', + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should_not == 1 + end + + shell 'test -f /etc/ceph/ceph.client.admin.keyring' do |r| + r.exit_code.should be_zero + end + end + + it 'should uninstall one monitor' do + pp = <<-EOS + ceph::mon { 'a': + ensure => absent, + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + end + + osfamily = facter.facts['osfamily'] + operatingsystem = facter.facts['operatingsystem'] + + if osfamily == 'Debian' && operatingsystem == 'Ubuntu' + shell 'status ceph-mon id=a' do |r| + r.stdout.should be_empty + r.stderr.should =~ /Unknown instance: ceph.a/ + r.exit_code.should_not be_zero + end + end + if osfamily == 'RedHat' + shell 'service ceph status mon.a' do |r| + r.stdout.should =~ /mon.a not found/ + r.stderr.should be_empty + r.exit_code.should_not be_zero + end end end end + describe 'on two hosts' do + it 'should be two hosts' do + machines.size.should == 2 + end + + it 'should install two monitors' do + machines.each do |mon| + pp = <<-EOS + class { 'ceph': + fsid => '#{fsid}', + mon_host => '10.11.12.2,10.11.12.3', + public_network => '10.11.12.0/24', + authentication_type => 'none', + } + -> + ceph::mon { '#{mon}': + public_addr => $::ipaddress_eth1, + authentication_type => 'none', + } + EOS + + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should_not == 1 + end + end + + shell 'ceph -s' do |r| + r.stdout.should =~ /2 mons .* quorum 0,1/ + r.stderr.should be_empty + r.exit_code.should be_zero + end + end + + it 'should uninstall two monitors' do + machines.each do |mon| + pp = <<-EOS + ceph::mon { '#{mon}': + ensure => absent, + } + EOS + + puppet_apply(:node => mon, :code => pp) do |r| + r.exit_code.should_not == 1 + end + + osfamily = facter.facts['osfamily'] + operatingsystem = facter.facts['operatingsystem'] + + if osfamily == 'Debian' && operatingsystem == 'Ubuntu' + shell "status ceph-mon id=#{mon}" do |r| + r.stdout.should be_empty + r.stderr.should =~ /Unknown instance: ceph.#{mon}/ + r.exit_code.should_not be_zero + end + end + if osfamily == 'RedHat' + shell "service ceph status mon.#{mon}" do |r| + r.stdout.should =~ /mon.#{mon} not found/ + r.stderr.should be_empty + r.exit_code.should_not be_zero + end + end + end + end + end end end - end # Local Variables: # compile-command: "cd ../.. diff --git a/spec/system/ceph_repo_spec.rb b/spec/system/ceph_repo_spec.rb index fe24dce7..be615af1 100644 --- a/spec/system/ceph_repo_spec.rb +++ b/spec/system/ceph_repo_spec.rb @@ -144,14 +144,15 @@ end # Local Variables: # compile-command: "cd ../.. # ( -# cd .rspec_system/vagrant_projects/two-centos-64-x64 && +# cd .rspec_system/vagrant_projects/one-ubuntu-server-12042-x64 # vagrant destroy --force # ) # cp -a Gemfile-rspec-system Gemfile # BUNDLE_PATH=/tmp/vendor bundle install --no-deployment -# RELEASES='cuttlefish dumpling' \ +# MACHINES=first \ +# RELEASES=cuttlefish \ # RS_DESTROY=no \ -# RS_SET=two-centos-64-x64 \ +# RS_SET=one-ubuntu-server-12042-x64 \ # BUNDLE_PATH=/tmp/vendor \ # bundle exec rake spec:system SPEC=spec/system/ceph_repo_spec.rb && # git checkout Gemfile