Skip to content

Commit

Permalink
Merge pull request #179 from mterzo/modulesync
Browse files Browse the repository at this point in the history
Update for rubocop compliance
  • Loading branch information
tobru authored Jan 15, 2018
2 parents d0c8504 + a89fbf7 commit 633792e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
This Puppet module installs and manages [Gitlab](https://about.gitlab.com/).
It makes use of the provided [Omnibus](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md) packages and the [packagecloud package repositories](https://packages.gitlab.com/gitlab).

[![Build Status](https://api.travis-ci.org/vshn/puppet-gitlab.svg?branch=master)](https://travis-ci.org/vshn/puppet-gitlab)
[![Build Status](https://api.travis-ci.org/voxpupuli/puppet-gitlab.svg?branch=master)](https://travis-ci.org/voxpupuli/puppet-gitlab)
[![vshn-gitlab](https://img.shields.io/puppetforge/v/vshn/gitlab.svg)](https://forge.puppetlabs.com/vshn/gitlab)

## Module Description
Expand Down
4 changes: 2 additions & 2 deletions lib/facter/gitlab_systemd.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fact: gitlab_systemd
#
# Purpose:
# Purpose:
# Determine whether SystemD is the init system on the node
#
# Resolution:
Expand All @@ -11,7 +11,7 @@
#

Facter.add(:gitlab_systemd) do
confine :kernel => :linux
confine kernel: :linux
setcode do
Facter::Util::Resolution.exec('ps -p 1 -o comm=') == 'systemd'
end
Expand Down
11 changes: 4 additions & 7 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
require 'spec_helper_acceptance'

describe 'gitlab class' do

context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
it 'idempotently with no errors' do
pp = <<-EOS
class { 'gitlab':
external_url => "http://${::fqdn}",
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('gitlab-ce') do
it { is_expected.to be_installed }
end


it 'allows http connection on port 8080' do
shell 'sleep 15' # give it some time to start up
describe command('curl 0.0.0.0:80/users/sign_in') do
its(:stdout) { should match /GitLab|password/ }
its(:stdout) { is_expected.to match %r{/GitLab|password/} }
end
end

end
end
7 changes: 3 additions & 4 deletions spec/acceptance/gitlabci_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
require 'spec_helper_acceptance'

describe 'gitlab:;cirunner class' do

context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
it 'idempotently with no errors' do
pp = <<-EOS
class { 'gitlab::cirunner': }
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('gitlab-runner') do
Expand Down
49 changes: 22 additions & 27 deletions spec/acceptance/travis_ci_acceptance_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'spec_helper_acceptance'

describe 'gitlab class' do

context 'travis specific docker tests' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
it 'idempotently with no errors' do
pp = <<-EOS
class { 'gitlab':
external_url => "http://${::fqdn}",
Expand All @@ -13,12 +12,11 @@ class { 'gitlab':
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

it 'should run reconfigure when config changes' do

it 'reconfigure when config changes' do
# gitlab-omnibus works differently in docker
# Requires manual kick for travis beaker docker tests
docker_workaround = <<-EOS
Expand All @@ -27,7 +25,7 @@ class { 'gitlab':
}
EOS

apply_manifest(docker_workaround, :catch_failures => true)
apply_manifest(docker_workaround, catch_failures: true)

start_service_pp = <<-EOS
class { 'gitlab':
Expand All @@ -36,8 +34,8 @@ class { 'gitlab':
}
EOS

apply_manifest(start_service_pp, :catch_failures => true, :show_diff => true) do |r|
expect(r.stdout).to match(/Scheduling refresh of Exec\[gitlab_reconfigure\]/)
apply_manifest(start_service_pp, catch_failures: true, show_diff: true) do |r|
expect(r.stdout).to match(%r{/Scheduling refresh of Exec\[gitlab_reconfigure\]/})
end
end

Expand All @@ -47,31 +45,28 @@ class { 'gitlab':

context 'allows http connection on port 80' do
describe command('curl 0.0.0.0:80/users/sign_in') do
its(:stdout) { should match /reset_password_token|GitLab/ }
its(:stdout) { is_expected.to match %r{/reset_password_token|GitLab/} }
end
end
end

describe 'gitlab::cirunner class' do

context 'basic parameters without docker' do
it 'idempotently with no errors' do
pp = <<-EOS
class { 'gitlab::cirunner':
manage_docker => false, # Running docker in docker in travis breaks things
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'gitlab::cirunner':
manage_docker => false, # Running docker in docker in travis breaks things
}
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('gitlab-runner') do
it { is_expected.to be_installed }
describe package('gitlab-runner') do
it { is_expected.to be_installed }
end
end
end
end

end
12 changes: 4 additions & 8 deletions spec/classes/cirunner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
let(:params) { {} }
let(:facts) do
{
osfamily: 'redhat',
osfamily: 'RedHat',
operatingsystem: 'CentOS',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
os: {
architecture: 'x86_64',
family: 'RedHat',
Expand All @@ -46,9 +47,6 @@
enabled: false
}
},
osfamily: 'RedHat',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
kernelversion: '2.6.32',
kernelrelease: '2.6.32-573.8.1.el6.x86_64'
}
Expand All @@ -65,9 +63,10 @@
describe 'gitlab::cirunner class OS-independent behavior' do
let(:facts) do
{
osfamily: 'redhat',
osfamily: 'RedHat',
operatingsystem: 'CentOS',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
os: {
architecture: 'x86_64',
family: 'RedHat',
Expand All @@ -82,9 +81,6 @@
enabled: false
}
},
osfamily: 'RedHat',
operatingsystemmajrelease: '6',
operatingsystemrelease: '6.5',
kernelversion: '2.6.32',
kernelrelease: '2.6.32-573.8.1.el6.x86_64'
}
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

it {
is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \
with_content(/^\s*external_url 'http:\/\/gitlab\.mycompany\.com\/'$/)
with_content(%r{^\s*external_url 'http:\/\/gitlab\.mycompany\.com\/'$})
}
end
describe 'external_port' do
Expand Down Expand Up @@ -155,7 +155,7 @@

it {
is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \
with_content(/^\s*gitlab_rails\['backup_path'\] = "\/opt\/gitlab_backup"$/)
with_content(%r{^\s*gitlab_rails\['backup_path'\] = "\/opt\/gitlab_backup"$})
}
end
describe 'rack_attack_git_basic_auth with Numbers and Strings' do
Expand Down Expand Up @@ -183,7 +183,7 @@

it {
is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \
with_content(/^\s*mattermost_external_url 'https:\/\/mattermost\.myserver\.tld'$/)
with_content(%r{^\s*mattermost_external_url 'https:\/\/mattermost\.myserver\.tld'$})
}
end
describe 'mattermost with hash value' do
Expand Down Expand Up @@ -216,7 +216,7 @@

it do
is_expected.to contain_file('/etc/gitlab/gitlab.rb').
with_content(/^\s*git_data_dirs\(\{\"alt\"\=\>\"\/opt\/data\"\,\s\"default\"=>\"\/var\/opt\/gitlab\/data\"\}\)/)
with_content(%r{^\s*git_data_dirs\(\{\"alt\"\=\>\"\/opt\/data\"\,\s\"default\"=>\"\/var\/opt\/gitlab\/data\"\}\)})
end
end
describe 'without data_dirs' do
Expand Down
8 changes: 4 additions & 4 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'gitlab')
puppet_module_install(source: proj_root, module_name: 'gitlab')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0] }
on host, puppet('module', 'install', 'puppetlabs-apt'), { :acceptable_exit_codes => [0] }
on host, puppet('module', 'install', 'garethr-docker'), { :acceptable_exit_codes => [0] }
on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0]
on host, puppet('module', 'install', 'puppetlabs-apt'), acceptable_exit_codes: [0]
on host, puppet('module', 'install', 'garethr-docker'), acceptable_exit_codes: [0]
end
end
end

0 comments on commit 633792e

Please sign in to comment.