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

Ensure FacterImpl consistency between example groups #19

Merged
merged 3 commits into from
Dec 10, 2021

Conversation

GabrielNagy
Copy link

Using the 'rspec' facter implementation we could sometimes get in a case where the values of FacterImpl and Puppet.runtime[:facter] diverged between example groups.

Because rspec-puppet overrides facts using the FacterImpl constant (which is only set once), Puppet.runtime[:facter] would point to a different instance of FacterTestImpl with no available facts, causing calls to Puppet.runtime[:facter].value to fail.

To prevent this from happening, attempt to set Puppet.runtime[:facter] to the value of FacterImpl if available, this way we make sure Puppet.runtime[:facter] and FacterImpl operate on the same instance of FacterTestImpl.

bastelfreak added a commit to voxpupuli/puppet-bird that referenced this pull request Dec 6, 2021
@bastelfreak
Copy link
Collaborator

I tested this on the borg module and it works fine: voxpupuli/puppet-bird#87

lib/rspec-puppet/adapters.rb Outdated Show resolved Hide resolved
Using the 'rspec' facter implementation we could sometimes get in a case
where the values of FacterImpl and Puppet.runtime[:facter] diverged
between example groups.

Because rspec-puppet overrides facts using the FacterImpl constant
(which is only set once), Puppet.runtime[:facter] would point to a
different instance of FacterTestImpl with no available facts, causing
calls to Puppet.runtime[:facter].value to fail.

To prevent this from happening, set Puppet.runtime[:facter] to the value
of FacterImpl; this way we make sure Puppet.runtime[:facter] and
FacterImpl operate on the same instance of FacterTestImpl.
@bastelfreak
Copy link
Collaborator

I restarted the CI in voxpupuli/puppet-bird#87 and the unit tests passed again.

lib/rspec-puppet/adapters.rb Outdated Show resolved Hide resolved
lib/rspec-puppet/adapters.rb Outdated Show resolved Hide resolved
Copy link

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let me know if you want to address the inline comment but I'm fine with merging this.

lib/rspec-puppet/adapters.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@bastelfreak bastelfreak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI in voxpupuli/puppet-bird#87 passed again.

Copy link

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ciprianbadescu ciprianbadescu merged commit baf75ac into puppetlabs:master Dec 10, 2021
@bastelfreak
Copy link
Collaborator

@ciprianbadescu would it be possible to release this soonish? (this blocks a few Vox Pupuli pipelines)

@GabrielNagy
Copy link
Author

@bastelfreak 2.11.1 should be out now!

@root-expert
Copy link

Hello folks!

I saw similar errors into 2 VoxPupuli PRs, voxpupuli/puppet-mongodb#633 and voxpupuli/puppet-windows_firewall#124

Do you think that's still related to this change?

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

Successfully merging this pull request may close these issues.

None yet

6 participants