-
Notifications
You must be signed in to change notification settings - Fork 897
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
[V2V] Lan validation in Transformation Mapping #19220
Conversation
@thearifismail 'djberg96 agrare' is an invalid reviewer, ignoring... |
@thearifismail 'djberg96, agrare' is an invalid reviewer, ignoring... |
Related PRs: |
vmware_cluster.hosts << [src_vmware_host] | ||
|
||
cloud_tenant.cloud_networks << [dst_cloud_network] | ||
end |
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.
I would say instead of doing it this way, you should use FactoryBot.create_list
with regular assignment instead of << [stuff]
.
@thearifismail You got the failures worked out, nice! |
let(:valid_source) { FactoryBot.create(:transformation_mapping_item, :source => src_lan, :destination => dst_cloud_network, :transformation_mapping_id => ops_mapping.id) } | ||
let(:invalid_source) { FactoryBot.build(:transformation_mapping_item, :source => dst_cloud_network, :destination => src_lan, :transformation_mapping_id => ops_mapping.id) } | ||
|
||
before do |
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.
Looks like there's an extra indentation here
src_vmware_host.switches << [src_switch] | ||
vmware_cluster.hosts << [src_vmware_host] | ||
|
||
cloud_tenant.cloud_networks << [dst_cloud_network] |
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.
Is this any different between contexts? If not you can just do this when you define these up 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.
Actually the way you have those set up e.g. setting the switch for the lan (FactoryBot.create(:lan, :switch => src_switch)
) then I doubt you need to do anything extra.
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 it is a different context.
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.
After these comments are addressed you don't need either before do;end
block
# Network Validation | ||
# --------------------------------------------------------------------------- | ||
context "Network validation" do | ||
let(:ems_vmware) { FactoryBot.create(:ems_vmware) } |
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 duplicate
let(:ems_vmware) { FactoryBot.create(:ems_vmware) } |
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.
Done.
let(:vmware_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_vmware) } | ||
|
||
let(:ems_redhat) { FactoryBot.create(:ems_redhat) } | ||
let(:redhat_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_redhat) } |
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.
Same
let(:redhat_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_redhat) } |
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.
Done.
let(:ems_redhat) { FactoryBot.create(:ems_redhat) } | ||
let(:redhat_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_redhat) } | ||
|
||
let(:ems_ops) { FactoryBot.create(:ems_openstack) } |
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 could just be
let(:ems_openstack) { FactoryBot.create(:ems_openstack) } |
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.
Done.
|
||
before do | ||
src_switch.lans << [src_lan] | ||
src_vmware_host.switches << [src_switch] |
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.
If you fix this https://github.com/ManageIQ/manageiq/pull/19220/files#diff-1f06e8e1d35539c0a3b5408fc280788dR126 to set the host properly then this isn't needed.
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.
Done
src_vmware_host.switches << [src_switch] | ||
vmware_cluster.hosts << [src_vmware_host] | ||
|
||
cloud_tenant.cloud_networks << [dst_cloud_network] |
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 isn't needed because you set cloud_network.cloud_tenant
here https://github.com/ManageIQ/manageiq/pull/19220/files#diff-1f06e8e1d35539c0a3b5408fc280788dR130
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.
Done
|
||
before do | ||
src_switch.lans << [src_lan] | ||
src_vmware_host.switches << [src_switch] |
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.
Similarly if you fix the switch.hosts then you don't need this
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.
Done.
|
||
context "destination red hat" do | ||
let(:dst_rh_host) { FactoryBot.create(:host_redhat, :ems_cluster => redhat_cluster) } | ||
let(:dst_rh_switch) { FactoryBot.create(:switch, :host => dst_rh_host) } |
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 has to be :hosts => [dst_rh_host]
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.
Done.
vmware_cluster.hosts << [src_vmware_host] | ||
|
||
dst_rh_switch.lans << [dst_rh_lan] | ||
dst_rh_host.switches << [dst_rh_switch] |
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.
Not needed if you set switch.hosts properly
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.
Done!
Checked commits thearifismail/manageiq@d4bcf52~...d27a818 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 spec/models/transformation_mapping_spec.rb
|
@agrare made all the changes pointed out. |
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.
There's a let(:ems_openstack) { FactoryBot.create(:ems_openstack) }
at the top level context, and two let(:ems_ops) { FactoryBot.create(:ems_openstack) } that could just use the top level one, but this can be done in a follow-up
[V2V] Lan validation in Transformation Mapping
[V2V] Lan validation in Transformation Mapping (cherry picked from commit b701622) https://bugzilla.redhat.com/show_bug.cgi?id=1768517
Ivanchuk backport details:
|
This PR validates that the source and target networks (lans) are associated with the parent EmsCluster.
Target Lans
RHV: Class Lan, Filters: Must belong to target cluster
OSP: Class CloudNetwork, Filters: Must belong to target CloudTenant's ExtManagementSystem
Source Lans
VMW: Class Lan, Filters: Must belong to one of the source clusters
https://trello.com/c/1x31IdD0/241-spike-mapping-and-plan-api-validation-of-input
https://bugzilla.redhat.com/show_bug.cgi?id=1666840