-
Notifications
You must be signed in to change notification settings - Fork 84
(MODULES-1723) Update Registry module for Puppet 4 / Ruby 2.1.5 / Unicode #72
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
(MODULES-1723) Update Registry module for Puppet 4 / Ruby 2.1.5 / Unicode #72
Conversation
7e2e40f
to
6406285
Compare
A bit more work to do on this one, but if you want to take a first pass @ferventcoder |
Will take a look tomorrow when I'm back "in the office." :) |
@cyberious feel free to take an early peek as well if you have a minute |
end | ||
|
||
beaker_version = ENV['BEAKER_VERSION'] || '~> 2.2' | ||
group :acceptance do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use :system_tests
as this is a pattern that the modules team has already adopted. https://github.com/puppetlabs/puppetlabs-concat/blob/master/Gemfile#L25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@Iristyle yeah we have standardized on :system_tests as a group. We actually have this specified in our modulesync script defaults. https://github.com/puppetlabs/modulesync_configs/blob/master/config_defaults.yml |
6406285
to
eb42c1b
Compare
Tests are now passing. |
eb42c1b
to
1df77dd
Compare
Rakefile needed updating to get the spec running see #74 |
@@ -49,6 +51,8 @@ def values | |||
# Only try and get the values for this key if the key itself exists. | |||
if exists? then | |||
hive.open(subkey, Win32::Registry::KEY_READ | access) do |reg| | |||
# TODO: tests for this since each_value triggers LOCALE conversion on Ruby 2.1.5 | |||
# require 'pry'; binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be part of the WIP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a note here so you don't forget to remove these lines.
b3bd0d2
to
b1ebc86
Compare
|
# https://github.com/ruby/ruby/blob/v2_1_5/ext/win32/lib/win32/registry.rb#L323-L329 | ||
# therefore, use our own code instead of hklm.delete_value | ||
|
||
# TODO: don't like registry_value tests depending on registry_key type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have 3 choices here:
- Go a little heavier weight / include ref to a separate class and use the
registry_key
provider - Use the Win32 API directly (or from the provider base class)
- Use
Win32::Registry
to calldelete
, which we know fails on Ruby 2.1.5
I went with option 1 for now, but I'm leaning toward reimplementing as option 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For 9db94e2, this is the only easy way of doing this. In a subsequent commit this could be rewritten to use the methods on ProviderBase
instead, but not sure that's worth it.
aa9108f
to
b3821f9
Compare
end | ||
else | ||
# TODO: expectations around never calling this are not working | ||
require 'pry'; binding.pry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what you are saying is, do not merge? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove binding.pry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup.
|
def from_string_to_wide_string(str, &block) | ||
self.class.from_string_to_wide_string(str, &block) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this was reintroduced for compatibility with older puppet versions :)
So this technically looks okay, the TODOs should be cleaned up - and the Puppet 3.7.3 / Ruby 1.9.3 combination is failing on this for me:
It's not a fluke - it's not deleting the registry key that it creates. It based in the after block when it is trying ti clean up. Well it could be a fluke. As an easy fix... |
I think something may be broken and the custom type is not using 64bit keys automatically anymore - normally a From https://github.com/puppetlabs/puppetlabs-registry/#custom-type-registry_key: |
Actually after researching, I think that there is a test now actually surfaced a pre-existing bug. After looking back through the changes several times I don't see anything that would have introduced a regression. |
db1d2de
to
0e5eaa7
Compare
Can't run through jenkins right now, please rebase from master as it has a fix in Rakefile when beaker is not loaded. |
@cyberious This is still ticketed as do not merge so we are good. |
- Beaker 2.4 will actually be required to test AIO packages
- Without Beaker in isolation, there is no way to actually install the bundle for this module on Windows, since Beaker contains gems with native extensions that don't compile on Ruby 2.1.5 and Windows (unf_ext in particular). With this change, we can now install the gems to be used for local integration testing with: bundle install --path .bundle/gems --without=system_tests
0e5eaa7
to
38a8c47
Compare
Ok @ferventcoder / @cyberious - final validation - run this through CI and I think we're good to merge. |
76d2626
to
14f4d58
Compare
- New tests to demonstrate Ruby 2.1.5 failures for: - Win32::Registry#delete_value which always fails based on passing wide character UTF-16LE strings to an ANSI Api (used in the registry_value provider destroy method) Ruby bug filed at https://bugs.ruby-lang.org/issues/10820 - Win32::Registry#each_key enumeration which initiates unnecessary locale conversion (used in registry_key provider .values method) - Note that these tests were crafted specifically to introduce failures of Ruby 2.1.5 code, and do not introduce failures when run against Ruby 2.0.0. The non-ASCII test is guarded to only run in Ruby 2.1 as it doesn't affect Ruby 2.0 or Ruby 2.2 and can write corrupt data to the registry under Ruby 1.9.3 due to Ruby using Windows ANSI APIs. - Ensure that when creating registry keys with Ruby to specify KEY_WOW64_64KEY to control the location of the key. When using the module provider code, this is the default specified for deletion. When these don't match, the key delete attempt may fail based on bitness of the Ruby process.
- Ensure that under Ruby 2.1.x that problematic method calls to Win32::Registry are not made. This was made in a separate commit because unfortunately Mocha's any_instance will actually hide other errors (which are visible in the prior commit). Once code has been changed to alter code paths under other Ruby versions, the guarding will be changed accordingly.
- Switch to using RegQueryValueExW and RegDeleteKeyExW instead of their ANSI counterparts - Since Ruby 2.1.5 is broken with respec to calling delete_key and delete_value, add our own code for RegDeleteValueW to be used. Ensure that all deletions of registry keys go through the API rather than Ruby. - Implement a helper method for converting Ruby strings to UTF-16LE strings and for creating an unmanaged LCPWSTR pointer for use in FFI calls given a Ruby string. This code appears in Puppet itself, but for compatibility reasons, the Registry module cannot rely on the Puppet version that defines it. - Implement an each_value inside of the provider base code that either uses Rubys Win32::Registry#each_value in Ruby 2.0 and lower, or uses the Puppet 4 implementation if available. This provides existing behavior for older versions of Puppet / Ruby which don't have LOCALE conversion issues, and the correct behavior for Puppet 4. This was implemented this way to avoid dragging in a lot of duplicated FFI code from Puppet 4 introduced via: puppetlabs/puppet@b46ede7
- Previously, the purge_values tests were only for Ruby 2.1, where we know that there are issues in Win32::Registry. - Add tests that demonstrate that other versions of Ruby / Puppet work as well.
14f4d58
to
868e77e
Compare
I'm plus 1 to merge. Now if Travis CI will give a green light |
Travis Y U So Slow? |
... |
Its like the energizer bunny in reverse |
…2-compatibility (MODULES-1723) Update Registry module for Puppet 4 / Ruby 2.1.5 / Unicode
No description provided.