voxpupuli / puppet-nftables

Puppet Module to manage nftables firewall rules.
Apache License 2.0
12 stars 33 forks source link

rspec tests fail on docker again. #167

Closed traylenator closed 1 year ago

traylenator commented 1 year ago

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 commented 1 year ago

No longer happens.