diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 12ed4ff10..000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM puppet/pdk:latest - -# [Optional] Uncomment this section to install additional packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index a71936168..000000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# devcontainer - - -For format details, see https://aka.ms/devcontainer.json. - -For config options, see the README at: -https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/puppet - -``` json -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash", - } - } - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ], - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pdk --version", -} -``` - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index cdd65d220..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "Puppet Development Kit (Community)", - "dockerFile": "Dockerfile", - - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "bash" - } - } - }, - - "extensions": [ - "puppet.puppet-vscode", - "rebornix.Ruby" - ] -} diff --git a/.fixtures.yml b/.fixtures.yml index a27ae9b8e..e5a7fb878 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,9 +1,8 @@ +--- fixtures: repositories: - "stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib" - "cron_core": "https://github.com/puppetlabs/puppetlabs-cron_core.git" - "facts": "https://github.com/puppetlabs/puppetlabs-facts.git" - "provision": "https://github.com/puppetlabs/provision.git" - puppet_agent: - repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.13.0 + stdlib: https://github.com/puppetlabs/puppetlabs-stdlib + cron_core: https://github.com/puppetlabs/puppetlabs-cron_core.git + facts: https://github.com/puppetlabs/puppetlabs-facts.git + provision: https://github.com/puppetlabs/provision.git + puppet_agent: https://github.com/puppetlabs/puppetlabs-puppet_agent.git diff --git a/.geppetto-rc.json b/.geppetto-rc.json deleted file mode 100644 index 7df232989..000000000 --- a/.geppetto-rc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "excludes": [ - "**/contrib/**", - "**/examples/**", - "**/tests/**", - "**/spec/**", - "**/pkg/**" - ] -} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d80c53ed..785843be8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,103 +1,25 @@ -name: "ci" +name: "CI" on: pull_request: branches: - "main" workflow_dispatch: - + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: Spec: uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" - with: - runs_on: "ubuntu-20.04" secrets: "inherit" - setup_matrix: - name: "Setup Test Matrix" - needs: "Spec" - runs-on: ubuntu-20.04 - outputs: - matrix: ${{ steps.get-matrix.outputs.matrix }} - - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - run: | - echo ::group::bundler environment - bundle env - echo ::endgroup:: - - - name: Setup Acceptance Test Matrix - id: get-matrix - run: | - bundle exec matrix_from_metadata_v2 --exclude-platforms '["Ubuntu-22.04-arm", "RedHat-9-arm"]' - Acceptance: - name: "${{matrix.platforms.label}}, ${{matrix.collection}}" - needs: - - setup_matrix - if: ${{ needs.setup_matrix.outputs.matrix != '{}' }} - - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} - - env: - PUPPET_GEM_VERSION: '~> 7.24' - FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' - - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - run: | - bundle env - - - name: "Disable mysqld apparmor profile" - if: ${{matrix.platforms.provider == 'docker'}} - run: | - sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ - sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld - sudo systemctl disable apparmor - sudo systemctl stop apparmor - - - name: Provision test environment - run: | - bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' - FILE='spec/fixtures/litmus_inventory.yaml' - sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true - - - name: Install agent - run: | - bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - - - name: Install module - run: | - bundle exec rake 'litmus:install_module' - - - name: Run acceptance tests - run: | - bundle exec rake 'litmus:acceptance:parallel' - - - name: Remove test environment - if: ${{ always() }} - continue-on-error: true - run: | - bundle exec rake 'litmus:tear_down' + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" + with: + runs_on: ubuntu-20.04 + kernel_modules: false + disable_apparmor: true diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index 0d4870d70..f29bd1b17 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -14,14 +14,6 @@ on: jobs: label: - runs-on: ubuntu-latest - steps: - - - uses: puppetlabs/community-labeller@v1.0.1 - name: Label issues or pull requests - with: - label_name: community - label_color: '5319e7' - org_membership: puppetlabs - fail_if_member: 'true' - token: ${{ secrets.IAC_COMMUNITY_LABELER }} + if: contains(fromJson('["puppetlabs", "puppet-toy-chest"]'), github.repository_owner) + uses: "puppetlabs/cat-github-actions/.github/workflows/labeller.yml@main" + secrets: inherit diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f14093117..a650924b7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,95 +8,13 @@ on: jobs: Spec: uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" - with: - runs_on: "ubuntu-20.04" secrets: "inherit" - setup_matrix: - name: "Setup Test Matrix" - needs: "Spec" - runs-on: ubuntu-20.04 - outputs: - matrix: ${{ steps.get-matrix.outputs.matrix }} - - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - run: | - echo ::group::bundler environment - bundle env - echo ::endgroup:: - - - name: Setup Acceptance Test Matrix - id: get-matrix - run: | - bundle exec matrix_from_metadata_v2 --exclude-platforms '["Ubuntu-22.04-arm", "RedHat-9-arm"]' - Acceptance: - name: "${{matrix.platforms.label}}, ${{matrix.collection}}" - needs: - - setup_matrix - if: ${{ needs.setup_matrix.outputs.matrix != '{}' }} - - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}} - - env: - PUPPET_GEM_VERSION: '~> 7.24' - FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' - - steps: - - name: Checkout Source - uses: actions/checkout@v3 - - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - - name: Print bundle environment - run: | - bundle env - - - name: "Disable mysqld apparmor profile" - if: ${{matrix.platforms.provider == 'docker'}} - run: | - sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ - sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld - sudo systemctl disable apparmor - sudo systemctl stop apparmor - - - name: Provision test environment - run: | - bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' - FILE='spec/fixtures/litmus_inventory.yaml' - sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true - - - name: Install agent - run: | - bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - - - name: Install module - run: | - bundle exec rake 'litmus:install_module' - - - name: Run acceptance tests - run: | - bundle exec rake 'litmus:acceptance:parallel' - - - name: Remove test environment - if: ${{ always() }} - continue-on-error: true - run: | - bundle exec rake 'litmus:tear_down' + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" + with: + runs_on: ubuntu-20.04 + kernel_modules: false + disable_apparmor: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b7b8a05d..a48081540 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,36 @@ name: "Publish module" +run-name: > + ${{ format('tag={0}', inputs.tag) }} + ${{ format('release={0}', inputs.release) }} + ${{ format('publish={0}', inputs.publish) }} + ${{ format('edit={0}', inputs.edit) }} on: workflow_dispatch: - + inputs: + tag: + description: "Leave blank to tag HEAD of branch, or existing tag to edit" + default: '' + type: string + release: + description: "Create a Github release" + type: boolean + default: true + publish: + description: "Publish to the Forge" + type: boolean + default: true + edit: + description: "Regenerate release notes and existing tag" + default: false + type: boolean + jobs: - release: + release: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" secrets: "inherit" + with: + tag: ${{ inputs.tag }} + release: ${{ inputs.release }} + publish: ${{ inputs.publish }} + edit: ${{ inputs.edit }} diff --git a/.github/workflows/release_prep.yml b/.github/workflows/release_prep.yml index bb0b7acce..7f7bf458f 100644 --- a/.github/workflows/release_prep.yml +++ b/.github/workflows/release_prep.yml @@ -1,4 +1,6 @@ name: "Release Prep" +run-name: > + version=${{ inputs.version }} on: workflow_dispatch: @@ -11,5 +13,5 @@ jobs: release_prep: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release_prep.yml@main" with: - version: "${{ github.event.inputs.version }}" + version: "${{ inputs.version }}" secrets: "inherit" diff --git a/.gitignore b/.gitignore index 3f1551212..0efe17545 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile deleted file mode 100644 index 0814c5e61..000000000 --- a/.gitpod.Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM gitpod/workspace-full -RUN sudo wget https://apt.puppet.com/puppet-tools-release-bionic.deb && \ - wget https://apt.puppetlabs.com/puppet6-release-bionic.deb && \ - sudo dpkg -i puppet6-release-bionic.deb && \ - sudo dpkg -i puppet-tools-release-bionic.deb && \ - sudo apt-get update && \ - sudo apt-get install -y pdk zsh puppet-agent && \ - sudo apt-get clean && \ - sudo rm -rf /var/lib/apt/lists/* -RUN sudo usermod -s $(which zsh) gitpod && \ - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ - echo "plugins=(git gitignore github gem pip bundler python ruby docker docker-compose)" >> /home/gitpod/.zshrc && \ - echo 'PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/puppetlabs/bin:/opt/puppetlabs/puppet/bin"' >> /home/gitpod/.zshrc && \ - sudo /opt/puppetlabs/puppet/bin/gem install puppet-debugger hub -N && \ - mkdir -p /home/gitpod/.config/puppet && \ - /opt/puppetlabs/puppet/bin/ruby -r yaml -e "puts ({'disabled' => true}).to_yaml" > /home/gitpod/.config/puppet/analytics.yml -RUN rm -f puppet6-release-bionic.deb puppet-tools-release-bionic.deb -ENTRYPOINT /usr/bin/zsh diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 9d89d9faa..000000000 --- a/.gitpod.yml +++ /dev/null @@ -1,9 +0,0 @@ -image: - file: .gitpod.Dockerfile - -tasks: - - init: pdk bundle install - -vscode: - extensions: - - puppet.puppet-vscode@1.2.0:f5iEPbmOj6FoFTOV6q8LTg== diff --git a/.pdkignore b/.pdkignore index 862847a72..9403b0898 100644 --- a/.pdkignore +++ b/.pdkignore @@ -26,6 +26,12 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 000000000..e4d136b75 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1 @@ +--format progress diff --git a/.rubocop.yml b/.rubocop.yml index 70ff105a8..21b82b99b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,11 @@ --- -inherit_from: .rubocop_todo.yml - require: - rubocop-performance - rubocop-rspec AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.7' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: @@ -530,6 +528,8 @@ Lint/DuplicateBranch: Enabled: false Lint/DuplicateMagicComment: Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: @@ -646,6 +646,8 @@ Style/ComparableClamp: Enabled: false Style/ConcatArrayLiterals: Enabled: false +Style/DataInheritance: + Enabled: false Style/DirEmpty: Enabled: false Style/DocumentDynamicEvalDefinition: @@ -714,6 +716,8 @@ Style/RedundantHeredocDelimiterQuotes: Enabled: false Style/RedundantInitialize: Enabled: false +Style/RedundantLineContinuation: + Enabled: false Style/RedundantSelfAssignmentBranch: Enabled: false Style/RedundantStringEscape: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index 153e14bfa..000000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,25 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2023-12-05 10:38:45 UTC using RuboCop version 1.48.1. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 143 -# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. -# SupportedStyles: always, named_only -RSpec/NamedSubject: - Exclude: - - 'spec/classes/graceful_failures_spec.rb' - - 'spec/classes/mycnf_template_spec.rb' - - 'spec/classes/mysql_backup_mysqldump_spec.rb' - - 'spec/classes/mysql_backup_xtrabackup_spec.rb' - - 'spec/classes/mysql_client_spec.rb' - - 'spec/classes/mysql_server_account_security_spec.rb' - - 'spec/classes/mysql_server_backup_spec.rb' - - 'spec/classes/mysql_server_spec.rb' - - 'spec/defines/mysql_db_spec.rb' - - 'spec/functions/mysql_innobackupex_args_spec.rb' - - 'spec/functions/mysql_normalise_and_deepmerge_spec.rb' - - 'spec/functions/mysql_strip_hash_spec.rb' diff --git a/.sync.yml b/.sync.yml index 383ce5c94..95d909421 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,34 +1,26 @@ --- -".gitlab-ci.yml": - delete: true -appveyor.yml: - delete: true -rubocop.yml: - include_todos: true - - spec/spec_helper.rb: spec_overrides: - require 'spec_helper_local' coverage_report: true -"  changelog_user": puppetlabs -.gitpod.Dockerfile: - unmanaged: false -.gitpod.yml: - unmanaged: false -.github/workflows/auto_release.yml: - unmanaged: false + minimum_code_coverage_percentage: 81 + .github/workflows/ci.yml: unmanaged: true .github/workflows/nightly.yml: unmanaged: true +.github/workflows/release_prep.yml: + unmanaged: true .github/workflows/release.yml: - unmanaged: false -.travis.yml: - delete: true -changelog_since_tag: 'v11.0.3' + unmanaged: true + Rakefile: + changelog_since_tag: 'v11.0.3' changelog_max_issues: 500 extra_disabled_lint_checks: - anchor_resource - params_empty_string_assignment + +spec/default_facts.yml: + extra_facts: + root_home: /root diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2f1e4f73a..6da8d472f 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ "puppet.puppet-vscode", - "rebornix.Ruby" + "Shopify.ruby-lsp" ] } diff --git a/Gemfile b/Gemfile index ca0e773ec..de5e1401f 100644 --- a/Gemfile +++ b/Gemfile @@ -20,30 +20,30 @@ group :development do gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.0', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 1.18', require: false - gem "metadata-json-lint", '~> 3.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false - gem "rspec-puppet-facts", '~> 2.0', require: false - gem "codecov", '~> 0.2', require: false + gem "facterdb", '~> 1.26', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 3.0', require: false gem "dependency_checker", '~> 1.0.0', require: false gem "parallel_tests", '= 3.12.1', require: false gem "pry", '~> 0.10', require: false - gem "simplecov-console", '~> 0.5', require: false + gem "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false - gem "puppet-strings", '~> 4.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "rexml", '>= 3.0.0', '< 3.2.7', require: false end -group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false -end -group :release_prep do +group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false + gem "puppetlabs_spec_helper", '~> 7.3', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/README.md b/README.md index c4bbdc6f6..e79be71e9 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ If required, the password can also be an empty string to allow connections witho ### Create login paths -This feature works only for the MySQL Community Edition >= 5.6.6. +This feature works only for the MySQL Community Edition >= 5.6.6, [not MariaDB](https://mariadb.com/kb/en/mysql_config_editor-compatibility/). A login path is a set of options (host, user, password, port and socket) that specify which MySQL server to connect to and which account to authenticate as. The authentication credentials and the other options are stored in an encrypted login file named .mylogin.cnf typically under the users home directory. diff --git a/manifests/backup/xtrabackup.pp b/manifests/backup/xtrabackup.pp index c73831f38..63b90feaa 100644 --- a/manifests/backup/xtrabackup.pp +++ b/manifests/backup/xtrabackup.pp @@ -177,7 +177,13 @@ # TODO: use EPP instead of ERB, as EPP can handle Data of Type Sensitive without further ado $parameters = { - 'innobackupex_args' => mysql::innobackupex_args($backupuser, $backupcompress, $backuppassword_unsensitive, $backupdatabases, $optional_args), + 'innobackupex_args' => mysql::innobackupex_args( + $backupuser, + $backupcompress, + $backuppassword_unsensitive, + $backupdatabases, + $optional_args + ), 'backuprotate' => $backuprotate, 'backupdir' => $backupdir, 'backupmethod' => $backupmethod, diff --git a/manifests/bindings.pp b/manifests/bindings.pp index 6f95ac4cb..75fe025be 100644 --- a/manifests/bindings.pp +++ b/manifests/bindings.pp @@ -85,27 +85,27 @@ Boolean $client_dev = false, Boolean $daemon_dev = false, # Settings for the various classes. - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $java_package_ensure = $mysql::params::java_package_ensure, - String[1] $java_package_name = $mysql::params::java_package_name, - Optional[String[1]] $java_package_provider = $mysql::params::java_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $perl_package_ensure = $mysql::params::perl_package_ensure, - String[1] $perl_package_name = $mysql::params::perl_package_name, - Optional[String[1]] $perl_package_provider = $mysql::params::perl_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $php_package_ensure = $mysql::params::php_package_ensure, - String[1] $php_package_name = $mysql::params::php_package_name, - Optional[String[1]] $php_package_provider = $mysql::params::php_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $python_package_ensure = $mysql::params::python_package_ensure, - String[1] $python_package_name = $mysql::params::python_package_name, - Optional[String[1]] $python_package_provider = $mysql::params::python_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $ruby_package_ensure = $mysql::params::ruby_package_ensure, - String[1] $ruby_package_name = $mysql::params::ruby_package_name, - Optional[String[1]] $ruby_package_provider = $mysql::params::ruby_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $client_dev_package_ensure = $mysql::params::client_dev_package_ensure, - Optional[String[1]] $client_dev_package_name = $mysql::params::client_dev_package_name, - Optional[String[1]] $client_dev_package_provider = $mysql::params::client_dev_package_provider, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $daemon_dev_package_ensure = $mysql::params::daemon_dev_package_ensure, - String[1] $daemon_dev_package_name = $mysql::params::daemon_dev_package_name, - Optional[String[1]] $daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider + Stdlib::Ensure::Package $java_package_ensure = $mysql::params::java_package_ensure, + String[1] $java_package_name = $mysql::params::java_package_name, + Optional[String[1]] $java_package_provider = $mysql::params::java_package_provider, + Stdlib::Ensure::Package $perl_package_ensure = $mysql::params::perl_package_ensure, + String[1] $perl_package_name = $mysql::params::perl_package_name, + Optional[String[1]] $perl_package_provider = $mysql::params::perl_package_provider, + Stdlib::Ensure::Package $php_package_ensure = $mysql::params::php_package_ensure, + String[1] $php_package_name = $mysql::params::php_package_name, + Optional[String[1]] $php_package_provider = $mysql::params::php_package_provider, + Stdlib::Ensure::Package $python_package_ensure = $mysql::params::python_package_ensure, + String[1] $python_package_name = $mysql::params::python_package_name, + Optional[String[1]] $python_package_provider = $mysql::params::python_package_provider, + Stdlib::Ensure::Package $ruby_package_ensure = $mysql::params::ruby_package_ensure, + String[1] $ruby_package_name = $mysql::params::ruby_package_name, + Optional[String[1]] $ruby_package_provider = $mysql::params::ruby_package_provider, + Stdlib::Ensure::Package $client_dev_package_ensure = $mysql::params::client_dev_package_ensure, + Optional[String[1]] $client_dev_package_name = $mysql::params::client_dev_package_name, + Optional[String[1]] $client_dev_package_provider = $mysql::params::client_dev_package_provider, + Stdlib::Ensure::Package $daemon_dev_package_ensure = $mysql::params::daemon_dev_package_ensure, + String[1] $daemon_dev_package_name = $mysql::params::daemon_dev_package_name, + Optional[String[1]] $daemon_dev_package_provider = $mysql::params::daemon_dev_package_provider ) inherits mysql::params { case $facts['os']['family'] { 'Archlinux': { diff --git a/manifests/client.pp b/manifests/client.pp index f888e0e9a..7dac1c13a 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -24,13 +24,13 @@ # Specify the path to the package source. Optional. Valid value is a String # class mysql::client ( - Boolean $bindings_enable = $mysql::params::bindings_enable, - Optional[Array[String[1]]] $install_options = undef, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $package_ensure = $mysql::params::client_package_ensure, - Boolean $package_manage = $mysql::params::client_package_manage, - String[1] $package_name = $mysql::params::client_package_name, - Optional[String[1]] $package_provider = undef, - Optional[String[1]] $package_source = undef, + Boolean $bindings_enable = $mysql::params::bindings_enable, + Optional[Array[String[1]]] $install_options = undef, + Stdlib::Ensure::Package $package_ensure = $mysql::params::client_package_ensure, + Boolean $package_manage = $mysql::params::client_package_manage, + String[1] $package_name = $mysql::params::client_package_name, + Optional[String[1]] $package_provider = undef, + Optional[String[1]] $package_source = undef, ) inherits mysql::params { include 'mysql::client::install' diff --git a/manifests/params.pp b/manifests/params.pp index ab495a3ef..ec641d64e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -185,7 +185,10 @@ $ssl_cert = '/etc/mysql/server-cert.pem' $ssl_key = '/etc/mysql/server-key.pem' $tmpdir = '/tmp' - $managed_dirs = ['tmpdir','basedir','datadir','innodb_data_home_dir','innodb_log_group_home_dir','innodb_undo_directory','innodb_tmpdir'] + $managed_dirs = [ + 'tmpdir','basedir','datadir','innodb_data_home_dir', + 'innodb_log_group_home_dir','innodb_undo_directory','innodb_tmpdir', + ] # mysql::bindings if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '10') >= 0) or diff --git a/manifests/server.pp b/manifests/server.pp index 8748e33bc..d236f1482 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -93,39 +93,39 @@ # See the `root_password` parameter above for details on changing the root password. # class mysql::server ( - String[1] $config_file = $mysql::params::config_file, - String[1] $config_file_mode = '0644', - Optional[String] $includedir = $mysql::params::includedir, - Optional[Array[String[1]]] $install_options = undef, - Variant[Boolean, String[1]] $manage_config_file = true, - Mysql::Options $options = {}, - Hash $override_options = {}, - Variant[Enum['present','absent'], Pattern[/(\d+)[\.](\d+)[\.](\d+)/]] $package_ensure = 'present', - Boolean $package_manage = true, - String[1] $package_name = $mysql::params::server_package_name, - Optional[String[1]] $package_provider = undef, - Optional[String[1]] $package_source = undef, - Variant[Boolean, String[1]] $purge_conf_dir = false, - Variant[Boolean, String[1]] $remove_default_accounts = false, - Variant[Boolean, String[1]] $restart = false, - String[1] $root_group = $mysql::params::root_group, - Optional[Array[String[1]]] $managed_dirs = $mysql::params::managed_dirs, - String[1] $mysql_group = $mysql::params::mysql_group, - Optional[String[1]] $mycnf_owner = undef, - Optional[String[1]] $mycnf_group = undef, - Variant[String, Sensitive[String]] $root_password = 'UNSET', - Variant[Boolean, String[1]] $service_enabled = true, - Variant[Boolean, String[1]] $service_manage = true, - String[1] $service_name = $mysql::params::server_service_name, - Optional[String[1]] $service_provider = undef, - Boolean $create_root_user = true, - Boolean $create_root_my_cnf = true, - Boolean $create_root_login_file = false, - Optional[String[1]] $login_file = undef, - Hash $users = {}, - Hash $grants = {}, - Hash $databases = {}, - Boolean $reload_on_config_change = false, + String[1] $config_file = $mysql::params::config_file, + String[1] $config_file_mode = '0644', + Optional[String] $includedir = $mysql::params::includedir, + Optional[Array[String[1]]] $install_options = undef, + Variant[Boolean, String[1]] $manage_config_file = true, + Mysql::Options $options = {}, + Hash $override_options = {}, + Stdlib::Ensure::Package $package_ensure = 'present', + Boolean $package_manage = true, + String[1] $package_name = $mysql::params::server_package_name, + Optional[String[1]] $package_provider = undef, + Optional[String[1]] $package_source = undef, + Variant[Boolean, String[1]] $purge_conf_dir = false, + Variant[Boolean, String[1]] $remove_default_accounts = false, + Variant[Boolean, String[1]] $restart = false, + String[1] $root_group = $mysql::params::root_group, + Optional[Array[String[1]]] $managed_dirs = $mysql::params::managed_dirs, + String[1] $mysql_group = $mysql::params::mysql_group, + Optional[String[1]] $mycnf_owner = undef, + Optional[String[1]] $mycnf_group = undef, + Variant[String, Sensitive[String]] $root_password = 'UNSET', + Variant[Boolean, String[1]] $service_enabled = true, + Variant[Boolean, String[1]] $service_manage = true, + String[1] $service_name = $mysql::params::server_service_name, + Optional[String[1]] $service_provider = undef, + Boolean $create_root_user = true, + Boolean $create_root_my_cnf = true, + Boolean $create_root_login_file = false, + Optional[String[1]] $login_file = undef, + Hash $users = {}, + Hash $grants = {}, + Hash $databases = {}, + Boolean $reload_on_config_change = false, # Deprecated parameters Optional[Variant[String[1], Boolean]] $enabled = undef, Optional[Variant[String[1], Boolean]] $manage_service = undef, diff --git a/manifests/server/root_password.pp b/manifests/server/root_password.pp index 91b047626..42146ce3c 100644 --- a/manifests/server/root_password.pp +++ b/manifests/server/root_password.pp @@ -23,7 +23,12 @@ # below exec will remove this default password. If the user has supplied a root # password it will be set further down with the mysql_user resource. exec { 'remove install pass': - command => "mysqladmin -u root --password=\$(grep -o '[^ ]\\+\$' /.mysql_secret) password && (rm -f /.mysql_secret; exit 0) || (rm -f /.mysql_secret; exit 1)", + command => @(EOD) + mysqladmin -u root --password=$(grep -o '[^ ]+$' /.mysql_secret) password && \ + (rm -f /.mysql_secret; exit 0) || \ + (rm -f /.mysql_secret; exit 1) + | EOD + , onlyif => [['test', '-f' ,'/.mysql_secret']], path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', } @@ -46,15 +51,12 @@ if $mysql::server::create_root_my_cnf and $root_password_set { # TODO: use EPP instead of ERB, as EPP can handle Data of Type Sensitive without further ado file { "${facts['root_home']}/.my.cnf": - content => epp('mysql/my.cnf.pass.epp',$parameters), - owner => 'root', - mode => '0600', + content => epp('mysql/my.cnf.pass.epp',$parameters), + owner => 'root', + mode => '0600', + show_diff => false, } - # show_diff was added with puppet 3.0 - if versioncmp($facts['puppetversion'], '3.0') >= 0 { - File["${facts['root_home']}/.my.cnf"] { show_diff => false } - } if $mysql::server::create_root_user { Mysql_user['root@localhost'] -> File["${facts['root_home']}/.my.cnf"] } diff --git a/metadata.json b/metadata.json index 52a1b70aa..7dfbf8d13 100644 --- a/metadata.json +++ b/metadata.json @@ -84,6 +84,6 @@ ], "description": "MySQL module", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g79a2f93", - "pdk-version": "3.0.0" + "template-ref": "tags/3.2.0.1-0-g52b3cba", + "pdk-version": "3.1.0 (g0d3e8e8)" } diff --git a/spec/acceptance/types/mysql_login_path_spec.rb b/spec/acceptance/types/mysql_login_path_spec.rb index 9c60a4018..3b6af09c0 100644 --- a/spec/acceptance/types/mysql_login_path_spec.rb +++ b/spec/acceptance/types/mysql_login_path_spec.rb @@ -2,21 +2,22 @@ require 'spec_helper_acceptance' -support_bin_dir = '/root/mysql_login_path' -mysql_version = if (os[:family] == 'redhat' && os[:release].to_i == 8) || (os[:family] == 'debian' && os[:release] =~ %r{9|10|11}) - '8.0' - elsif os[:family] == 'ubuntu' && os[:release] =~ %r{18\.04|20\.04} - '5.7' - else - '5.6' - end +describe 'mysql_login_path' do + begin + # mysql_config_editor is not supported on mariadb + # all tests should be skipped + run_shell('mysql_config_editor -V') + rescue + return + end -describe 'mysql_login_path', unless: "#{os[:family]}-#{os[:release].to_i}".include?('suse') do - before(:all) do - run_shell("rm -rf #{support_bin_dir}") - bolt_upload_file('spec/support/mysql_login_path', support_bin_dir) - run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/my_print_defaults /usr/bin/.") - run_shell("cp #{support_bin_dir}/mysql-#{mysql_version}/mysql_config_editor /usr/bin/.") + let(:base_pp) do + <<-MANIFEST + user { 'loginpath_test': + ensure => present, + managehome => true, + } + MANIFEST end after(:all) do @@ -29,36 +30,13 @@ } MANIFEST apply_manifest(pp_cleanup, catch_failures: true) - run_shell("rm -rf #{support_bin_dir}") - end - - describe 'setup' do - pp = <<-MANIFEST - user { 'loginpath_test': - ensure => present, - managehome => true, - } - MANIFEST - it 'works with no errors' do - apply_manifest(pp, catch_failures: true) - end - - it 'finds mysql_config_editor binary for the provider' do - run_shell('mysql_config_editor -V') do |r| - expect(r.stdout).to match(%r{Ver.*#{mysql_version}.*x86_64}) - end - end - - it 'finds my_print_defaults binary for the provider' do - run_shell('my_print_defaults -V') do |r| - expect(r.exit_status).to eq(0) - end - end end context 'for user root' do describe 'add login path' do - pp = <<-MANIFEST + let(:pp) do + <<-MANIFEST + #{base_pp} mysql_login_path { 'local_socket': owner => root, host => 'localhost', @@ -75,7 +53,9 @@ port => 3306, ensure => present, } - MANIFEST + MANIFEST + end + it 'works without errors' do apply_manifest(pp, catch_failures: true) end @@ -102,7 +82,9 @@ end describe 'update login path' do - pp = <<-MANIFEST + let(:pp) do + <<-MANIFEST + #{base_pp} mysql_login_path { 'local_tcp-root': owner => root, host => '10.0.0.1', @@ -111,13 +93,18 @@ port => 3307, ensure => present, } - MANIFEST - pp2 = <<-MANIFEST + MANIFEST + end + + let(:pp2) do + <<-MANIFEST mysql_login_path { 'local_tcp-root': ensure => present, host => '192.168.0.1' } - MANIFEST + MANIFEST + end + it 'works without errors' do apply_manifest(pp, catch_failures: true) end @@ -193,7 +180,9 @@ context 'for user loginpath_test' do describe 'add login path' do - pp = <<-MANIFEST + let(:pp) do + <<-MANIFEST + #{base_pp} mysql_login_path { 'local_tcp': owner => loginpath_test, host => '10.0.0.2', @@ -202,7 +191,9 @@ port => 3306, ensure => present, } - MANIFEST + MANIFEST + end + it 'works without errors' do apply_manifest(pp, catch_failures: true) end @@ -225,7 +216,9 @@ end describe 'update login path' do - pp = <<-MANIFEST + let(:pp) do + <<-MANIFEST + #{base_pp} mysql_login_path { 'local_tcp-loginpath_test': host => '10.0.0.3', user => 'other2', @@ -233,7 +226,9 @@ port => 3307, ensure => present, } - MANIFEST + MANIFEST + end + it 'works without errors' do apply_manifest(pp, catch_failures: true) end @@ -256,12 +251,16 @@ end describe 'delete login path' do - pp = <<-MANIFEST + let(:pp) do + <<-MANIFEST + #{base_pp} mysql_login_path { 'local_tcp': owner => loginpath_test, ensure => absent, } - MANIFEST + MANIFEST + end + it 'works without errors' do apply_manifest(pp, catch_failures: true) end diff --git a/spec/classes/graceful_failures_spec.rb b/spec/classes/graceful_failures_spec.rb index bba9d4ad1..71567eeee 100644 --- a/spec/classes/graceful_failures_spec.rb +++ b/spec/classes/graceful_failures_spec.rb @@ -12,7 +12,7 @@ end it 'gracefully fails' do - expect(subject).to compile.and_raise_error(%r{Unsupported platform:}) + is_expected.to compile.and_raise_error(%r{Unsupported platform:}) end end end diff --git a/spec/classes/mycnf_template_spec.rb b/spec/classes/mycnf_template_spec.rb index 8be85579f..f6662ae6a 100644 --- a/spec/classes/mycnf_template_spec.rb +++ b/spec/classes/mycnf_template_spec.rb @@ -5,15 +5,13 @@ describe 'mysql::server' do on_supported_os.each do |os, facts| context "my.cnf template - on #{os}" do - let(:facts) do - facts.merge(root_home: '/root') - end + let(:facts) { facts } context 'normal entry' do let(:params) { { override_options: { 'mysqld' => { 'socket' => '/var/lib/mysql/mysql.sock' } } } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0644', + is_expected.to contain_file('mysql-config-file').with(mode: '0644', selinux_ignore_defaults: true).with_content(%r{socket = /var/lib/mysql/mysql.sock}) end end @@ -22,7 +20,7 @@ let(:params) { { override_options: { 'mysqld' => { 'replicate-do-db' => ['base1', 'base2'] } } } } it do - expect(subject).to contain_file('mysql-config-file').with_content( + is_expected.to contain_file('mysql-config-file').with_content( %r{.*replicate-do-db = base1\nreplicate-do-db = base2.*}, ) end @@ -80,7 +78,7 @@ let(:params) { { includedir: '/etc/my.cnf.d' } } it 'makes the directory' do - expect(subject).to contain_file('/etc/my.cnf.d').with(ensure: :directory, + is_expected.to contain_file('/etc/my.cnf.d').with(ensure: :directory, mode: '0755') end @@ -91,7 +89,7 @@ let(:params) { { includedir: '' } } it 'shouldnt contain the directory' do - expect(subject).not_to contain_file('mysql-config-file').with(ensure: :directory, + is_expected.not_to contain_file('mysql-config-file').with(ensure: :directory, mode: '0755') end @@ -102,7 +100,7 @@ let(:params) { { 'config_file_mode' => '0644' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0644') + is_expected.to contain_file('mysql-config-file').with(mode: '0644') end end @@ -110,7 +108,7 @@ let(:params) { { 'config_file_mode' => '0664' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0664') + is_expected.to contain_file('mysql-config-file').with(mode: '0664') end end @@ -118,7 +116,7 @@ let(:params) { { 'config_file_mode' => '0660' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0660') + is_expected.to contain_file('mysql-config-file').with(mode: '0660') end end @@ -126,7 +124,7 @@ let(:params) { { 'config_file_mode' => '0641' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0641') + is_expected.to contain_file('mysql-config-file').with(mode: '0641') end end @@ -134,7 +132,7 @@ let(:params) { { 'config_file_mode' => '0610' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0610') + is_expected.to contain_file('mysql-config-file').with(mode: '0610') end end @@ -142,7 +140,7 @@ let(:params) { { 'config_file_mode' => '0600' } } it do - expect(subject).to contain_file('mysql-config-file').with(mode: '0600') + is_expected.to contain_file('mysql-config-file').with(mode: '0600') end end @@ -150,7 +148,7 @@ let(:params) { { 'mycnf_owner' => '12345' } } it do - expect(subject).to contain_file('mysql-config-file').with( + is_expected.to contain_file('mysql-config-file').with( owner: '12345', ) end @@ -160,7 +158,7 @@ let(:params) { { 'mycnf_group' => '12345' } } it do - expect(subject).to contain_file('mysql-config-file').with( + is_expected.to contain_file('mysql-config-file').with( group: '12345', ) end @@ -170,7 +168,7 @@ let(:params) { { 'mycnf_owner' => '12345', 'mycnf_group' => '12345' } } it do - expect(subject).to contain_file('mysql-config-file').with( + is_expected.to contain_file('mysql-config-file').with( owner: '12345', group: '12345', ) diff --git a/spec/classes/mysql_backup_mysqldump_spec.rb b/spec/classes/mysql_backup_mysqldump_spec.rb index 6389e580a..505e338a2 100644 --- a/spec/classes/mysql_backup_mysqldump_spec.rb +++ b/spec/classes/mysql_backup_mysqldump_spec.rb @@ -5,14 +5,12 @@ describe 'mysql::backup::mysqldump' do on_supported_os.each do |os, facts| context "on #{os}" do + let(:facts) { facts } let(:pre_condition) do <<-MANIFEST class { 'mysql::server': } MANIFEST end - let(:facts) do - facts.merge(root_home: '/root') - end let(:default_params) do { 'backupuser' => 'testuser', @@ -30,7 +28,7 @@ class { 'mysql::server': } end it { - expect(subject).to contain_cron('mysql-backup').with( + is_expected.to contain_cron('mysql-backup').with( hour: 23, minute: 59, monthday: 30, @@ -43,14 +41,35 @@ class { 'mysql::server': } context 'with defaults' do let(:params) { default_params } + it { is_expected.to contain_class('mysql::params') } + it { - expect(subject).to contain_cron('mysql-backup').with( + is_expected.to contain_cron('mysql-backup').with( command: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', hour: 23, minute: 5, ) } + + it { + is_expected.to contain_package('bzip2') + } + + it { + package_name = (facts[:os]['family'] == 'RedHat') ? 'cronie' : 'cron' + is_expected.to contain_package(package_name) + } + end + + context 'without backupcomress' do + let(:params) do + { 'backupcompress' => false, }.merge(default_params) + end + + it { + is_expected.not_to contain_package('bzip2') + } end context 'with compression_command' do @@ -62,13 +81,13 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{(\| TEST -TEST)}, ) - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{(\.TEST)}, ) - expect(subject).not_to contain_package('bzip2') + is_expected.not_to contain_package('bzip2') } end @@ -81,7 +100,7 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{information_schema}, ) } diff --git a/spec/classes/mysql_backup_xtrabackup_spec.rb b/spec/classes/mysql_backup_xtrabackup_spec.rb index 3232d686f..21eda9510 100644 --- a/spec/classes/mysql_backup_xtrabackup_spec.rb +++ b/spec/classes/mysql_backup_xtrabackup_spec.rb @@ -5,14 +5,36 @@ describe 'mysql::backup::xtrabackup' do on_supported_os.each do |os, facts| context "on #{os}" do + let(:package) do + if facts[:os]['family'] == 'RedHat' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0 + 'percona-xtrabackup-24' + else + 'percona-xtrabackup' + end + elsif facts[:os]['name'] == 'Debian' + 'percona-xtrabackup-24' + elsif facts[:os]['name'] == 'Ubuntu' + if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') < 0 && + Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0 + 'percona-xtrabackup' + else + 'percona-xtrabackup-24' + end + elsif facts[:os]['family'] == 'Suse' + 'xtrabackup' + else + 'percona-xtrabackup' + end + end + let(:pre_condition) do <<-MANIFEST class { 'mysql::server': } MANIFEST end let(:facts) do - facts.merge(root_home: '/root', - mysql_version: '5.7', + facts.merge(mysql_version: '5.7', mysld_version: 'mysqld Ver 5.7.38 for Linux on x86_64 (MySQL Community Server - (GPL)') end @@ -25,41 +47,24 @@ class { 'mysql::server': } default_params end + it { is_expected.to contain_class('mysql::params') } + it 'does not contain the touch command' do - expect(subject).to contain_file('xtrabackup.sh').without_content( + is_expected.to contain_file('xtrabackup.sh').without_content( %r{(^\s+touch\s+$)}, ) end it 'contains the wrapper script' do - expect(subject).to contain_file('xtrabackup.sh').with_content( + is_expected.to contain_file('xtrabackup.sh').with_content( %r{(\n*^xtrabackup\s+.*\$@)}, ) end - package = if facts[:os]['family'] == 'RedHat' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '8') >= 0 - 'percona-xtrabackup-24' - else - 'percona-xtrabackup' - end - elsif facts[:os]['name'] == 'Debian' - 'percona-xtrabackup-24' - elsif facts[:os]['name'] == 'Ubuntu' - if Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '20') < 0 && - Puppet::Util::Package.versioncmp(facts[:os]['release']['major'], '16') >= 0 - 'percona-xtrabackup' - else - 'percona-xtrabackup-24' - end - elsif facts[:os]['family'] == 'Suse' - 'xtrabackup' - else - 'percona-xtrabackup' - end + it { is_expected.to contain_package(package) } it 'contains the weekly cronjob' do - expect(subject).to contain_cron('xtrabackup-weekly') + is_expected.to contain_cron('xtrabackup-weekly') .with( ensure: 'present', command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup', @@ -71,6 +76,11 @@ class { 'mysql::server': } .that_requires("Package[#{package}]") end + it { + package_name = (facts[:os]['family'] == 'RedHat') ? 'cronie' : 'cron' + is_expected.to contain_package(package_name) + } + it 'contains the daily cronjob for weekdays 1-6' do dateformat = case facts[:os]['name'] when 'FreeBSD', 'OpenBSD' @@ -78,7 +88,7 @@ class { 'mysql::server': } else '$(date -d "last sunday" +\%F)_full' end - expect(subject).to contain_cron('xtrabackup-daily') + is_expected.to contain_cron('xtrabackup-daily') .with( ensure: 'present', command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\%F_\\%H-\\%M-\\%S) --backup", @@ -98,14 +108,14 @@ class { 'mysql::server': } end it 'contains the defined mysql user' do - expect(subject).to contain_mysql_user('backupuser@localhost') + is_expected.to contain_mysql_user('backupuser@localhost') .with( ensure: 'present', password_hash: '*4110E08DF51E70A4BA1D4E33A84205E38CF3FE58', ) .that_requires('Class[mysql::server::root_password]') - expect(subject).to contain_mysql_grant('backupuser@localhost/*.*') + is_expected.to contain_mysql_grant('backupuser@localhost/*.*') .with( ensure: 'present', user: 'backupuser@localhost', @@ -127,9 +137,9 @@ class { 'mysql::server': } end it { - expect(subject).not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status') - expect(subject).not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status') - expect(subject).not_to contain_mysql_grant('backupuser@localhost/*.*') + is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status') + is_expected.not_to contain_mysql_grant('backupuser@localhost/performance_schema.log_status') + is_expected.not_to contain_mysql_grant('backupuser@localhost/*.*') .with( ensure: 'present', user: 'backupuser@localhost', @@ -148,7 +158,7 @@ class { 'mysql::server': } end it { - expect(subject).to contain_mysql_grant('backupuser@localhost/*.*') + is_expected.to contain_mysql_grant('backupuser@localhost/*.*') .with( ensure: 'present', user: 'backupuser@localhost', @@ -162,7 +172,7 @@ class { 'mysql::server': } end, ) .that_requires('Mysql_user[backupuser@localhost]') - expect(subject).to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status') + is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.keyring_component_status') .with( ensure: 'present', user: 'backupuser@localhost', @@ -172,7 +182,7 @@ class { 'mysql::server': } ) .that_requires('Mysql_user[backupuser@localhost]') - expect(subject).to contain_mysql_grant('backupuser@localhost/performance_schema.log_status') + is_expected.to contain_mysql_grant('backupuser@localhost/performance_schema.log_status') .with( ensure: 'present', user: 'backupuser@localhost', @@ -219,7 +229,7 @@ class { 'mysql::server': } end it 'contains the weekly cronjob' do - expect(subject).to contain_cron('xtrabackup-weekly') + is_expected.to contain_cron('xtrabackup-weekly') .with( ensure: 'present', command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F)_full --backup --skip-ssl', @@ -232,7 +242,7 @@ class { 'mysql::server': } end it 'contains the daily cronjob for weekdays 1-6' do - expect(subject).to contain_cron('xtrabackup-daily') + is_expected.to contain_cron('xtrabackup-daily') .with( ensure: 'present', command: "/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/#{dateformat} --target-dir=/tmp/$(date +\\%F_\\%H-\\%M-\\%S) --backup --skip-ssl", @@ -251,11 +261,11 @@ class { 'mysql::server': } end it 'not contains the weekly cronjob' do - expect(subject).not_to contain_cron('xtrabackup-weekly') + is_expected.not_to contain_cron('xtrabackup-weekly') end it 'contains the daily cronjob with all weekdays' do - expect(subject).to contain_cron('xtrabackup-daily').with( + is_expected.to contain_cron('xtrabackup-daily').with( ensure: 'present', command: '/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/$(date +\%F_\%H-\%M-\%S) --backup', user: 'root', @@ -273,7 +283,7 @@ class { 'mysql::server': } end it 'contains the prescript' do - expect(subject).to contain_file('xtrabackup.sh').with_content( + is_expected.to contain_file('xtrabackup.sh').with_content( %r{.*rsync -a /tmp backup01.local-lan:\n\nrsync -a /tmp backup02.local-lan:.*}, ) end @@ -286,7 +296,7 @@ class { 'mysql::server': } end it 'contains the prostscript' do - expect(subject).to contain_file('xtrabackup.sh').with_content( + is_expected.to contain_file('xtrabackup.sh').with_content( %r{.*rsync -a /tmp backup01.local-lan:\n\nrsync -a /tmp backup02.local-lan:.*}, ) end @@ -299,10 +309,12 @@ class { 'mysql::server': } end it 'contain the mariabackup executor' do - expect(subject).to contain_file('xtrabackup.sh').with_content( + is_expected.to contain_file('xtrabackup.sh').with_content( %r{(\n*^mariabackup\s+.*\$@)}, ) end + + it { is_expected.to contain_package(params[:backupmethod_package]) } end context 'with backup_success_file_path' do @@ -311,7 +323,7 @@ class { 'mysql::server': } end it 'contain the touch /tmp/backup_success command' do - expect(subject).to contain_file('xtrabackup.sh').with_content( + is_expected.to contain_file('xtrabackup.sh').with_content( %r{(^\s+touch /tmp/backup_success$)}, ) end diff --git a/spec/classes/mysql_bindings_spec.rb b/spec/classes/mysql_bindings_spec.rb index bce58cc97..05da6aa98 100644 --- a/spec/classes/mysql_bindings_spec.rb +++ b/spec/classes/mysql_bindings_spec.rb @@ -7,10 +7,7 @@ next if facts[:os]['family'] == 'Archlinux' context "on #{os}" do - let(:facts) do - facts.merge(root_home: '/root') - end - + let(:facts) { facts } let(:params) do { 'java_enable' => true, @@ -25,11 +22,27 @@ } end + it { is_expected.to contain_class('mysql::params') } + + it { is_expected.to contain_class('mysql::bindings::java') } it { is_expected.to contain_package('mysql-connector-java') } + + it { is_expected.to contain_class('mysql::bindings::perl') } it { is_expected.to contain_package('perl_mysql') } + + it { is_expected.to contain_class('mysql::bindings::python') } it { is_expected.to contain_package('python-mysqldb') } + + it { is_expected.to contain_class('mysql::bindings::ruby') } it { is_expected.to contain_package('ruby_mysql') } + + it { is_expected.to contain_class('mysql::bindings::php') } + it { is_expected.to contain_package('php-mysql') } + + it { is_expected.to contain_class('mysql::bindings::client_dev') } it { is_expected.to contain_package('mysql-client_dev') } + + it { is_expected.to contain_class('mysql::bindings::daemon_dev') } it { is_expected.to contain_package('mysql-daemon_dev') } end end diff --git a/spec/classes/mysql_client_spec.rb b/spec/classes/mysql_client_spec.rb index 839d30bb5..67cc79553 100644 --- a/spec/classes/mysql_client_spec.rb +++ b/spec/classes/mysql_client_spec.rb @@ -5,13 +5,15 @@ describe 'mysql::client' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) do - facts.merge(root_home: '/root') - end + let(:facts) { facts } context 'with defaults' do + it { is_expected.to contain_class('mysql::params') } + it { is_expected.to contain_class('mysql::client::install') } it { is_expected.not_to contain_class('mysql::bindings') } it { is_expected.to contain_package('mysql_client') } + it { is_expected.to contain_anchor('mysql::client::start') } + it { is_expected.to contain_anchor('mysql::client::end') } end context 'with bindings enabled' do @@ -42,7 +44,7 @@ end it do - expect(subject).to contain_package('mysql_client').with( + is_expected.to contain_package('mysql_client').with( provider: 'dpkg', source: '/somewhere', ) diff --git a/spec/classes/mysql_server_account_security_spec.rb b/spec/classes/mysql_server_account_security_spec.rb index ec27e1ad3..25275499f 100644 --- a/spec/classes/mysql_server_account_security_spec.rb +++ b/spec/classes/mysql_server_account_security_spec.rb @@ -16,7 +16,6 @@ let(:facts) do override_facts( super(), - 'root_home' => '/root', 'networking' => { 'fqdn' => 'myhost.mydomain', 'hostname' => 'myhost', @@ -33,7 +32,7 @@ '@localhost', '@%'].each do |user| it "removes Mysql_User[#{user}]" do # rubocop:disable RSpec/RepeatedExample,RSpec/RepeatedDescription - expect(subject).to contain_mysql_user(user).with_ensure('absent') + is_expected.to contain_mysql_user(user).with_ensure('absent') end end @@ -42,12 +41,12 @@ # covered by the above list. ['root@myhost', '@myhost'].each do |user| it "removes Mysql_User[#{user}]" do # rubocop:disable RSpec/RepeatedExample,RSpec/RepeatedDescription - expect(subject).to contain_mysql_user(user).with_ensure('absent') + is_expected.to contain_mysql_user(user).with_ensure('absent') end end it 'removes Mysql_database[test]' do - expect(subject).to contain_mysql_database('test').with_ensure('absent') + is_expected.to contain_mysql_database('test').with_ensure('absent') end end @@ -55,7 +54,6 @@ let(:facts) do override_facts( super(), - 'root_home' => '/root', 'networking' => { 'fqdn' => 'localhost', 'hostname' => 'localhost', @@ -70,7 +68,7 @@ '@localhost.localdomain', '@%'].each do |user| it "removes Mysql_User[#{user}] for fqdn==localhost" do - expect(subject).to contain_mysql_user(user).with_ensure('absent') + is_expected.to contain_mysql_user(user).with_ensure('absent') end end end @@ -79,7 +77,6 @@ let(:facts) do override_facts( super(), - 'root_home' => '/root', 'networking' => { 'fqdn' => 'localhost.localdomain', 'hostname' => 'localhost', @@ -94,7 +91,7 @@ '@localhost.localdomain', '@%'].each do |user| it "removes Mysql_User[#{user}] for fqdn==localhost.localdomain" do - expect(subject).to contain_mysql_user(user).with_ensure('absent') + is_expected.to contain_mysql_user(user).with_ensure('absent') end end end diff --git a/spec/classes/mysql_server_backup_spec.rb b/spec/classes/mysql_server_backup_spec.rb index b1af7b1f1..34b3e8dd9 100644 --- a/spec/classes/mysql_server_backup_spec.rb +++ b/spec/classes/mysql_server_backup_spec.rb @@ -10,9 +10,7 @@ class { 'mysql::server': } MANIFEST end - let(:facts) do - facts.merge(root_home: '/root') - end + let(:facts) { facts } let(:default_params) do { 'backupuser' => 'testuser', @@ -27,15 +25,17 @@ class { 'mysql::server': } context 'standard conditions' do let(:params) { default_params } + it { is_expected.to contain_class('mysql::params') } + # Cannot use that_requires here, doesn't work on classes. it { - expect(subject).to contain_mysql_user('testuser@localhost').with( + is_expected.to contain_mysql_user('testuser@localhost').with( require: 'Class[Mysql::Server::Root_password]', ) } it { - expect(subject).to contain_mysql_grant('testuser@localhost/*.*').with( + is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( privileges: ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS'], ).that_requires('Mysql_user[testuser@localhost]') } @@ -46,63 +46,63 @@ class { 'mysql::server': } end it { - expect(subject).to contain_mysql_grant('testuser@localhost/*.*').with( + is_expected.to contain_mysql_grant('testuser@localhost/*.*').with( privileges: ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER'], ).that_requires('Mysql_user[testuser@localhost]') } end it { - expect(subject).to contain_cron('mysql-backup').with( + is_expected.to contain_cron('mysql-backup').with( command: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', ) } it { - expect(subject).to contain_file('mysqlbackup.sh').with( + is_expected.to contain_file('mysqlbackup.sh').with( path: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', ) } it { - expect(subject).to contain_file('/tmp/mysql-backup').with( + is_expected.to contain_file('/tmp/mysql-backup').with( ensure: 'directory', ) } it 'has compression by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{bzcat -zc}, ) end it 'skips backing up events table by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="--ignore-table=mysql.event"}, ) end it 'does not mention triggers by default because file_per_database is false' do - expect(subject).to contain_file('mysqlbackup.sh').without_content( + is_expected.to contain_file('mysqlbackup.sh').without_content( %r{.*triggers.*}, ) end it 'does not mention routines by default because file_per_database is false' do - expect(subject).to contain_file('mysqlbackup.sh').without_content( + is_expected.to contain_file('mysqlbackup.sh').without_content( %r{.*routines.*}, ) end it 'has 25 days of rotation' do # MySQL counts from 0 - expect(subject).to contain_file('mysqlbackup.sh').with_content(%r{.*ROTATE=24.*}) + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*ROTATE=24.*}) end it 'has a standard PATH' do - expect(subject).to contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin}) + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin}) end end @@ -141,7 +141,7 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('/tmp/mysql-backup').with( + is_expected.to contain_file('/tmp/mysql-backup').with( ensure: 'directory', mode: '0750', owner: 'testuser', @@ -156,14 +156,14 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('mysqlbackup.sh').with( + is_expected.to contain_file('mysqlbackup.sh').with( path: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', ) } it 'is able to disable compression' do - expect(subject).to contain_file('mysqlbackup.sh').without_content( + is_expected.to contain_file('mysqlbackup.sh').without_content( %r{.*bzcat -zc.*}, ) end @@ -175,14 +175,14 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('mysqlbackup.sh').with( + is_expected.to contain_file('mysqlbackup.sh').with( path: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', ) } it 'is able to backup events table' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="--events"}, ) end @@ -194,26 +194,26 @@ class { 'mysql::server': } end it { - expect(subject).to contain_file('mysqlbackup.sh').with( + is_expected.to contain_file('mysqlbackup.sh').with( path: '/usr/local/sbin/mysqlbackup.sh', ensure: 'present', ) } it 'has a backup file for each database' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{mysql | bzcat -zc \${DIR}\\\${PREFIX}mysql_`date'}, ) end it 'skips backup triggers by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end it 'skips backing up routines by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end @@ -225,7 +225,7 @@ class { 'mysql::server': } end it 'backups triggers when asked' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"}, ) end @@ -238,7 +238,7 @@ class { 'mysql::server': } end it 'skips backing up triggers when asked to skip' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end @@ -251,7 +251,7 @@ class { 'mysql::server': } end it 'backups routines when asked' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"}, ) end @@ -264,7 +264,7 @@ class { 'mysql::server': } end it 'skips backing up routines when asked to skip' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end @@ -277,7 +277,7 @@ class { 'mysql::server': } end it 'loops through backup all databases' do - expect(subject).to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) end context 'with compression disabled' do @@ -286,22 +286,22 @@ class { 'mysql::server': } end it 'loops through backup all databases without compression #show databases' do - expect(subject).to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) + is_expected.to contain_file('mysqlbackup.sh').with_content(%r{.*SHOW DATABASES.*}) end it 'loops through backup all databases without compression #bzcat' do - expect(subject).to contain_file('mysqlbackup.sh').without_content(%r{.*bzcat -zc.*}) + is_expected.to contain_file('mysqlbackup.sh').without_content(%r{.*bzcat -zc.*}) end end it 'skips backup triggers by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end it 'skips backing up routines by default' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end @@ -313,7 +313,7 @@ class { 'mysql::server': } end it 'backups triggers when asked' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"}, ) end @@ -326,7 +326,7 @@ class { 'mysql::server': } end it 'skips backing up triggers when asked to skip' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"}, ) end @@ -339,7 +339,7 @@ class { 'mysql::server': } end it 'backups routines when asked' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --routines"}, ) end @@ -352,7 +352,7 @@ class { 'mysql::server': } end it 'skips backing up routines when asked to skip' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-routines"}, ) end @@ -365,7 +365,7 @@ class { 'mysql::server': } end it 'is add postscript' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{rsync -a /tmp backup01.local-lan:}, ) end @@ -380,7 +380,7 @@ class { 'mysql::server': } end it 'is add postscript' do - expect(subject).to contain_file('mysqlbackup.sh').with_content( + is_expected.to contain_file('mysqlbackup.sh').with_content( %r{.*rsync -a /tmp backup01.local-lan:\n\nrsync -a /tmp backup02.local-lan:.*}, ) end diff --git a/spec/classes/mysql_server_spec.rb b/spec/classes/mysql_server_spec.rb index 3ff307b71..55abfa853 100644 --- a/spec/classes/mysql_server_spec.rb +++ b/spec/classes/mysql_server_spec.rb @@ -5,18 +5,34 @@ describe 'mysql::server' do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) do - facts.merge(root_home: '/root') - end + let(:facts) { facts } context 'with defaults' do + it { is_expected.to contain_class('mysql::params') } it { is_expected.to contain_class('mysql::server::install') } it { is_expected.to contain_class('mysql::server::config') } + it { is_expected.to contain_class('mysql::server::managed_dirs') } + it { is_expected.to contain_class('mysql::server::installdb') } it { is_expected.to contain_class('mysql::server::service') } it { is_expected.to contain_class('mysql::server::root_password') } it { is_expected.to contain_class('mysql::server::providers') } it { is_expected.to contain_file('mysql-config-file').that_comes_before('Service[mysqld]') } it { is_expected.not_to contain_file('mysql-config-file').that_notifies('Service[mysqld]') } + + it { is_expected.to contain_anchor('mysql::server::start') } + it { is_expected.to contain_anchor('mysql::server::end') } + + it { + is_expected.to contain_exec('wait_for_mysql_socket_to_open') + .with( + command: ['test', '-S', %r{.*\.sock}], + unless: [['test', '-S', %r{.*\.sock}]], + tries: '3', + try_sleep: '10', + require: 'Service[mysqld]', + path: '/bin:/usr/bin', + ) + } end context 'with remove_default_accounts set' do @@ -65,7 +81,7 @@ context 'mysql::server::install' do it 'contains the package by default' do - expect(subject).to contain_package('mysql-server').with(ensure: :present) + is_expected.to contain_package('mysql-server').with(ensure: :present) end context 'with package_manage set to true' do @@ -95,7 +111,7 @@ end it do - expect(subject).to contain_package('mysql-server').with( + is_expected.to contain_package('mysql-server').with( provider: 'dpkg', source: '/somewhere', ) @@ -125,7 +141,7 @@ let(:params) { { service_enabled: false } } it do - expect(subject).to contain_service('mysqld').with(ensure: :stopped) + is_expected.to contain_service('mysqld').with(ensure: :stopped) end context 'with package_manage set to true' do @@ -179,8 +195,12 @@ context 'mysql::server::root_password' do describe 'when defaults' do it { - expect(subject).to contain_exec('remove install pass').with( - command: "mysqladmin -u root --password=$(grep -o '[^ ]\\+$' /.mysql_secret) password && (rm -f /.mysql_secret; exit 0) || (rm -f /.mysql_secret; exit 1)", + is_expected.to contain_exec('remove install pass').with( + command: <<-'CMD'.gsub(%r{^\s+}, ''), + mysqladmin -u root --password=$(grep -o '[^ ]+$' /.mysql_secret) password && \ + (rm -f /.mysql_secret; exit 0) || \ + (rm -f /.mysql_secret; exit 1) + CMD onlyif: [['test', '-f', '/.mysql_secret']], path: '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', ) @@ -195,11 +215,7 @@ it { is_expected.to contain_mysql_user('root@localhost') } - if Puppet.version.to_f >= 3.0 - it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false).that_requires('Mysql_user[root@localhost]') } - else - it { is_expected.to contain_file('/root/.my.cnf').that_requires('Mysql_user[root@localhost]') } - end + it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false).that_requires('Mysql_user[root@localhost]') } end describe 'when root_password set, create_root_user set to false' do @@ -207,11 +223,7 @@ it { is_expected.not_to contain_mysql_user('root@localhost') } - if Puppet.version.to_f >= 3.0 - it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false) } - else - it { is_expected.to contain_file('/root/.my.cnf') } - end + it { is_expected.to contain_file('/root/.my.cnf').with(show_diff: false) } end describe 'when root_password set, create_root_my_cnf set to false' do @@ -245,7 +257,7 @@ end it { - expect(subject).to contain_mysql_user('foo@localhost').with( + is_expected.to contain_mysql_user('foo@localhost').with( max_connections_per_hour: '1', max_queries_per_hour: '2', max_updates_per_hour: '3', max_user_connections: '4', password_hash: '*F3A2A51A9B0F2BE2468926B4132313728C250DBF' @@ -253,7 +265,7 @@ } it { - expect(subject).to contain_mysql_user('foo2@localhost').with( + is_expected.to contain_mysql_user('foo2@localhost').with( max_connections_per_hour: nil, max_queries_per_hour: nil, max_updates_per_hour: nil, max_user_connections: nil, password_hash: nil @@ -276,7 +288,7 @@ end it { - expect(subject).to contain_mysql_user('foo@localhost').with( + is_expected.to contain_mysql_user('foo@localhost').with( max_connections_per_hour: '1', max_queries_per_hour: '2', max_updates_per_hour: '3', max_user_connections: '4', password_hash: 'Sensitive [value redacted]' @@ -302,14 +314,14 @@ end it { - expect(subject).to contain_mysql_grant('foo@localhost/somedb.*').with( + is_expected.to contain_mysql_grant('foo@localhost/somedb.*').with( user: 'foo@localhost', table: 'somedb.*', privileges: ['SELECT', 'UPDATE'], options: ['GRANT'] ) } it { - expect(subject).to contain_mysql_grant('foo2@localhost/*.*').with( + is_expected.to contain_mysql_grant('foo2@localhost/*.*').with( user: 'foo2@localhost', table: '*.*', privileges: ['SELECT'], options: nil ) @@ -328,7 +340,7 @@ end it { - expect(subject).to contain_mysql_database('somedb').with( + is_expected.to contain_mysql_database('somedb').with( charset: 'latin1', collate: 'latin1', ) diff --git a/spec/default_facts.yml b/spec/default_facts.yml index 3346c394d..ec9a921b6 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -7,3 +7,5 @@ networking: ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" mac: "AA:AA:AA:AA:AA:AA" is_pe: false +root_home: "/root" + diff --git a/spec/defines/mysql_db_spec.rb b/spec/defines/mysql_db_spec.rb index ce4e524a4..dc33c620b 100644 --- a/spec/defines/mysql_db_spec.rb +++ b/spec/defines/mysql_db_spec.rb @@ -5,10 +5,7 @@ describe 'mysql::db', type: :define do on_supported_os.each do |os, facts| context "on #{os}" do - let(:facts) do - facts.merge(root_home: '/root') - end - + let(:facts) { facts } let(:title) { 'test_db' } let(:params) do @@ -20,66 +17,66 @@ let(:sql) { ['/tmp/test.sql'] } it 'does not notify the import sql exec if no sql script was provided' do - expect(subject).to contain_mysql_database('test_db').without_notify + is_expected.to contain_mysql_database('test_db').without_notify end it 'subscribes to database if sql script is given' do params['sql'] = sql - expect(subject).to contain_mysql_database('test_db') - expect(subject).to contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]') + is_expected.to contain_mysql_database('test_db') + is_expected.to contain_exec('test_db-import').with_subscribe('Mysql_database[test_db]') end it 'onlies import sql script on creation if not enforcing' do params.merge!('sql' => sql, 'enforce_sql' => false) - expect(subject).to contain_exec('test_db-import').with_refreshonly(true) + is_expected.to contain_exec('test_db-import').with_refreshonly(true) end it 'imports sql script on creation' do params.merge!('sql' => sql, 'enforce_sql' => true) # ' if enforcing #refreshonly' - expect(subject).to contain_exec('test_db-import').with_refreshonly(false) + is_expected.to contain_exec('test_db-import').with_refreshonly(false) # 'if enforcing #command' - expect(subject).to contain_exec('test_db-import').with_command('cat /tmp/test.sql | mysql test_db') + is_expected.to contain_exec('test_db-import').with_command('cat /tmp/test.sql | mysql test_db') end it 'imports sql script with custom command on creation' do params.merge!('sql' => sql, 'enforce_sql' => true, 'import_cat_cmd' => 'zcat') # if enforcing #refreshonly - expect(subject).to contain_exec('test_db-import').with_refreshonly(false) + is_expected.to contain_exec('test_db-import').with_refreshonly(false) # if enforcing #command - expect(subject).to contain_exec('test_db-import').with_command('zcat /tmp/test.sql | mysql test_db') + is_expected.to contain_exec('test_db-import').with_command('zcat /tmp/test.sql | mysql test_db') end it 'imports sql scripts when more than one is specified' do params['sql'] = ['/tmp/test.sql', '/tmp/test_2.sql'] - expect(subject).to contain_exec('test_db-import').with_command('cat /tmp/test.sql /tmp/test_2.sql | mysql test_db') + is_expected.to contain_exec('test_db-import').with_command('cat /tmp/test.sql /tmp/test_2.sql | mysql test_db') end it 'does not create database' do params.merge!('ensure' => 'absent', 'host' => 'localhost') - expect(subject).to contain_mysql_database('test_db').with_ensure('absent') - expect(subject).to contain_mysql_user('testuser@localhost').with_ensure('absent') + is_expected.to contain_mysql_database('test_db').with_ensure('absent') + is_expected.to contain_mysql_user('testuser@localhost').with_ensure('absent') end it 'creates with an appropriate collate and charset' do params.merge!('charset' => 'utf8', 'collate' => 'utf8_danish_ci') - expect(subject).to contain_mysql_database('test_db').with('charset' => 'utf8', + is_expected.to contain_mysql_database('test_db').with('charset' => 'utf8', 'collate' => 'utf8_danish_ci') end it 'uses dbname parameter as database name instead of name' do params['dbname'] = 'real_db' - expect(subject).to contain_mysql_database('real_db') + is_expected.to contain_mysql_database('real_db') end it 'uses tls_options for user when set' do params['tls_options'] = ['SSL'] - expect(subject).to contain_mysql_user('testuser@localhost').with_tls_options(['SSL']) + is_expected.to contain_mysql_user('testuser@localhost').with_tls_options(['SSL']) end it 'uses grant_options for grant when set' do params['grant_options'] = ['GRANT'] - expect(subject).to contain_mysql_grant('testuser@localhost/test_db.*').with_options(['GRANT']) + is_expected.to contain_mysql_grant('testuser@localhost/test_db.*').with_options(['GRANT']) end # Invalid file paths @@ -94,7 +91,7 @@ ].each do |path| it "fails when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path] - expect(subject).to raise_error(Puppet::PreformattedError, %r{The file '#{Regexp.escape(path)}' is invalid. A valid file path is expected.}) + is_expected.to raise_error(Puppet::PreformattedError, %r{The file '#{Regexp.escape(path)}' is invalid. A valid file path is expected.}) end end @@ -111,7 +108,7 @@ ].each do |path| it "succeeds when provided '#{path}' as a value to the 'sql' parameter" do params['sql'] = [path] - expect(subject).to contain_exec('test_db-import').with_command("cat #{path} | mysql test_db") + is_expected.to contain_exec('test_db-import').with_command("cat #{path} | mysql test_db") end end @@ -125,7 +122,7 @@ ].each do |name| it "fails when provided '#{name}' as a value to the 'name' parameter" do params['name'] = name - expect(subject).to raise_error(Puppet::PreformattedError, %r{The database name '#{name}' is invalid.}) + is_expected.to raise_error(Puppet::PreformattedError, %r{The database name '#{name}' is invalid.}) end end @@ -138,7 +135,7 @@ ].each do |name| it "succeeds when the provided '#{name}' as a value to the 'dbname' parameter" do params['dbname'] = name - expect(subject).to contain_mysql_database(name) + is_expected.to contain_mysql_database(name) end end end diff --git a/spec/functions/mysql_innobackupex_args_spec.rb b/spec/functions/mysql_innobackupex_args_spec.rb index 36be79ca7..6a2e94f57 100644 --- a/spec/functions/mysql_innobackupex_args_spec.rb +++ b/spec/functions/mysql_innobackupex_args_spec.rb @@ -4,55 +4,55 @@ describe 'mysql::innobackupex_args' do it 'exists' do - expect(subject).not_to be_nil + is_expected.not_to be_nil end it 'accepts empty strings as puppet undef' do - expect(subject).to run.with_params('', true, '', [], []) + is_expected.to run.with_params('', true, '', [], []) end context 'should work with username and password' do it 'returns args with username and password' do - expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') + is_expected.to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') end it 'returns args with database lists' do - expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], []).and_return('--user="root" --password="12345" --databases="db1 db2"') + is_expected.to run.with_params('root', false, '12345', ['db1', 'db2'], []).and_return('--user="root" --password="12345" --databases="db1 db2"') end it 'returns args with backup compress only' do expected_results = '--user="root" --password="12345" --compress' - expect(subject).to run.with_params('root', true, '12345', [], []).and_return(expected_results) + is_expected.to run.with_params('root', true, '12345', [], []).and_return(expected_results) end it 'returns args with backup compress, database list and optional_args' do expected_results = '--user="root" --password="12345" --compress --databases="db1 db2" tst_arg_1 tst_arg_2' - expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) + is_expected.to run.with_params('root', true, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) end end context 'should work without database args' do it 'returns args without database list' do - expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') + is_expected.to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') end end it 'returns args without backup compress' do - expect(subject).to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') + is_expected.to run.with_params('root', false, '12345', [], []).and_return('--user="root" --password="12345"') end it 'returns args with backup compress and database list' do expected_results = '--user="root" --password="12345" --compress --databases="db1 db2"' - expect(subject).to run.with_params('root', true, '12345', ['db1', 'db2'], []).and_return(expected_results) + is_expected.to run.with_params('root', true, '12345', ['db1', 'db2'], []).and_return(expected_results) end it 'returns args without backup compress database list and optional_args' do expected_results = '--user="root" --password="12345" --databases="db1 db2" tst_arg_1 tst_arg_2' - expect(subject).to run.with_params('root', false, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) + is_expected.to run.with_params('root', false, '12345', ['db1', 'db2'], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) end it 'returns args without backup compress database list and with optional_args' do expected_results = '--user="root" --password="12345" tst_arg_1 tst_arg_2' - expect(subject).to run.with_params('root', false, '12345', [], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) + is_expected.to run.with_params('root', false, '12345', [], ['tst_arg_1', 'tst_arg_2']).and_return(expected_results) end end diff --git a/spec/functions/mysql_normalise_and_deepmerge_spec.rb b/spec/functions/mysql_normalise_and_deepmerge_spec.rb index c4f9cd651..d5b5fad83 100644 --- a/spec/functions/mysql_normalise_and_deepmerge_spec.rb +++ b/spec/functions/mysql_normalise_and_deepmerge_spec.rb @@ -4,91 +4,86 @@ describe 'mysql::normalise_and_deepmerge' do it 'exists' do - expect(subject).not_to be_nil + is_expected.not_to be_nil end it 'throws error with no arguments' do - expect(subject).to run.with_params.and_raise_error(Puppet::ParseError) + is_expected.to run.with_params.and_raise_error(Puppet::ParseError) end it 'throws error with only one argument' do - expect(subject).to run.with_params('one' => 1).and_raise_error(Puppet::ParseError) + is_expected.to run.with_params('one' => 1).and_raise_error(Puppet::ParseError) end it 'accepts empty strings as puppet undef' do - expect(subject).to run.with_params({}, '') + is_expected.to run.with_params({}, '') end - index_values = ['one', 'two', 'three'] - expected_values_one = ['1', '2', '2'] it 'merge two hashes' do - new_hash = subject.execute({ 'one' => '1', 'two' => '1' }, 'two' => '2', 'three' => '2') - index_values.each_with_index do |index, expected| - expect(new_hash[index]).to eq(expected_values_one[expected]) - end + is_expected.to run.with_params( + { 'one' => '1', 'two' => '1' }, 'two' => '2', 'three' => '2' + ).and_return( + { 'one' => '1', 'two' => '2', 'three' => '2' }, + ) end it 'merges multiple hashes' do - hash = subject.execute({ 'one' => 1 }, { 'one' => '2' }, 'one' => '3') - expect(hash['one']).to eq('3') + is_expected.to run.with_params( + { 'one' => 1 }, { 'one' => '2' }, 'one' => '3' + ).and_return( + { 'one' => '3' }, + ) end it 'accepts empty hashes' do - expect(subject).to run.with_params({}, {}, {}).and_return({}) + is_expected.to run.with_params({}, {}, {}).and_return({}) end - expected_values_two = [1, 2, { 'four' => 4 }] it 'merges subhashes' do - hash = subject.execute({ 'one' => 1 }, 'two' => 2, 'three' => { 'four' => 4 }) - index_values.each_with_index do |index, expected| - expect(hash[index]).to eq(expected_values_two[expected]) - end + is_expected.to run.with_params( + { 'one' => 1 }, 'two' => 2, 'three' => { 'four' => 4 } + ).and_return( + { 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, + ) end it 'appends to subhashes' do - hash = subject.execute({ 'one' => { 'two' => 2 } }, 'one' => { 'three' => 3 }) - expect(hash['one']).to eq('two' => 2, 'three' => 3) + is_expected.to run.with_params( + { 'one' => { 'two' => 2 } }, 'one' => { 'three' => 3 } + ).and_return( + { 'one' => { 'two' => 2, 'three' => 3 } }, + ) end - expected_values_three = [1, 'dos', { 'four' => 4, 'five' => 5 }] it 'appends to subhashes 2' do - hash = subject.execute({ 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, 'two' => 'dos', 'three' => { 'five' => 5 }) - index_values.each_with_index do |index, expected| - expect(hash[index]).to eq(expected_values_three[expected]) - end + is_expected.to run.with_params( + { 'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }, 'two' => 'dos', 'three' => { 'five' => 5 } + ).and_return( + { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }, + ) end - index_values_two = ['key1', 'key2'] - expected_values_four = [{ 'a' => 1, 'b' => 99 }, 'c' => 3] it 'appends to subhashes 3' do - hash = subject.execute({ 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, 'key1' => { 'b' => 99 }) - index_values_two.each_with_index do |index, expected| - expect(hash[index]).to eq(expected_values_four[expected]) - end + is_expected.to run.with_params( + { 'key1' => { 'a' => 1, 'b' => 2 }, 'key2' => { 'c' => 3 } }, 'key1' => { 'b' => 99 } + ).and_return( + { 'key1' => { 'a' => 1, 'b' => 99 }, 'key2' => { 'c' => 3 } }, + ) end it 'equates keys mod dash and underscore #value' do - hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10) - expect(hash['a_b_c']).to eq(10) + is_expected.to run.with_params( + { 'a-b-c' => 1 }, 'a_b_c' => 10 + ).and_return( + { 'a_b_c' => 10 }, + ) end - it 'equates keys mod dash and underscore #not' do - hash = subject.execute({ 'a-b-c' => 1 }, 'a_b_c' => 10) - expect(hash).not_to have_key('a-b-c') - end - - index_values_three = ['a_b_c', 'b-c-d'] - expected_values_five = [10, { 'e-f-g' => 3, 'c_d_e' => 12 }] - index_values_error = ['a-b-c', 'b_c_d'] - index_values_three.each_with_index do |index, expected| - it 'keeps style of the last when keys are equal mod dash and underscore #value' do - hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 }) - expect(hash[index]).to eq(expected_values_five[expected]) - end - - it 'keeps style of the last when keys are equal mod dash and underscore #not' do - hash = subject.execute({ 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 }) - expect(hash).not_to have_key(index_values_error[expected]) - end + it 'keeps style of the last when keys are equal mod dash and underscore #value' do + is_expected.to run.with_params( + { 'a-b-c' => 1, 'b_c_d' => { 'c-d-e' => 2, 'e-f-g' => 3 } }, 'a_b_c' => 10, 'b-c-d' => { 'c_d_e' => 12 } + ).and_return( + { 'a_b_c' => 10, 'b-c-d' => { 'e-f-g' => 3, 'c_d_e' => 12 } }, + ) end end diff --git a/spec/functions/mysql_strip_hash_spec.rb b/spec/functions/mysql_strip_hash_spec.rb index 2f6778340..e80f8ed34 100644 --- a/spec/functions/mysql_strip_hash_spec.rb +++ b/spec/functions/mysql_strip_hash_spec.rb @@ -4,26 +4,26 @@ describe 'mysql::strip_hash' do it 'exists' do - expect(subject).not_to be_nil + is_expected.not_to be_nil end it 'raises a ArgumentError if there is less than 1 arguments' do - expect(subject).to run.with_params.and_raise_error(ArgumentError) + is_expected.to run.with_params.and_raise_error(ArgumentError) end it 'raises a ArgumentError if there is more than 1 arguments' do - expect(subject).to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(ArgumentError) + is_expected.to run.with_params({ 'foo' => 1 }, 'bar' => 2).and_raise_error(ArgumentError) end it 'raises a ArgumentError if argument is not a hash' do - expect(subject).to run.with_params('foo').and_raise_error(ArgumentError) + is_expected.to run.with_params('foo').and_raise_error(ArgumentError) end it 'passes a hash without blanks through' do - expect(subject).to run.with_params('one' => 1, 'two' => 2, 'three' => 3).and_return('one' => 1, 'two' => 2, 'three' => 3) + is_expected.to run.with_params('one' => 1, 'two' => 2, 'three' => 3).and_return('one' => 1, 'two' => 2, 'three' => 3) end it 'removes blank hash elements' do - expect(subject).to run.with_params('one' => 1, 'two' => '', 'three' => nil, 'four' => 4).and_return('one' => 1, 'three' => nil, 'four' => 4) + is_expected.to run.with_params('one' => 1, 'two' => '', 'three' => nil, 'four' => 4).and_return('one' => 1, 'three' => nil, 'four' => 4) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d7abc00f..52d4acdb6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -33,7 +34,7 @@ # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| - add_custom_fact fact, value + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c| @@ -46,7 +47,7 @@ end c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] c.after(:suite) do - RSpec::Puppet::Coverage.report!(0) + RSpec::Puppet::Coverage.report!(81) end # Filter backtrace noise diff --git a/spec/support/mysql_login_path/mysql-5.6/my_print_defaults b/spec/support/mysql_login_path/mysql-5.6/my_print_defaults deleted file mode 100755 index 0ccc5acf9..000000000 Binary files a/spec/support/mysql_login_path/mysql-5.6/my_print_defaults and /dev/null differ diff --git a/spec/support/mysql_login_path/mysql-5.6/mysql_config_editor b/spec/support/mysql_login_path/mysql-5.6/mysql_config_editor deleted file mode 100755 index 6df452bcb..000000000 Binary files a/spec/support/mysql_login_path/mysql-5.6/mysql_config_editor and /dev/null differ diff --git a/spec/support/mysql_login_path/mysql-5.7/my_print_defaults b/spec/support/mysql_login_path/mysql-5.7/my_print_defaults deleted file mode 100755 index 74749f587..000000000 Binary files a/spec/support/mysql_login_path/mysql-5.7/my_print_defaults and /dev/null differ diff --git a/spec/support/mysql_login_path/mysql-5.7/mysql_config_editor b/spec/support/mysql_login_path/mysql-5.7/mysql_config_editor deleted file mode 100755 index 38645a2a7..000000000 Binary files a/spec/support/mysql_login_path/mysql-5.7/mysql_config_editor and /dev/null differ diff --git a/spec/support/mysql_login_path/mysql-8.0/my_print_defaults b/spec/support/mysql_login_path/mysql-8.0/my_print_defaults deleted file mode 100755 index e6650bdae..000000000 Binary files a/spec/support/mysql_login_path/mysql-8.0/my_print_defaults and /dev/null differ diff --git a/spec/support/mysql_login_path/mysql-8.0/mysql_config_editor b/spec/support/mysql_login_path/mysql-8.0/mysql_config_editor deleted file mode 100755 index e64fcacd6..000000000 Binary files a/spec/support/mysql_login_path/mysql-8.0/mysql_config_editor and /dev/null differ diff --git a/spec/unit/facter/mysql_server_id_spec.rb b/spec/unit/facter/mysql_server_id_spec.rb index fb914a9d4..36608b194 100644 --- a/spec/unit/facter/mysql_server_id_spec.rb +++ b/spec/unit/facter/mysql_server_id_spec.rb @@ -14,7 +14,7 @@ end it do - Facter.fact(:mysql_server_id).value.to_s.should == '241857808' + expect(Facter.fact(:mysql_server_id).value).to be(241_857_808) end end @@ -24,7 +24,7 @@ end it do - Facter.fact(:mysql_server_id).value.to_s.should == '1' + expect(Facter.fact(:mysql_server_id).value).to be(1) end end @@ -34,7 +34,7 @@ end it do - Facter.fact(:mysql_server_id).value.to_s.should == '' + expect(Facter.fact(:mysql_server_id).value).to be(nil) end end end diff --git a/spec/unit/puppet/provider/mysql_database/mysql_spec.rb b/spec/unit/puppet/provider/mysql_database/mysql_spec.rb index fd4c07e7a..25ffcc1ee 100644 --- a/spec/unit/puppet/provider/mysql_database/mysql_spec.rb +++ b/spec/unit/puppet/provider/mysql_database/mysql_spec.rb @@ -25,7 +25,7 @@ end before :each do - allow(Facter.fact(:value)).to receive(:root_home).and_return('/root') + allow(Facter).to receive(:value).with(:root_home).and_return('/root') allow(Puppet::Util).to receive(:which).with('mysql').and_return('/usr/bin/mysql') allow(File).to receive(:file?).with('/root/.my.cnf').and_return(true) allow(provider.class).to receive(:mysql_caller).with('show databases', 'regular').and_return('new_database')