Skip to content

Commit

Permalink
Use hiera in acceptance tests
Browse files Browse the repository at this point in the history
This removes duplication from the examples and allows it to only show
what's really needed. It currently relies on my git fork of beaker-hiera
since that's archived.

It also updates to PostgreSQL 12 on EL7 since Rails 6 now needs that.
  • Loading branch information
ekohl committed May 4, 2020
1 parent 4307abe commit d20f1e6
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 117 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem 'voxpupuli-test', '~> 1.3'
gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]}
gem 'puppet-blacksmith', '>= 4.1.0', {"groups"=>["development"]}
gem 'voxpupuli-acceptance', '~> 0.1', {"groups"=>["system_tests"]}
gem 'beaker-hiera', {"git"=>"https://github.com/ekohl/beaker-hiera", "branch"=>"fix", "groups"=>["system_tests"]}
gem 'webmock', '~> 2.0'
gem 'oauth'

Expand Down
25 changes: 3 additions & 22 deletions spec/acceptance/foreman_basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,9 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman-certs'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
class { 'foreman':
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
}
EOS
<<-PUPPET
include foreman
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
16 changes: 8 additions & 8 deletions spec/acceptance/foreman_cli_plugins_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
<<-PUPPET
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
if $facts['osfamily'] == 'RedHat' {
include ::foreman::cli::ansible
include ::foreman::cli::azure
include foreman::cli::ansible
include foreman::cli::azure
}
include ::foreman::cli::discovery
include ::foreman::cli::remote_execution
include ::foreman::cli::tasks
include ::foreman::cli::templates
EOS
include foreman::cli::discovery
include foreman::cli::remote_execution
include foreman::cli::tasks
include foreman::cli::templates
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/foreman_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
<<-PUPPET
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
EOS
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
24 changes: 3 additions & 21 deletions spec/acceptance/foreman_journald_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,11 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman-certs'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
<<-PUPPET
class { 'foreman':
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
logging_type => 'journald',
logging_type => 'journald',
}
EOS
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
26 changes: 4 additions & 22 deletions spec/acceptance/foreman_prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,20 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman-certs'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
<<-PUPPET
class { 'foreman':
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
telemetry_prometheus_enabled => true,
}
EOS
PUPPET
end

it_behaves_like 'a idempotent resource'

it_behaves_like 'the foreman application'

describe package('foreman-telemetry') do
it { is_expected.to be_installed }
end

it_behaves_like 'the foreman application'

# TODO: actually verify prometheus functionality
end
25 changes: 3 additions & 22 deletions spec/acceptance/foreman_rex_cockpit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,10 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman-certs'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
class { 'foreman':
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
}
<<-PUPPET
include foreman
include foreman::plugin::remote_execution::cockpit
EOS
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
22 changes: 2 additions & 20 deletions spec/acceptance/foreman_statsd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,11 @@
before(:context) { purge_foreman }

let(:pp) do
<<-EOS
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' {
class { 'redis::globals':
scl => 'rh-redis5',
}
}
$directory = '/etc/foreman-certs'
$certificate = "${directory}/certificate.pem"
$key = "${directory}/key.pem"
<<-PUPPET
class { 'foreman':
user_groups => [],
initial_admin_username => 'admin',
initial_admin_password => 'changeme',
server_ssl_ca => $certificate,
server_ssl_chain => $certificate,
server_ssl_cert => $certificate,
server_ssl_key => $key,
server_ssl_crl => '',
telemetry_statsd_enabled => true,
}
EOS
PUPPET
end

it_behaves_like 'a idempotent resource'
Expand Down
8 changes: 8 additions & 0 deletions spec/acceptance/hieradata/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
foreman::initial_admin_password: changeme
foreman::server_ssl_ca: /etc/foreman-certs/certificate.pem
foreman::server_ssl_cert: /etc/foreman-certs/certificate.pem
foreman::server_ssl_chain: /etc/foreman-certs/certificate.pem
foreman::server_ssl_crl: ""
foreman::server_ssl_key: /etc/foreman-certs/key.pem
foreman::user_groups: []
11 changes: 11 additions & 0 deletions spec/acceptance/hieradata/os/RedHat/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
postgresql::globals::version: '12'
postgresql::globals::client_package_name: 'rh-postgresql12-postgresql-syspaths'
postgresql::globals::server_package_name: 'rh-postgresql12-postgresql-server-syspaths'
postgresql::globals::contrib_package_name: 'rh-postgresql12-postgresql-contrib-syspaths'
postgresql::globals::service_name: 'postgresql'
postgresql::globals::datadir: '/var/lib/pgsql/data'
postgresql::globals::confdir: '/var/lib/pgsql/data'
postgresql::globals::bindir: '/usr/bin'

redis::globals::scl: rh-redis5
12 changes: 12 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'voxpupuli/acceptance/spec_helper_acceptance'
require 'beaker-hiera'

ENV['BEAKER_setfile'] ||= 'centos7-64{hostname=centos7-64.example.com}'

Expand All @@ -13,6 +14,17 @@
on host, 'yum clean expire-cache'
end

if File.exist?('spec/acceptance/hieradata')
hierarchy = [
'fqdn/%{fqdn}.yaml',
'os/%{os.family}/%{os.release.major}.yaml',
'os/%{os.family}.yaml',
'common.yaml',
]
write_hiera_config_on(host, hierarchy)
copy_hiera_data_to(host, 'spec/acceptance/hieradata')
end

local_setup = File.join(__dir__, 'setup_acceptance_node.pp')
if File.exist?(local_setup)
puts "Configuring #{host} by applying #{local_setup}"
Expand Down

0 comments on commit d20f1e6

Please sign in to comment.