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

Add acceptance test #109

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ concurrency:
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1
with:
pidfile_workaround: 'false'
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
spec/spec_helper.rb:
spec_overrides: "require_relative './settings_helper'"
spec/spec_helper_acceptance.rb:
unmanaged: false
57 changes: 38 additions & 19 deletions examples/init.pp
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# https://docs.puppet.com/guides/tests_smoke.html
#
class { 'bareos':
manage_repo => false,
include postgresql::server
$storage_password = 'Password of the storage instance'

postgresql::server::db { 'bareos_catalog':
user => 'dbuser',
password => postgresql::postgresql_password('bareos_catalog', 'dbpass'),
}
class { 'bareos::director::director':
password => 'pw',
# Install and configure an Director Server
-> class { 'bareos::profile::director':
password => 'Password of the director instance itself',
storage_address => 'localhost',
storage_password => $storage_password,
catalog_conf => {
'db_name' => 'bareos_catalog',
'db_address' => '127.0.0.1',
'db_port' => 5432,
'db_user' => 'dbuser',
'db_password' => 'dbpass',
},
}
class { 'bareos::client::client':

include bareos::profile::director::fileset
include bareos::profile::director::jobdefs

# add storage server to the same machine
class { 'bareos::profile::storage':
password => $storage_password,
archive_device => '/var/lib/bareos/storage',
}
class { 'bareos::storage::storage':

# add the client to the config
bareos::director::client { 'bareos-client':
description => 'Your fancy client to backup',
password => 'MyClientPasswordPleaseChange',
address => 'localhost',
}

# Create an backup job by referencing to the jobDef template.
bareos::director::job { 'backup-bareos-client':
job_defs => 'DefaultJob',
client => 'bareos-client', # which client to assign this job
}
include bareos::console
include bareos::monitor
6 changes: 6 additions & 0 deletions manifests/console.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@
require => Package[$package_name],
tag => ['bareos', 'bareos_console'],
}

file { "${bareos::config_dir}/bconsole.conf":
ensure => absent,
force => true,
require => Package[$package_name],
}
}
6 changes: 5 additions & 1 deletion manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$service_ensure = $bareos::service_ensure,
$service_enable = $bareos::service_enable,
$config_dir = "${bareos::config_dir}/bareos-dir.d",
$export_dir = "${bareos::config_dir}/bareos-dir-export",
Array[String] $managed_dirs = $bareos::director_managed_dirs,
Hash $catalogs = {},
Hash $clients = {},
Expand Down Expand Up @@ -55,8 +56,10 @@
}
}

file { $config_dir:
file { [$config_dir, $export_dir]:
ensure => directory,
purge => true,
recurse => true,
force => true,
mode => $bareos::file_dir_mode,
owner => $bareos::file_owner,
Expand All @@ -83,6 +86,7 @@

if $manage_database {
File <| tag == 'bareos_director' |> -> exec { 'bareos director init catalog':
user => 'postgres',
command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges',
notify => Service[$bareos::director::service_name],
refreshonly => true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/director/catalog.pp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
define bareos::director::catalog (
$ensure = present,
$db_address = undef,
$db_driver = undef,
Enum['postgresql'] $db_driver = 'postgresql',
$db_name = undef,
$db_password = undef,
$db_port = undef,
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@
ensure => directory,
purge => true,
recurse => true,
force => true,
recurselimit => 1,
mode => $bareos::file_dir_mode,
owner => $bareos::file_owner,
group => $bareos::file_group,
require => Package[$package_name],
tag => ['bareos', 'bareos_core'],
}
}
3 changes: 2 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
'bareos-database-tools',
]
$director_service_name = 'bareos-dir'
$director_managed_dirs = ['catalog',
$director_managed_dirs = [
'catalog',
'client',
'console',
'counter',
Expand Down
7 changes: 7 additions & 0 deletions spec/acceptance/bareos_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'bareos class' do
it_behaves_like 'the example', 'init.pp'
end
10 changes: 10 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker

Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }
5 changes: 5 additions & 0 deletions spec/support/acceptance/setup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

configure_beaker do |host|
install_module_from_forge_on(host, 'puppetlabs/postgresql', '> 8 < 9')
end