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

[V2V] Lan validation in Transformation Mapping #19220

Merged
merged 4 commits into from
Sep 5, 2019

Conversation

thearifismail
Copy link
Contributor

@thearifismail thearifismail commented Aug 28, 2019

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

@thearifismail
Copy link
Contributor Author

thearifismail commented Aug 28, 2019

@miq-bot add_reviewers @djberg96, @agrare
@miq-bot add_labels transformation, ivanchuk/yes, hammer/yes

@miq-bot
Copy link
Member

miq-bot commented Aug 28, 2019

@thearifismail 'djberg96 agrare' is an invalid reviewer, ignoring...

@miq-bot
Copy link
Member

miq-bot commented Aug 28, 2019

@thearifismail 'djberg96, agrare' is an invalid reviewer, ignoring...

@agrare agrare self-assigned this Aug 28, 2019
@thearifismail
Copy link
Contributor Author

Related PRs:
#19204
ManageIQ/manageiq-api#664
#19168
#18986

vmware_cluster.hosts << [src_vmware_host]

cloud_tenant.cloud_networks << [dst_cloud_network]
end
Copy link
Contributor

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].

@djberg96
Copy link
Contributor

djberg96 commented Sep 4, 2019

@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
Copy link
Member

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]
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@agrare agrare left a 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) }
Copy link
Member

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) }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

spec/models/transformation_mapping_item_spec.rb Outdated Show resolved Hide resolved
spec/models/transformation_mapping_item_spec.rb Outdated Show resolved Hide resolved
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) }
Copy link
Member

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) }

Copy link
Contributor Author

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) }
Copy link
Member

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) }

Copy link
Contributor Author

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]
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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]
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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]
Copy link
Member

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

Copy link
Contributor Author

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) }
Copy link
Member

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]

Copy link
Contributor Author

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]
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@miq-bot
Copy link
Member

miq-bot commented Sep 4, 2019

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
3 files checked, 1 offense detected

spec/models/transformation_mapping_spec.rb

@thearifismail
Copy link
Contributor Author

@agrare made all the changes pointed out.

Copy link
Member

@agrare agrare left a 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

agrare added a commit that referenced this pull request Sep 5, 2019
[V2V] Lan validation in Transformation Mapping
@agrare agrare merged commit d27a818 into ManageIQ:master Sep 5, 2019
@agrare agrare added this to the Sprint 120 Ending Sep 16, 2019 milestone Sep 5, 2019
simaishi pushed a commit that referenced this pull request Nov 4, 2019
[V2V] Lan validation in Transformation Mapping

(cherry picked from commit b701622)

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

simaishi commented Nov 4, 2019

Ivanchuk backport details:

$ git log -1
commit 5e5246b9eef2861d58714d4d281fcf761138b7c5
Author: Adam Grare <[email protected]>
Date:   Thu Sep 5 07:58:32 2019 -0400

    Merge pull request #19220 from thearifismail/new_lanv
    
    [V2V] Lan validation in Transformation Mapping
    
    (cherry picked from commit b701622b83c45fe6568f48431396d8318f29faec)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1768517

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.

6 participants