Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure acceptance tests #908

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions spec/acceptance/foreman_basic_spec.rb

This file was deleted.

43 changes: 0 additions & 43 deletions spec/acceptance/foreman_cli_plugins_spec.rb

This file was deleted.

76 changes: 63 additions & 13 deletions spec/acceptance/foreman_cli_spec.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,69 @@
require 'spec_helper_acceptance'

describe 'Scenario: install foreman-cli without foreman' do
before(:context) { purge_foreman }

let(:pp) do
<<-PUPPET
class { 'foreman::cli':
foreman_url => 'https://foreman.example.com',
username => 'admin',
password => 'changeme',
}
PUPPET
describe 'foreman-cli', order: defined do
shared_examples 'hammer' do
describe command('hammer --version') do
its(:stdout) { is_expected.to match(/^hammer/) }
end
end

it_behaves_like 'a idempotent resource'
context 'without Foreman' do
before(:context) { purge_foreman }

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

it_behaves_like 'a idempotent resource'

it_behaves_like 'hammer'
end

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

if $facts['os']['family'] == 'RedHat' {
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
PUPPET
end

it_behaves_like 'a idempotent resource'

it_behaves_like 'hammer'

['discovery', 'remote_execution', 'tasks', 'templates'].each do |plugin|
package_name = case fact('os.family')
when 'RedHat'
fact('os.release.major') == '7' ? "tfm-rubygem-hammer_cli_foreman_#{plugin}" : "rubygem-hammer_cli_foreman_#{plugin}"
when 'Debian'
"ruby-hammer-cli-foreman-#{plugin.tr('_', '-')}"
else
plugin
end

describe package(package_name) do
it { is_expected.to be_installed }
end
end
end
end
end
33 changes: 0 additions & 33 deletions spec/acceptance/foreman_journald_spec.rb

This file was deleted.

23 changes: 0 additions & 23 deletions spec/acceptance/foreman_prometheus_spec.rb

This file was deleted.

20 changes: 0 additions & 20 deletions spec/acceptance/foreman_rex_cockpit_spec.rb

This file was deleted.

138 changes: 138 additions & 0 deletions spec/acceptance/foreman_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
require 'spec_helper_acceptance'

describe 'foreman', order: :defined do
shared_examples 'the foreman application' do
[
['debian', 'ubuntu'].include?(os[:family]) ? 'apache2' : 'httpd',
'dynflow-sidekiq@orchestrator',
'dynflow-sidekiq@worker',
'foreman',
].each do |service_name|
describe service(service_name) do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end

describe port(80) do
it { is_expected.to be_listening }
end

describe port(443) do
it { is_expected.to be_listening }
end

describe file('/run/foreman.sock') do
it { should be_socket }
end

describe command("curl -s --cacert /etc/foreman-certs/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
end

before(:context) { purge_foreman }

context 'without plugins' do
let(:pp) do
<<-PUPPET
include foreman
PUPPET
end

it_behaves_like 'a idempotent resource'
it_behaves_like 'the foreman application'

describe package('foreman-journald') do
it { is_expected.not_to be_installed }
end

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

context 'with journald' do
let(:pp) do
<<-PUPPET
class { 'foreman':
logging_type => 'journald',
}
PUPPET
end

it_behaves_like 'a idempotent resource'
it_behaves_like 'the foreman application'

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

# Logging to the journal is broken on Docker 18+ and EL7 but works in Vagrant
# VMs (and EL7's Docker version)
broken_journald_logging = ENV['BEAKER_HYPERVISOR'] == 'docker' && 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: broken_journald_logging do
its(:stdout) { is_expected.to match(%r{Everything ready for world: }) }
end
end

context 'with prometheus' do
let(:pp) do
<<-PUPPET
class { 'foreman':
telemetry_prometheus_enabled => true,
}
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

# TODO: actually verify prometheus functionality
end

context 'with statsd' do
let(:pp) do
<<-PUPPET
class { 'foreman':
telemetry_statsd_enabled => true,
}
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

# TODO: actually verify statsd functionality
end

context 'with rex cockpit', if: os[:family] == 'centos' do
let(:pp) do
<<-PUPPET
include foreman
include foreman::plugin::remote_execution::cockpit
PUPPET
end

it_behaves_like 'a idempotent resource'
it_behaves_like 'the foreman application'

describe port(19090) do
it { is_expected.to be_listening.on('127.0.0.1').with('tcp') }
end
end
end
23 changes: 0 additions & 23 deletions spec/acceptance/foreman_statsd_spec.rb

This file was deleted.

Loading