From fb6deef2b3a481f6292714742afd8622e2c23612 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 27 Mar 2018 16:19:20 +0200 Subject: [PATCH] Add a basic acceptance test --- spec/acceptance/foreman_basic_spec.rb | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 spec/acceptance/foreman_basic_spec.rb diff --git a/spec/acceptance/foreman_basic_spec.rb b/spec/acceptance/foreman_basic_spec.rb new file mode 100644 index 000000000..3948f1a02 --- /dev/null +++ b/spec/acceptance/foreman_basic_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper_acceptance' + +describe 'Scenario: install foreman' do + before(:context) do + case os[:family] + when /redhat|fedora/ + on default, 'yum -y remove foreman* tfm-* && rm -rf /etc/yum.repos.d/foreman*.repo' + when /debian|ubuntu/ + 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 = os[:family] == 'redhat' && os[:family] != 'fedora' + <<-EOS + # Workarounds + + ## Ensure repos are present before installing + Yumrepo <| |> -> Package <| |> + + ## We want passenger from EPEL + class { '::apache::mod::passenger': + manage_repo => false, + } + + # Get a certificate from puppet + exec { 'puppet_server_config-generate_ca_cert': + creates => '/etc/puppetlabs/puppet/ssl/certs/#{host_inventory['fqdn']}.pem', + command => '/opt/puppetlabs/bin/puppet ca generate #{host_inventory['fqdn']}', + umask => '0022', + } + + # Actual test + class { '::foreman': + custom_repo => false, + repo => 'nightly', + gpgcheck => true, + configure_epel_repo => #{configure}, + configure_scl_repo => #{configure}, + user_groups => [], + admin_username => 'admin', + admin_password => 'changeme', + } + EOS + end + + it_behaves_like 'a idempotent resource' + + describe service(os[:family] == 'debian' ? 'apache2' : 'httpd') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe service('dynflowd') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + describe port(80) do + it { is_expected.to be_listening } + end + + describe port(443) do + it { is_expected.to be_listening } + end +end