Skip to content

Commit d8a026a

Browse files
smortexh0tw1r3
authored andcommitted
Modernize/Fix CI
* Fix acceptance tests to work with Litmus * Fix acceptance test installation path of puppet modules * update/add dependencies to fixtures * Fix CI failures related to legacy facts * More CI fixes with latest posgresql module * Remove local facts overrides They break adding facts from a context. * Match the ensure value of the manifest This was changed in 68d8c64 to fix puppet lint issues, but as the test suite was not run it passed through. * Match owner / mode of the manifest This was changed in 010bf13 to match best practice, but as the test suite was not run it passed through. * Add path to the custom facts The systemd module use this to run `systemctl daemon-reload`. Set an arbitrary value to avoid: > Validation of Exec[systemd-postgresql.service-systemctl-daemon-reload] failed: 'systemctl' is not qualified and no path was specified. Please qualify the command or specify a path.
1 parent 3da561a commit d8a026a

21 files changed

+133
-221
lines changed

.fixtures.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ fixtures:
1010
file_concat: 'https://github.com/electrical/puppet-lib-file_concat.git'
1111
systemd: 'https://github.com/camptocamp/puppet-systemd.git'
1212
cron: 'https://github.com/voxpupuli/puppet-cron.git'
13-
cron_core: 'https://github.com/puppetlabs/puppetlabs-cron_core.git'
14-
yumrepo_core: 'https://github.com/puppetlabs/puppetlabs-yumrepo_core.git'
15-
augeas_core: 'https://github.com/puppetlabs/puppetlabs-augeas_core.git'
13+
provision: 'https://github.com/puppetlabs/provision.git'
14+
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
15+
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
16+
cron_core:
17+
repo: https://github.com/puppetlabs/puppetlabs-cron_core.git
18+
puppet_version: ">= 6.0.0"
19+
yumrepo_core:
20+
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
21+
puppet_version: ">= 6.0.0"
22+
augeas_core:
23+
repo: https://github.com/puppetlabs/puppetlabs-augeas_core.git
24+
puppet_version: ">= 6.0.0"
25+
symlinks:
26+
puppetdb: '#{source_dir}'

.sync.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Rakefile:
1717
- parameter_documentation
1818
- documentation
1919
- 140chars
20+
spec/default_facts.yml:
21+
unmanaged: true
2022
spec/spec_helper.rb:
2123
coverage_report: true
2224
minimum_code_coverage_percentage: 100

spec/acceptance/basic_spec.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
require 'beaker-puppet'
2-
require 'beaker-pe'
31
require 'spec_helper_acceptance'
42

53
describe 'basic tests:' do
64
it 'make sure we have copied the module across' do
75
# No point diagnosing any more if the module wasn't copied properly
8-
shell('ls /etc/puppetlabs/code/modules/puppetdb') do |r|
6+
run_shell('ls /etc/puppetlabs/code/environments/production/modules/puppetdb') do |r|
97
r.exit_code.should be_zero
108
r.stdout.should contain 'metadata.json'
119
r.stderr.should == ''
1210
end
1311
end
1412

13+
describe 'setup puppetserver' do
14+
pp = <<-EOS
15+
package { 'puppetserver': ensure => installed, } ->
16+
exec { '/opt/puppetlabs/bin/puppetserver ca setup': creates => '/etc/puppetlabs/puppetserver/ca/ca_crt.pem', }
17+
service { 'puppetserver': ensure => running, enable => true, }
18+
EOS
19+
20+
it 'make sure it runs without error' do
21+
apply_manifest(pp, catch_errors: true)
22+
apply_manifest(pp, catch_changes: true)
23+
end
24+
end
25+
1526
describe 'single node setup' do
1627
pp = <<-EOS
1728
# Single node setup
@@ -72,7 +83,7 @@ class { 'puppetdb::master::config':
7283
apply_manifest(pp, catch_errors: true)
7384
apply_manifest(pp, catch_changes: true)
7485

75-
shell('cat /etc/puppetlabs/puppet/puppet.conf') do |r|
86+
run_shell('cat /etc/puppetlabs/puppet/puppet.conf') do |r|
7687
expect(r.stdout).to match(%r{^reports\s*=\s*([^,]+,)*puppetdb(,[^,]+)*$})
7788
end
7889
end
@@ -91,7 +102,7 @@ class { 'puppetdb::master::config':
91102
apply_manifest(pp, catch_errors: true)
92103
apply_manifest(pp, catch_changes: true)
93104

94-
shell('psql "postgresql://puppetdb-read:puppetdb-read@localhost/puppetdb" -c "create table tables(id int)" || true') do |r|
105+
run_shell('psql "postgresql://puppetdb-read:puppetdb-read@localhost/puppetdb" -c "create table tables(id int)" || true') do |r|
95106
expect(r.stderr).to match(%r{^ERROR: permission denied for schema public.*})
96107
end
97108
end

spec/default_facts.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

spec/spec_helper_acceptance.rb

Lines changed: 4 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,6 @@
1-
require 'beaker-rspec'
2-
require 'beaker-puppet'
3-
require 'beaker/puppet_install_helper'
4-
require 'beaker/module_install_helper'
1+
# frozen_string_literal: true
52

6-
def use_puppet4?
7-
(ENV['PUPPET_INSTALL_VERSION'] =~ %r{^2016}) ? true : false
8-
end
3+
require 'puppet_litmus'
4+
PuppetLitmus.configure!
95

10-
def use_puppet5?
11-
(ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet5}) ? true : false
12-
end
13-
14-
def use_puppet6?
15-
(ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet6}) ? true : false
16-
end
17-
18-
def use_puppet7?
19-
(ENV['BEAKER_PUPPET_COLLECTION'] =~ %r{^puppet7}) ? true : false
20-
end
21-
22-
def build_url(platform)
23-
if use_puppet4?
24-
url4 = 'http://%{mngr}.puppetlabs.com/puppetlabs-release-pc1%{plat}'
25-
case platform
26-
when 'el' then url4 % { mngr: 'yum', plat: '-el-' }
27-
when 'fedora' then url4 % { mngr: 'yum', plat: '-fedora-' }
28-
when 'debian', 'ubuntu' then url4 % { mngr: 'apt', plat: '-' }
29-
else
30-
raise "build_url() called with unsupported platform '#{platform}'"
31-
end
32-
elsif use_puppet5?
33-
url5 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet5-release%{plat}'
34-
case platform
35-
when 'el' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-el-' }
36-
when 'fedora' then url5 % { mngr: 'yum', dir: 'puppet5/', plat: '-fedora-' }
37-
when 'debian', 'ubuntu' then url5 % { mngr: 'apt', dir: '', plat: '-' }
38-
else
39-
raise "build_url() called with unsupported platform '#{platform}'"
40-
end
41-
elsif use_puppet6?
42-
url6 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet6-release%{plat}'
43-
case platform
44-
when 'el' then url6 % { mngr: 'yum', dir: 'puppet6/', plat: '-el-' }
45-
when 'fedora' then url6 % { mngr: 'yum', dir: 'puppet6/', plat: '-fedora-' }
46-
when 'debian', 'ubuntu' then url6 % { mngr: 'apt', dir: '', plat: '-' }
47-
else
48-
raise "build_url() called with unsupported platform '#{platform}'"
49-
end
50-
else
51-
url7 = 'http://%{mngr}.puppetlabs.com/%{dir}puppet7-release%{plat}'
52-
case platform
53-
when 'el' then url7 % { mngr: 'yum', dir: 'puppet7/', plat: '-el-' }
54-
when 'fedora' then url7 % { mngr: 'yum', dir: 'puppet7/', plat: '-fedora-' }
55-
when 'debian', 'ubuntu' then url7 % { mngr: 'apt', dir: '', plat: '-' }
56-
else
57-
raise "build_url() called with unsupported platform '#{platform}'"
58-
end
59-
end
60-
end
61-
62-
hosts.each do |host|
63-
if host['platform'].include? 'debian'
64-
on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc'
65-
end
66-
# install_puppet
67-
if host['platform'].match? %r{el-(5|6|7|8)}
68-
relver = Regexp.last_match(1)
69-
on host, "rpm -ivh #{build_url('el')}#{relver}.noarch.rpm"
70-
on host, 'yum install -y puppetserver'
71-
on host, '/opt/puppetlabs/bin/puppetserver ca setup'
72-
73-
# TODO: we should probably be using the relatively new postgresql
74-
# module settings manage_dnf_module on el8 when we are managing the postgresql
75-
# database
76-
if relver == '8'
77-
on host, 'dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm'
78-
on host, 'dnf -qy module disable postgresql'
79-
end
80-
elsif host['platform'].match? %r{fedora-(\d+)}
81-
relver = Regexp.last_match(1)
82-
on host, "rpm -ivh #{build_url('fedora')}#{relver}.noarch.rpm"
83-
on host, 'yum install -y puppetserver'
84-
elsif host['platform'].match? %r{(ubuntu|debian)}
85-
unless host.check_for_package 'curl'
86-
on host, 'apt-get install -y curl'
87-
end
88-
# For openjdk8
89-
if host['platform'].version == '8' && !use_puppet4?
90-
create_remote_file(host,
91-
'/etc/apt/sources.list.d/jessie-backports.list',
92-
'deb https://artifactory.delivery.puppetlabs.net/artifactory/debian_archive__remote/ jessie-backports main')
93-
on host, 'apt-get -y -m update'
94-
install_package(host, 'openjdk-8-jre-headless')
95-
end
96-
on host, 'apt-get install apt-transport-https --assume-yes'
97-
on host, "curl -O #{build_url('debian')}$(lsb_release -c -s).deb"
98-
if use_puppet4?
99-
on host, 'dpkg -i puppetlabs-release-pc1-$(lsb_release -c -s).deb'
100-
elsif use_puppet5?
101-
on host, 'dpkg -i puppet5-release-$(lsb_release -c -s).deb'
102-
elsif use_puppet6?
103-
on host, 'dpkg -i puppet6-release-$(lsb_release -c -s).deb'
104-
else
105-
on host, 'dpkg -i puppet7-release-$(lsb_release -c -s).deb'
106-
end
107-
on host, 'apt-get -y -m update'
108-
on host, 'apt-get install -y puppetserver'
109-
on host, '/opt/puppetlabs/bin/puppetserver ca setup'
110-
else
111-
raise "install_puppet() called for unsupported platform '#{host['platform']}' on '#{host.name}'"
112-
end
113-
end
114-
115-
opts = { puppet_agent_version: 'latest' }
116-
opts[:puppet_collection] = if use_puppet5?
117-
'puppet5'
118-
elsif use_puppet6?
119-
'puppet6'
120-
elsif use_puppet7?
121-
'puppet7'
122-
end
123-
install_puppet_agent_on(hosts, opts) unless ENV['BEAKER_provision'] == 'no'
124-
install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'].match? %r{pe}i
125-
install_module_on(hosts)
126-
install_module_dependencies_on(hosts)
127-
128-
RSpec.configure do |c|
129-
# Readable test descriptions
130-
c.formatter = :documentation
131-
hosts.each do |host|
132-
if host[:platform].include?('el-7-x86_64') && host[:hypervisor].include?('docker')
133-
on(host, "sed -i '/nodocs/d' /etc/yum.conf")
134-
end
135-
end
136-
end
6+
require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))

spec/unit/classes/database/postgresql_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
release: { 'full' => '7.0', 'major' => '7' },
1717
selinux: { 'enabled' => true },
1818
},
19+
service_provider: 'systemd',
1920
}
2021
end
2122

spec/unit/classes/database/ssl_configuration_spec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
operatingsystemrelease: '7.0',
1111
kernel: 'Linux',
1212
selinux: true,
13+
path: '/usr/bin:/bin',
1314
os: {
1415
family: 'RedHat',
1516
name: 'RedHat',
1617
release: { 'full' => '7.0', 'major' => '7' },
1718
selinux: { 'enabled' => true },
1819
},
19-
fqdn: 'cheery-rime@puppet',
20+
networking: {
21+
fqdn: 'cheery-rime@puppet',
22+
},
23+
service_provider: 'systemd',
2024
}
2125
end
2226

@@ -125,7 +129,7 @@
125129
it 'has ident rule' do
126130
is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:database_username]} user")
127131
.with_map_name(identity_map)
128-
.with_system_username(facts[:fqdn])
132+
.with_system_username(facts[:networking][:fqdn])
129133
.with_database_username(params[:database_name])
130134
end
131135

@@ -184,7 +188,7 @@
184188
it 'has read ident rule' do
185189
is_expected.to contain_postgresql__server__pg_ident_rule("Map the SSL certificate of the server as a #{params[:read_database_username]} user")
186190
.with_map_name(read_identity_map)
187-
.with_system_username(facts[:fqdn])
191+
.with_system_username(facts[:networking][:fqdn])
188192
.with_database_username(params[:read_database_username])
189193
end
190194
end

spec/unit/classes/init_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
on_supported_os.each do |os, facts|
77
context "on #{os}" do
88
let(:facts) do
9-
facts.merge(selinux: false)
9+
facts.merge(selinux: false, service_provider: 'systemd')
1010
end
1111

1212
describe 'when using default values for puppetdb class' do

spec/unit/classes/master/config_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
context "on #{os}" do
66
let(:facts) do
77
facts.merge(puppetversion: Puppet.version,
8-
fqdn: 'puppetdb.example.com',
8+
networking: { fqdn: 'puppetdb.example.com' },
9+
service_provider: 'systemd',
910
selinux: true)
1011
end
1112

@@ -114,6 +115,7 @@
114115
release: { 'full' => '7.0', 'major' => '7' },
115116
selinux: { 'enabled' => true },
116117
},
118+
service_provider: 'systemd',
117119
}
118120
end
119121

spec/unit/classes/master/puppetdb_conf_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
context "on #{os}" do
1010
let(:facts) do
1111
facts.merge(puppetversion: Puppet.version,
12+
service_provider: 'systemd',
1213
selinux: false)
1314
end
1415

0 commit comments

Comments
 (0)