Skip to content

Commit

Permalink
Add Beaker Travis acceptance tests
Browse files Browse the repository at this point in the history
* Add workaround for Docker container issue
* Rspec tests tweaked to work on Docker beaker
* Slight tweaks to Gemfile for new changes
  • Loading branch information
petems committed Sep 17, 2016
1 parent fdd82af commit 465a2c5
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ Gemfile.lock
spec/fixtures
!spec/fixtures/hiera.yaml
!spec/fixtures/hieradata/*

log/
junit/
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ matrix:
env: PUPPET_VERSION="~> 3.8.0" STRICT_VARIABLES=yes
- rvm: 2.3.0
env: PUPPET_VERSION="~> 3.8.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes
include:
- rvm: '2.1'
sudo: required
services: docker
env: BEAKER_set="ubuntu-server-1204-docker" PUPPET_INSTALL_TYPE=foss
script: bundle exec rake acceptance
bundler_args: --without development
- rvm: '2.1'
sudo: required
services: docker
env: BEAKER_set="centos-6-docker" PUPPET_INSTALL_TYPE=foss
script: bundle exec rake acceptance
bundler_args: --without development
27 changes: 20 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
source "https://rubygems.org"
source ENV['GEM_SOURCE'] || "https://rubygems.org"

group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0'
gem 'rake', '< 11'
gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 3.8.0'
gem 'safe_yaml', '~> 1.0.4'
gem "rspec", '< 3.2.0'
gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git'
gem "puppetlabs_spec_helper"
gem "metadata-json-lint"
gem "listen", "3.0.6"
gem "rspec-puppet-facts"
gem 'rubocop', '0.33.0'
gem 'simplecov', '>= 0.11.0'
gem 'simplecov-console'

gem "puppet-lint-absolute_classname-check"
gem "puppet-lint-leading_zero-check"
gem "puppet-lint-trailing_comma-check"
gem "puppet-lint-version_comparison-check"
gem "puppet-lint-classes_and_types_beginning_with_digits-check"
gem "puppet-lint-unquoted_string-check"
gem 'puppet-lint-resource_reference_syntax'
end

group :development do
gem "travis"
gem "travis-lint"
gem "puppet-blacksmith"
gem "guard-rake"
end

group :system_tests do
gem "beaker"
gem "beaker-rspec"
gem 'beaker', '2.43.0'
gem 'beaker-rspec', '5.3.0'
gem "beaker-puppet_install_helper"
end
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ The module installs the Gitlab package from the provided repositories and create
which is then used by `gitlab-ctl reconfigure` to configure all the services. *Fun fact: This really uses
Chef to configure all the services.*

Supported are Debian based (Ubuntu, Debian) and RedHat based (CentOS, RHEL) operating systems. Although the
RedHat based are not yet tested.
Supported are Debian based (Ubuntu, Debian) and RedHat based (CentOS, RHEL) operating systems.

Beaker acceptance tests are run in Travis for CentOS 6 and Ubuntu 12.04.

As Gitlab is providing the package repo since 7.10+, this module only works with CE edition greater than 7.10.
Also the enterprise edition package is only available since 7.11+. So the EE is supported with versions greater
Expand Down Expand Up @@ -135,7 +136,7 @@ gitlab::secrets:
```

*Hint 1*: This secret tokens can be generated f.e. using Ruby with `SecureRandom.hex(64)`, or
taken out of an installation without having `secrets` used.
taken out of an installation without having `secrets` used.
*Hint 2*: When using the `gitlab_ci` parameter to specify the `gitlab_server`, then this parameters
must be added also to the `secrets` hash (Omnibus overrides `gitlab-secrets.json`).

Expand Down
36 changes: 28 additions & 8 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'gitlab':
external_url => "http://${::fqdn}",
external_url => "http://${::fqdn}",
service_manage => false,
}
EOS

Expand All @@ -16,18 +17,37 @@ class { 'gitlab':
apply_manifest(pp, :catch_changes => true)
end

describe package('gitlab') do
it { is_expected.to be_installed }
it 'should run reconfigure when config changes' do

# gitlab-omnibus works differently in docker
# Requires manual kick for beaker docker tests
docker_workaround = <<-EOS
exec { '/opt/gitlab/embedded/bin/runsvdir-start &':
onlyif => '/bin/cat /proc/self/cgroup | grep docker'
}
EOS

apply_manifest(docker_workaround, :catch_failures => true)

start_service_pp = <<-EOS
class { 'gitlab':
external_url => "http://${::fqdn}",
gitlab_rails => { 'time_zone' => 'GMT' }
}
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\]/)
end
end

describe service('gitlab') do
it { is_expected.to be_running }
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
context 'allows http connection on port 80' do
describe command('curl 0.0.0.0:80/users/sign_in') do
its(:stdout) { should match /GitLab/ }
its(:stdout) { should match /reset_password_token/ }
end
end

Expand Down
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/centos-6-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
centos-6-x64:
platform: el-6-x86_64
hypervisor : docker
image: centos:6
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_preserve_image: true
CONFIG:
type: foss
log_level: debug
11 changes: 11 additions & 0 deletions spec/acceptance/nodesets/centos-7-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
centos-7-x64:
platform: el-7-x86_64
hypervisor : docker
image: centos:7
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_preserve_image: true
CONFIG:
type: foss
log_level: debug
13 changes: 13 additions & 0 deletions spec/acceptance/nodesets/ubuntu-server-1204-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
HOSTS:
ubuntu-12-04:
platform: ubuntu-12.04-amd64
image: ubuntu:12.04
hypervisor: docker
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y net-tools wget curl'
- 'locale-gen en_US.UTF-8'
docker_preserve_image: true
CONFIG:
type: foss
log_level: debug
13 changes: 13 additions & 0 deletions spec/acceptance/nodesets/ubuntu-server-1404-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
HOSTS:
ubuntu-14-04:
platform: ubuntu-14.04-amd64
image: ubuntu:14.04
hypervisor: docker
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get install -y net-tools wget curl'
- 'locale-gen en_US.UTF-8'
docker_preserve_image: true
CONFIG:
type: foss
log_level: debug
16 changes: 5 additions & 11 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'

unless ENV['BEAKER_provision'] == 'no'
hosts.each do |host|
# Install Puppet
if host.is_pe?
install_pe
else
install_puppet
end
end
end
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'

RSpec.configure do |c|
# Project root
Expand All @@ -24,7 +16,9 @@
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'gitlab')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
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 465a2c5

Please sign in to comment.