Skip to content

Commit a638ce5

Browse files
Merge pull request #68 from carabasdaniel/main
Add initial acceptance tests
2 parents b099a3a + e7c07d2 commit a638ce5

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

spec/acceptance/backup_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'pe_databases with manage database backups' do
4+
it 'applies the class with default parameters' do
5+
pp = <<-MANIFEST
6+
class { 'pe_databases':
7+
manage_database_backups => true
8+
}#{' '}
9+
MANIFEST
10+
11+
# Run it twice and test for idempotency
12+
idempotent_apply(pp)
13+
end
14+
it 'checks if backup cron jobs are up' do
15+
run_shell('crontab -l -u pe-postgres') do |r|
16+
expect(r.stdout).to match(%r{pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac})
17+
expect(r.stdout).to match(%r{pe-puppetdb})
18+
end
19+
end
20+
end

spec/acceptance/collect_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'check collect with default values' do
4+
before(:all) do
5+
pp = <<-MANIFEST
6+
include pe_databases
7+
MANIFEST
8+
idempotent_apply(pp)
9+
end
10+
context 'check if service files are created' do
11+
it 'service files are created' do
12+
files = run_shell('ls /etc/systemd/system/pe_databases-*.service').stdout
13+
expect(files.split("\n").count).to be >= 3
14+
end
15+
it 'service timer files are created' do
16+
files = run_shell('ls /etc/systemd/system/pe_databases-*.timer').stdout
17+
expect(files.split("\n").count).to be >= 3
18+
end
19+
end
20+
end

spec/acceptance/init_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@
88
MANIFEST
99

1010
# Run it twice and test for idempotency
11-
expect(apply_manifest(pp).exit_code).not_to eq(1)
12-
expect(apply_manifest(pp).exit_code).not_to eq(1)
1311
idempotent_apply(pp)
1412
end
1513
end
14+
15+
describe 'check pe_databases script directory' do
16+
it 'scripts folder exists' do
17+
expect(file('/opt/puppetlabs/pe_databases/scripts')).to be_directory
18+
end
19+
end
20+
21+
describe 'check systemd fact' do
22+
it 'is true on all supported OS' do
23+
expect(host_inventory['facter']['pe_databases']['have_systemd']).to eq true
24+
end
25+
end
1626
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'reset_pgrepack_schema task' do
4+
before(:all) do
5+
pp = <<-MANIFEST
6+
include pe_databases
7+
MANIFEST
8+
9+
# Run it twice and test for idempotency
10+
idempotent_apply(pp)
11+
end
12+
it 'returns success' do
13+
result = run_bolt_task('pe_databases::reset_pgrepack_schema')
14+
expect(result.stdout).to contain(%r{success})
15+
end
16+
end

spec/spec_helper_acceptance_local.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,20 @@
33
require 'singleton'
44
require 'serverspec'
55
require 'puppetlabs_spec_helper/module_spec_helper'
6+
7+
class LitmusHelper
8+
include Singleton
9+
include PuppetLitmus
10+
end
11+
12+
RSpec.configure do |c|
13+
c.before :suite do
14+
LitmusHelper.instance.run_shell('/opt/puppetlabs/bin/puppet plugin download')
15+
pp = <<-MANIFEST
16+
package { 'cron':
17+
ensure => 'latest',
18+
}
19+
MANIFEST
20+
LitmusHelper.instance.apply_manifest(pp)
21+
end
22+
end

0 commit comments

Comments
 (0)