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

Removed validate_vm_control method and calls as it is already replaced by supports_control #11565

Merged

Conversation

gauravaradhye
Copy link
Contributor

@gauravaradhye gauravaradhye commented Sep 28, 2016

The method validate_vm_control was replaced by supports_control method long back, still few functions were calling the old method. Replaced all such methods to call the new method instead of old method and removed the old method to have consistency.

@gauravaradhye
Copy link
Contributor Author

@miq-bot add_label wip

@miq-bot miq-bot added the wip label Sep 28, 2016
@gauravaradhye
Copy link
Contributor Author

@miq-bot add_label refactoring

@gauravaradhye
Copy link
Contributor Author

@miq-bot assign @durandom

@gauravaradhye gauravaradhye changed the title [WIP] Removed validate_vm_control method and calls as it is already replaced by supports_control Removed validate_vm_control method and calls as it is already replaced by supports_control Sep 29, 2016
@gauravaradhye
Copy link
Contributor Author

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Sep 29, 2016
@miq-bot
Copy link
Member

miq-bot commented Sep 29, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

I like this as a intermediate version until those validate_ methods using this are also converted.

I guess you checked, that no UI or other part is relying on validate_vm_control ?

TBH I can see this supports_control feature go away completely as I think its only really used as a helper, but that is off topic.

So, please rebase then we can merge this

@gauravaradhye
Copy link
Contributor Author

@durandom I have rebased the commit but few test cases are failing and I couldn't find out why. Will need your help in finding out the reason after we have travis results.

@durandom
Copy link
Member

durandom commented Oct 4, 2016

@gauravaradhye looks like the specs or some buttons? expect false but we return the message now?

@gauravaradhye
Copy link
Contributor Author

@durandom yeah but I haven't changed the return format for any method, so not able to figure out what's causing it.

@gauravaradhye
Copy link
Contributor Author

I got the tests working by changing the rspec, this is essentially because in earlier code, in some cases, :available was true with error message. This combination is not present in current code.

Need to discuss it with @durandom

@@ -1720,7 +1720,7 @@ def setup_firefox_with_linux
end
context "when with snapshots" do
before { allow(@record).to receive_message_chain(:snapshots, :size).and_return(2) }
it_behaves_like 'default case'
it_behaves_like 'record with error message', 'remove_snapshot'
Copy link
Member

Choose a reason for hiding this comment

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

tbh, this spec file is a nightmare. Not only in length, but...

by changing this, you change what is expected as a return value of the subject, which is build_toolbar_disabled_button. And it should still be the default case, which is to return false. Yikes. To understand that it took me quite some time. So the problem lies in your refactoring of supports_control - See above

Copy link
Member

Choose a reason for hiding this comment

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

don't get me wrong, I was bashing the former spec file, not your changes :)

msg = validate_vm_control
return {:available => msg[0], :message => msg[1]} unless msg.nil?
unless supports_control?
return {:available => false, :message => unsupported_reason(:control)}
Copy link
Member

Choose a reason for hiding this comment

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

changing this to return {:available => true, :message => unsupported_reason(:control)} makes the test pass. But this is only part of the truth.

def validate_vm_control
# Check the basic require to interact with a VM.
return [false, 'The VM is retired'] if self.retired?
return [false, 'The VM is a template'] if self.template?
Copy link
Member

Choose a reason for hiding this comment

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

As a reminder, I think false would indicate that the feature is generally unsupported by the class. Whereas true is: as a class I support it, but there are conditions that prevent me.

return [true, "The VM is not connected to an active #{ui_lookup(:table => "ext_management_systems")}"] unless self.has_active_ems?
nil
end

included do
supports :control do
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you have more luck moving this to Vm (and removing the validate_vm_control above).
It looks like control is generally unsupported by Templates

@durandom
Copy link
Member

@gauravaradhye maybe I dont get exactly what the spec changes do. Whats the difference of 'default case' and 'record with error message' ?

This PR #11711 does something similar

@gauravaradhye
Copy link
Contributor Author

@durandom In earlier code, the validate_vm_control returned true for few error messages and false for others. And the method build_toolbar_disable_button in toolbar_builder.rb file returns the error message only if is_available is false, else it returns false.

With supports_control method, we are making is_available as false if the error message is present, hence the spec needs to be changed to expect the error message instead of the boolean value. That's why I have changed the spec.

@miq-bot
Copy link
Member

miq-bot commented Oct 19, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@durandom
Copy link
Member

ok, so, I was expecting a string to be a truthy return value for build_toolbar_disable_button.
could you rebase again, then it looks good to go

@miq-bot
Copy link
Member

miq-bot commented Oct 24, 2016

Checked commit gauravaradhye@3818044 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 0 offenses detected
Everything looks good. 👍

@gauravaradhye
Copy link
Contributor Author

@durandom Rebased.

@durandom
Copy link
Member

durandom commented Oct 25, 2016

@miq-bot add_label pluggable providers
@miq-bot add_label euwe/no

@durandom
Copy link
Member

@blomquisg 👍 please merge

@gauravaradhye
Copy link
Contributor Author

@blomquisg ping!

@durandom
Copy link
Member

durandom commented Nov 1, 2016

@miq-bot assign @blomquisg
@blomquisg please merge

@miq-bot miq-bot assigned blomquisg and unassigned durandom Nov 1, 2016
@blomquisg blomquisg merged commit 5cec786 into ManageIQ:master Nov 2, 2016
@blomquisg blomquisg added this to the Sprint 49 Ending Nov 14, 2016 milestone Nov 2, 2016
@blomquisg
Copy link
Member

@blomquisg
Copy link
Member

This switched to euwe/yes because it ended up fixing a Euwe bug ... non-blocker.

simaishi pushed a commit that referenced this pull request Jan 5, 2017
Removed validate_vm_control method and calls as it is already replaced by supports_control
(cherry picked from commit 5cec786)

https://bugzilla.redhat.com/show_bug.cgi?id=1400616
@simaishi
Copy link
Contributor

simaishi commented Jan 5, 2017

Euwe backport details:

$ git log -1
commit 39f215889a29a9243abe41c2345976b8abb6110c
Author: Greg Blomquist <blomquisg@gmail.com>
Date:   Wed Nov 2 11:16:56 2016 -0400

    Merge pull request #11565 from gauravaradhye/remove_validate_vm_control
    
    Removed validate_vm_control method and calls as it is already replaced by supports_control
    (cherry picked from commit 5cec7864342fdb73f553cf392d759d87f3c17610)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1400616

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

Successfully merging this pull request may close these issues.

None yet

5 participants