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

storage service edit #1216

Merged
merged 1 commit into from Apr 30, 2023
Merged

Conversation

OrGur1987
Copy link
Contributor

@OrGur1987 OrGur1987 commented Mar 23, 2023

belongs to issue: ManageIQ/manageiq-ui-classic#8728

depends upon:

adds editing/update option to storage service controller and app yaml

@OrGur1987
Copy link
Contributor Author

@bdunne hi, this is ready for review
thanks

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

this looks great. just that one change

config/api.yml Outdated Show resolved Hide resolved
@kbrock
Copy link
Member

kbrock commented Mar 29, 2023

Also, is there a way to add a spec here?

@OrGur1987
Copy link
Contributor Author

Also, is there a way to add a spec here?

should I use spec/models/cloud_volume_spec.rb as an example?
the specs there test queuing methods

@OrGur1987
Copy link
Contributor Author

Also, is there a way to add a spec here?

should I use spec/models/cloud_volume_spec.rb as an example? the specs there test queuing methods

@kbrock

@kbrock
Copy link
Member

kbrock commented Apr 5, 2023

@OrGur1987 good point. you can't test that the records have been modified because this is just a request for the provider.

Yes, base your tests upon those.

@OrGur1987
Copy link
Contributor Author

@OrGur1987 good point. you can't test that the records have been modified because this is just a request for the provider.

Yes, base your tests upon those.

added an edit spec to spec/requests/storage_services_spec.rb.

require 'byebug'
byebug
provider = FactoryBot.create(:ems_autosde, :name => 'Autosde')
storage_service = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service1', :ext_management_system => provider)
Copy link
Member

@kbrock kbrock Apr 12, 2023

Choose a reason for hiding this comment

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

Suggested change
storage_service = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service1', :ext_management_system => provider)
storage_service = FactoryBot.create(:autosde_storage_manager, :ext_management_system => provider)

also noticed that others use :storage_service, not sure if that works for you.

You could probably put the provider and storage_service into a let() {} at the top of this file to reduce some of this duplication... but that is up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

extracted provider to let().
extracting storage_service didn't quite work out with the delete and get specs..

in the edit spec, for some reason when I use FactoryBot.create(:storage_service, ... ) the service does not support update, but it does when I use FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService",...).

do u have any idea why? maybe it references the core repo storage_service model and not the provider's one?
it supposedly doesn't support create and delete as well, but those spec do pass..

    83:   context 'Storage Services edit action' do
    84:     it "PUT /api/storage_services/:id'" do
    85:       storage_service1 = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service1', :ext_management_system => provider)
    86:       storage_service2 = FactoryBot.create(:storage_service, :name => 'test_service1', :ext_management_system => provider)
    87: 
    88:       require 'byebug'
    89:       byebug
    90: 
=>  91:       api_basic_authorize('storage_service_edit')
    92:       put(api_storage_service_url(nil, storage_service))
    93: 
    94: 
    95:       expect(response.parsed_body["message"]).to include("Updating")
    96:       expect(response).to have_http_status(:ok)
    97:     end
    98:   end
    99: 
   100: end
(byebug) storage_service1.supports_update?
true
(byebug) storage_service2.supports_update?
false
(byebug) storage_service2.supports_create?
false
(byebug) storage_service2.supports_delete?
false
(byebug) storage_service1.supports_delete?
true

Copy link
Member

@kbrock kbrock Apr 28, 2023

Choose a reason for hiding this comment

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

sorry.

We tend to use stub_supports to ensure that you get the expected supports?.
In the far far future, we would like to change all these tests to use a generic providers with a bunch of expectations on them.

In your example, I know you specified the correct :provider for service2, but the class of storage_service is not right. You would need to use a factory like :autosde_storage_manager.

But stub_supports on the storage_service2 would probably get your needs met if that factory does not work for you.

@kbrock
Copy link
Member

kbrock commented Apr 12, 2023

@OrGur1987 This looks great. Just one or two tweaks and we can get it in right away.

Thanks for doing this

@kbrock kbrock self-assigned this Apr 12, 2023
@OrGur1987
Copy link
Contributor Author

@OrGur1987 This looks great. Just one or two tweaks and we can get it in right away.

Thanks for doing this

@kbrock is spec ok like that?

@OrGur1987 OrGur1987 requested a review from kbrock April 19, 2023 07:17
@OrGur1987
Copy link
Contributor Author

@kbrock
kind reminder :)

@kbrock
Copy link
Member

kbrock commented Apr 28, 2023

@OrGur1987 thanks for the ping. I'll leave this tab open and hope it does not slip through the cracks again.

Could you see my notes around the class of the storage_service2?
Also, don't set any attributes (i.e.: name) in the provider if it will work without it set.

Not sure why the factory is a sticking point for me

@OrGur1987 OrGur1987 force-pushed the storage_service_update branch 2 times, most recently from 938214a to 55bc611 Compare April 30, 2023 07:56
@miq-bot
Copy link
Member

miq-bot commented Apr 30, 2023

Checked commit Autosde@004d17c with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@OrGur1987
Copy link
Contributor Author

@OrGur1987 thanks for the ping. I'll leave this tab open and hope it does not slip through the cracks again.

Could you see my notes around the class of the storage_service2? Also, don't set any attributes (i.e.: name) in the provider if it will work without it set.

Not sure why the factory is a sticking point for me

@kbrock
stub_supports fixed it thnx :)
removed the name from the provider

@kbrock kbrock merged commit 29a826f into ManageIQ:master Apr 30, 2023
4 checks passed
@Fryguy Fryguy added this to the Petrosian milestone Sep 14, 2023
@Fryguy Fryguy added this to Petrosian in Roadmap Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Roadmap
  
Petrosian
Development

Successfully merging this pull request may close these issues.

None yet

5 participants