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

Use leaf classes for ems type validation #19342

Merged
merged 1 commit into from
Sep 30, 2019

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented Sep 27, 2019

Recent changes put the automation thingy factory back to not being a leaf class and LJ wouldn't leaf me alone so.

From comment here: https://github.com/ManageIQ/manageiq/pull/19330/files#r329235409

@miq-bot assign @jrafanie
I think this's all, right?

@jameswnl
Copy link
Contributor

Don't do this. Change to use factory :automation_manager_ansible_tower instead of :automation_manager

@miq-bot
Copy link
Member

miq-bot commented Sep 27, 2019

Checked commit d-m-u@8e61b03 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

@jrafanie
Copy link
Member

Don't do this. Change to use factory :automation_manager_ansible_tower instead of :automation_manager

We can't. The automation_manager factory is unusable right now.

@jameswnl
Copy link
Contributor

Don't do this. Change to use factory :automation_manager_ansible_tower instead of :automation_manager

We can't. The automation_manager factory is unusable right now.

This is passing: ManageIQ/manageiq-content#586

@d-m-u
Copy link
Contributor Author

d-m-u commented Sep 27, 2019

@jameswnl LJ's spec on https://github.com/ManageIQ/manageiq/pull/19330/files#r329235208 shows that the factory is currently unusable. Even if the content repo greens because we change those specs, the factories in this file need to be leaf classes. All of them. Argue with LJ about it all you want.

@kbrock
Copy link
Member

kbrock commented Sep 28, 2019

This fixes an issue introduced in #19330

@jrafanie
Copy link
Member

@jameswnl I'll merge this for now since ems factories can't be abstract/non-leaf classes, see:

errors.add(:base, "emstype #{self.class.name} is not supported for create") unless ExtManagementSystem.supported_types_and_descriptions_hash.key?(emstype)

We can discuss other solutions for the original problem of preventing creation of these non-leaf classes that was implemented in #18842. Ultimately, in that PR, we decided it was better to have all the base factories use a concrete leaf ems class from a provider to allow non-provider tests to be able to use the base factory in situations that are provider agnostic. In other words, it's better to have provider class information in one location in the base factories than to force tests in several repos to know this class information in their tests. Of course, if the non-provider tests are testing provider specific use cases, then they should be using the specific provider, so I think your change in ManageIQ/manageiq-content#586 was good.

It's a gnarly problem and any other solutions would be greatly appreciated.

cc @agrare

@jrafanie jrafanie self-requested a review September 30, 2019 14:17
@jrafanie jrafanie merged commit bf11400 into ManageIQ:master Sep 30, 2019
@jrafanie jrafanie added this to the Sprint 121 Ending Sep 30, 2019 milestone Sep 30, 2019
@d-m-u d-m-u deleted the fixing_failing_content_spec branch September 30, 2019 14:19
@jameswnl
Copy link
Contributor

jameswnl commented Sep 30, 2019

We can discuss other solutions for the original problem of preventing creation of these non-leaf classes that was implemented in #18842. Ultimately, in that PR, we decided it was better to have all the base factories use a concrete leaf ems class from a provider to allow non-provider tests to be able to use the base factory in situations that are provider agnostic. In other words, it's better to have provider class information in one location in the base factories than to force tests in several repos to know this class information in their tests. Of course, if the non-provider tests are testing provider specific use cases, then they should be using the specific provider, so I think your change in ManageIQ/manageiq-content#586 was good.

This approach is problematic because it allows creating tests that seems general (i.e. applicable to all implementations of that provider), but in fact it depends on implementation-specific features.

This approach also creates barrier to make our providers more pluggable.

I still believe ManageIQ/manageiq-content#586 is the way to go.

Yeah, we can discuss more on "ems factories can't be abstract/non-leaf classes"

@jrafanie
Copy link
Member

This approach is problematic because it allows creating tests that seems general (i.e. applicable to all implementations of that provider), but in fact it depends on implementation-specific features.

Yes, these tests need to depend on the specific subclass factory like I mentioned was good about ManageIQ/manageiq-content#586

This approach also creates barrier to make our providers more pluggable.

Sure, if there are better solutions to prevent non-leaf ems classes from being created, I think we're open to something better. I think #18842 was the solution we disliked least.

I still believe ManageIQ/manageiq-content#586 is the way to go.

👍 It's ansible tower specific tests so it should use ansible tower specific factories.

This PR was merely to make the base factory usable again. It's not the complete solution.

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.

5 participants