Skip to content

Add initial acceptance tests #68

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

Merged
merged 1 commit into from
Jul 1, 2021
Merged
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
20 changes: 20 additions & 0 deletions spec/acceptance/backup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper_acceptance'

describe 'pe_databases with manage database backups' do
it 'applies the class with default parameters' do
pp = <<-MANIFEST
class { 'pe_databases':
manage_database_backups => true
}#{' '}
MANIFEST

# Run it twice and test for idempotency
idempotent_apply(pp)
end
it 'checks if backup cron jobs are up' do
run_shell('crontab -l -u pe-postgres') do |r|
expect(r.stdout).to match(%r{pe-activity, pe-classifier, pe-inventory, pe-orchestrator, pe-postgres, pe-rbac})
expect(r.stdout).to match(%r{pe-puppetdb})
end
end
end
20 changes: 20 additions & 0 deletions spec/acceptance/collect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper_acceptance'

describe 'check collect with default values' do
before(:all) do
pp = <<-MANIFEST
include pe_databases
MANIFEST
idempotent_apply(pp)
end
context 'check if service files are created' do
it 'service files are created' do
files = run_shell('ls /etc/systemd/system/pe_databases-*.service').stdout
expect(files.split("\n").count).to be >= 3
end
it 'service timer files are created' do
files = run_shell('ls /etc/systemd/system/pe_databases-*.timer').stdout
expect(files.split("\n").count).to be >= 3
end
end
end
14 changes: 12 additions & 2 deletions spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,19 @@
MANIFEST

# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).not_to eq(1)
expect(apply_manifest(pp).exit_code).not_to eq(1)
idempotent_apply(pp)
end
end

describe 'check pe_databases script directory' do
it 'scripts folder exists' do
expect(file('/opt/puppetlabs/pe_databases/scripts')).to be_directory
end
end

describe 'check systemd fact' do
it 'is true on all supported OS' do
expect(host_inventory['facter']['pe_databases']['have_systemd']).to eq true
end
end
end
16 changes: 16 additions & 0 deletions spec/acceptance/tasks/reset_pgrepack_schema_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper_acceptance'

describe 'reset_pgrepack_schema task' do
before(:all) do
pp = <<-MANIFEST
include pe_databases
MANIFEST

# Run it twice and test for idempotency
idempotent_apply(pp)
end
it 'returns success' do
result = run_bolt_task('pe_databases::reset_pgrepack_schema')
expect(result.stdout).to contain(%r{success})
end
end
17 changes: 17 additions & 0 deletions spec/spec_helper_acceptance_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@
require 'singleton'
require 'serverspec'
require 'puppetlabs_spec_helper/module_spec_helper'

class LitmusHelper
include Singleton
include PuppetLitmus
end

RSpec.configure do |c|
c.before :suite do
LitmusHelper.instance.run_shell('/opt/puppetlabs/bin/puppet plugin download')
pp = <<-MANIFEST
package { 'cron':
ensure => 'latest',
}
MANIFEST
LitmusHelper.instance.apply_manifest(pp)
end
end