-
Notifications
You must be signed in to change notification settings - Fork 795
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
Fix having wildcards (%) in hostnames of grants #366
Conversation
This changes the mysql_grant grant regex to more closely resemble the one in current master. This version is now able to handle wildcards in grants ('user'@'192.168.%').
Can you please add an rspec:system test so we won't break this kind of thing in the future? |
Sorry, I neither know how to write ruby code (I can read it and patch a regexp, but that's about it) nor do I have any idea how to write such a test. I had a look at cc51d7a but I don't understand how that test works. It apparently tests only if the privileges are granted but not whether the regex does recognize them again (which was the problem here), as far as I can see. So copying and adjusting this doesn't seem like the way to go. How should I proceed with that? |
What we'd be looking for is basically a modification to https://github.com/puppetlabs/puppetlabs-mysql/blob/master/spec/system/types/mysql_grant_spec.rb to copy an existing test and tweak it. You'd copy a describe block completely, change the pp = puppet stuff to use 'user'@'192.168.%' and then modify one of the: it 'should find the user' do Blocks to be SHOW GRANTS FOR user@192.168.% and tweak what the stdout return is. I hope that makes sense, it's basically cut and pasting and tweaking a few bits. If you have vagrant and virtualbox installed you can run: rake spec:system And it'll run all those tests against a centos VM. |
To install all the dependency ruby gems, you'll also need to install the gem bundler, e.g.:
and then, in your puppetlabs-mysql clone:
|
Thanks for the pointers. I got bundler to run and install all those packages. My Laptops CPU is not able to run 64bit VMs with virtualbox, so I still have to find a way to actually run the tests. Tonight it's getting late, so that has to wait till tomorrow. |
I was going to suggest to run spec:system with an option to select a different prefab, but we don't have a 32bit prefab |
Status update: I got the tests to run on a machine at work, so tomorrow I can start writing the test. I have one failing test which should be unrelated to this, but I'm wondering whether my setup is ok or not.
|
I've seen this fail before and it bugs me, just ignore it, I don't know what's up with it :( |
(I'll spend some time trying to figure out what's going on tho) |
seeing how this issue is developing into that general direction, we should copy&paste its gist to the README or to CONTRIBUTING to tell people how to get started with writing tests. I think the only thing missing is, how do I run one specific test or test file. |
I did as suggested and added a test applying a puppet definition and then verifying that mysql indeed had the grant. However, this proved to be insufficient as this test also succeeded without my change (as expected, it did work, but reapplied the change on every puppet run without my change). Therefore I added another test applying the puppet definition a second time and checking whether puppet would change the grant again. This test only succeeds with my change applied. As my ruby knowledge is near to zero I hope the code I copied and adjusted makes sense. |
Fix having wildcards (%) in hostnames of grants
Testing looked good to me, thanks! |
This changes the mysql_grant grant regex to more closely
resemble the one in current master. This version is now
able to handle wildcards in grants ('user'@'192.168.%').