Revision 46c40319
Added by Ewoud Kohl van Wijngaarden about 4 years ago
.sync.yml | ||
---|---|---|
beaker_puppet_collections:
|
||
- puppet5
|
||
- puppet6
|
||
Rakefile:
|
||
param_docs_pattern:
|
||
- manifests/init.pp
|
CONTRIBUTING.md | ||
---|---|---|
package manager such as [bundler](https://bundler.io/) what Ruby packages,
|
||
or Gems, are required to build, develop, and test this software.
|
||
|
||
Please make sure you have [bundler installed](https://bundler.io/#getting-started)
|
||
on your system, then use it to install all dependencies needed for this project,
|
||
by running
|
||
|
||
```shell
|
||
% bundle install
|
||
**Prerequisites**
|
||
1. Make sure you have [bundler installed](https://bundler.io/#getting-started)
|
||
on your system. If you are using Fedora, you can get `bundler` using
|
||
```shell
|
||
sudo dnf install rubygem-bundler
|
||
```
|
||
2. If you are using Fedora, you may need these additional packages
|
||
```shell
|
||
sudo dnf install -y ruby-devel redhat-rpm-config
|
||
```
|
||
|
||
Now, go to the root directory of this project and use `bundler` to install all
|
||
dependencies needed for this project by running
|
||
|
||
```console
|
||
$ bundle install
|
||
Fetching gem metadata from https://rubygems.org/........
|
||
Fetching gem metadata from https://rubygems.org/..
|
||
Using rake (10.1.0)
|
||
... | ... | |
If you already have those gems installed, make sure they are up-to-date:
|
||
|
||
```shell
|
||
% bundle update
|
||
bundle update
|
||
```
|
||
|
||
With all dependencies in place and up-to-date we can now run the tests:
|
||
|
||
```shell
|
||
% rake spec
|
||
rake spec
|
||
```
|
||
|
||
This will execute all the [rspec tests](http://rspec-puppet.com/) tests
|
||
... | ... | |
|
||
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
|
||
|
||
|
||
Modulesync
|
||
==========
|
||
|
||
Various files, including this one, are
|
||
[modulesynced](https://github.com/voxpupuli/modulesync) using
|
||
[foreman-installer-modulesync](https://github.com/theforeman/foreman-installer-modulesync)
|
||
configuration. Changes should be made over there and then synced to
|
||
all [managed
|
||
modules](https://github.com/theforeman/foreman-installer-modulesync/blob/master/managed_modules.yml).
|
Gemfile | ||
---|---|---|
|
||
gem 'puppet', ENV.key?('PUPPET_VERSION') ? "~> #{ENV['PUPPET_VERSION']}" : '>= 5.5'
|
||
|
||
gem 'rake'
|
||
gem 'rspec', '~> 3.0'
|
||
gem 'rspec-puppet', '~> 2.3'
|
||
gem 'rspec-puppet-facts', '>= 1.7'
|
||
gem 'puppetlabs_spec_helper', '>= 2.1.1'
|
||
gem 'puppet-lint', '>= 2'
|
||
gem 'puppet-lint-classes_and_types_beginning_with_digits-check'
|
||
gem 'kafo_module_lint'
|
||
gem 'puppet-lint-empty_string-check'
|
||
gem 'puppet-lint-file_ensure-check'
|
||
gem 'puppet-lint-leading_zero-check'
|
||
gem 'puppet-lint-param-docs', '>= 1.3.0'
|
||
gem 'puppet-lint-spaceship_operator_without_tag-check'
|
||
gem 'puppet-lint-strict_indent-check'
|
||
gem 'puppet-lint-trailing_comma-check'
|
||
gem 'puppet-lint-undef_in_function-check'
|
||
gem 'puppet-lint-unquoted_string-check'
|
||
gem 'puppet-lint-variable_contains_upcase'
|
||
gem 'puppet-lint-version_comparison-check'
|
||
gem 'simplecov'
|
||
gem 'github_changelog_generator', '>= 1.15.0'
|
||
gem 'voxpupuli-test', '~> 1.0'
|
||
gem 'github_changelog_generator', '>= 1.15.0', {"groups"=>["development"]}
|
||
gem 'puppet-blacksmith', '>= 4.1.0', {"groups"=>["development"]}
|
||
gem 'beaker', '>= 4.2.0', {"groups"=>["system_tests"]}
|
||
gem 'beaker-docker', {"groups"=>["system_tests"]}
|
||
gem 'beaker-hostgenerator', '>= 1.1.10', {"groups"=>["system_tests"]}
|
||
gem 'beaker-puppet', {"groups"=>["system_tests"]}
|
||
gem 'beaker-rspec', {"groups"=>["system_tests"]}
|
||
gem 'beaker-module_install_helper', {"groups"=>["system_tests"]}
|
||
gem 'beaker-puppet_install_helper', {"groups"=>["system_tests"]}
|
||
gem 'metadata-json-lint'
|
||
gem 'kafo_module_lint'
|
||
gem 'parallel_tests'
|
||
gem 'voxpupuli-acceptance', '~> 0.1', {"groups"=>["system_tests"]}
|
||
|
||
# vim:ft=ruby
|
Rakefile | ||
---|---|---|
# This file is managed centrally by modulesync
|
||
# https://github.com/theforeman/foreman-installer-modulesync
|
||
|
||
require 'puppetlabs_spec_helper/rake_tasks'
|
||
require 'puppet-lint/tasks/puppet-lint'
|
||
require 'voxpupuli/test/rake'
|
||
|
||
# blacksmith isn't always present, e.g. on Travis with --without development
|
||
begin
|
||
... | ... | |
end
|
||
rescue LoadError
|
||
end
|
||
|
||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"]
|
||
PuppetLint.configuration.log_format = '%{path}:%{line}:%{KIND}: %{message}'
|
||
|
||
require 'puppet-lint-param-docs/tasks'
|
||
PuppetLintParamDocs.define_selective do |config|
|
||
config.pattern = ["manifests/init.pp"]
|
||
end
|
||
|
||
require 'kafo_module_lint/tasks'
|
||
KafoModuleLint::RakeTask.new do |config|
|
||
config.pattern = ["manifests/init.pp"]
|
||
end
|
||
|
||
task :default => [:release_checks]
|
spec/spec_helper.rb | ||
---|---|---|
# This file is managed centrally by modulesync
|
||
# https://github.com/theforeman/foreman-installer-modulesync
|
||
|
||
RSpec.configure do |c|
|
||
c.mock_with :rspec
|
||
end
|
||
|
||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||
require 'voxpupuli/test/spec_helper'
|
||
|
||
require 'rspec-puppet-facts'
|
||
include RspecPuppetFacts
|
||
|
||
# Original fact sources:
|
||
add_custom_fact :puppet_environmentpath, '/etc/puppetlabs/code/environments' # puppetlabs-stdlib
|
||
add_custom_fact :root_home, '/root' # puppetlabs-stdlib
|
||
# Rough conversion of grepping in the puppet source:
|
||
# grep defaultfor lib/puppet/provider/service/*.rb
|
||
add_custom_fact :service_provider, ->(os, facts) do
|
||
... | ... | |
end
|
||
end
|
||
|
||
# Workaround for no method in rspec-puppet to pass undef through :params
|
||
class Undef
|
||
def inspect; 'undef'; end
|
||
end
|
||
|
||
# Running tests with the ONLY_OS environment variable set
|
||
# limits the tested platforms to the specified values.
|
||
# Example: ONLY_OS=centos-7-x86_64,ubuntu-14-x86_64
|
||
def only_test_os
|
||
if ENV.key?('ONLY_OS')
|
||
ENV['ONLY_OS'].split(',')
|
||
end
|
||
end
|
||
|
||
# Running tests with the EXCLUDE_OS environment variable set
|
||
# limits the tested platforms to all but the specified values.
|
||
# Example: EXCLUDE_OS=centos-7-x86_64,ubuntu-14-x86_64
|
||
def exclude_test_os
|
||
if ENV.key?('EXCLUDE_OS')
|
||
ENV['EXCLUDE_OS'].split(',')
|
||
end
|
||
end
|
||
|
||
# Use the above environment variables to limit the platforms under test
|
||
def on_os_under_test
|
||
on_supported_os.reject do |os, facts|
|
||
(only_test_os() && !only_test_os.include?(os)) ||
|
||
(exclude_test_os() && exclude_test_os.include?(os))
|
||
end
|
||
end
|
||
|
||
def get_content(subject, title)
|
||
is_expected.to contain_file(title)
|
||
content = subject.resource('file', title).send(:parameters)[:content]
|
spec/spec_helper_acceptance.rb | ||
---|---|---|
ENV['PUPPET_INSTALL_TYPE'] ||= 'agent'
|
||
ENV['BEAKER_IS_PE'] ||= 'no'
|
||
ENV['BEAKER_PUPPET_COLLECTION'] ||= 'puppet6'
|
||
ENV['BEAKER_debug'] ||= 'true'
|
||
require 'voxpupuli/acceptance/spec_helper_acceptance'
|
||
|
||
ENV['BEAKER_setfile'] ||= 'centos7-64{hostname=centos7-64.example.com}'
|
||
ENV['BEAKER_HYPERVISOR'] ||= 'docker'
|
||
|
||
require 'beaker-puppet'
|
||
require 'beaker-rspec'
|
||
require 'beaker/puppet_install_helper'
|
||
require 'beaker/module_install_helper'
|
||
|
||
run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
|
||
install_module_on(hosts)
|
||
install_module_dependencies_on(hosts)
|
||
|
||
RSpec.configure do |c|
|
||
# Readable test descriptions
|
||
c.formatter = :documentation
|
||
|
||
# Configure all nodes in nodeset
|
||
c.before :suite do
|
||
# Install module and dependencies
|
||
hosts.each do |host|
|
||
if fact_on(host, 'osfamily') == 'RedHat'
|
||
# don't delete downloaded rpm for use with BEAKER_provision=no +
|
||
# BEAKER_destroy=no
|
||
on host, 'sed -i "s/keepcache=.*/keepcache=1/" /etc/yum.conf'
|
||
# refresh check if cache needs refresh on next yum command
|
||
on host, 'yum clean expire-cache'
|
||
end
|
||
if fact_on(host, 'operatingsystem') == 'Ubuntu'
|
||
on host, 'apt-get -qq -y install cron'
|
||
end
|
||
|
||
configure_beaker do |host|
|
||
if fact_on(host, 'os.family') == 'RedHat'
|
||
unless fact_on(host, 'os.name') == 'Fedora'
|
||
# don't delete downloaded rpm for use with BEAKER_provision=no +
|
||
# BEAKER_destroy=no
|
||
on host, 'sed -i "s/keepcache=.*/keepcache=1/" /etc/yum.conf'
|
||
end
|
||
# refresh check if cache needs refresh on next yum command
|
||
on host, 'yum clean expire-cache'
|
||
|
||
# this is absent in the el8 container images used for testing
|
||
if fact_on(host, 'os.release.major') == '8'
|
||
on host, puppet('resource', 'package', 'glibc-langpack-en', 'ensure=installed')
|
||
end
|
||
elsif fact_on(host, 'os.name') == 'Ubuntu'
|
||
on host, 'apt-get -qq -y install cron'
|
||
end
|
||
end
|
||
|
||
... | ... | |
|
||
shared_examples 'the example' do |name|
|
||
let(:pp) do
|
||
path = File.join(File.dirname(File.dirname(__FILE__)), 'examples', name)
|
||
path = File.join(File.dirname(__dir__), 'examples', name)
|
||
File.read(path)
|
||
end
|
||
|
Also available in: Unified diff
Modulesync: use voxpupuli helper gems