-
Notifications
You must be signed in to change notification settings - Fork 217
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
Bmc fixes #264
Bmc fixes #264
Conversation
logicminds
commented
Mar 11, 2015
- Fixes 9709
- Fixes 9710
- Fixes 9711
- Fixes 9740
* updates rubyipmi to use version 0.9.0 or later as its now required
This will require rubyipmi 0.9.1 which was just released today. |
[test] |
An example of what this provider can be seen here. http://projects.theforeman.org/projects/smart-proxy/wiki/API#BMC-Controls (Troubleshooting section) |
end | ||
end | ||
|
||
def self.providers_installed? | ||
return Rubyipmi.providers_installed? | ||
def self.providers_installed |
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 is a bit confusing -- the convention is that methods with a ?
suffix return a boolean, but here it appears to return a list...
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.
Yes, I know. I noticed this the other day in Rubyipmi and I plan to fix it but it will have to wait since its a breaking change. I have updated this in smart-proxy but this this will most likely be fixed in 0.11.0 of rubyipmi.
0ef2b14
to
ba22482
Compare
@witlessbird regarding the private method. It appears after some testing that that even when I remove the private decorator all methods are still marked private. I am not sure why the class is still setting the methods private so there is something that I don't understand. This looks to be the case will all the other smart proxy modules as well. So as far as refactoring this to have a public bmc_setup method I am not sure this is possible unless its removed from the class and place inside a Proxy::BMC module which might not be ideal and might introduce other issues like authorization. [3] pry(#<BmcApiTest>)> Proxy::BMC::Api.new.bmc_setup
NoMethodError: undefined method `bmc_setup' for #<Sinatra::Wrapper:0x007fa5619ebef8>
from (pry):3:in `test_api_recovers_from_missing_provider'
[4] pry(#<BmcApiTest>)>
Proxy::BMC::Api.new.send(:bmc_setup)
NoMethodError: undefined method `bmc_setup' for #<Sinatra::Wrapper:0x007fa5632969a8>
from (pry):5:in `test_api_recovers_from_missing_provider' |
sinatra overrides |
@@ -1,30 +1,48 @@ | |||
require 'bmc/ipmi' |
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.
You are adding global require here, this will cause issues on discovery-image. Please load dependencies only when ipmi is enabled by configuration later on, not here.
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.
It's actually ok here, as bmc_api will only get loaded if the module was enabled. https://github.com/theforeman/smart-proxy/blob/develop/lib/smart_proxy.rb#L100 is the bit that takes care of this...
Do you have an advice how to test this without BMC-enabled hardware? I guess there could be some mock mode or something in the library or IPMI stack. |
@lzap About the only thing that I came up with is a tool that feeds back STDOUT and STDERR along with an error code given STDIN. But I did not finish writing that tool and its still a private repo. |
* previously when IPMI errors occured at the Rubyipmi or CLI level there was no good way to troubleshoot the issue. With this addition we can now watch an erorrs Rubyipmi spits out by sending Rubyipmi a custom logger.
c81a738
to
876d174
Compare
I could probably add a mock provider to rubyipmi which could then be used in smart-proxy when the mock provider is selected. I don't know when I would have time to do this though. |
[test] |
@witlessbird @lzap Jenkins seems to be failing tests, but I can get them to fail on my system. Is this a known issue with Jenkins and doing forced updates? |
This is ready to merge, I have addressed all the issues discussed above and refactored the code. |
I think it's because we don't have freeipmi installed on our slaves. We installed ipmitool as the existing tests assume that's present, but I also get failures locally without freeipmi: [ 3/309] BmcApiTest#test_api_bmc_setup_returns_new_ipmi_proxy_given_freeipmiwhich: no ipmipower in (/home/dcleal/.rvm/gems/ruby-2.1.0@proxy/bin:/home/dcleal/.rvm/gems/ruby-2.1.0@global/bin:/home/dcleal/.rvm/rubies/ruby-2.1.0/bin:/home/dcleal/.rvm/bin:/home/dcleal/bin:/ho me/dcleal/go/bin:/home/dcleal/.gem/home/bin:/home/dcleal/code/puppet/puppet/bin:/home/dcleal/code/facter/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin/code/augeas/augeas-sandbox:/sbin) = 0.01 s 1) Error: BmcApiTest#test_api_bmc_setup_returns_new_ipmi_proxy_given_freeipmi: NoMethodError: undefined method `accept?' for nil:NilClass /home/dcleal/code/foreman/smart-proxy/lib/proxy/helpers.rb:20:in `log_halt' /home/dcleal/code/foreman/smart-proxy/modules/bmc/bmc_api.rb:283:in `rescue in bmc_setup' /home/dcleal/code/foreman/smart-proxy/modules/bmc/bmc_api.rb:250:in `bmc_setup' /home/dcleal/code/foreman/smart-proxy/test/bmc/bmc_api_test.rb:89:in `test_api_bmc_setup_returns_new_ipmi_proxy_given_freeipmi' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1265:in `run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit/testcase.rb:17:in `run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:940:in `block in _run_suite' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:933:in `map' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:933:in `_run_suite' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:663:in `block in _run_suites' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:661:in `each' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:661:in `_run_suites' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:884:in `_run_anything' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1092:in `run_tests' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1079:in `block in _run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1078:in `each' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1078:in `_run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/minitest/unit.rb:1066:in `run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:27:in `run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:780:in `run' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:372:in `block (2 levels) in autorun' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:33:in `run_once' /home/dcleal/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/test/unit.rb:371:in `block in autorun' [ 8/309] BmcApiTest#test_api_can_get_installed_providerswhich: no ipmipower in (/home/dcleal/.rvm/gems/ruby-2.1.0@proxy/bin:/home/dcleal/.rvm/gems/ruby-2.1.0@global/bin:/home/dcleal/.rvm/rubies/ruby-2.1.0/bin:/home/dcleal/.rvm/bin:/home/dcleal/bin:/home/dcleal/go/bin:/ho me/dcleal/.gem/home/bin:/home/dcleal/code/puppet/puppet/bin:/home/dcleal/code/facter/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin/code/augeas/augeas-sandbox:/sbin) = 0.01 s 2) Failure: BmcApiTest#test_api_can_get_installed_providers [/home/dcleal/code/foreman/smart-proxy/test/bmc/bmc_api_test.rb:157]: <["freeipmi", "ipmitool", "shell"]> expected but was <["ipmitool", "shell"]>. I'm rolling it out now, will retest in a bit. |
I'm seeing a local test failure when both freeipmi and ipmitool have been installed:
|
[test] |
Unit tests pass now on Jenkins, I wonder why it fails for @witlessbird. However there are some rubocop warnings, see the link on http://ci.theforeman.org/job/test_proxy_develop_pr_rubocop/200/ |
I looked into the failure I'm seeing:
Not sure why in my case test gets an instance of Proxy::BMC::Shell. More importantly, implementation of either I think either api has to catch |
I can reproduce this when I enable :bmc_default_provider: shell in the config/bmc.yml file. So this is probably what you have in your config file.
Easy fix could catch.
I have been mocking the settings provider value for some tests, but not all tests, so the default would apply if the value is not mocked.
You are getting an instance of shell because that is what you have set as your shell provider and because nil was expected in the test but I didn’t mock the settings value it was picking up your settings value.
|
@logicminds: |
@witlessbird makes sense now. https://robots.thoughtbot.com/rescue-standarderror-not-exception So than we could assume all other methods that the shell provider does not implement will also suffer from this same issue. Should we file a new ticket for this issue, since its out of scope? |
* updates rubyipmi to 0.9.1 * adds new bmc api call /bmc/:host/test that tests the connection * adds test method to shell provider
* adds additional logic around providers * implements /providers, /providers/installed, /host, / * the / returns a list of resources to use to help the user * catches a case where if the provider is nil, we can default to a provider and warn the user * changes the bmc_setup method to be public instead of private. * refactors the providers_installed? rubyipmi command to providers_installed
…n't implement the api call * catches the NotImplementedError properely and returns 501 http code * fixes rubocop warnings
[test] I just fixed all rubocop warnings and pushed another rubyipmi gem version to fix some style issues. I also opened issue 9840 because it was unrelated but still important for future provider support. I would expect all tests to pass on any system. |