From 465a2c5636be6f972f9f11360763660d52e9a370 Mon Sep 17 00:00:00 2001
From: Peter Souter
Date: Mon, 22 Aug 2016 11:08:06 +0100
Subject: [PATCH] Add Beaker Travis acceptance tests
* Add workaround for Docker container issue
* Rspec tests tweaked to work on Docker beaker
* Slight tweaks to Gemfile for new changes
---
.gitignore | 3 ++
.travis.yml | 13 +++++++
Gemfile | 27 ++++++++++----
README.md | 7 ++--
spec/acceptance/class_spec.rb | 36 ++++++++++++++-----
spec/acceptance/nodesets/centos-6-docker.yml | 11 ++++++
spec/acceptance/nodesets/centos-7-docker.yml | 11 ++++++
.../nodesets/ubuntu-server-1204-docker.yml | 13 +++++++
.../nodesets/ubuntu-server-1404-docker.yml | 13 +++++++
spec/spec_helper_acceptance.rb | 16 +++------
10 files changed, 121 insertions(+), 29 deletions(-)
create mode 100644 spec/acceptance/nodesets/centos-6-docker.yml
create mode 100644 spec/acceptance/nodesets/centos-7-docker.yml
create mode 100644 spec/acceptance/nodesets/ubuntu-server-1204-docker.yml
create mode 100644 spec/acceptance/nodesets/ubuntu-server-1404-docker.yml
diff --git a/.gitignore b/.gitignore
index d8a35f36..704f1135 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,6 @@ Gemfile.lock
spec/fixtures
!spec/fixtures/hiera.yaml
!spec/fixtures/hieradata/*
+
+log/
+junit/
diff --git a/.travis.yml b/.travis.yml
index 58c561e0..4f310742 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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
diff --git a/Gemfile b/Gemfile
index 6d12c019..130e08c5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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
diff --git a/README.md b/README.md
index 65e09452..987bae04 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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`).
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb
index 5937c915..00b703a1 100644
--- a/spec/acceptance/class_spec.rb
+++ b/spec/acceptance/class_spec.rb
@@ -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
@@ -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
diff --git a/spec/acceptance/nodesets/centos-6-docker.yml b/spec/acceptance/nodesets/centos-6-docker.yml
new file mode 100644
index 00000000..272c0a9b
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-6-docker.yml
@@ -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
diff --git a/spec/acceptance/nodesets/centos-7-docker.yml b/spec/acceptance/nodesets/centos-7-docker.yml
new file mode 100644
index 00000000..77317e2e
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-7-docker.yml
@@ -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
diff --git a/spec/acceptance/nodesets/ubuntu-server-1204-docker.yml b/spec/acceptance/nodesets/ubuntu-server-1204-docker.yml
new file mode 100644
index 00000000..16881f67
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-server-1204-docker.yml
@@ -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
diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-docker.yml b/spec/acceptance/nodesets/ubuntu-server-1404-docker.yml
new file mode 100644
index 00000000..8581f796
--- /dev/null
+++ b/spec/acceptance/nodesets/ubuntu-server-1404-docker.yml
@@ -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
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 6d7d4668..41f79813 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -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
@@ -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