-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This uses hiera for common parameters. It also does some common things in the acceptance helper to reduce duplication.
- Loading branch information
Showing
13 changed files
with
147 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,15 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'Scenario: install foreman-cli without foreman' do | ||
before(:context) do | ||
case fact('osfamily') | ||
when 'RedHat' | ||
on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo' | ||
when 'Debian' | ||
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] } | ||
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] } | ||
on default, 'rm -rf /etc/apt/sources.list.d/foreman*' | ||
end | ||
end | ||
|
||
let(:pp) do | ||
configure = fact('osfamily') == 'RedHat' && fact('operatingsystem') != 'Fedora' | ||
<<-EOS | ||
class { '::foreman::repo': | ||
repo => 'nightly', | ||
gpgcheck => true, | ||
configure_epel_repo => #{configure}, | ||
configure_scl_repo => #{configure}, | ||
} -> | ||
class { '::foreman::cli': | ||
<<-PUPPET | ||
class { 'foreman::cli': | ||
foreman_url => 'https://foreman.example.com', | ||
username => 'admin', | ||
password => 'changeme', | ||
} | ||
EOS | ||
PUPPET | ||
end | ||
|
||
it_behaves_like 'a idempotent resource' | ||
|
||
describe command('hammer --version') do | ||
its(:stdout) { is_expected.to match(/^hammer/) } | ||
end | ||
include_examples 'hammer' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,29 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'Scenario: install foreman with journald' do | ||
apache_service_name = ['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd' | ||
|
||
before(:context) do | ||
case fact('osfamily') | ||
when 'RedHat' | ||
on default, 'yum -y remove foreman* tfm-* mod_passenger && rm -rf /etc/yum.repos.d/foreman*.repo' | ||
when 'Debian' | ||
on default, 'apt-get purge -y foreman*', { :acceptable_exit_codes => [0, 100] } | ||
on default, 'apt-get purge -y ruby-hammer-cli-*', { :acceptable_exit_codes => [0, 100] } | ||
on default, 'rm -rf /etc/apt/sources.list.d/foreman*' | ||
end | ||
|
||
on default, "systemctl stop #{apache_service_name}", { :acceptable_exit_codes => [0, 5] } | ||
end | ||
|
||
let(:pp) do | ||
<<-EOS | ||
# Workarounds | ||
## Ensure repos are present before installing | ||
Yumrepo <| |> -> Package <| |> | ||
## We want passenger from EPEL | ||
class { '::apache::mod::passenger': | ||
manage_repo => false, | ||
<<-PUPPET | ||
class { 'foreman': | ||
logging_type => 'journald', | ||
} | ||
if $facts['os']['family'] == 'RedHat' and $facts['os']['name'] != 'Fedora' { | ||
class { 'redis::globals': | ||
scl => 'rh-redis5', | ||
} | ||
} | ||
$directory = '/etc/foreman' | ||
$certificate = "${directory}/certificate.pem" | ||
$key = "${directory}/key.pem" | ||
exec { 'Create certificate directory': | ||
command => "mkdir -p ${directory}", | ||
path => ['/bin', '/usr/bin'], | ||
creates => $directory, | ||
} -> | ||
exec { 'Generate certificate': | ||
command => "openssl req -nodes -x509 -newkey rsa:2048 -subj '/CN=${facts['fqdn']}' -keyout '${key}' -out '${certificate}' -days 365", | ||
path => ['/bin', '/usr/bin'], | ||
creates => $certificate, | ||
umask => '0022', | ||
} -> | ||
file { [$key, $certificate]: | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0640', | ||
} -> | ||
class { '::foreman': | ||
repo => 'nightly', | ||
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', | ||
} | ||
EOS | ||
PUPPET | ||
end | ||
|
||
it_behaves_like 'a idempotent resource' | ||
|
||
describe service(apache_service_name) do | ||
it { is_expected.to be_enabled } | ||
it { is_expected.to be_running } | ||
end | ||
|
||
describe service('dynflow-sidekiq@orchestrator') do | ||
it { is_expected.to be_enabled } | ||
it { is_expected.to be_running } | ||
end | ||
|
||
describe service('dynflow-sidekiq@worker') do | ||
it { is_expected.to be_enabled } | ||
it { is_expected.to be_running } | ||
end | ||
|
||
describe service('foreman') do | ||
it { is_expected.to be_enabled } | ||
it { is_expected.to be_running } | ||
end | ||
include_examples 'foreman application' | ||
|
||
describe package('foreman-journald') do | ||
it { is_expected.to be_installed } | ||
end | ||
|
||
describe port(80) do | ||
it { is_expected.to be_listening } | ||
end | ||
|
||
describe port(443) do | ||
it { is_expected.to be_listening } | ||
end | ||
|
||
describe command("curl -s --cacert /etc/foreman/certificate.pem https://#{host_inventory['fqdn']} -w '\%{redirect_url}' -o /dev/null") do | ||
its(:stdout) { is_expected.to eq("https://#{host_inventory['fqdn']}/users/login") } | ||
its(:exit_status) { is_expected.to eq 0 } | ||
end | ||
|
||
# Logging to the journal is broken on Travis and EL7 but works in Vagrant VMs | ||
# and regular docker containers | ||
describe command('journalctl -u foreman'), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do | ||
broken_journald_logging = ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ | ||
|
||
describe command('journalctl -u foreman'), unless: broken_journald_logging do | ||
its(:stdout) { is_expected.to match(%r{Redirected to https://#{host_inventory['fqdn']}/users/login}) } | ||
end | ||
|
||
describe command('journalctl -u dynflow-sidekiq@orchestrator'), unless: ENV['TRAVIS'] == 'true' && os[:family] == 'redhat' && os[:release] =~ /^7\./ do | ||
describe command('journalctl -u dynflow-sidekiq@orchestrator'), unless: broken_journald_logging do | ||
its(:stdout) { is_expected.to match(%r{Everything ready for world: }) } | ||
end | ||
end |
Oops, something went wrong.