Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes via rubocop -a #176

Merged
merged 1 commit into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 95 additions & 91 deletions spec/classes/cirunner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
context 'supported operating systems' do
package_name = 'gitlab-runner'

describe "gitlab::cirunner class without any parameters on Ubuntu Trusty" do
let(:params) {{ }}
let(:facts) {{
:osfamily => 'Debian',
:lsbdistid => 'Ubuntu',
:lsbdistcodename => 'trusty',
:operatingsystem => 'Debian',
:operatingsystemmajrelease => 'jessie/sid',
:kernelrelease => '3.13.0-71-generic',
}}
describe 'gitlab::cirunner class without any parameters on Ubuntu Trusty' do
let(:params) { {} }
let(:facts) do
{
osfamily: 'Debian',
lsbdistid: 'Ubuntu',
lsbdistcodename: 'trusty',
operatingsystem: 'Debian',
operatingsystemmajrelease: 'jessie/sid',
kernelrelease: '3.13.0-71-generic'
}
end

it { is_expected.to compile.with_all_deps }

Expand All @@ -23,32 +25,34 @@

it { is_expected.to contain_package(package_name).with_ensure('installed') }
end
describe "gitlab::cirunner class without any parameters on RedHat (CentOS)" do
let(:params) {{ }}
let(:facts) {{
:osfamily => 'redhat',
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => '6',
:os => {
:architecture => "x86_64",
:family => "RedHat",
:hardware => "x86_64",
:name => "CentOS",
:release => {
:full => "6.7",
:major => "6",
:minor => "7"
describe 'gitlab::cirunner class without any parameters on RedHat (CentOS)' do
let(:params) { {} }
let(:facts) do
{
osfamily: 'redhat',
operatingsystem: 'CentOS',
operatingsystemmajrelease: '6',
os: {
architecture: 'x86_64',
family: 'RedHat',
hardware: 'x86_64',
name: 'CentOS',
release: {
full: '6.7',
major: '6',
minor: '7'
},
selinux: {
enabled: false
}
},
:selinux => {
:enabled => false
}
},
:osfamily => 'RedHat',
:operatingsystemmajrelease => '6',
:operatingsystemrelease => '6.5',
:kernelversion => '2.6.32',
:kernelrelease => '2.6.32-573.8.1.el6.x86_64'
}}
osfamily: 'RedHat',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
kernelversion: '2.6.32',
kernelrelease: '2.6.32-573.8.1.el6.x86_64'
}
end

it { is_expected.to compile.with_all_deps }

Expand All @@ -58,84 +62,84 @@

it { is_expected.to contain_package(package_name).with_ensure('installed') }
end
describe "gitlab::cirunner class OS-independent behavior" do
let(:facts) {{
:osfamily => 'redhat',
:operatingsystem => 'CentOS',
:operatingsystemmajrelease => '6',
:os => {
:architecture => "x86_64",
:family => "RedHat",
:hardware => "x86_64",
:name => "CentOS",
:release => {
:full => "6.7",
:major => "6",
:minor => "7"
describe 'gitlab::cirunner class OS-independent behavior' do
let(:facts) do
{
osfamily: 'redhat',
operatingsystem: 'CentOS',
operatingsystemmajrelease: '6',
os: {
architecture: 'x86_64',
family: 'RedHat',
hardware: 'x86_64',
name: 'CentOS',
release: {
full: '6.7',
major: '6',
minor: '7'
},
selinux: {
enabled: false
}
},
:selinux => {
:enabled => false
}
},
:osfamily => 'RedHat',
:operatingsystemmajrelease => '6',
:operatingsystemrelease => '6.5',
:kernelversion => '2.6.32',
:kernelrelease => '2.6.32-573.8.1.el6.x86_64'
}}
osfamily: 'RedHat',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
kernelversion: '2.6.32',
kernelrelease: '2.6.32-573.8.1.el6.x86_64'
}
end

context 'with default parameters' do
it { should contain_exec('gitlab-runner-restart').that_requires("Package[#{package_name}]") }
it { is_expected.to contain_exec('gitlab-runner-restart').that_requires("Package[#{package_name}]") }
it do
should contain_exec('gitlab-runner-restart').with({
'command' => "/usr/bin/#{package_name} restart",
'refreshonly' => true,
})
is_expected.to contain_exec('gitlab-runner-restart').with('command' => "/usr/bin/#{package_name} restart",
'refreshonly' => true)
end
it { should contain_gitlab__runner('test_runner').that_requires('Exec[gitlab-runner-restart]') }
it { should_not contain_file_line('gitlab-runner-concurrent') }
it { should_not contain_file_line('gitlab-runner-metrics-server') }
it { is_expected.to contain_gitlab__runner('test_runner').that_requires('Exec[gitlab-runner-restart]') }
it { is_expected.not_to contain_file_line('gitlab-runner-concurrent') }
it { is_expected.not_to contain_file_line('gitlab-runner-metrics-server') }
end

context 'with concurrent => 10' do
let(:params) { { :concurrent => 10 } }
it { should contain_file_line('gitlab-runner-concurrent').that_requires("Package[#{package_name}]") }
it { should contain_file_line('gitlab-runner-concurrent').that_notifies('Exec[gitlab-runner-restart]') }
let(:params) { { concurrent: 10 } }

it { is_expected.to contain_file_line('gitlab-runner-concurrent').that_requires("Package[#{package_name}]") }
it { is_expected.to contain_file_line('gitlab-runner-concurrent').that_notifies('Exec[gitlab-runner-restart]') }
it do
should contain_file_line('gitlab-runner-concurrent').with({
'path' => '/etc/gitlab-runner/config.toml',
'line' => 'concurrent = 10',
'match' => '^concurrent = \d+',
})
is_expected.to contain_file_line('gitlab-runner-concurrent').with('path' => '/etc/gitlab-runner/config.toml',
'line' => 'concurrent = 10',
'match' => '^concurrent = \d+')
end
end

context 'with metrics_server => localhost:9252' do
let(:params) { { :metrics_server => 'localhost:9252' } }
it { should contain_file_line('gitlab-runner-metrics-server').that_requires("Package[#{package_name}]") }
it { should contain_file_line('gitlab-runner-metrics-server').that_notifies('Exec[gitlab-runner-restart]') }
let(:params) { { metrics_server: 'localhost:9252' } }

it { is_expected.to contain_file_line('gitlab-runner-metrics-server').that_requires("Package[#{package_name}]") }
it { is_expected.to contain_file_line('gitlab-runner-metrics-server').that_notifies('Exec[gitlab-runner-restart]') }
it do
should contain_file_line('gitlab-runner-metrics-server').with({
'path' => '/etc/gitlab-runner/config.toml',
'line' => 'metrics_server = "localhost:9252"',
'match' => '^metrics_server = .+',
})
is_expected.to contain_file_line('gitlab-runner-metrics-server').with('path' => '/etc/gitlab-runner/config.toml',
'line' => 'metrics_server = "localhost:9252"',
'match' => '^metrics_server = .+')
end
end
end
end
context 'unsupported operating systems' do
describe "gitlab::cirunner class without any parameters on unsupported OS" do
let(:params) {{ }}
let(:facts) {{
:osfamily => 'unsupported_os_family',
}}
it "should fail" do
describe 'gitlab::cirunner class without any parameters on unsupported OS' do
let(:params) { {} }
let(:facts) do
{
osfamily: 'unsupported_os_family'
}
end

it 'fails' do
expect do
catalogue
end.to raise_error(Puppet::Error, /OS family unsupported_os_family is not supported. Only Debian and Redhat is suppported./)
end.to raise_error(Puppet::Error, %r{OS family unsupported_os_family is not supported. Only Debian and Redhat is suppported.})
end
end
end

end
Loading