Skip to content

Commit

Permalink
Merge pull request #335 from wyardley/fix_acceptance_tests
Browse files Browse the repository at this point in the history
Fix acceptance tests and run in Travis. Resolve idempotency issue
  • Loading branch information
wyardley authored Sep 17, 2017
2 parents c29139a + 2f3923a commit 99df53a
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
.travis.yml:
secure: "ExSbFQsxOlpFTc/4TTGJElIx0/sYNZ1I2Nbd9EfGPNeECXBgmqTdJmPqdV6cl3mKDFh+tSSxnIDZe5BILhmxIR7aF2lbf8jwcbo2nxe9qAZ42GDKNV2klNXUjR7kA7tz220RNO9rM3HDKAwrKtCPtwQ0Q5u90YGGJDj2nr7NUaM="
docker_sets:
- set: docker/ubuntu-16.04
- set: docker/centos-7
addons:
apt:
packages:
Expand Down
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ script:
matrix:
fast_finish: true
include:
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-16.04 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker
services: docker
sudo: required
- rvm: 2.1.9
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ group :system_tests do
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'beaker-module_install_helper', :require => false
end


Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,19 @@ The rundeck puppet module for installing and managing [Rundeck](http://rundeck.o
## Module Description

This module provides a way to manage the installation and configuration of
rundeck, it's projects, jobs and plugins.
rundeck, its projects, jobs and plugins.

## Setup

### Setup requirements

You need a compatible version of Java installed; you can use the
[puppetlabs/java](https://github.com/puppetlabs/puppetlabs-java) module if there
isn't already a suitable version.

On systems that use apt, there's a soft dependency on the
[puppetlabs/apt](https://github.com/puppetlabs/puppetlabs-apt) module.

### Classes and Defined Types

#### Class: `rundeck`
Expand Down Expand Up @@ -383,7 +392,7 @@ enable `key` and `project` storage in the database, you must also set the two
parameters associated parameters.

```puppet
class { '::rundeck':
class { 'rundeck':
key_storage_type => 'db',
projects_storage_type => 'db',
database_config => {
Expand Down
2 changes: 1 addition & 1 deletion examples/ldap_shared.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Configuring shared authentication credentials
# Performs LDAP authentication and file authorization
#
class { '::rundeck':
class { 'rundeck':
auth_types => ['ldap_shared'],
auth_config => {
'file' => {
Expand Down
26 changes: 13 additions & 13 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,31 @@
notify => Service[$service_name],
}

include '::rundeck::config::global::framework'
include '::rundeck::config::global::project'
include '::rundeck::config::global::rundeck_config'
include '::rundeck::config::global::file_keystore'
contain rundeck::config::global::framework
contain rundeck::config::global::project
contain rundeck::config::global::rundeck_config
contain rundeck::config::global::file_keystore

Class[rundeck::config::global::framework]
-> Class[rundeck::config::global::project]
-> Class[rundeck::config::global::rundeck_config]
-> Class[rundeck::config::global::file_keystore]
Class['rundeck::config::global::framework']
-> Class['rundeck::config::global::project']
-> Class['rundeck::config::global::rundeck_config']
-> Class['rundeck::config::global::file_keystore']

if $ssl_enabled {
include '::rundeck::config::global::ssl'
Class[rundeck::config::global::rundeck_config]
-> Class[rundeck::config::global::ssl]
contain rundeck::config::global::ssl
Class['rundeck::config::global::rundeck_config']
-> Class['rundeck::config::global::ssl']
}

create_resources(rundeck::config::project, $projects)

class { '::rundeck::config::global::web':
class { 'rundeck::config::global::web':
security_role => $security_role,
session_timeout => $session_timeout,
security_roles_array_enabled => $security_roles_array_enabled,
security_roles_array => $security_roles_array,
notify => Service[$service_name],
require => Class['::rundeck::install'],
require => Class['rundeck::install'],
}

if !empty($kerberos_realms) {
Expand Down
4 changes: 2 additions & 2 deletions manifests/config/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
$ensure = 'present',
) {

include '::rundeck'
include '::archive'
include rundeck
include archive

$framework_config = deep_merge($::rundeck::params::framework_config, $::rundeck::framework_config)

Expand Down
2 changes: 1 addition & 1 deletion manifests/config/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
$user = $rundeck::user,
) {

include ::rundeck
include rundeck

$framework_properties = deep_merge($rundeck::params::framework_config, $rundeck::framework_config, $framework_config)

Expand Down
2 changes: 1 addition & 1 deletion manifests/config/resource_source.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
$puppet_enterprise_metrics_interval = '',
) {

include ::rundeck
include rundeck

$framework_properties = deep_merge($rundeck::params::framework_config, $::rundeck::framework_config)

Expand Down
12 changes: 8 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@
validate_string($user_id)
validate_string($group_id)

class { '::rundeck::install': }
-> class { '::rundeck::config': }
~> class { '::rundeck::service': }
-> Class['rundeck']
contain rundeck::install
contain rundeck::config
contain rundeck::service

Class['rundeck::install']
-> Class['rundeck::config']
~> Class['rundeck::service']

}
9 changes: 5 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@
}
}

ensure_resource('package', 'rundeck', {'ensure' => $package_ensure, notify => Class['rundeck::service'] } )
ensure_resource('package', 'rundeck-config', {'ensure' => $package_ensure, notify => Class['rundeck::service'] } )
ensure_packages(['rundeck', 'rundeck-config'], {'ensure' => $package_ensure, notify => Class['rundeck::service'] } )
}
'Debian': {
if $manage_repo == true {
include ::apt
include apt
apt::source { 'bintray-rundeck':
location => 'https://dl.bintray.com/rundeck/rundeck-deb',
release => '/',
Expand All @@ -63,7 +62,7 @@
before => Package['rundeck'],
}
}
ensure_resource('package', 'rundeck', {'ensure' => $package_ensure, notify => Class['rundeck::service'], require => Class['apt::update'] } )
ensure_packages(['rundeck'], {'ensure' => $package_ensure, notify => Class['rundeck::service'], require => Class['apt::update'] } )
}
default: {
err("The osfamily: ${::osfamily} is not supported")
Expand Down Expand Up @@ -124,6 +123,8 @@
}
}

Package['rundeck'] -> File[$rundeck::service_logs_dir]

file { $rundeck::service_logs_dir:
ensure => directory,
}
Expand Down
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
{
"name": "puppetlabs/java_ks",
"version_requirement": ">= 1.3.1 < 2.0.0"
},
{
"name": "puppetlabs/apt",
"version_requirement": ">= 2.2.0 < 4.1.0"
}
],
"requirements": [
Expand Down
37 changes: 5 additions & 32 deletions spec/acceptance/rundeck_spec.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
# rubocop:disable RSpec/MultipleExpectations

require 'spec_helper_acceptance'

describe 'rundeck class' do
context 'default parameters on ubuntu', if: fact('osfamily').eql?('Debian') do
it 'works with no errors' do
pp = <<-EOS
class { 'java':
distribution => 'jre'
}
class { 'rundeck': }
Package['openjdk-7-jre-headless'] -> Exec['install rundeck package']
EOS

# Run it twice and test for idempotency
expect(apply_manifest(pp, expect_changes: true).exit_code).to eq(2)
expect(apply_manifest(pp).exit_code).to eq(0)
end

describe package('rundeck') do
it { is_expected.to be_installed }
end

describe service('rundeckd') do
it { is_expected.to be_running }
end
end

context 'default parameters on centos', if: fact('osfamily').eql?('RedHat') do
it 'works with no errors' do
context 'default parameters' do
it 'applies successfully' do
pp = <<-EOS
class { 'java':
distribution => 'jre'
}
class { 'rundeck': }
Package['java-1.7.0-openjdk'] -> Package['rundeck']
Class['java'] -> Class['rundeck']
EOS

# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).not_to eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe package('rundeck') do
Expand Down
6 changes: 2 additions & 4 deletions spec/classes/rundeck_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# rubocop:disable RSpec/MultipleExpectations

require 'spec_helper'

describe 'rundeck' do
Expand All @@ -15,9 +14,8 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('rundeck::params') }
it { is_expected.to contain_class('rundeck::install').that_comes_before('Class[rundeck::config]') }
it { is_expected.to contain_class('rundeck::config') }
it { is_expected.to contain_class('rundeck::service').that_comes_before('Class[rundeck]') }
it { is_expected.to contain_class('rundeck').that_requires('Class[rundeck::service]') }
it { is_expected.to contain_class('rundeck::config').that_notifies('Class[rundeck::service]') }
it { is_expected.to contain_class('rundeck::service') }
end

context 'non-platform-specific config parameters' do
Expand Down
36 changes: 12 additions & 24 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker-rspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'

hosts.each do |_host|
version = ENV['PUPPET_GEM_VERSION']
install_puppet(version: version)
end

RSpec.configure do |c|
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

c.formatter = :documentation

c.before :suite do
hosts.each do |host|
c.host = host
UNSUPPORTED_PLATFORMS = [].freeze

path = File.expand_path(File.dirname(__FILE__) + '/../').split('/')
name = path[path.length - 1].split('-')[1]
run_puppet_install_helper
install_module
install_module_dependencies

copy_module_to(host, source: proj_root, module_name: name)
# Install additional modules for soft deps
install_module_from_forge('puppetlabs-java', '>= 2.1.0 < 3.0.0')
install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 5.0.0')

on host, puppet('module', 'install', 'puppetlabs-stdlib'), acceptable_exit_codes: [0, 1]
on host, puppet('module', 'install', 'puppetlabs-java'), acceptable_exit_codes: [0, 1]
on host, puppet('module', 'install', 'puppetlabs-inifile'), acceptable_exit_codes: [0, 1]
on host, puppet('module', 'install', 'puppetlabs-apt'), acceptable_exit_codes: [0, 1]
end
end
RSpec.configure do |c|
c.formatter = :documentation
end

0 comments on commit 99df53a

Please sign in to comment.