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

Currently on a successful ActionResult (start / stop) we return nil #18036

Merged
merged 1 commit into from
Oct 1, 2018

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Sep 28, 2018

Returning the result of the api call would at least be a positive result
https://bugzilla.redhat.com/show_bug.cgi?id=1628658

@@ -231,24 +231,24 @@ def expect_api_call(expected_action, expected_args = nil)
it "calls the given action with the given args" do
args = {:my => "args", :here => 123}
expect(api_collection).to receive(action).with(args).and_return(api_success_result)
described_class.exec_api_call(region, collection_name, action, args)
expect(described_class.exec_api_call(region, collection_name, action, args)).to be(api_success_result)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be .to eq? I'm not sure what this syntax actually does.

Copy link
Member Author

Choose a reason for hiding this comment

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

¯\_(ツ)_/¯ since it's stubbed, it will be the same object id.

@@ -77,6 +77,7 @@ def self.exec_api_call(region, collection_name, action, api_args = nil, id = nil
case result
when ManageIQ::API::Client::ActionResult
raise InterRegionApiMethodRelayError, result.message if result.failed?
result
Copy link
Member

Choose a reason for hiding this comment

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

Is there something better in the action result that we can return? Or maybe just true would be better to indicate a successful API call?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking it should be the JSON response from the remote region API. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

What does that actually look like in this case? Could you post an example?

I agree that it's better than the result object itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, updated the PR accordingly and the output is:

irb(main):003:0> r = vm.stop({})
=> #<ManageIQ::API::Client::ActionResult:0x0000000009d66010 @attributes={"success"=>true, "message"=>"VM id:1 name:'something' stopping", "task_id"=>"4", "task_href"=>"https://x.x.x.x/api/tasks/4", "href"=>"https://x.x.x.x/api/vms/1"}>
irb(main):004:0> r.attributes
=> {"success"=>true, "message"=>"VM id:1 name:'something' stopping", "task_id"=>"4", "task_href"=>"https://x.x.x.x/api/tasks/4", "href"=>"https://x.x.x.x/api/vms/1"}

@bdunne bdunne force-pushed the action_result_shouldnt_be_nil branch from 4b81358 to d5c75ad Compare October 1, 2018 18:45
@miq-bot
Copy link
Member

miq-bot commented Oct 1, 2018

Checked commit bdunne@d5c75ad with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@carbonin carbonin merged commit 2fb6260 into ManageIQ:master Oct 1, 2018
@carbonin carbonin added this to the Sprint 96 Ending Oct 8, 2018 milestone Oct 1, 2018
@bdunne bdunne deleted the action_result_shouldnt_be_nil branch October 1, 2018 20:14
simaishi pushed a commit that referenced this pull request Oct 2, 2018
Currently on a successful ActionResult (start / stop) we return nil

(cherry picked from commit 2fb6260)

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

simaishi commented Oct 2, 2018

Hammer backport details:

$ git log -1
commit 266b6c550dcb461206993916828ea9c5295b4e4a
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Mon Oct 1 15:56:11 2018 -0400

    Merge pull request #18036 from bdunne/action_result_shouldnt_be_nil
    
    Currently on a successful ActionResult (start / stop) we return nil
    
    (cherry picked from commit 2fb626056c1b7e53203ac7d727780693a1c619c1)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1628658

@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit a44cae5a04cd9965eee660d0cef5864fb4a3ee07
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Mon Oct 1 15:56:11 2018 -0400

    Merge pull request #18036 from bdunne/action_result_shouldnt_be_nil
    
    Currently on a successful ActionResult (start / stop) we return nil
    
    (cherry picked from commit 2fb626056c1b7e53203ac7d727780693a1c619c1)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1635764

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.

4 participants