1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
require 'spec_helper'
describe 'zookeeper::install::repo' do
shared_examples 'redhat-install' do |os, codename, puppet, cdhver, precond|
let(:hardwaremodel){ 'x86_64' }
let(:facts) do
{
:operatingsystem => os,
:osfamily => 'RedHat',
:lsbdistcodename => codename,
:operatingsystemrelease => codename,
:operatingsystemmajrelease => codename,
:hardwaremodel => hardwaremodel,
:puppetversion => puppet,
}
end
# load class, handle custom params
let :pre_condition do
precond
end
it { is_expected.to contain_yumrepo('cloudera-cdh5').with({
baseurl: "http://archive.cloudera.com/cdh#{cdhver}/redhat/#{codename}/#{hardwaremodel}/cdh/#{cdhver}/"
}) }
end
context 'on RedHat-like system' do
let(:user) { 'zookeeper' }
let(:group) { 'zookeeper' }
precond = 'class {"zookeeper":
repo => "cloudera",
cdhver => "5",
}'
# ENV variable might contain characters which are not supported
# by versioncmp function (like '~>')
it_behaves_like 'redhat-install', 'RedHat', '7', Puppet.version, '5', precond
end
context 'fail when architecture not supported' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:hardwaremodel => 'arc',
:puppetversion => Puppet.version,
}
end
let :pre_condition do
'class {"zookeeper":
repo => "cloudera",
cdhver => "5",
}'
end
it do
expect do
is_expected.to compile
end.to raise_error(/is not supported for architecture/) end
end
context 'fail when release not supported' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystemmajrelease => '8',
:hardwaremodel => 'x86_64',
:osrel => '8',
:puppetversion => Puppet.version,
}
end
let :pre_condition do
'class {"zookeeper":
repo => "cloudera",
cdhver => "5",
}'
end
it do
expect do
is_expected.to compile
end.to raise_error(/is not supported for redhat version/) end
end
context 'fail when CDH version not supported' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:hardwaremodel => 'x86_64',
:osrel => '7',
:puppetversion => Puppet.version,
}
end
let :pre_condition do
'class {"zookeeper":
repo => "cloudera",
cdhver => "6",
}'
end
it do
expect do
should compile
end.to raise_error(/is not a supported cloudera repo./) end
end
context 'fail when repository source not supported' do
let(:facts) do
{
:osfamily => 'RedHat',
:operatingsystemmajrelease => '7',
:hardwaremodel => 'x86_64',
:osrel => '7',
:puppetversion => Puppet.version,
}
end
let :pre_condition do
'class {"zookeeper":
repo => "another-repo",
}'
end
it do
expect do
should compile
end.to raise_error(/provides no repository information for yum repository/) end
end
end
|