Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rspec tests fail on docker again. #167

Closed
traylenator opened this issue Mar 24, 2023 · 1 comment
Closed

rspec tests fail on docker again. #167

traylenator opened this issue Mar 24, 2023 · 1 comment

Comments

@traylenator
Copy link
Collaborator

traylenator commented Mar 24, 2023

Previously when rspec tests on docker the rspec tests failed as the systemd provider was not selected and
so services what not maskable.

This was resolved by mocking systemd in #128

Unfortunately somewhere between versions 2.5.0 and 2.6.1 we again see the failures:

nftables on almalinux-9-x86_64 with snat4 is expected to compile into a catalogue without dependency cycles
      Failure/Error: it { is_expected.to compile }
        error during compilation: Parameter enable failed on Service[firewalld]: Provider redhat must have features 'maskable' to set 'enable' to 'mask' (file: /builds/ai/it-puppet-module-nftables/code/spec/fixtures/modules/nftables/manifests/init.pp, line: 200)

Changing the conditional from:

RSpec.configure do |c|
  c.before do
    # select the systemd service provider even when on docker
    # https://tickets.puppetlabs.com/browse/PUP-11167
    if defined?(facts) && %w[Archlinux RedHat].include?(facts[:os]['family'])
      allow(Puppet::FileSystem).to receive(:exist?).and_call_original
      allow(Puppet::FileSystem).to receive(:exist?).with('/proc/1/comm').and_return(true)
      allow(Puppet::FileSystem).to receive(:read).and_call_original
      allow(Puppet::FileSystem).to receive(:read).with('/proc/1/comm').and_return(['systemd'])
    end
  end
end

to

RSpec.configure do |c|
  c.before do
    # select the systemd service provider even when on docker
    # https://tickets.puppetlabs.com/browse/PUP-11167
    if defined?(facts) 
      allow(Puppet::FileSystem).to receive(:exist?).and_call_original
      allow(Puppet::FileSystem).to receive(:exist?).with('/proc/1/comm').and_return(true)
      allow(Puppet::FileSystem).to receive(:read).and_call_original
      allow(Puppet::FileSystem).to receive(:read).with('/proc/1/comm').and_return(['systemd'])
    end
  end
end

i.e dropping && %w[Archlinux RedHat].include?(facts[:os]['family']) does work and allow the tests to complete but that makes no sense to me and seems the wrong thing to do.

@traylenator
Copy link
Collaborator Author

No longer happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant