Puppet 4.10.x version comparisons

31 views
Skip to first unread message

Dominic Cleal

unread,
Mar 14, 2017, 7:03:40 AM3/14/17
to Puppet Developers, Vox Pupuli list
Hello,

It looks like there will be a new Puppet 4.10.x release series soon,
which I think is going to cause a few issues in tests for modules and in
supporting projects, due to reaching minor version 10.

In quite a few projects there are constructs such as:

if Puppet.version.to_f >= 4.4

which will return false when `Puppet.version` is "4.10.0" (since
"4.10.0".to_f is 4.1, not four-point-ten).

These are mostly in tests, where specs might be constrained to
particular versions or expect different slightly results depending on
the version of Puppet. It's also possible that functions, types, or
providers occasionally have version constraints. Manifests are likely
safe as they should use the versioncmp() function, so this probably only
really affects module tests.

A safer way of comparing versions from Ruby is to use versioncmp too:

if Puppet::Util::Package.versioncmp(Puppet.version, '4.4.0') >= 0

Comparisons against 4.0, 3.x etc, or using `.to_i` are going to be
unaffected. It will only affect comparisons against later 4.x version
numbers.

I've opened a PR against rspec-puppet
(https://github.com/rodjek/rspec-puppet/pull/479) to fix some internal
checks and its own specs, and puppetlabs_spec_helper looks to be fine.

stdlib is an example of a module that has a lot of tests with affected
version comparisons:
https://github.com/puppetlabs/puppetlabs-stdlib/blob/db8c1fbb2394d93fe3156b17c840455f1b3e2c76/spec/functions/deprecation_spec.rb#L3

I'll continue trying to open PRs where I can find issues, but would
appreciate help to check modules to ensure it works on release.

Cheers,

--
Dominic Cleal
dom...@cleal.org

Dominic Cleal

unread,
Mar 14, 2017, 10:52:47 AM3/14/17
to puppe...@googlegroups.com, Vox Pupuli list
On 14/03/17 10:05, Dominic Cleal wrote:
> It looks like there will be a new Puppet 4.10.x release series soon,
> which I think is going to cause a few issues in tests for modules and in
> supporting projects, due to reaching minor version 10.
>
[..]
> I've opened a PR against rspec-puppet
> (https://github.com/rodjek/rspec-puppet/pull/479) to fix some internal
> checks and its own specs, and puppetlabs_spec_helper looks to be fine.

Merged, just awaiting release.

> stdlib is an example of a module that has a lot of tests with affected
> version comparisons:
> https://github.com/puppetlabs/puppetlabs-stdlib/blob/db8c1fbb2394d93fe3156b17c840455f1b3e2c76/spec/functions/deprecation_spec.rb#L3

https://github.com/puppetlabs/puppetlabs-stdlib/pull/737 opened to fix
these tests, and David's opened
https://tickets.puppetlabs.com/browse/MODULES-4528 for tracking any
issues in other supported modules. Vox Pupuli modules look entirely
unaffected to me.

> I'll continue trying to open PRs where I can find issues, but would
> appreciate help to check modules to ensure it works on release.

puppet-syntax 2.4.0's been released with a fix, so I think the only
supporting gems affected are it and rspec-puppet.

--
Dominic Cleal
dom...@cleal.org

Reply all
Reply to author
Forward
0 new messages