From 167843da9e219c9789a04341490d30a74d8b6381 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Sun, 24 Dec 2023 13:15:28 -0500 Subject: [PATCH] Major updates - read description * Drop Puppet 6 support * Add Puppet 8 support * Add EL9 support * Support latest module dependencies --- .github/workflows/ci.yaml | 13 +++--- .github/workflows/release.yaml | 2 +- .rubocop.yml | 35 +++++---------- .sync.yml | 12 ++--- Gemfile | 26 ++++------- Rakefile | 2 +- lib/facter/has_mellanox_infiniband.rb | 4 +- lib/facter/mellanox_ofed_version.rb | 2 + lib/facter/util/mellanox_infiniband.rb | 4 +- manifests/config.pp | 1 - manifests/init.pp | 10 ----- manifests/install.pp | 1 - manifests/interface.pp | 6 +-- manifests/opensm.pp | 34 +++++++------- manifests/repo.pp | 3 +- manifests/service.pp | 1 - manifests/srp.pp | 44 +++++++++---------- metadata.json | 27 ++++++++---- .../nodesets/{centos-7.yml => el7.yml} | 2 + .../nodesets/{rocky-8.yml => el8.yml} | 4 +- spec/acceptance/nodesets/el9.yml | 26 +++++++++++ spec/classes/init_spec.rb | 33 +++++++++++--- spec/classes/opensm_spec.rb | 20 +++++---- spec/classes/srp_spec.rb | 20 +++++---- spec/defines/interface_spec.rb | 28 ++++++------ spec/shared_examples/config.rb | 3 -- spec/shared_examples/install.rb | 6 --- spec/shared_examples/service.rb | 9 ---- spec/spec_helper.rb | 10 ++--- spec/spec_helper_acceptance.rb | 4 +- spec/spec_helper_local.rb | 4 +- .../facter/has_mellanox_infiniband_spec.rb | 2 + .../unit/facter/mellanox_ofed_version_spec.rb | 6 ++- .../facter/util/mellanox_infiniband_spec.rb | 4 +- 34 files changed, 208 insertions(+), 200 deletions(-) rename spec/acceptance/nodesets/{centos-7.yml => el7.yml} (65%) rename spec/acceptance/nodesets/{rocky-8.yml => el8.yml} (88%) create mode 100644 spec/acceptance/nodesets/el9.yml delete mode 100644 spec/shared_examples/config.rb delete mode 100644 spec/shared_examples/install.rb delete mode 100644 spec/shared_examples/service.rb diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d3cefdf..59b1612 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,6 +7,7 @@ on: - master pull_request: + jobs: unit: runs-on: ubuntu-latest @@ -15,27 +16,27 @@ jobs: fail-fast: false matrix: include: - - ruby: 2.5.7 - puppet: 6 + - ruby: 2.7.7 + puppet: 7 fixtures: .fixtures.yml allow_failure: false - - ruby: 2.7.0 - puppet: 7 + - ruby: 3.2.2 + puppet: 8 fixtures: .fixtures.yml allow_failure: false env: BUNDLE_WITHOUT: system_tests:release PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0" - FACTER_GEM_VERSION: "< 4.0" FIXTURES_YML: ${{ matrix.fixtures }} name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + cache-version: 2 bundler: '2.1.0' - name: Validate run: bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 495a715..f55e6af 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.rubocop.yml b/.rubocop.yml index 5307849..3b93cd8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,11 @@ --- require: - rubocop-rspec -- rubocop-i18n AllCops: DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '2.5' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -21,13 +20,6 @@ AllCops: Metrics/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. @@ -40,10 +32,6 @@ Style/BlockDelimiters: Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining -Style/BracesAroundHashParameters: - Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0. - See https://github.com/rubocop-hq/rubocop/pull/7643 - Enabled: true Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. EnforcedStyle: compact @@ -72,13 +60,16 @@ Style/TrailingCommaInArguments: Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets +RSpec/ImplicitSubject: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Naming/MethodParameterName: + AllowedNames: + - is RSpec/MessageSpies: EnforcedStyle: receive Style/Documentation: @@ -93,15 +84,9 @@ Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: - Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: - Enabled: false -GetText/DecorateStringFormattingUsingPercent: - Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/HeredocIndentation: Enabled: false Metrics/AbcSize: Enabled: false diff --git a/.sync.yml b/.sync.yml index 7287990..fac1971 100644 --- a/.sync.yml +++ b/.sync.yml @@ -5,15 +5,9 @@ delete: true appveyor.yml: delete: true -spec/acceptance/nodesets/debian-8.yml: - delete: true -spec/acceptance/nodesets/debian-9.yml: - delete: true -spec/acceptance/nodesets/debian-10.yml: - delete: true -spec/acceptance/nodesets/ubuntu-1604.yml: - delete: true -spec/acceptance/nodesets/ubuntu-1804.yml: +spec/acceptance/nodesets/debian-11.yml: delete: true spec/acceptance/nodesets/ubuntu-2004.yml: delete: true +spec/acceptance/nodesets/ubuntu-2204.yml: + delete: true diff --git a/Gemfile b/Gemfile index 2f01d84..60f2000 100644 --- a/Gemfile +++ b/Gemfile @@ -17,30 +17,22 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-lint-param-docs", require: false - gem "github_changelog_generator", require: false + gem "voxpupuli-test", '7.0.0', require: false + gem "faraday", '~> 1.0', require: false + gem "github_changelog_generator", require: false + gem "puppet-blacksmith", require: false + gem "puppet-strings", require: false end group :system_tests do - gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby] - gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0') + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.29') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "beaker-pe", require: false gem "beaker-hostgenerator" gem "beaker-rspec" - gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || '~> 0.7.0') + gem "beaker-docker" gem "beaker-puppet" + gem "beaker-puppet_install_helper", require: false + gem "beaker-module_install_helper", require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/Rakefile b/Rakefile index dc7ab0a..1bdbda9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' +require 'beaker-rspec/rake_task' if Bundler.rubygems.find_name('beaker-rspec').any? require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? diff --git a/lib/facter/has_mellanox_infiniband.rb b/lib/facter/has_mellanox_infiniband.rb index 14a6003..9120da7 100644 --- a/lib/facter/has_mellanox_infiniband.rb +++ b/lib/facter/has_mellanox_infiniband.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Fact: has_mellanox_infiniband # # Purpose: Determine if the system's hardware supports Mellanox InfiniBand. @@ -12,6 +14,6 @@ confine kernel: 'Linux' setcode do ib_device_count = Facter::Util::MellanoxInfiniband.count_ib_devices - ib_device_count > 0 + ib_device_count.positive? end end diff --git a/lib/facter/mellanox_ofed_version.rb b/lib/facter/mellanox_ofed_version.rb index 87affd7..490dc86 100644 --- a/lib/facter/mellanox_ofed_version.rb +++ b/lib/facter/mellanox_ofed_version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Fact: mellanox_ofed_version # # Purpose: Determine version of Mellanox OFED installed diff --git a/lib/facter/util/mellanox_infiniband.rb b/lib/facter/util/mellanox_infiniband.rb index d6056ea..734fcfe 100644 --- a/lib/facter/util/mellanox_infiniband.rb +++ b/lib/facter/util/mellanox_infiniband.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + # Class for Mellanox Infiniband fact functions class Facter::Util::MellanoxInfiniband # REF: http://cateee.net/lkddb/web-lkddb/INFINIBAND.html - LSPCI_IB_REGEX = %r{\s15b3:} + LSPCI_IB_REGEX = %r{\s15b3:}.freeze # lspci is a delegating helper method intended to make it easier to stub the # system call without affecting other calls to Facter::Core::Execution.exec diff --git a/manifests/config.pp b/manifests/config.pp index fa63ffc..b318f35 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -11,5 +11,4 @@ create_resources('shellvar', $mofed::openib_shellvars, $_shellvar_defaults) } - } diff --git a/manifests/init.pp b/manifests/init.pp index b820f20..55d6e8f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -75,15 +75,6 @@ Hash $openib_shellvars = {}, Hash $interfaces = {} ) { - - $osfamily = $facts.dig('os', 'family') - $osmajor = $facts.dig('os', 'release', 'major') - $supported = ['RedHat-6','RedHat-7','RedHat-8'] - $os = "${osfamily}-${osmajor}" - if ! ($os in $supported) { - fail("Unsupported OS: ${osfamily}, module ${module_name} only supports RedHat 6, 7, and 8") - } - if $restart_service { $openib_shellvar_notify = Service['openibd'] } else { @@ -101,5 +92,4 @@ -> Class['mofed::service'] create_resources('mofed::interface', $interfaces) - } diff --git a/manifests/install.pp b/manifests/install.pp index 0003fa8..377e134 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -18,5 +18,4 @@ ensure_packages($extra_packages) } } - } diff --git a/manifests/interface.pp b/manifests/interface.pp index ec98867..f55ebb0 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -31,7 +31,7 @@ # @param bonding_opts # The bonding options to use for this bonding interface # -define mofed::interface( +define mofed::interface ( Enum['present', 'absent'] $ensure = 'present', Optional[Stdlib::Compat::Ip_address] $ipaddr = undef, Optional[Stdlib::Compat::Ip_address] $netmask = undef , @@ -44,7 +44,6 @@ Array[String] $bonding_slaves = [], String $bonding_opts = 'mode=active-backup miimon=100', ) { - if $ensure == 'present' { if ! $ipaddr { fail('ipaddr is required with ensure=present') @@ -66,7 +65,7 @@ 'CONNECTED_MODE' => $connected_mode, } - if $mofed::osfamily == 'RedHat' and versioncmp($mofed::osmajor, '8') >= 0 { + if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '8') >= 0 { $_nm_controlled = pick($nm_controlled, false) } else { $_nm_controlled = pick($nm_controlled, 'no') @@ -120,5 +119,4 @@ options_extra_redhat => $options_extra_redhat, } } - } diff --git a/manifests/opensm.pp b/manifests/opensm.pp index 035d30f..437c6a6 100644 --- a/manifests/opensm.pp +++ b/manifests/opensm.pp @@ -19,7 +19,6 @@ Array $ports = [], Integer $sweep = 10, ) { - include mofed case $ensure { @@ -82,26 +81,23 @@ require => Package['opensm'], } - if versioncmp($::operatingsystemrelease, '7.0') >= 0 { - systemd::unit_file { 'opensmd@.service': - ensure => $file_ensure, - source => 'puppet:///modules/mofed/opensm/opensmd@.service', - } + systemd::unit_file { 'opensmd@.service': + ensure => $file_ensure, + source => 'puppet:///modules/mofed/opensm/opensmd@.service', + } - $ports.each |Integer $index, String $port| { - $i = $index + 1 - service { "opensmd@${i}": - ensure => $service_ensure, - enable => $service_enable, - hasstatus => true, - hasrestart => true, - subscribe => [ - File['/etc/sysconfig/opensm'], - Systemd::Unit_file['opensmd@.service'] - ] - } + $ports.each |Integer $index, String $port| { + $i = $index + 1 + service { "opensmd@${i}": + ensure => $service_ensure, + enable => $service_enable, + hasstatus => true, + hasrestart => true, + subscribe => [ + File['/etc/sysconfig/opensm'], + Systemd::Unit_file['opensmd@.service'] + ], } } } - } diff --git a/manifests/repo.pp b/manifests/repo.pp index 255515a..d6d6e43 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -3,7 +3,7 @@ assert_private() if $mofed::manage_repo { - case $::osfamily { + case $facts['os']['family'] { 'RedHat': { yumrepo { 'mlnx_ofed': descr => 'MLNX_OFED Repository', @@ -20,5 +20,4 @@ } } } - } diff --git a/manifests/service.pp b/manifests/service.pp index 3b4210c..0b6a9be 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -21,5 +21,4 @@ hasrestart => $mofed::openibd_service_hasrestart, } } - } diff --git a/manifests/srp.pp b/manifests/srp.pp index d55d565..c8019f7 100644 --- a/manifests/srp.pp +++ b/manifests/srp.pp @@ -22,7 +22,6 @@ Optional[Variant[String, Array]] $srp_daemon_config = undef, Optional[Hash[String, Variant[String,Integer], 1]] $ib_srp_options = undef, ) { - include mofed case $ensure { @@ -63,7 +62,7 @@ target => $mofed::openib_config_path, value => $srp_load, notify => $mofed::openib_shellvar_notify, - require => Class['::mofed::install'], + require => Class['mofed::install'], } } @@ -138,30 +137,27 @@ require => Package['srptools'], } - if versioncmp($::operatingsystemrelease, '7.0') >= 0 { - systemd::unit_file { 'srpd@.service': - ensure => $file_ensure, - source => 'puppet:///modules/mofed/srp/srpd@.service', - } + systemd::unit_file { 'srpd@.service': + ensure => $file_ensure, + source => 'puppet:///modules/mofed/srp/srpd@.service', + } - $ports.each |Integer $index, String $port| { - $i = $index + 1 - service { "srpd@${i}": - ensure => $service_ensure, - enable => $service_enable, - hasstatus => true, - hasrestart => true, - require => [ - File['/etc/modprobe.d/ib_srp.conf'], - ], - subscribe => [ - File['/etc/sysconfig/srpd'], - File['/etc/srp_daemon.conf'], - Systemd::Unit_file['srpd@.service'], - ] - } + $ports.each |Integer $index, String $port| { + $i = $index + 1 + service { "srpd@${i}": + ensure => $service_ensure, + enable => $service_enable, + hasstatus => true, + hasrestart => true, + require => [ + File['/etc/modprobe.d/ib_srp.conf'], + ], + subscribe => [ + File['/etc/sysconfig/srpd'], + File['/etc/srp_daemon.conf'], + Systemd::Unit_file['srpd@.service'], + ], } } } - } diff --git a/metadata.json b/metadata.json index 23d59db..79e0635 100644 --- a/metadata.json +++ b/metadata.json @@ -10,15 +10,15 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.13.1 <9.0.0" + "version_requirement": ">= 4.13.1 <10.0.0" }, { - "name": "herculesteam/augeasproviders_shellvar", - "version_requirement": ">= 2.0.0 <5.0.0" + "name": "puppet/augeasproviders_shellvar", + "version_requirement": ">= 5.0.0 <6.0.0" }, { "name": "puppet/systemd", - "version_requirement": ">= 0.3.0 <4.0.0" + "version_requirement": ">= 0.3.0 <7.0.0" }, { "name": "saz/rsyslog", @@ -34,7 +34,8 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { @@ -46,14 +47,22 @@ { "operatingsystem": "Rocky", "operatingsystemrelease": [ - "8" + "8", + "9" + ] + }, + { + "operatingsystem": "AlmaLinux", + "operatingsystemrelease": [ + "8", + "9" ] } ], "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.1.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "tags": [ @@ -62,7 +71,7 @@ "infiniband", "hpc" ], - "pdk-version": "2.1.0", + "pdk-version": "2.7.1", "template-url": "https://github.com/treydock/pdk-templates.git#master", - "template-ref": "heads/master-0-g089be8b" + "template-ref": "heads/master-0-g52b1622" } diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/el7.yml similarity index 65% rename from spec/acceptance/nodesets/centos-7.yml rename to spec/acceptance/nodesets/el7.yml index b038234..94f0e93 100644 --- a/spec/acceptance/nodesets/centos-7.yml +++ b/spec/acceptance/nodesets/el7.yml @@ -10,6 +10,8 @@ HOSTS: - '/usr/sbin/init' docker_image_commands: - 'yum install -y wget which cronie iproute initscripts' + - 'wget --no-check-certificate https://copr.fedorainfracloud.org/coprs/jsynacek/systemd-backports-for-centos-7/repo/epel-7/jsynacek-systemd-backports-for-centos-7-epel-7.repo -O /etc/yum.repos.d/jsynacek-systemd-centos-7.repo' + - 'yum update -y systemd' docker_env: - LANG=en_US.UTF-8 - LANGUAGE=en_US.UTF-8 diff --git a/spec/acceptance/nodesets/rocky-8.yml b/spec/acceptance/nodesets/el8.yml similarity index 88% rename from spec/acceptance/nodesets/rocky-8.yml rename to spec/acceptance/nodesets/el8.yml index 445c142..ee7a52a 100644 --- a/spec/acceptance/nodesets/rocky-8.yml +++ b/spec/acceptance/nodesets/el8.yml @@ -4,14 +4,14 @@ HOSTS: - agent platform: el-8-x86_64 hypervisor: docker - image: rockylinux/rockylinux:8 + image: almalinux:8 docker_preserve_image: true docker_cmd: - '/usr/sbin/init' docker_image_commands: - 'dnf install -y dnf-utils' - 'dnf config-manager --set-enabled powertools' - - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks cpio' + - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks glibc-langpack-en cpio' docker_env: - LANG=en_US.UTF-8 - LANGUAGE=en_US.UTF-8 diff --git a/spec/acceptance/nodesets/el9.yml b/spec/acceptance/nodesets/el9.yml new file mode 100644 index 0000000..ec01b85 --- /dev/null +++ b/spec/acceptance/nodesets/el9.yml @@ -0,0 +1,26 @@ +HOSTS: + almalinux-9: + roles: + - agent + platform: el-9-x86_64 + hypervisor: docker + image: almalinux:9 + docker_preserve_image: true + docker_cmd: + - '/usr/sbin/init' + docker_image_commands: + - 'dnf install -y dnf-utils' + - 'dnf config-manager --set-enabled crb' + - 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks glibc-langpack-en cpio' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 + docker_container_name: 'mofed-el9' +CONFIG: + log_level: debug + type: foss +ssh: + password: root + auth_methods: ["password"] + diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 24f18b9..13cc224 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'mofed' do on_supported_os.each do |os, facts| - context "on #{os}" do + context "when #{os}" do let(:facts) do facts.merge(concat_basedir: '/dne') end @@ -16,9 +18,26 @@ it { is_expected.to contain_class('mofed::config').that_comes_before('Class[mofed::service]') } it { is_expected.to contain_class('mofed::service') } - include_context 'mofed::install' - include_context 'mofed::config' - include_context 'mofed::service' - end # end context - end # end on_supported_os loop -end # end describe + describe 'mofed::install' do + it do + is_expected.to contain_package('mlnx-ofed').only_with( + ensure: 'present', + name: 'mlnx-ofed-basic', + ) + end + end + + describe 'mofed::service' do + it do + is_expected.to contain_service('openibd').only_with( + ensure: 'running', + enable: 'true', + name: 'openibd', + hasstatus: 'true', + hasrestart: 'true', + ) + end + end + end + end +end diff --git a/spec/classes/opensm_spec.rb b/spec/classes/opensm_spec.rb index 6ee17f4..0d89ced 100644 --- a/spec/classes/opensm_spec.rb +++ b/spec/classes/opensm_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'mofed::opensm' do on_supported_os.each do |os, facts| - context "on #{os}" do + context "when #{os}" do let(:facts) do facts.merge(concat_basedir: '/dne') end @@ -27,7 +29,7 @@ it do verify_exact_contents(catalogue, '/etc/sysconfig/opensm', [ - 'SWEEP=10', + 'SWEEP=10' ]) end @@ -46,7 +48,7 @@ context 'when ports defined' do let(:params) do { - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -56,7 +58,7 @@ verify_exact_contents(catalogue, '/etc/sysconfig/opensm', [ 'SWEEP=10', 'PORT_1=mlx5_0 1', - 'PORT_2=mlx5_0 2', + 'PORT_2=mlx5_0 2' ]) end @@ -103,7 +105,7 @@ let(:params) do { ensure: 'disabled', - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -135,7 +137,7 @@ let(:params) do { ensure: 'absent', - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -150,6 +152,6 @@ end end end - end # end context - end # end on_supported_os loop -end # end describe + end + end +end diff --git a/spec/classes/srp_spec.rb b/spec/classes/srp_spec.rb index ac982f5..577fc37 100644 --- a/spec/classes/srp_spec.rb +++ b/spec/classes/srp_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'mofed::srp' do on_supported_os.each do |os, facts| - context "on #{os}" do + context "when #{os}" do let(:facts) do facts.merge(concat_basedir: '/dne') end @@ -22,7 +24,7 @@ ensure: 'present', target: '/etc/infiniband/openib.conf', value: 'yes', - #:notify => 'Service[openibd]', + # :notify => 'Service[openibd]', ) end @@ -80,7 +82,7 @@ context 'when ports defined' do let(:params) do { - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -89,7 +91,7 @@ it do verify_exact_contents(catalogue, '/etc/sysconfig/srpd', [ 'PORT_1=mlx5_0 1', - 'PORT_2=mlx5_0 2', + 'PORT_2=mlx5_0 2' ]) end @@ -139,7 +141,7 @@ let(:params) do { ensure: 'disabled', - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -172,7 +174,7 @@ let(:params) do { ensure: 'absent', - ports: ['mlx5_0 1', 'mlx5_0 2'], + ports: ['mlx5_0 1', 'mlx5_0 2'] } end @@ -187,6 +189,6 @@ end end end - end # end context - end # end on_supported_os loop -end # end describe + end + end +end diff --git a/spec/defines/interface_spec.rb b/spec/defines/interface_spec.rb index 37650ae..15f7c16 100644 --- a/spec/defines/interface_spec.rb +++ b/spec/defines/interface_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'mofed::interface' do on_supported_os.each do |os, facts| - context "on #{os}" do + context "when #{os}" do let(:facts) do facts.merge(concat_basedir: '/dne') end @@ -14,7 +16,7 @@ let :default_params do { ipaddr: '192.168.1.1', - netmask: '255.255.255.0', + netmask: '255.255.255.0' } end @@ -32,9 +34,9 @@ it do is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with('ensure' => 'present', - 'owner' => 'root', - 'group' => 'root', - 'mode' => '0644') + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644') end it do @@ -42,13 +44,13 @@ .with_content(my_fixture_read("ifcfg-ib0_with_connected_mode#{fixture_suffix}")) end - context 'ensure => absent' do + context 'when ensure => absent' do let(:params) { { ensure: 'absent' } } it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_ensure('absent') } end - context 'enable => false' do + context 'when enable => false' do let :params do default_params.merge(enable: false) end @@ -56,7 +58,7 @@ it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_onboot_no#{fixture_suffix}")) } end - context 'connected_mode => no' do + context 'when connected_mode => no' do let :params do default_params.merge(connected_mode: 'no') end @@ -64,15 +66,15 @@ it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_without_connected_mode#{fixture_suffix}")) } end - context 'mtu => 65520' do + context 'when mtu => 65520' do let :params do default_params.merge(mtu: 65_520) end - it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0'). with_content(my_fixture_read("ifcfg-ib0_with_mtu#{fixture_suffix}")) } + it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_mtu#{fixture_suffix}")) } end - context 'gateway => 192.168.1.254' do + context 'when gateway => 192.168.1.254' do let :params do default_params.merge(gateway: '192.168.1.254') end @@ -80,7 +82,7 @@ it { is_expected.to contain_file('/etc/sysconfig/network-scripts/ifcfg-ib0').with_content(my_fixture_read("ifcfg-ib0_with_gateway#{fixture_suffix}")) } end - context 'bonding => true' do + context 'when bonding => true' do let :title do 'ibbond0' end @@ -96,7 +98,7 @@ } end - context 'bonding => true, no slave interfaces' do + context 'when bonding => true, no slave interfaces' do let :params do default_params.merge(bonding: true) end diff --git a/spec/shared_examples/config.rb b/spec/shared_examples/config.rb deleted file mode 100644 index 7584d9c..0000000 --- a/spec/shared_examples/config.rb +++ /dev/null @@ -1,3 +0,0 @@ -shared_context 'mofed::config' do - # TODO -end diff --git a/spec/shared_examples/install.rb b/spec/shared_examples/install.rb deleted file mode 100644 index 50d703e..0000000 --- a/spec/shared_examples/install.rb +++ /dev/null @@ -1,6 +0,0 @@ -shared_examples 'mofed::install' do - it do - is_expected.to contain_package('mlnx-ofed').only_with(ensure: 'present', - name: 'mlnx-ofed-basic') - end -end diff --git a/spec/shared_examples/service.rb b/spec/shared_examples/service.rb deleted file mode 100644 index 373506a..0000000 --- a/spec/shared_examples/service.rb +++ /dev/null @@ -1,9 +0,0 @@ -shared_examples 'mofed::service' do - it do - is_expected.to contain_service('openibd').only_with(ensure: 'running', - enable: 'true', - name: 'openibd', - hasstatus: 'true', - hasrestart: 'true') - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b367fde..7272754 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,24 +9,24 @@ require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) -include RspecPuppetFacts +include RspecPuppetFacts # rubocop:disable Style/MixinUsage default_facts = { puppetversion: Puppet.version, - facterversion: Facter.version, + facterversion: Facter.version } default_fact_files = [ File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')) ] default_fact_files.each do |f| next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e + default_facts.merge!(YAML.safe_load(File.read(f))) + rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0f66cf4..d0d3a82 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + require 'beaker-rspec' require 'beaker-puppet' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' -dir = File.expand_path(File.dirname(__FILE__)) +dir = __dir__ Dir["#{dir}/acceptance/shared_examples/**/*.rb"].sort.each { |f| require f } require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb')) diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index f649aad..df5e246 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -1,4 +1,6 @@ -dir = File.expand_path(File.dirname(__FILE__)) +# frozen_string_literal: true + +dir = __dir__ Dir["#{dir}/shared_examples/**/*.rb"].sort.each { |f| require f } def verify_exact_contents(subject, title, expected_lines) diff --git a/spec/unit/facter/has_mellanox_infiniband_spec.rb b/spec/unit/facter/has_mellanox_infiniband_spec.rb index 77ed785..0dc64dd 100644 --- a/spec/unit/facter/has_mellanox_infiniband_spec.rb +++ b/spec/unit/facter/has_mellanox_infiniband_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'facter/util/mellanox_infiniband' diff --git a/spec/unit/facter/mellanox_ofed_version_spec.rb b/spec/unit/facter/mellanox_ofed_version_spec.rb index bd0d45c..5530a12 100644 --- a/spec/unit/facter/mellanox_ofed_version_spec.rb +++ b/spec/unit/facter/mellanox_ofed_version_spec.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'mellanox_ofed_version fact' do - context 'on Linux' do + context 'when Linux' do before(:each) do Facter.clear allow(Facter.fact(:kernel)).to receive(:value).and_return('Linux') @@ -25,7 +27,7 @@ end end - context 'on Windows' do + context 'when Windows' do before(:each) do Facter.clear allow(Facter.fact(:kernel)).to receive(:value).and_return('windows') diff --git a/spec/unit/facter/util/mellanox_infiniband_spec.rb b/spec/unit/facter/util/mellanox_infiniband_spec.rb index 33d8cb5..ab9a1f9 100644 --- a/spec/unit/facter/util/mellanox_infiniband_spec.rb +++ b/spec/unit/facter/util/mellanox_infiniband_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'facter/util/mellanox_infiniband' @@ -8,7 +10,7 @@ describe 'lspci' do it 'returns output' do - expect(Facter::Util::Resolution).to receive(:exec).with('lspci -n 2>/dev/null').and_return('foo') + allow(Facter::Util::Resolution).to receive(:exec).with('lspci -n 2>/dev/null').and_return('foo') expect(described_class.lspci).to eq('foo') end end