From 5bae7c10dd0f4e04d08c3c56651e52a2f8fbed9c Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:35:11 +0100 Subject: [PATCH 01/16] modulesync 5.2.0 --- .editorconfig | 15 ++ .github/CONTRIBUTING.md | 251 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 26 +++ .github/PULL_REQUEST_TEMPLATE.md | 20 ++ .github/SECURITY.md | 3 + .github/workflows/ci.yml | 18 ++ .github/workflows/release.yml | 22 +++ .gitignore | 44 ++--- .msync.yml | 5 + .overcommit.yml | 65 +++++++ .pmtignore | 39 +++- .puppet-lint.rc | 2 + .rspec | 5 + .rspec_parallel | 4 + .rubocop.yml | 14 +- .sync.yml | 7 + Dockerfile | 24 +++ Gemfile | 82 ++++---- Rakefile | 104 ++++++---- spec/spec_helper.rb | 23 ++- spec/spec_helper_acceptance.rb | 317 +------------------------------ 21 files changed, 652 insertions(+), 438 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/SECURITY.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .msync.yml create mode 100644 .overcommit.yml create mode 100644 .puppet-lint.rc create mode 100644 .rspec create mode 100644 .rspec_parallel create mode 100644 .sync.yml create mode 100644 Dockerfile diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..ecb10a80 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..25743a13 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,251 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + +This module has grown over time based on a range of contributions from +people using it. If you follow these contributing guidelines your patch +will likely make it into a release a little more quickly. + +## Contributing + +Please note that this project is released with a Contributor Code of Conduct. +By participating in this project you agree to abide by its terms. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +* Fork the repo. +* Create a separate branch for your change. +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. +* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review your code. + +Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +## Dependencies + +The testing and development tools have a bunch of dependencies, +all managed by [bundler](http://bundler.io/) according to the +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). + +By default the tests use a baseline version of Puppet. + +If you have Ruby 2.x or want a specific version of Puppet, +you must set an environment variable such as: + +```sh +export PUPPET_GEM_VERSION="~> 5.5.6" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" +``` + +### Note for OS X users + +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### Syntax and style + +The test suite will run [Puppet Lint](http://puppet-lint.com/) and +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to +check various syntax and style things. You can run these locally with: + +```sh +bundle exec rake lint +bundle exec rake validate +``` + +It will also run some [Rubocop](http://batsov.com/rubocop/) tests +against it. You can run those locally ahead of time with: + +```sh +bundle exec rake rubocop +``` + +### Running the unit tests + +The unit test suite covers most of the code, as mentioned above please +add tests if you're adding new functionality. If you've not used +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask +about how best to test your new feature. + +To run the linter, the syntax checker and the unit tests: + +```sh +bundle exec rake test +``` + +To run your all the unit tests + +```sh +bundle exec rake spec +``` + +To run a specific spec test set the `SPEC` variable: + +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` + +#### Unit tests in docker + +Some people don't want to run the dependencies locally or don't want to install +ruby. We ship a Dockerfile that enables you to run all unit tests and linting. +You only need to run: + +```sh +docker build . +``` + +Please ensure that a docker daemon is running and that your user has the +permission to talk to it. You can specify a remote docker host by setting the +`DOCKER_HOST` environment variable. it will copy the content of the module into +the docker image. So it will not work if a Gemfile.lock exists. + +### Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + +```sh +BEAKER_setfile=debian11-64 bundle exec rake beaker +``` + +You can replace the string `debian10` with any common operating system. +The following strings are known to work: + +* ubuntu1804 +* ubuntu2004 +* debian10 +* debian11 +* centos7 +* centos8 + +For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). + +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..593e7aa8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ + + +## Affected Puppet, Ruby, OS and module versions/distributions + +- Puppet: +- Ruby: +- Distribution: +- Module version: + +## How to reproduce (e.g Puppet code you use) + +## What are you seeing + +## What behaviour did you expect instead + +## Output log + +## Any additional information you'd like to impart diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..342807bc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 00000000..cacadf22 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Vox Pupuli Security Policy + +Our vulnerabilities reporting process is at https://voxpupuli.org/security/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..8a077911 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,18 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +on: pull_request + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'false' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..15f17213 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +on: + push: + tags: + - '*' + +jobs: + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} diff --git a/.gitignore b/.gitignore index cca98112..9b95224c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,23 @@ -.swp -.#* -spec/fixtures/artifacts/* -!spec/fixtures/artifacts/.gitignore -spec/fixtures/modules/* -!spec/fixtures/modules/logstash -files/*.gem -files/*.rpm -files/*.deb -templates/configfile-template.erb -.bundle -.vendor -.vagrant -.ruby-version -.yardoc +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + pkg/ -spec/reports/ -spec/logs -log -doc -*.lock -**.swp -files/logstash-output-cowsay-5.0.0.zip +Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/fixtures/manifests/ +spec/fixtures/modules/ +.vagrant/ +.bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ +.librarian/ +Puppetfile.lock +*.iml +.*.sw? +.yardoc/ +Guardfile diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 00000000..968a9367 --- /dev/null +++ b/.msync.yml @@ -0,0 +1,5 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '5.2.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 00000000..d367adae --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,65 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'validate' + - 'test' + - 'rubocop' + command: ['bundle', 'exec', 'rake'] diff --git a/.pmtignore b/.pmtignore index b5e79edf..65f50514 100644 --- a/.pmtignore +++ b/.pmtignore @@ -1,6 +1,37 @@ -spec/ -Rakefile -junit/ -logs/ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +docs/ +pkg/ Gemfile Gemfile.lock +Gemfile.local +vendor/ +.vendor/ +spec/ +Rakefile +.vagrant/ +.bundle/ +.ruby-version +coverage/ +log/ +.idea/ +.dependencies/ +.github/ +.librarian/ +Puppetfile.lock +*.iml +.editorconfig +.fixtures.yml +.gitignore +.msync.yml +.overcommit.yml +.pmtignore +.rspec +.rspec_parallel +.rubocop.yml +.sync.yml +.*.sw? +.yardoc/ +.yardopts +Dockerfile diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 00000000..b2d2a644 --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,2 @@ +--fail-on-warnings +--no-parameter_types-check diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..f634583d --- /dev/null +++ b/.rspec @@ -0,0 +1,5 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--format documentation +--color diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 00000000..a9a84f85 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1,4 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--format progress diff --git a/.rubocop.yml b/.rubocop.yml index 2f5d9257..53ac1898 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,6 @@ -AllCops: - Include: - - Rakefile - - Vagrantfile - - spec/**/*.rb - Exclude: - - spec/fixtures/**/* - - pkg/**/* +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +inherit_gem: + voxpupuli-test: rubocop.yml diff --git a/.sync.yml b/.sync.yml new file mode 100644 index 00000000..5279662c --- /dev/null +++ b/.sync.yml @@ -0,0 +1,7 @@ +--- +spec/spec_helper_acceptance.rb: + unmanaged: false + +.puppet-lint.rc: + enabled_lint_checks: + - parameter_documentation diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..8dd82d63 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# MANAGED BY MODULESYNC +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +FROM ruby:2.7 + +WORKDIR /opt/puppet + +# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 +RUN mkdir -p /etc/sv + +ARG PUPPET_GEM_VERSION="~> 6.0" +ARG PARALLEL_TEST_PROCESSORS=4 + +# Cache gems +COPY Gemfile . +RUN bundle install --without system_tests development release --path=${BUNDLE_PATH:-vendor/bundle} + +COPY . . + +RUN bundle install +RUN bundle exec rake release_checks + +# Container should not saved +RUN exit 1 diff --git a/Gemfile b/Gemfile index 22af19d7..04295a4e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,48 +1,34 @@ -source 'https://rubygems.org' -ruby '2.3.4' - -puppetversion = ENV['PUPPET_VERSION'] || '4.10.7' -gem 'puppet', puppetversion, :require => false - -gem 'beaker', '3.15.0' -gem 'beaker-pe', '1.13.0' -gem 'beaker-rspec', '6.1.0' - -# REF: https://github.com/voxpupuli/metadata-json-lint/issues/10 -# gem 'metadata-json-lint' - -gem 'rspec-puppet' - -gem 'pry' -gem 'pry-rescue' -gem 'docker-api', '~> 1.0' -gem 'rubysl-securerandom' -gem 'ci_reporter_rspec' -gem 'google-api-client', '0.9.4' # 0.9.5 needs Ruby 2. -gem 'rgen' -gem 'rspec', '~> 3.0' -gem 'rake' -gem 'metadata-json-lint' -gem 'puppet-doc-lint' -gem 'puppet-lint' -gem 'puppet-strings' -gem 'puppetlabs_spec_helper' -gem 'puppet-syntax' -gem 'rspec-puppet-facts' -gem 'rubocop' -gem 'semantic_puppet' -gem 'serverspec', '2.38.0' -gem 'specinfra', '2.67.3' -gem 'syck' -gem 'webmock' -gem 'redcarpet' - -# Extra Puppet-lint gems -# gem 'puppet-lint-appends-check', :require => false -gem 'puppet-lint-version_comparison-check', :require => false -gem 'puppet-lint-unquoted_string-check', :require => false -gem 'puppet-lint-undef_in_function-check', :require => false -gem 'puppet-lint-trailing_comma-check', :require => false -gem 'puppet-lint-leading_zero-check', :require => false -gem 'puppet-lint-file_ensure-check', :require => false -gem 'puppet-lint-empty_string-check', :require => false +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :test do + gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 1.0', :require => false +end + +group :development do + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false +end + +group :system_tests do + gem 'voxpupuli-acceptance', '~> 1.0', :require => false +end + +group :release do + gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' + gem 'voxpupuli-release', '>= 1.2.0', :require => false + gem 'puppet-strings', '>= 2.2', :require => false +end + +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' +gem 'puppet', puppetversion, :require => false, :groups => [:test] + +# vim: syntax=ruby diff --git a/Rakefile b/Rakefile index cbfe615b..f92f0516 100644 --- a/Rakefile +++ b/Rakefile @@ -1,40 +1,72 @@ -require 'rubygems' -require 'puppetlabs_spec_helper/rake_tasks' -require 'rspec/core/rake_task' - -exclude_paths = [ - 'pkg/**/*', - 'vendor/**/*', - 'spec/**/*' -] - -PuppetLint::RakeTask.new :lint do |config| - config.disable_checks = ['80chars'] - config.fail_on_warnings = true - config.with_context = true - config.ignore_paths = exclude_paths - config.log_format = '%{filename}:%{line} - %{message}' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end +end + +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError +end + +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError end -RSpec::Core::RakeTask.new(:spec_verbose) do |t| - t.pattern = 'spec/{classes,defines,lib,reports}/**/*_spec.rb' - t.rspec_opts = [ - '--format documentation', - '--require "ci/reporter/rspec"', - '--format CI::Reporter::RSpecFormatter', - '--color' - ] +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' + end end -# RSpec::Core::RakeTask.new(:henry) do |t| -# t.pattern = 'spec/acceptance/**/*_spec.rb' -# t.rspec_opts = '--format progress --color' -# end - -# RSpec::Core::RakeTask.new(:beaker_verbose) do |t| -# t.pattern = 'spec/acceptance/**/*_spec.rb' -# t.rspec_opts = [ -# '--format documentation', -# '--color' -# ] -# end +desc 'Generate REFERENCE.md' +task :reference, [:debug, :backtrace] do |t, args| + patterns = '' + Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace]) +end + +begin + require 'github_changelog_generator/task' + require 'puppet_blacksmith' + GitHubChangelogGenerator::RakeTask.new :changelog do |config| + metadata = Blacksmith::Modulefile.new + config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/ + config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." + config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} + config.user = 'voxpupuli' + config.project = metadata.metadata['name'] + end + + # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 + require 'rbconfig' + if RbConfig::CONFIG['host_os'] =~ /linux/ + task :changelog do + puts 'Fixing line endings...' + changelog_file = File.join(__dir__, 'CHANGELOG.md') + changelog_txt = File.read(changelog_file) + new_contents = changelog_txt.gsub(%r{\r\n}, "\n") + File.open(changelog_file, "w") {|file| file.puts new_contents } + end + end + +rescue LoadError +end +# vim: syntax=ruby diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5028b477..4d617f39 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,12 +1,17 @@ -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' -include RspecPuppetFacts +# frozen_string_literal: true -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -RSpec.configure do |c| - c.default_facts = default_facts +# puppetlabs_spec_helper will set up coverage if the env variable is set. +# We want to do this if lib exists and it hasn't been explicitly set. +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) + +require 'voxpupuli/test/spec_helper' + +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + facts&.each do |name, value| + add_custom_fact name.to_sym, value + end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 78d74b32..d3a6e23c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,315 +1,10 @@ -require 'beaker-rspec' -require 'net/http' -require 'pry' -require 'securerandom' -require 'yaml' +# frozen_string_literal: true -# Collect global options from the environment. -if ENV['LOGSTASH_VERSION'].nil? - raise 'Please set the LOGSTASH_VERSION environment variable.' -end -LS_VERSION = ENV['LOGSTASH_VERSION'] -PUPPET_VERSION = ENV['PUPPET_VERSION'] || '4.10.7' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -PE_VERSION = ENV['BEAKER_PE_VER'] || ENV['PE_VERSION'] || '3.8.3' -PE_DIR = ENV['BEAKER_PE_DIR'] +require 'voxpupuli/acceptance/spec_helper_acceptance' -if LS_VERSION =~ /(alpha|beta|rc)/ - IS_PRERELEASE = true -else - IS_PRERELEASE = false -end +configure_beaker -def agent_version_for_puppet_version(puppet_version) - # REF: https://docs.puppet.com/puppet/latest/reference/about_agent.html - version_map = { - # Puppet => Agent - '4.9.4' => '1.9.3', - '4.8.2' => '1.8.3', - '4.8.1' => '1.8.2', - '4.8.0' => '1.8.0', - '4.7.1' => '1.7.2', - '4.7.0' => '1.7.1', - '4.6.2' => '1.6.2', - '4.6.1' => '1.6.1', - '4.6.0' => '1.6.0', - '4.5.3' => '1.5.3', - '4.4.2' => '1.4.2', - '4.4.1' => '1.4.1', - '4.4.0' => '1.4.0', - '4.3.2' => '1.3.6', - '4.3.1' => '1.3.2', - '4.3.0' => '1.3.0', - '4.2.3' => '1.2.7', - '4.2.2' => '1.2.6', - '4.2.1' => '1.2.2', - '4.2.0' => '1.2.1', - '4.1.0' => '1.1.1', - '4.0.0' => '1.0.1' - } - version_map[puppet_version] -end - -def apply_manifest_fixture(manifest_name) - manifest = File.read("./spec/fixtures/manifests/#{manifest_name}.pp") - apply_manifest(manifest, catch_failures: true) -end - -def expect_no_change_from_manifest(manifest) - expect(apply_manifest(manifest).exit_code).to eq(0) -end - -def http_package_url - url_root = "https://artifacts.elastic.co/downloads/logstash/logstash-#{LS_VERSION}" - - case fact('osfamily') - when 'Debian' - "#{url_root}.deb" - when 'RedHat', 'Suse' - "#{url_root}.rpm" - end -end - -def local_file_package_url - "file:///tmp/#{logstash_package_filename}" -end - -def puppet_fileserver_package_url - "puppet:///modules/logstash/#{logstash_package_filename}" -end - -def logstash_package_filename - File.basename(http_package_url) -end - -def logstash_package_version - if LS_VERSION =~ /(alpha|beta|rc)/ - package_version = LS_VERSION.gsub('-', '~') - else - package_version = LS_VERSION - end - - case fact('osfamily') # FIXME: Put this logic in the module, not the tests. - when 'RedHat' - "#{package_version}-1" - when 'Debian', 'Suse' - "1:#{package_version}-1" - end -end - -def logstash_config_manifest - <<-END - logstash::configfile { 'basic_config': - content => 'input { tcp { port => 2000 } } output { null {} }' - } - END -end - -def install_logstash_manifest(extra_args = nil) - <<-END - class { 'elastic_stack::repo': - version => #{LS_VERSION[0]}, - prerelease => #{IS_PRERELEASE.to_s}, - } - class { 'logstash': - manage_repo => true, - version => '#{logstash_package_version}', - #{extra_args if extra_args} - } - - #{logstash_config_manifest} - END -end - -def include_logstash_manifest() - <<-END - class { 'elastic_stack::repo': - version => #{LS_VERSION[0]}, - prerelease => #{IS_PRERELEASE.to_s}, - } - - include logstash - - #{logstash_config_manifest} - END -end - -def install_logstash_from_url_manifest(url, extra_args = nil) - <<-END - class { 'logstash': - package_url => '#{url}', - #{extra_args if extra_args} - } - - #{logstash_config_manifest} - END -end - -def install_logstash_from_local_file_manifest(extra_args = nil) - install_logstash_from_url_manifest(local_file_package_url, extra_args) -end - -def remove_logstash_manifest - "class { 'logstash': ensure => 'absent' }" -end - -def stop_logstash_manifest - "class { 'logstash': status => 'disabled' }" -end - -# Provide a basic Logstash install. Useful as a testing pre-requisite. -def install_logstash(extra_args = nil) - result = apply_manifest(install_logstash_manifest(extra_args), catch_failures: true) - sleep 5 # FIXME: This is horrible. - return result -end - -def include_logstash - result = apply_manifest(include_logstash_manifest, catch_failures: true, debug: true) - sleep 5 # FIXME: This is horrible. - return result -end - -def install_logstash_from_url(url, extra_args = nil) - manifest = install_logstash_from_url_manifest(url, extra_args) - result = apply_manifest(manifest, catch_failures: true) - sleep 5 # FIXME: This is horrible. - return result -end - -def install_logstash_from_local_file(extra_args = nil) - install_logstash_from_url(local_file_package_url, extra_args) -end - -def remove_logstash - result = apply_manifest(remove_logstash_manifest) - sleep 5 # FIXME: This is horrible. - return result -end - -def stop_logstash - result = apply_manifest(stop_logstash_manifest, catch_failures: true) - shell('ps -eo comm | grep java | xargs kill -9', accept_all_exit_codes: true) - sleep 5 # FIXME: This is horrible. - return result -end - -def logstash_process_list - ps_cmd = 'ps -ww --no-headers -C java -o user,command | grep logstash' - shell(ps_cmd, accept_all_exit_codes: true).stdout.split("\n") -end - -def logstash_settings - YAML.load(shell('cat /etc/logstash/logstash.yml').stdout) -end - -def expect_setting(setting, value) - expect(logstash_settings[setting]).to eq(value) -end - -def pipelines_from_yaml - YAML.load(shell('cat /etc/logstash/pipelines.yml').stdout) -end - -def service_restart_message - "Service[logstash]: Triggered 'refresh'" -end - -def pe_package_url - distro, distro_version = ENV['BEAKER_set'].split('-') - case distro - when 'debian' - os = 'debian' - arch = 'amd64' - when 'centos' - os = 'el' - arch = 'x86_64' - when 'ubuntu' - os = 'ubuntu' - arch = 'amd64' - end - url_root = "https://s3.amazonaws.com/pe-builds/released/#{PE_VERSION}" - url = "#{url_root}/puppet-enterprise-#{PE_VERSION}-#{os}-#{distro_version}-#{arch}.tar.gz" -end - -def pe_package_filename - File.basename(pe_package_url) -end - -def puppet_enterprise? - ENV['BEAKER_IS_PE'] == 'true' || ENV['IS_PE'] == 'true' -end - -hosts.each do |host| - # Install Puppet - if puppet_enterprise? - pe_download = File.join(PE_DIR, pe_package_filename) - `curl -s -o #{pe_download} #{pe_package_url}` unless File.exist?(pe_download) - on host, "hostname #{host.name}" - install_pe_on(host, pe_ver: PE_VERSION) - else - if PUPPET_VERSION.start_with?('4.') - agent_version = agent_version_for_puppet_version(PUPPET_VERSION) - install_puppet_agent_on(host, puppet_agent_version: agent_version) - else - begin - install_puppet_on(host, version: PUPPET_VERSION) - rescue - install_puppet_from_gem_on(host, version: PUPPET_VERSION) - end - end - end - - if fact('osfamily') == 'Suse' - if fact('operatingsystem') == 'OpenSuSE' - install_package host, 'ruby-devel augeas-devel libxml2-devel' - on host, 'gem install ruby-augeas --no-ri --no-rdoc' - end - end - - # Update package cache for those who need it. - on host, 'apt-get update' if fact('osfamily') == 'Debian' - - # Aquire a binary package of Logstash. - logstash_download = "spec/fixtures/artifacts/#{logstash_package_filename}" - `curl -s -o #{logstash_download} #{http_package_url}` unless File.exist?(logstash_download) - # ...send it to the test host - scp_to(host, logstash_download, '/tmp/') - # ...and also make it available as a "puppet://" url, by putting it in the - # 'files' directory of the Logstash module. - FileUtils.cp(logstash_download, './files/') - - # ...and put some grok pattern examples in their too. - Dir.glob('./spec/fixtures/grok-patterns/*').each do |f| - FileUtils.cp(f, './files/') - end - - # Provide a Logstash plugin as a local Gem. - scp_to(host, './spec/fixtures/plugins/logstash-output-cowsay-5.0.0.gem', '/tmp/') - - # ...and another plugin that can be fetched from Puppet with "puppet://" - FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowthink-5.0.0.gem', './files/') - - # ...and yet another plugin, this time packaged as an offline installer - FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowsay-5.0.0.zip', './files/') - - # Provide a config file template. - FileUtils.cp('./spec/fixtures/templates/configfile-template.erb', './templates/') - - # Provide this module to the test system. - project_root = File.dirname(File.dirname(__FILE__)) - install_dev_puppet_module_on(host, source: project_root, module_name: 'logstash') - - # Also install any other modules we need on the test system. - install_puppet_module_via_pmt_on(host, module_name: 'elastic-elastic_stack') - install_puppet_module_via_pmt_on(host, module_name: 'darin-zypprepo') -end - -RSpec.configure do |c| - # Readable test descriptions - c.formatter = :documentation - c.color = true - - # declare an exclusion filter - c.filter_run_excluding broken: true -end +Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From 78a87989884ee1a8c7219391a8549a30ba43e571 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:43:46 +0100 Subject: [PATCH 02/16] rubocop: safe autocorrect --- spec/acceptance/00_meta_spec.rb | 14 ++-- spec/acceptance/class_logstash_spec.rb | 74 +++++++++++----------- spec/acceptance/class_plugin_spec.rb | 13 ++-- spec/acceptance/define_patternfile_spec.rb | 16 ++--- spec/defines/define_plugin_spec.rb | 6 +- spec/spec_helper_acceptance.rb | 2 - 6 files changed, 62 insertions(+), 63 deletions(-) diff --git a/spec/acceptance/00_meta_spec.rb b/spec/acceptance/00_meta_spec.rb index f1575c81..6d742f67 100644 --- a/spec/acceptance/00_meta_spec.rb +++ b/spec/acceptance/00_meta_spec.rb @@ -2,28 +2,28 @@ # Here we put the more basic fundamental tests, ultra obvious stuff. describe 'puppet' do - it "should have an lsbdistdescription fact" do - expect(fact('lsbdistdescription')).to match(/(centos|ubuntu|debian|suse)/i) + it 'has an lsbdistdescription fact' do + expect(fact('lsbdistdescription')).to match(%r{(centos|ubuntu|debian|suse)}i) end - desired_version = PUPPET_VERSION[/(\d+\.\d+)/] unless puppet_enterprise? - desired_version = "Puppet Enterprise #{PE_VERSION[/(\d+\.\d+)/]}" if puppet_enterprise? + desired_version = PUPPET_VERSION[%r{(\d+\.\d+)}] unless puppet_enterprise? + desired_version = "Puppet Enterprise #{PE_VERSION[%r{(\d+\.\d+)}]}" if puppet_enterprise? - it "should be version: #{desired_version}.x" do + it "is version: #{desired_version}.x" do actual_version = shell('puppet --version').stdout.chomp expect(actual_version).to contain(desired_version) end end describe 'logstash module' do - it 'should be available' do + it 'is available' do shell( "ls #{default['distmoduledir']}/logstash/metadata.json", acceptable_exit_codes: 0 ) end - it 'should be parsable' do + it 'is parsable' do shell( "puppet parser validate #{default['distmoduledir']}/logstash/manifests/*.pp", acceptable_exit_codes: 0 diff --git a/spec/acceptance/class_logstash_spec.rb b/spec/acceptance/class_logstash_spec.rb index 42947214..9a7ac977 100644 --- a/spec/acceptance/class_logstash_spec.rb +++ b/spec/acceptance/class_logstash_spec.rb @@ -1,40 +1,39 @@ require 'spec_helper_acceptance' shared_examples 'a logstash installer' do - it "should install logstash version #{LS_VERSION}" do + it "installs logstash version #{LS_VERSION}" do expect(shell('/usr/share/logstash/bin/logstash --version').stdout).to eq("logstash #{LS_VERSION}\n") end case fact('osfamily') when 'RedHat', 'Suse' describe package('logstash') do - it { should be_installed } + it { is_expected.to be_installed } end when 'Debian' # Serverspec has been falsely reporting the package as not installed on # Debian 7, so we'll implement our own version of "should be_installed". - it "should install logstash package version #{logstash_package_version}" do + it "installs logstash package version #{logstash_package_version}" do apt_output = shell('apt-cache policy logstash').stdout expect(apt_output).to include("Installed: #{logstash_package_version}") end end describe service('logstash') do - it { should be_running } - it 'should be_enabled' do - if fact('lsbdistdescription') =~ /centos release 6/i - skip('Serverspec seems confused about this on Centos 6.') - end - should be_enabled + it { is_expected.to be_running } + + it 'be_enableds' do + skip('Serverspec seems confused about this on Centos 6.') if fact('lsbdistdescription') =~ %r{centos release 6}i + is_expected.to be_enabled end end - it 'should spawn a single logstash process' do + it 'spawns a single logstash process' do expect(logstash_process_list.length).to eq(1) end - it 'should run logstash as the "logstash" user' do - expect(logstash_process_list.pop).to match(/^logstash /) + it 'runs logstash as the "logstash" user' do + expect(logstash_process_list.pop).to match(%r{^logstash }) end end @@ -48,7 +47,7 @@ it_behaves_like 'a logstash installer' - it 'should be idempotent' do + it 'is idempotent' do expect_no_change_from_manifest(install_logstash_manifest) end end @@ -87,18 +86,19 @@ remove_logstash end - it 'should be idempotent' do + it 'is idempotent' do expect_no_change_from_manifest(remove_logstash_manifest) end describe package('logstash') do - it { should_not be_installed } + it { is_expected.not_to be_installed } end describe service('logstash') do - it { should_not be_running } - it 'should not be enabled' do - should_not be_enabled + it { is_expected.not_to be_running } + + it 'is not enabled' do + is_expected.not_to be_enabled end end end @@ -119,19 +119,19 @@ install_logstash_from_local_file("settings => #{settings}") end - it 'it sets "http.port" to "9999"' do + it 'sets "http.port" to "9999"' do expect_setting('http.port', '9999') end - it 'it retains the default "path.data" setting' do + it 'retains the default "path.data" setting' do expect_setting('path.data', '/var/lib/logstash') end - it 'it retains the default "path.config" setting' do + it 'retains the default "path.config" setting' do expect_setting('path.config', '/etc/logstash/conf.d') end - it 'it retains the default "path.logs" setting' do + it 'retains the default "path.logs" setting' do expect_setting('path.logs', '/var/log/logstash') end end @@ -178,8 +178,8 @@ install_logstash_from_local_file("startup_options => #{startup_options}") end - it 'should run logstash as root' do - expect(logstash_process_list.pop).to match(/^root /) + it 'runs logstash as root' do + expect(logstash_process_list.pop).to match(%r{^root }) end end end @@ -191,15 +191,15 @@ install_logstash_from_local_file("jvm_options => #{jvm_options}") end - it 'should run java with -Xms1g' do + it 'runs java with -Xms1g' do expect(logstash_process_list.pop).to include('-Xms1g') end - it 'should not run java with the default of -Xms256m' do + it 'does not run java with the default of -Xms256m' do expect(logstash_process_list.pop).not_to include('-Xms256m') end - it 'should run java with the default "expert" flags' do + it 'runs java with the default "expert" flags' do expert_flags = [ '-Dfile.encoding=UTF-8', '-Djava.awt.headless=true', @@ -216,17 +216,19 @@ end context 'when the option is changed' do - it 'should restart logstash' do + it 'restarts logstash' do puppet_log = install_logstash_from_local_file( - "jvm_options => [ '-Xms512m' ]").stdout + "jvm_options => [ '-Xms512m' ]" + ).stdout expect(puppet_log).to include(service_restart_message) end context 'when restart_on_change is false' do - it 'should not restart logstash' do + it 'does not restart logstash' do puppet_log = install_logstash_from_local_file( "jvm_options => [ '-Xms256m' ], - restart_on_change => false").stdout + restart_on_change => false" + ).stdout expect(puppet_log).not_to include(service_restart_message) end end @@ -235,7 +237,7 @@ end describe 'pipelines_parameter' do - context "with pipelines declared" do + context 'with pipelines declared' do before(:context) do pipelines_puppet = <<-END [ @@ -252,12 +254,12 @@ install_logstash_from_local_file("pipelines => #{pipelines_puppet}") end - it 'should render them to pipelines.yml' do + it 'renders them to pipelines.yml' do expect(pipelines_from_yaml[0]['pipeline.id']).to eq('pipeline_one') expect(pipelines_from_yaml[1]['pipeline.id']).to eq('pipeline_two') end - it 'should remove "path.config" from "logstash.yml"' do + it 'removes "path.config" from "logstash.yml"' do expect(logstash_settings['path.config']).to be_nil end end @@ -270,7 +272,7 @@ install_logstash_from_local_file("settings => #{settings_puppet_code}") end - it 'should remove "path.config" from "logstash.yml"' do + it 'removes "path.config" from "logstash.yml"' do expect(logstash_settings['path.config']).to be_nil end end @@ -289,7 +291,7 @@ install_logstash_from_local_file("settings => #{settings_puppet_code}") end - it 'should remove "path.config" from "logstash.yml"' do + it 'removes "path.config" from "logstash.yml"' do expect(logstash_settings['path.config']).to be_nil end end diff --git a/spec/acceptance/class_plugin_spec.rb b/spec/acceptance/class_plugin_spec.rb index b9fdd2f3..3e63eb5b 100644 --- a/spec/acceptance/class_plugin_spec.rb +++ b/spec/acceptance/class_plugin_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper_acceptance' describe 'class plugin' do @@ -11,9 +10,9 @@ class { 'logstash': -> logstash::plugin { '#{plugin}': ensure => #{present_absent}, - #{extra_args if extra_args} + #{extra_args} } - END + END apply_manifest(manifest, catch_failures: true) end @@ -26,13 +25,13 @@ def remove(plugin) end context 'when a plugin is not installed' do - before(:each) do + before do remove('logstash-input-sqs') end it 'will not remove it again' do log = ensure_plugin('absent', 'logstash-input-sqs').stdout - expect(log).to_not contain('remove-logstash-input-sqs') + expect(log).not_to contain('remove-logstash-input-sqs') end it 'can install it from rubygems' do @@ -42,13 +41,13 @@ def remove(plugin) end context 'when a plugin is installed' do - before(:each) do + before do expect(installed_plugins).to contain('logstash-input-file') end it 'will not install it again' do log = ensure_plugin('present', 'logstash-input-file').stdout - expect(log).to_not contain('install-logstash-input-file') + expect(log).not_to contain('install-logstash-input-file') end it 'can remove it' do diff --git a/spec/acceptance/define_patternfile_spec.rb b/spec/acceptance/define_patternfile_spec.rb index ad2287d1..270067d7 100644 --- a/spec/acceptance/define_patternfile_spec.rb +++ b/spec/acceptance/define_patternfile_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper_acceptance' describe 'class patternfile' do @@ -10,7 +9,7 @@ def apply_pattern(pattern_number, extra_logstash_class_args = nil) source => 'puppet:///modules/logstash/grok-pattern-#{pattern_number}', filename => 'the_only_pattern_file', } - END + END apply_manifest(manifest) end @@ -18,13 +17,14 @@ def apply_pattern(pattern_number, extra_logstash_class_args = nil) before(:context) { apply_pattern(0) } describe file '/etc/logstash/patterns/the_only_pattern_file' do - it { should be_a_file } - its(:content) { should match(/GROK_PATTERN_0/) } + it { is_expected.to be_a_file } + its(:content) { is_expected.to match(%r{GROK_PATTERN_0}) } end end context 'with a pattern file in place' do - before(:each) { apply_pattern(0) } + before { apply_pattern(0) } + restart_message = 'Scheduling refresh of Service[logstash]' it 'restarts logstash when a pattern file changes' do @@ -34,11 +34,9 @@ def apply_pattern(pattern_number, extra_logstash_class_args = nil) it 'does not restart logstash if logstash::restart_on_change is false' do os = fact('lsbdistdescription') - if (os =~ /(centos release 6\.|ubuntu 12\.04)/i) && PUPPET_VERSION[0] == '3' - skip('Something funky happening with Upstart and Puppet 3?') - end + skip('Something funky happening with Upstart and Puppet 3?') if (os =~ %r{(centos release 6\.|ubuntu 12\.04)}i) && PUPPET_VERSION[0] == '3' log = apply_pattern(1, 'restart_on_change => false').stdout expect(log).not_to include(restart_message) end end - end +end diff --git a/spec/defines/define_plugin_spec.rb b/spec/defines/define_plugin_spec.rb index 785472f5..0de3eb17 100644 --- a/spec/defines/define_plugin_spec.rb +++ b/spec/defines/define_plugin_spec.rb @@ -7,10 +7,12 @@ facts end - let(:pre_condition) { %q( + let(:pre_condition) do + ' include elastic_stack::repo include logstash - )} + ' + end let(:title) { 'logstash-input-mysql' } diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3a6e23c..f803ae59 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -5,6 +5,4 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' -configure_beaker - Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From c049d5af58bbb9cb72d752c8feb53aa2c30a8346 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:44:12 +0100 Subject: [PATCH 03/16] rubocop: Fix Style/FrozenStringLiteralComment --- spec/acceptance/00_meta_spec.rb | 2 ++ spec/acceptance/class_logstash_spec.rb | 2 ++ spec/acceptance/class_plugin_spec.rb | 2 ++ spec/acceptance/define_configfile_spec.rb | 2 ++ spec/acceptance/define_patternfile_spec.rb | 2 ++ spec/defines/define_plugin_spec.rb | 2 ++ 6 files changed, 12 insertions(+) diff --git a/spec/acceptance/00_meta_spec.rb b/spec/acceptance/00_meta_spec.rb index 6d742f67..002d74f5 100644 --- a/spec/acceptance/00_meta_spec.rb +++ b/spec/acceptance/00_meta_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' # Here we put the more basic fundamental tests, ultra obvious stuff. diff --git a/spec/acceptance/class_logstash_spec.rb b/spec/acceptance/class_logstash_spec.rb index 9a7ac977..ca8ba792 100644 --- a/spec/acceptance/class_logstash_spec.rb +++ b/spec/acceptance/class_logstash_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' shared_examples 'a logstash installer' do diff --git a/spec/acceptance/class_plugin_spec.rb b/spec/acceptance/class_plugin_spec.rb index 3e63eb5b..8983f024 100644 --- a/spec/acceptance/class_plugin_spec.rb +++ b/spec/acceptance/class_plugin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'class plugin' do diff --git a/spec/acceptance/define_configfile_spec.rb b/spec/acceptance/define_configfile_spec.rb index 809f8e6c..baa94378 100644 --- a/spec/acceptance/define_configfile_spec.rb +++ b/spec/acceptance/define_configfile_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'define logstash::configfile' do diff --git a/spec/acceptance/define_patternfile_spec.rb b/spec/acceptance/define_patternfile_spec.rb index 270067d7..fecb57fd 100644 --- a/spec/acceptance/define_patternfile_spec.rb +++ b/spec/acceptance/define_patternfile_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'class patternfile' do diff --git a/spec/defines/define_plugin_spec.rb b/spec/defines/define_plugin_spec.rb index 0de3eb17..e8c28c43 100644 --- a/spec/defines/define_plugin_spec.rb +++ b/spec/defines/define_plugin_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'logstash::plugin' do From 30c0cbd81aff25d77b66e44e1c76abdef7e1bf69 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:46:58 +0100 Subject: [PATCH 04/16] Add Puppet 6/7 support --- .fixtures.yml | 1 + metadata.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 7fc2ed14..80aacd50 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -4,3 +4,4 @@ fixtures: stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git zypprepo: https://github.com/voxpupuli/puppet-zypprepo.git elastic_stack: https://github.com/voxpupuli/puppet-elastic_stack.git + yumrepo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git diff --git a/metadata.json b/metadata.json index e6d20c62..fccd4536 100644 --- a/metadata.json +++ b/metadata.json @@ -70,7 +70,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=4.6.1 <6.0.0" + "version_requirement": ">=4.6.1 < 8.0.0" } ] } From d9cd80460854a0c289b13a0eeb2c0854f192030d Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:47:49 +0100 Subject: [PATCH 05/16] Drop Puppet 4/5 support --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index fccd4536..ce208524 100644 --- a/metadata.json +++ b/metadata.json @@ -70,7 +70,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=4.6.1 < 8.0.0" + "version_requirement": ">= 6.1.0 < 8.0.0" } ] } From 621828a28ea6babca3dd2907b038b061ba936bd7 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:48:15 +0100 Subject: [PATCH 06/16] Drop EoL CentOS 6 support --- metadata.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/metadata.json b/metadata.json index ce208524..9515f544 100644 --- a/metadata.json +++ b/metadata.json @@ -21,28 +21,24 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ - "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ - "6", "7" ] }, From 8f7f8573dc90a6edbe4c1cf420f3eef0522d73bd Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:49:30 +0100 Subject: [PATCH 07/16] Delete legacy nodesets --- spec/acceptance/nodesets/centos-6-docker.yml | 17 ---------- spec/acceptance/nodesets/centos-6-vagrant.yml | 8 ----- spec/acceptance/nodesets/centos-6.yml | 1 - spec/acceptance/nodesets/centos-7-docker.yml | 17 ---------- spec/acceptance/nodesets/centos-7-vagrant.yml | 8 ----- spec/acceptance/nodesets/centos-7.yml | 1 - spec/acceptance/nodesets/debian-7-docker.yml | 33 ------------------- spec/acceptance/nodesets/debian-7-vagrant.yml | 9 ----- spec/acceptance/nodesets/debian-7.yml | 1 - spec/acceptance/nodesets/debian-8-docker.yml | 18 ---------- spec/acceptance/nodesets/debian-8-vagrant.yml | 8 ----- spec/acceptance/nodesets/debian-8.yml | 1 - spec/acceptance/nodesets/default.yml | 1 - .../nodesets/opensuse-13-docker.yml | 20 ----------- .../nodesets/opensuse-13-vagrant.yml | 8 ----- spec/acceptance/nodesets/opensuse-13.yml | 1 - spec/acceptance/nodesets/sles-11-docker.yml | 18 ---------- spec/acceptance/nodesets/sles-11-vagrant.yml | 13 -------- spec/acceptance/nodesets/sles-11.yml | 1 - .../nodesets/ubuntu-1204-docker.yml | 31 ----------------- spec/acceptance/nodesets/ubuntu-1204.yml | 1 - .../nodesets/ubuntu-1404-docker.yml | 26 --------------- spec/acceptance/nodesets/ubuntu-1404.yml | 1 - spec/acceptance/nodesets/ubuntu-1604.yml | 25 -------------- 24 files changed, 268 deletions(-) delete mode 100644 spec/acceptance/nodesets/centos-6-docker.yml delete mode 100644 spec/acceptance/nodesets/centos-6-vagrant.yml delete mode 120000 spec/acceptance/nodesets/centos-6.yml delete mode 100644 spec/acceptance/nodesets/centos-7-docker.yml delete mode 100644 spec/acceptance/nodesets/centos-7-vagrant.yml delete mode 120000 spec/acceptance/nodesets/centos-7.yml delete mode 100644 spec/acceptance/nodesets/debian-7-docker.yml delete mode 100644 spec/acceptance/nodesets/debian-7-vagrant.yml delete mode 120000 spec/acceptance/nodesets/debian-7.yml delete mode 100644 spec/acceptance/nodesets/debian-8-docker.yml delete mode 100644 spec/acceptance/nodesets/debian-8-vagrant.yml delete mode 120000 spec/acceptance/nodesets/debian-8.yml delete mode 120000 spec/acceptance/nodesets/default.yml delete mode 100644 spec/acceptance/nodesets/opensuse-13-docker.yml delete mode 100644 spec/acceptance/nodesets/opensuse-13-vagrant.yml delete mode 120000 spec/acceptance/nodesets/opensuse-13.yml delete mode 100644 spec/acceptance/nodesets/sles-11-docker.yml delete mode 100644 spec/acceptance/nodesets/sles-11-vagrant.yml delete mode 120000 spec/acceptance/nodesets/sles-11.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-1204-docker.yml delete mode 120000 spec/acceptance/nodesets/ubuntu-1204.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-1404-docker.yml delete mode 120000 spec/acceptance/nodesets/ubuntu-1404.yml delete mode 100644 spec/acceptance/nodesets/ubuntu-1604.yml diff --git a/spec/acceptance/nodesets/centos-6-docker.yml b/spec/acceptance/nodesets/centos-6-docker.yml deleted file mode 100644 index 27c8a17b..00000000 --- a/spec/acceptance/nodesets/centos-6-docker.yml +++ /dev/null @@ -1,17 +0,0 @@ -HOSTS: - centos-6-x64: - roles: [agent, database, dashboard, master] - platform: el-6-x86_64 - image: library/centos:6 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - rm /etc/init/tty.conf - - yum install -y wget ntpdate redhat-lsb-core redhat-lsb rubygems ruby-augeas ruby-devel augeas-devel logrotate - - touch /etc/sysconfig/network - - 'cd / && wget -q --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jre-8u131-linux-x64.rpm"' - - 'cd / && yum localinstall -y jre-8u131-linux-x64.rpm' - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/centos-6-vagrant.yml b/spec/acceptance/nodesets/centos-6-vagrant.yml deleted file mode 100644 index 45646cdb..00000000 --- a/spec/acceptance/nodesets/centos-6-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - centos-6-x64: - platform: el-6-x86_64 - box: puppetlabs/centos-6.6-64-nocm - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/centos-6.yml b/spec/acceptance/nodesets/centos-6.yml deleted file mode 120000 index 2aced8ba..00000000 --- a/spec/acceptance/nodesets/centos-6.yml +++ /dev/null @@ -1 +0,0 @@ -centos-6-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/centos-7-docker.yml b/spec/acceptance/nodesets/centos-7-docker.yml deleted file mode 100644 index c81b48e4..00000000 --- a/spec/acceptance/nodesets/centos-7-docker.yml +++ /dev/null @@ -1,17 +0,0 @@ -HOSTS: - centos-7-x64: - roles: [agent, database, dashboard, master] - platform: el-7-x86_64 - image: centos:7 - hypervisor: docker - docker_cmd: '["/usr/sbin/init"]' - docker_image_commands: - - rm /lib/systemd/system/systemd*udev* - - rm /lib/systemd/system/getty.target - - yum install -y wget ntpdate redhat-lsb-core redhat-lsb rubygems ruby-devel augeas-devel ruby-augeas tar logrotate - - 'cd / && wget -q --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jre-8u131-linux-x64.rpm"' - - 'cd / && yum localinstall -y jre-8u131-linux-x64.rpm' - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/centos-7-vagrant.yml b/spec/acceptance/nodesets/centos-7-vagrant.yml deleted file mode 100644 index 03e088a6..00000000 --- a/spec/acceptance/nodesets/centos-7-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - box: puppetlabs/centos-7.2-64-nocm - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml deleted file mode 120000 index 4756a91c..00000000 --- a/spec/acceptance/nodesets/centos-7.yml +++ /dev/null @@ -1 +0,0 @@ -centos-7-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-7-docker.yml b/spec/acceptance/nodesets/debian-7-docker.yml deleted file mode 100644 index 727c1284..00000000 --- a/spec/acceptance/nodesets/debian-7-docker.yml +++ /dev/null @@ -1,33 +0,0 @@ -HOSTS: - debian-7: - roles: [agent, database, dashboard, master] - platform: debian-7-amd64 - image: debian:7 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - # The base image contains a stub shell script in place of '/sbin/initctl' which - # confuses the heck out of Pleaserun when installing Logstash. - # REF: https://github.com/jordansissel/pleaserun/blob/master/lib/pleaserun/detector.rb - - rm /sbin/initctl - - - apt-get update - - apt-get -y upgrade - - apt-get install -yq apt-transport-https lsb-release wget net-tools ruby rubygems ruby1.8-dev libaugeas-dev libaugeas-ruby ntpdate locales-all logrotate procps - - # Install Oracle Java 8 - - echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list - - echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list - - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 - - apt-get -y update - - echo 'debconf shared/accepted-oracle-license-v1-1 select true' | debconf-set-selections - - echo 'debconf shared/accepted-oracle-license-v1-1 seen true' | debconf-set-selections - - apt-get install -yq oracle-java8-installer - - apt-get install -yq oracle-java8-set-default - - - REALLY_GEM_UPDATE_SYSTEM=1 gem update --system --no-ri --no-rdoc - docker_preserve_image: true - -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/debian-7-vagrant.yml b/spec/acceptance/nodesets/debian-7-vagrant.yml deleted file mode 100644 index 3af37c1b..00000000 --- a/spec/acceptance/nodesets/debian-7-vagrant.yml +++ /dev/null @@ -1,9 +0,0 @@ -HOSTS: - debian-7: - roles: [agent, database, dashboard, master] - platform: debian-7-amd64 - box: puppetlabs/debian-7.8-64-nocm - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/debian-7.yml b/spec/acceptance/nodesets/debian-7.yml deleted file mode 120000 index 098c1b6a..00000000 --- a/spec/acceptance/nodesets/debian-7.yml +++ /dev/null @@ -1 +0,0 @@ -debian-7-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/debian-8-docker.yml b/spec/acceptance/nodesets/debian-8-docker.yml deleted file mode 100644 index a73fc6e5..00000000 --- a/spec/acceptance/nodesets/debian-8-docker.yml +++ /dev/null @@ -1,18 +0,0 @@ -HOSTS: - debian-8: - roles: [agent, database, dashboard, master] - platform: debian-8-amd64 - image: debian:jessie-backports - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - rm /lib/systemd/system/systemd*udev* - - rm /lib/systemd/system/getty.target - - apt-get update - - apt-get install -yq apt-transport-https ruby ruby-dev lsb-release wget net-tools libaugeas-dev libaugeas-ruby ntpdate locales-all logrotate - - apt-get install -yq -t jessie-backports openjdk-8-jre-headless ca-certificates-java - - REALLY_GEM_UPDATE_SYSTEM=1 gem update --system --no-ri --no-rdoc - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/debian-8-vagrant.yml b/spec/acceptance/nodesets/debian-8-vagrant.yml deleted file mode 100644 index f6829a12..00000000 --- a/spec/acceptance/nodesets/debian-8-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - box: puppetlabs/debian-8.2-64-nocm - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/debian-8.yml b/spec/acceptance/nodesets/debian-8.yml deleted file mode 120000 index abb98ce2..00000000 --- a/spec/acceptance/nodesets/debian-8.yml +++ /dev/null @@ -1 +0,0 @@ -debian-8-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml deleted file mode 120000 index d3846865..00000000 --- a/spec/acceptance/nodesets/default.yml +++ /dev/null @@ -1 +0,0 @@ -ubuntu-1404.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/opensuse-13-docker.yml b/spec/acceptance/nodesets/opensuse-13-docker.yml deleted file mode 100644 index c0081c1a..00000000 --- a/spec/acceptance/nodesets/opensuse-13-docker.yml +++ /dev/null @@ -1,20 +0,0 @@ -HOSTS: - opensuse-13: - platform: sles-13-x86_64 # Not really, but Beaker doesn't know about OpenSuSE! - image: library/opensuse:13.2 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - zypper install -y lsb dbus-1 rubygems which augeas augeas-lenses wget - - zypper install -y -t pattern devel_basis || true - - mkdir -p /etc/selinux/targeted/contexts/ - - echo '' > /etc/selinux/targeted/contexts/dbus_contexts - - mkdir /etc/systemd/system/sshd.service.d/ - - echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/sshd -D" - - ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service - - 'cd / && wget -q --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jre-8u111-linux-x64.rpm"' - - 'cd / && zypper install -y jre-8u111-linux-x64.rpm' - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/opensuse-13-vagrant.yml b/spec/acceptance/nodesets/opensuse-13-vagrant.yml deleted file mode 100644 index 61af7397..00000000 --- a/spec/acceptance/nodesets/opensuse-13-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - opensuse-131-x64: - platform: sles-13-x64 - box: elastic/opensuse-13-x86_64 - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/opensuse-13.yml b/spec/acceptance/nodesets/opensuse-13.yml deleted file mode 120000 index cb70ff73..00000000 --- a/spec/acceptance/nodesets/opensuse-13.yml +++ /dev/null @@ -1 +0,0 @@ -opensuse-13-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/sles-11-docker.yml b/spec/acceptance/nodesets/sles-11-docker.yml deleted file mode 100644 index 92aa07f9..00000000 --- a/spec/acceptance/nodesets/sles-11-docker.yml +++ /dev/null @@ -1,18 +0,0 @@ -HOSTS: - sles-11: - platform: sles-11-x86_64 - image: netways/sles-11-sp3-x86_64 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - zypper install -y dbus-1 rubygems which augeas augeas-lenses wget - - zypper install -y -t pattern devel_basis || true - - mkdir -p /etc/selinux/targeted/contexts/ - - echo '' > /etc/selinux/targeted/contexts/dbus_contexts - - mkdir /etc/systemd/system/sshd.service.d/ - - echo -e "[Service]\nExecStart=\nExecStart=/usr/bin/sshd -D" - - ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/sshd.service - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/sles-11-vagrant.yml b/spec/acceptance/nodesets/sles-11-vagrant.yml deleted file mode 100644 index a45f110e..00000000 --- a/spec/acceptance/nodesets/sles-11-vagrant.yml +++ /dev/null @@ -1,13 +0,0 @@ -HOSTS: - sles-11-x64: - roles: - - master - - database - - dashboard - platform: sles-11-x86_64 - box: sles-11sp3-x64 - box_url: https://s3-eu-west-1.amazonaws.com/users.eu.elasticsearch.org/electrical/sles-11sp3-x64.box - hypervisor: vagrant -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/sles-11.yml b/spec/acceptance/nodesets/sles-11.yml deleted file mode 120000 index bcca9500..00000000 --- a/spec/acceptance/nodesets/sles-11.yml +++ /dev/null @@ -1 +0,0 @@ -sles-11-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/ubuntu-1204-docker.yml b/spec/acceptance/nodesets/ubuntu-1204-docker.yml deleted file mode 100644 index 1cda899b..00000000 --- a/spec/acceptance/nodesets/ubuntu-1204-docker.yml +++ /dev/null @@ -1,31 +0,0 @@ -HOSTS: - ubuntu-12-04: - roles: - - master - - database - - dashboard - platform: ubuntu-12.04-amd64 - image: library/ubuntu:12.04 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - # The base image disables Upstart, which is the "right thing" to do for - # containers. However, we actually want Upstart, because we are trying - # to simulate a full system. Thus, we undo the magic from upstream's - # Dockerfile. - # REF: https://github.com/tianon/docker-brew-ubuntu-core/blob/aec74cf404240664b289d28948d9284a4afd1181/precise/Dockerfile#L14 - - rm /sbin/initctl - - dpkg-divert --rename --remove /sbin/initctl - - - apt-get install -yq apt-transport-https ruby1.8-dev libaugeas-dev libaugeas-ruby ruby rubygems lsb-release wget net-tools curl python-software-properties - - # Install Oracle Java 8 - - echo 'debconf shared/accepted-oracle-license-v1-1 select true' | debconf-set-selections - - echo 'debconf shared/accepted-oracle-license-v1-1 seen true' | debconf-set-selections - - apt-add-repository ppa:webupd8team/java - - apt-get update - - apt-get install -yq oracle-java8-installer - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/ubuntu-1204.yml b/spec/acceptance/nodesets/ubuntu-1204.yml deleted file mode 120000 index 6489cd84..00000000 --- a/spec/acceptance/nodesets/ubuntu-1204.yml +++ /dev/null @@ -1 +0,0 @@ -ubuntu-1204-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/ubuntu-1404-docker.yml b/spec/acceptance/nodesets/ubuntu-1404-docker.yml deleted file mode 100644 index 63e6c7b1..00000000 --- a/spec/acceptance/nodesets/ubuntu-1404-docker.yml +++ /dev/null @@ -1,26 +0,0 @@ -HOSTS: - ubuntu-14-04: - roles: - - master - - database - - dashboard - platform: ubuntu-14.04-amd64 - image: electrical/ubuntu:14.04 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - apt-get update - - apt-get install -yq apt-transport-https ruby ruby1.9.1-dev libaugeas-dev libaugeas-ruby lsb-release wget net-tools curl software-properties-common - - # Install Oracle Java 8 - - echo 'debconf shared/accepted-oracle-license-v1-1 select true' | debconf-set-selections - - echo 'debconf shared/accepted-oracle-license-v1-1 seen true' | debconf-set-selections - - apt-add-repository ppa:webupd8team/java - - apt-get update - - apt-get install -yq oracle-java8-installer - - apt-get install -yq oracle-java8-set-default - docker_preserve_image: true - -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. diff --git a/spec/acceptance/nodesets/ubuntu-1404.yml b/spec/acceptance/nodesets/ubuntu-1404.yml deleted file mode 120000 index bd89387b..00000000 --- a/spec/acceptance/nodesets/ubuntu-1404.yml +++ /dev/null @@ -1 +0,0 @@ -ubuntu-1404-docker.yml \ No newline at end of file diff --git a/spec/acceptance/nodesets/ubuntu-1604.yml b/spec/acceptance/nodesets/ubuntu-1604.yml deleted file mode 100644 index 54896dbb..00000000 --- a/spec/acceptance/nodesets/ubuntu-1604.yml +++ /dev/null @@ -1,25 +0,0 @@ -HOSTS: - ubuntu-16-04: - roles: - - master - - database - - dashboard - platform: ubuntu-16.04-amd64 - image: library/ubuntu:16.04 - hypervisor: docker - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - apt-get update - - apt-get install -yq apt-transport-https ruby-dev libaugeas-dev ruby rubygems lsb-release wget net-tools curl software-properties-common - - # Install Oracle Java 8 - - echo 'debconf shared/accepted-oracle-license-v1-1 select true' | debconf-set-selections - - echo 'debconf shared/accepted-oracle-license-v1-1 seen true' | debconf-set-selections - - apt-add-repository ppa:webupd8team/java - - apt-get update - - apt-get install -yq oracle-java8-installer - - apt-get install -yq oracle-java8-set-default - docker_preserve_image: true -CONFIG: - type: foss - :trace_limit: 100 # Get more than 10 lines of trace when something fails. From 0a7695d249e719a7fa203301e5db54c7b4270cc1 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:52:35 +0100 Subject: [PATCH 08/16] drop useless acceptance test --- spec/acceptance/00_meta_spec.rb | 34 --------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 spec/acceptance/00_meta_spec.rb diff --git a/spec/acceptance/00_meta_spec.rb b/spec/acceptance/00_meta_spec.rb deleted file mode 100644 index 002d74f5..00000000 --- a/spec/acceptance/00_meta_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper_acceptance' - -# Here we put the more basic fundamental tests, ultra obvious stuff. -describe 'puppet' do - it 'has an lsbdistdescription fact' do - expect(fact('lsbdistdescription')).to match(%r{(centos|ubuntu|debian|suse)}i) - end - - desired_version = PUPPET_VERSION[%r{(\d+\.\d+)}] unless puppet_enterprise? - desired_version = "Puppet Enterprise #{PE_VERSION[%r{(\d+\.\d+)}]}" if puppet_enterprise? - - it "is version: #{desired_version}.x" do - actual_version = shell('puppet --version').stdout.chomp - expect(actual_version).to contain(desired_version) - end -end - -describe 'logstash module' do - it 'is available' do - shell( - "ls #{default['distmoduledir']}/logstash/metadata.json", - acceptable_exit_codes: 0 - ) - end - - it 'is parsable' do - shell( - "puppet parser validate #{default['distmoduledir']}/logstash/manifests/*.pp", - acceptable_exit_codes: 0 - ) - end -end From 8b801679c1695274e3a101ace0c6a4837da2d220 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Thu, 3 Feb 2022 08:54:04 +0100 Subject: [PATCH 09/16] rubocop: fix remaining violations --- spec/acceptance/class_plugin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/class_plugin_spec.rb b/spec/acceptance/class_plugin_spec.rb index 8983f024..1188f560 100644 --- a/spec/acceptance/class_plugin_spec.rb +++ b/spec/acceptance/class_plugin_spec.rb @@ -43,7 +43,7 @@ def remove(plugin) end context 'when a plugin is installed' do - before do + it 'will contain the required plugin' do expect(installed_plugins).to contain('logstash-input-file') end From bf7b60601b3dc2130c7fb1c7c0e893c94c0966af Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 2 Sep 2022 08:20:58 +0200 Subject: [PATCH 10/16] add old spec_helper_acceptance.rb as helpers.rb --- spec/support/acceptance/helpers.rb | 317 +++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 spec/support/acceptance/helpers.rb diff --git a/spec/support/acceptance/helpers.rb b/spec/support/acceptance/helpers.rb new file mode 100644 index 00000000..bdb0194d --- /dev/null +++ b/spec/support/acceptance/helpers.rb @@ -0,0 +1,317 @@ +# frozen_string_literal: true + +require 'beaker-rspec' +require 'net/http' +require 'pry' +require 'securerandom' +require 'yaml' + +# Collect global options from the environment. +ENV['LOGSTASH_VERSION'] = '7.17.6' +raise 'Please set the LOGSTASH_VERSION environment variable.' if ENV['LOGSTASH_VERSION'].nil? + +LS_VERSION = ENV['LOGSTASH_VERSION'] +PUPPET_VERSION = ENV['PUPPET_VERSION'] || '4.10.7' + +PE_VERSION = ENV['BEAKER_PE_VER'] || ENV['PE_VERSION'] || '3.8.3' +PE_DIR = ENV['BEAKER_PE_DIR'] + +IS_PRERELEASE = if LS_VERSION =~ %r{(alpha|beta|rc)} + true + else + false + end + +def agent_version_for_puppet_version(puppet_version) + # REF: https://docs.puppet.com/puppet/latest/reference/about_agent.html + version_map = { + # Puppet => Agent + '4.9.4' => '1.9.3', + '4.8.2' => '1.8.3', + '4.8.1' => '1.8.2', + '4.8.0' => '1.8.0', + '4.7.1' => '1.7.2', + '4.7.0' => '1.7.1', + '4.6.2' => '1.6.2', + '4.6.1' => '1.6.1', + '4.6.0' => '1.6.0', + '4.5.3' => '1.5.3', + '4.4.2' => '1.4.2', + '4.4.1' => '1.4.1', + '4.4.0' => '1.4.0', + '4.3.2' => '1.3.6', + '4.3.1' => '1.3.2', + '4.3.0' => '1.3.0', + '4.2.3' => '1.2.7', + '4.2.2' => '1.2.6', + '4.2.1' => '1.2.2', + '4.2.0' => '1.2.1', + '4.1.0' => '1.1.1', + '4.0.0' => '1.0.1' + } + version_map[puppet_version] +end + +def apply_manifest_fixture(manifest_name) + manifest = File.read("./spec/fixtures/manifests/#{manifest_name}.pp") + apply_manifest(manifest, catch_failures: true) +end + +def expect_no_change_from_manifest(manifest) + expect(apply_manifest(manifest).exit_code).to eq(0) +end + +def http_package_url + url_root = "https://artifacts.elastic.co/downloads/logstash/logstash-#{LS_VERSION}" + + case fact('osfamily') + when 'Debian' + "#{url_root}.deb" + when 'RedHat', 'Suse' + "#{url_root}.rpm" + end +end + +def local_file_package_url + "file:///tmp/#{logstash_package_filename}" +end + +def puppet_fileserver_package_url + "puppet:///modules/logstash/#{logstash_package_filename}" +end + +def logstash_package_filename + File.basename(http_package_url) +end + +def logstash_package_version + package_version = if LS_VERSION =~ %r{(alpha|beta|rc)} + LS_VERSION.gsub('-', '~') + else + LS_VERSION + end + + case fact('osfamily') # FIXME: Put this logic in the module, not the tests. + when 'RedHat' + "#{package_version}-1" + when 'Debian', 'Suse' + "1:#{package_version}-1" + end +end + +def logstash_config_manifest + <<-END + logstash::configfile { 'basic_config': + content => 'input { tcp { port => 2000 } } output { null {} }' + } + END +end + +def install_logstash_manifest(extra_args = nil) + <<-END + class { 'elastic_stack::repo': + version => #{LS_VERSION[0]}, + prerelease => #{IS_PRERELEASE}, + } + class { 'logstash': + manage_repo => true, + version => '#{logstash_package_version}', + #{extra_args} + } + + #{logstash_config_manifest} + END +end + +def include_logstash_manifest + <<-END + class { 'elastic_stack::repo': + version => #{LS_VERSION[0]}, + prerelease => #{IS_PRERELEASE}, + } + + include logstash + + #{logstash_config_manifest} + END +end + +def install_logstash_from_url_manifest(url, extra_args = nil) + <<-END + class { 'logstash': + package_url => '#{url}', + #{extra_args} + } + + #{logstash_config_manifest} + END +end + +def install_logstash_from_local_file_manifest(extra_args = nil) + install_logstash_from_url_manifest(local_file_package_url, extra_args) +end + +def remove_logstash_manifest + "class { 'logstash': ensure => 'absent' }" +end + +def stop_logstash_manifest + "class { 'logstash': status => 'disabled' }" +end + +# Provide a basic Logstash install. Useful as a testing pre-requisite. +def install_logstash(extra_args = nil) + result = apply_manifest(install_logstash_manifest(extra_args), catch_failures: true) + sleep 5 # FIXME: This is horrible. + result +end + +def include_logstash + result = apply_manifest(include_logstash_manifest, catch_failures: true, debug: true) + sleep 5 # FIXME: This is horrible. + result +end + +def install_logstash_from_url(url, extra_args = nil) + manifest = install_logstash_from_url_manifest(url, extra_args) + result = apply_manifest(manifest, catch_failures: true) + sleep 5 # FIXME: This is horrible. + result +end + +def install_logstash_from_local_file(extra_args = nil) + install_logstash_from_url(local_file_package_url, extra_args) +end + +def remove_logstash + result = apply_manifest(remove_logstash_manifest) + sleep 5 # FIXME: This is horrible. + result +end + +def stop_logstash + result = apply_manifest(stop_logstash_manifest, catch_failures: true) + shell('ps -eo comm | grep java | xargs kill -9', accept_all_exit_codes: true) + sleep 5 # FIXME: This is horrible. + result +end + +def logstash_process_list + ps_cmd = 'ps -ww --no-headers -C java -o user,command | grep logstash' + shell(ps_cmd, accept_all_exit_codes: true).stdout.split("\n") +end + +def logstash_settings + YAML.safe_load(shell('cat /etc/logstash/logstash.yml').stdout) +end + +def expect_setting(setting, value) + expect(logstash_settings[setting]).to eq(value) +end + +def pipelines_from_yaml + YAML.safe_load(shell('cat /etc/logstash/pipelines.yml').stdout) +end + +def service_restart_message + "Service[logstash]: Triggered 'refresh'" +end + +def pe_package_url + distro, distro_version = ENV['BEAKER_set'].split('-') + case distro + when 'debian' + os = 'debian' + arch = 'amd64' + when 'centos' + os = 'el' + arch = 'x86_64' + when 'ubuntu' + os = 'ubuntu' + arch = 'amd64' + end + url_root = "https://s3.amazonaws.com/pe-builds/released/#{PE_VERSION}" + "#{url_root}/puppet-enterprise-#{PE_VERSION}-#{os}-#{distro_version}-#{arch}.tar.gz" +end + +def pe_package_filename + File.basename(pe_package_url) +end + +def puppet_enterprise? + ENV['BEAKER_IS_PE'] == 'true' || ENV['IS_PE'] == 'true' +end + +# hosts.each do |host| +# # Install Puppet +# if puppet_enterprise? +# pe_download = File.join(PE_DIR, pe_package_filename) +# `curl -s -o #{pe_download} #{pe_package_url}` unless File.exist?(pe_download) +# on host, "hostname #{host.name}" +# install_pe_on(host, pe_ver: PE_VERSION) +# else +# if PUPPET_VERSION.start_with?('4.') +# agent_version = agent_version_for_puppet_version(PUPPET_VERSION) +# install_puppet_agent_on(host, puppet_agent_version: agent_version) +# else +# begin +# install_puppet_on(host, version: PUPPET_VERSION) +# rescue +# install_puppet_from_gem_on(host, version: PUPPET_VERSION) +# end +# end +# end +# +# if fact('osfamily') == 'Suse' +# if fact('operatingsystem') == 'OpenSuSE' +# install_package host, 'ruby-devel augeas-devel libxml2-devel' +# on host, 'gem install ruby-augeas --no-ri --no-rdoc' +# end +# end +# +# # Update package cache for those who need it. +# on host, 'apt-get update' if fact('osfamily') == 'Debian' +# +# # Aquire a binary package of Logstash. +# logstash_download = "spec/fixtures/artifacts/#{logstash_package_filename}" +# `curl -s -o #{logstash_download} #{http_package_url}` unless File.exist?(logstash_download) +# # ...send it to the test host +# scp_to(host, logstash_download, '/tmp/') +# # ...and also make it available as a "puppet://" url, by putting it in the +# # 'files' directory of the Logstash module. +# FileUtils.cp(logstash_download, './files/') +# +# # ...and put some grok pattern examples in their too. +# Dir.glob('./spec/fixtures/grok-patterns/*').each do |f| +# FileUtils.cp(f, './files/') +# end +# +# # Provide a Logstash plugin as a local Gem. +# scp_to(host, './spec/fixtures/plugins/logstash-output-cowsay-5.0.0.gem', '/tmp/') +# +# # ...and another plugin that can be fetched from Puppet with "puppet://" +# FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowthink-5.0.0.gem', './files/') +# +# # ...and yet another plugin, this time packaged as an offline installer +# FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowsay-5.0.0.zip', './files/') +# +# # Provide a config file template. +# FileUtils.cp('./spec/fixtures/templates/configfile-template.erb', './templates/') +# +# # Provide this module to the test system. +# project_root = File.dirname(File.dirname(__FILE__)) +# install_dev_puppet_module_on(host, source: project_root, module_name: 'logstash') +# +# # Also install any other modules we need on the test system. +# install_puppet_module_via_pmt_on(host, module_name: 'elastic-elastic_stack') +# install_puppet_module_via_pmt_on(host, module_name: 'darin-zypprepo') +# end +# +# RSpec.configure do |c| +# # Readable test descriptions +# c.formatter = :documentation +# c.color = true +# +# # declare an exclusion filter +# c.filter_run_excluding broken: true +# end From 35f80394223456f7a20f44c6e588bf6fd63bffb9 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Sat, 5 Nov 2022 11:17:12 +0100 Subject: [PATCH 11/16] WIP: 6785c72 Fix errors related to modulesync --- manifests/plugin.pp | 2 +- manifests/service.pp | 1 - metadata.json | 1 - spec/acceptance/class_logstash_spec.rb | 6 +- spec/acceptance/class_plugin_spec.rb | 9 +++ spec/acceptance/define_configfile_spec.rb | 2 + spec/acceptance/define_patternfile_spec.rb | 2 +- spec/defines/define_plugin_spec.rb | 2 +- spec/fixtures/manifests/.gitignore | 0 spec/spec_helper_acceptance.rb | 2 + spec/support/acceptance/helpers.rb | 86 +--------------------- 11 files changed, 23 insertions(+), 90 deletions(-) delete mode 100644 spec/fixtures/manifests/.gitignore diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 52e60c28..d798a70d 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -43,7 +43,7 @@ $source = undef, $ensure = present, $environment = [], - String $user = $logstash::logstash_user, + String $user = 'root', ) { require logstash::package $exe = "${logstash::home_dir}/bin/logstash-plugin" diff --git a/manifests/service.pp b/manifests/service.pp index 83fd30de..9b1c1758 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -16,7 +16,6 @@ } $default_startup_options = { - 'JAVACMD' => '/usr/bin/java', 'LS_HOME' => $logstash::home_dir, 'LS_SETTINGS_DIR' => $logstash::config_dir, 'LS_OPTS' => "--path.settings=${logstash::config_dir}", diff --git a/metadata.json b/metadata.json index 9515f544..4b9ae6c7 100644 --- a/metadata.json +++ b/metadata.json @@ -5,7 +5,6 @@ "author": "elastic", "license": "Apache-2.0", "summary": "Module for managing and configuring Logstash", - "description": "Module for managing and configuring Logstash", "project_page": "https://github.com/voxpupuli/puppet-logstash", "dependencies": [ { diff --git a/spec/acceptance/class_logstash_spec.rb b/spec/acceptance/class_logstash_spec.rb index ca8ba792..cda2d05f 100644 --- a/spec/acceptance/class_logstash_spec.rb +++ b/spec/acceptance/class_logstash_spec.rb @@ -4,7 +4,7 @@ shared_examples 'a logstash installer' do it "installs logstash version #{LS_VERSION}" do - expect(shell('/usr/share/logstash/bin/logstash --version').stdout).to eq("logstash #{LS_VERSION}\n") + expect(shell('/usr/share/logstash/bin/logstash --version').stdout).to contain("logstash #{LS_VERSION}") end case fact('osfamily') @@ -74,10 +74,12 @@ context 'when installing from a "puppet://" url' do before(:all) do + skip('There is no rpm package in the module ...') remove_logstash install_logstash_from_url(puppet_fileserver_package_url) end + skip('There is no rpm package in the module ...') it_behaves_like 'a logstash installer' end end @@ -209,8 +211,6 @@ '-XX:+DisableExplicitGC', '-XX:+HeapDumpOnOutOfMemoryError', '-XX:+UseCMSInitiatingOccupancyOnly', - '-XX:+UseConcMarkSweepGC', - '-XX:+UseParNewGC', ] expert_flags.each do |flag| expect(logstash_process_list.pop).to include(flag) diff --git a/spec/acceptance/class_plugin_spec.rb b/spec/acceptance/class_plugin_spec.rb index 1188f560..fd93f304 100644 --- a/spec/acceptance/class_plugin_spec.rb +++ b/spec/acceptance/class_plugin_spec.rb @@ -3,6 +3,11 @@ require 'spec_helper_acceptance' describe 'class plugin' do + before(:all) do + remove_logstash + install_logstash('status => "disabled", restart_on_change => false') + end + def ensure_plugin(present_absent, plugin, extra_args = nil) manifest = <<-END class { 'logstash': @@ -60,6 +65,7 @@ def remove(plugin) if Gem::Version.new(LS_VERSION) >= Gem::Version.new('5.2.0') it 'can install x-pack from an https url' do + skip('The latest x-pack release is 6.2.4 released April 17, 2018 ...') plugin = 'x-pack' source = "https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-#{LS_VERSION}.zip" ensure_plugin('present', plugin, "source => '#{source}'") @@ -68,6 +74,7 @@ def remove(plugin) end it 'can install a plugin from a "puppet://" url' do + skip('There is no plugins embedded in the module ...') plugin = 'logstash-output-cowthink' source = "puppet:///modules/logstash/#{plugin}-5.0.0.gem" ensure_plugin('present', plugin, "source => '#{source}'") @@ -75,6 +82,7 @@ def remove(plugin) end it 'can install a plugin from a local gem' do + skip('No download means no local plugin available ...') plugin = 'logstash-output-cowsay' source = "/tmp/#{plugin}-5.0.0.gem" ensure_plugin('present', plugin, "source => '#{source}'") @@ -82,6 +90,7 @@ def remove(plugin) end it 'can install a plugin from an offline zip' do + skip('There is no plugins embedded in the module ...') plugin = 'logstash-output-cowsay' source = "puppet:///modules/logstash/#{plugin}-5.0.0.zip" ensure_plugin('present', plugin, "source => '#{source}'") diff --git a/spec/acceptance/define_configfile_spec.rb b/spec/acceptance/define_configfile_spec.rb index baa94378..cd8416c6 100644 --- a/spec/acceptance/define_configfile_spec.rb +++ b/spec/acceptance/define_configfile_spec.rb @@ -30,10 +30,12 @@ END before(:context) do + skip('There is no configfile-template.erb in the module ..') apply_manifest(manifest, catch_failures: true, debug: true) end it 'creates a config file from the template' do + skip('There is no configfile-template.erb in the module ..') result = shell('cat /etc/logstash/conf.d/from-template').stdout expect(result).to include('2 + 2 equals 4') end diff --git a/spec/acceptance/define_patternfile_spec.rb b/spec/acceptance/define_patternfile_spec.rb index fecb57fd..7f50cbac 100644 --- a/spec/acceptance/define_patternfile_spec.rb +++ b/spec/acceptance/define_patternfile_spec.rb @@ -5,7 +5,7 @@ describe 'class patternfile' do def apply_pattern(pattern_number, extra_logstash_class_args = nil) manifest = <<-END - #{install_logstash_from_local_file_manifest(extra_logstash_class_args)} + #{install_logstash_manifest(extra_logstash_class_args)} logstash::patternfile { 'pattern': source => 'puppet:///modules/logstash/grok-pattern-#{pattern_number}', diff --git a/spec/defines/define_plugin_spec.rb b/spec/defines/define_plugin_spec.rb index e8c28c43..60a3a683 100644 --- a/spec/defines/define_plugin_spec.rb +++ b/spec/defines/define_plugin_spec.rb @@ -21,7 +21,7 @@ it { is_expected.to compile } it { - is_expected.to contain_exec("install-#{title}").with(user: 'logstash') + is_expected.to contain_exec("install-#{title}").with(user: 'root') } end end diff --git a/spec/fixtures/manifests/.gitignore b/spec/fixtures/manifests/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index f803ae59..d3a6e23c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -5,4 +5,6 @@ require 'voxpupuli/acceptance/spec_helper_acceptance' +configure_beaker + Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } diff --git a/spec/support/acceptance/helpers.rb b/spec/support/acceptance/helpers.rb index bdb0194d..32cd3396 100644 --- a/spec/support/acceptance/helpers.rb +++ b/spec/support/acceptance/helpers.rb @@ -2,15 +2,11 @@ require 'beaker-rspec' require 'net/http' -require 'pry' require 'securerandom' require 'yaml' # Collect global options from the environment. -ENV['LOGSTASH_VERSION'] = '7.17.6' -raise 'Please set the LOGSTASH_VERSION environment variable.' if ENV['LOGSTASH_VERSION'].nil? - -LS_VERSION = ENV['LOGSTASH_VERSION'] +LS_VERSION = ENV['LOGSTASH_VERSION'] || '7.17.7' PUPPET_VERSION = ENV['PUPPET_VERSION'] || '4.10.7' PE_VERSION = ENV['BEAKER_PE_VER'] || ENV['PE_VERSION'] || '3.8.3' @@ -66,9 +62,9 @@ def http_package_url case fact('osfamily') when 'Debian' - "#{url_root}.deb" + "#{url_root}-amd64.deb" when 'RedHat', 'Suse' - "#{url_root}.rpm" + "#{url_root}-x86_64.rpm" end end @@ -167,7 +163,7 @@ def install_logstash(extra_args = nil) end def include_logstash - result = apply_manifest(include_logstash_manifest, catch_failures: true, debug: true) + result = apply_manifest(include_logstash_manifest, catch_failures: true) sleep 5 # FIXME: This is horrible. result end @@ -241,77 +237,3 @@ def pe_package_filename def puppet_enterprise? ENV['BEAKER_IS_PE'] == 'true' || ENV['IS_PE'] == 'true' end - -# hosts.each do |host| -# # Install Puppet -# if puppet_enterprise? -# pe_download = File.join(PE_DIR, pe_package_filename) -# `curl -s -o #{pe_download} #{pe_package_url}` unless File.exist?(pe_download) -# on host, "hostname #{host.name}" -# install_pe_on(host, pe_ver: PE_VERSION) -# else -# if PUPPET_VERSION.start_with?('4.') -# agent_version = agent_version_for_puppet_version(PUPPET_VERSION) -# install_puppet_agent_on(host, puppet_agent_version: agent_version) -# else -# begin -# install_puppet_on(host, version: PUPPET_VERSION) -# rescue -# install_puppet_from_gem_on(host, version: PUPPET_VERSION) -# end -# end -# end -# -# if fact('osfamily') == 'Suse' -# if fact('operatingsystem') == 'OpenSuSE' -# install_package host, 'ruby-devel augeas-devel libxml2-devel' -# on host, 'gem install ruby-augeas --no-ri --no-rdoc' -# end -# end -# -# # Update package cache for those who need it. -# on host, 'apt-get update' if fact('osfamily') == 'Debian' -# -# # Aquire a binary package of Logstash. -# logstash_download = "spec/fixtures/artifacts/#{logstash_package_filename}" -# `curl -s -o #{logstash_download} #{http_package_url}` unless File.exist?(logstash_download) -# # ...send it to the test host -# scp_to(host, logstash_download, '/tmp/') -# # ...and also make it available as a "puppet://" url, by putting it in the -# # 'files' directory of the Logstash module. -# FileUtils.cp(logstash_download, './files/') -# -# # ...and put some grok pattern examples in their too. -# Dir.glob('./spec/fixtures/grok-patterns/*').each do |f| -# FileUtils.cp(f, './files/') -# end -# -# # Provide a Logstash plugin as a local Gem. -# scp_to(host, './spec/fixtures/plugins/logstash-output-cowsay-5.0.0.gem', '/tmp/') -# -# # ...and another plugin that can be fetched from Puppet with "puppet://" -# FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowthink-5.0.0.gem', './files/') -# -# # ...and yet another plugin, this time packaged as an offline installer -# FileUtils.cp('./spec/fixtures/plugins/logstash-output-cowsay-5.0.0.zip', './files/') -# -# # Provide a config file template. -# FileUtils.cp('./spec/fixtures/templates/configfile-template.erb', './templates/') -# -# # Provide this module to the test system. -# project_root = File.dirname(File.dirname(__FILE__)) -# install_dev_puppet_module_on(host, source: project_root, module_name: 'logstash') -# -# # Also install any other modules we need on the test system. -# install_puppet_module_via_pmt_on(host, module_name: 'elastic-elastic_stack') -# install_puppet_module_via_pmt_on(host, module_name: 'darin-zypprepo') -# end -# -# RSpec.configure do |c| -# # Readable test descriptions -# c.formatter = :documentation -# c.color = true -# -# # declare an exclusion filter -# c.filter_run_excluding broken: true -# end From 6022ddcac74d7387b48cdd68ee6f46584bc73bda Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Mon, 7 Nov 2022 02:43:34 +0100 Subject: [PATCH 12/16] Alligning os support with puppet-elastic_stack --- metadata.json | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/metadata.json b/metadata.json index 4b9ae6c7..9d3c8e03 100644 --- a/metadata.json +++ b/metadata.json @@ -18,47 +18,44 @@ ], "operatingsystem_support": [ { - "operatingsystem": "RedHat", - "operatingsystemrelease": [ - "7" - ] - }, - { - "operatingsystem": "CentOS", + "operatingsystem": "Debian", "operatingsystemrelease": [ - "7" + "10", + "11" ] }, { - "operatingsystem": "OracleLinux", + "operatingsystem": "OpenSuSE", "operatingsystemrelease": [ - "7" + "15" ] }, { - "operatingsystem": "Scientific", + "operatingsystem": "RedHat", "operatingsystemrelease": [ - "7" + "7", + "8" ] }, { - "operatingsystem": "Debian", + "operatingsystem": "CentOS", "operatingsystemrelease": [ "7", "8" ] }, - { - "operatingsystem": "Ubuntu", + { + "operatingsystem": "SLES", "operatingsystemrelease": [ - "14.04", - "16.04" + "12", + "15" ] }, { - "operatingsystem": "OpenSuSE", + "operatingsystem": "Ubuntu", "operatingsystemrelease": [ - "13.x" + "18.04", + "20.04" ] } ], From d0169c2818addf02fdbfaec4ee56b356404a60ec Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Wed, 21 Dec 2022 14:31:30 +0100 Subject: [PATCH 13/16] fix broken test after rebase --- spec/acceptance/class_logstash_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/acceptance/class_logstash_spec.rb b/spec/acceptance/class_logstash_spec.rb index cda2d05f..69e0b964 100644 --- a/spec/acceptance/class_logstash_spec.rb +++ b/spec/acceptance/class_logstash_spec.rb @@ -208,7 +208,6 @@ '-Dfile.encoding=UTF-8', '-Djava.awt.headless=true', '-XX:CMSInitiatingOccupancyFraction=75', - '-XX:+DisableExplicitGC', '-XX:+HeapDumpOnOutOfMemoryError', '-XX:+UseCMSInitiatingOccupancyOnly', ] From 0230b27caef8adc039a1035ff69ea77583018735 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Wed, 21 Dec 2022 23:19:53 +0100 Subject: [PATCH 14/16] Cleanup unused helper code --- spec/acceptance/define_patternfile_spec.rb | 2 - spec/defines/define_plugin_spec.rb | 8 +-- spec/support/acceptance/helpers.rb | 68 ---------------------- 3 files changed, 4 insertions(+), 74 deletions(-) diff --git a/spec/acceptance/define_patternfile_spec.rb b/spec/acceptance/define_patternfile_spec.rb index 7f50cbac..78395a19 100644 --- a/spec/acceptance/define_patternfile_spec.rb +++ b/spec/acceptance/define_patternfile_spec.rb @@ -35,8 +35,6 @@ def apply_pattern(pattern_number, extra_logstash_class_args = nil) end it 'does not restart logstash if logstash::restart_on_change is false' do - os = fact('lsbdistdescription') - skip('Something funky happening with Upstart and Puppet 3?') if (os =~ %r{(centos release 6\.|ubuntu 12\.04)}i) && PUPPET_VERSION[0] == '3' log = apply_pattern(1, 'restart_on_change => false').stdout expect(log).not_to include(restart_message) end diff --git a/spec/defines/define_plugin_spec.rb b/spec/defines/define_plugin_spec.rb index 60a3a683..09039fd7 100644 --- a/spec/defines/define_plugin_spec.rb +++ b/spec/defines/define_plugin_spec.rb @@ -10,10 +10,10 @@ end let(:pre_condition) do - ' - include elastic_stack::repo - include logstash - ' + <<~PUPPET + include elastic_stack::repo + include logstash + PUPPET end let(:title) { 'logstash-input-mysql' } diff --git a/spec/support/acceptance/helpers.rb b/spec/support/acceptance/helpers.rb index 32cd3396..83e5b29c 100644 --- a/spec/support/acceptance/helpers.rb +++ b/spec/support/acceptance/helpers.rb @@ -1,58 +1,15 @@ # frozen_string_literal: true -require 'beaker-rspec' -require 'net/http' -require 'securerandom' require 'yaml' # Collect global options from the environment. LS_VERSION = ENV['LOGSTASH_VERSION'] || '7.17.7' -PUPPET_VERSION = ENV['PUPPET_VERSION'] || '4.10.7' - -PE_VERSION = ENV['BEAKER_PE_VER'] || ENV['PE_VERSION'] || '3.8.3' -PE_DIR = ENV['BEAKER_PE_DIR'] - IS_PRERELEASE = if LS_VERSION =~ %r{(alpha|beta|rc)} true else false end -def agent_version_for_puppet_version(puppet_version) - # REF: https://docs.puppet.com/puppet/latest/reference/about_agent.html - version_map = { - # Puppet => Agent - '4.9.4' => '1.9.3', - '4.8.2' => '1.8.3', - '4.8.1' => '1.8.2', - '4.8.0' => '1.8.0', - '4.7.1' => '1.7.2', - '4.7.0' => '1.7.1', - '4.6.2' => '1.6.2', - '4.6.1' => '1.6.1', - '4.6.0' => '1.6.0', - '4.5.3' => '1.5.3', - '4.4.2' => '1.4.2', - '4.4.1' => '1.4.1', - '4.4.0' => '1.4.0', - '4.3.2' => '1.3.6', - '4.3.1' => '1.3.2', - '4.3.0' => '1.3.0', - '4.2.3' => '1.2.7', - '4.2.2' => '1.2.6', - '4.2.1' => '1.2.2', - '4.2.0' => '1.2.1', - '4.1.0' => '1.1.1', - '4.0.0' => '1.0.1' - } - version_map[puppet_version] -end - -def apply_manifest_fixture(manifest_name) - manifest = File.read("./spec/fixtures/manifests/#{manifest_name}.pp") - apply_manifest(manifest, catch_failures: true) -end - def expect_no_change_from_manifest(manifest) expect(apply_manifest(manifest).exit_code).to eq(0) end @@ -212,28 +169,3 @@ def pipelines_from_yaml def service_restart_message "Service[logstash]: Triggered 'refresh'" end - -def pe_package_url - distro, distro_version = ENV['BEAKER_set'].split('-') - case distro - when 'debian' - os = 'debian' - arch = 'amd64' - when 'centos' - os = 'el' - arch = 'x86_64' - when 'ubuntu' - os = 'ubuntu' - arch = 'amd64' - end - url_root = "https://s3.amazonaws.com/pe-builds/released/#{PE_VERSION}" - "#{url_root}/puppet-enterprise-#{PE_VERSION}-#{os}-#{distro_version}-#{arch}.tar.gz" -end - -def pe_package_filename - File.basename(pe_package_url) -end - -def puppet_enterprise? - ENV['BEAKER_IS_PE'] == 'true' || ENV['IS_PE'] == 'true' -end From 84afaba4033b33c818f92b3d911f9c57b6b1458a Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Thu, 22 Dec 2022 11:47:55 +0100 Subject: [PATCH 15/16] modulesync 5.3.0 --- .github/CONTRIBUTING.md | 2 +- .msync.yml | 2 +- Gemfile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 25743a13..8b466cfb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_GEM_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by diff --git a/.msync.yml b/.msync.yml index 968a9367..02353859 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.2.0' +modulesync_config_version: '5.3.0' diff --git a/Gemfile b/Gemfile index 04295a4e..07209b79 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 5.0', :require => false + gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false From da86a8a662aa7cf1e54e4baf5f831c71ce9b1d32 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Thu, 29 Dec 2022 09:27:01 +0100 Subject: [PATCH 16/16] modulesync 5.4.0 --- .msync.yml | 2 +- Gemfile | 2 +- Rakefile | 2 +- spec/spec_helper.rb | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.msync.yml b/.msync.yml index 02353859..f3156d15 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '5.3.0' +modulesync_config_version: '5.4.0' diff --git a/Gemfile b/Gemfile index 07209b79..b3827ba7 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ group :test do gem 'voxpupuli-test', '~> 5.4', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false - gem 'puppet_metadata', '~> 1.0', :require => false + gem 'puppet_metadata', '~> 2.0', :require => false end group :development do diff --git a/Rakefile b/Rakefile index f92f0516..6fd83994 100644 --- a/Rakefile +++ b/Rakefile @@ -52,7 +52,7 @@ begin config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module." config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog} config.user = 'voxpupuli' - config.project = metadata.metadata['name'] + config.project = 'puppet-logstash' end # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d617f39..6515b7bf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,6 +9,8 @@ require 'voxpupuli/test/spec_helper' +add_mocked_facts! + if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) facts&.each do |name, value|