-
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
Changes from 2 commits
d4bcf52
7f17f59
2ae1efb
d27a818
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -8,6 +8,9 @@ | |||
let(:ems_openstack) { FactoryBot.create(:ems_openstack) } | ||||
let(:openstack_cluster) { FactoryBot.create(:ems_cluster_openstack, :ext_management_system => ems_openstack) } | ||||
|
||||
# --------------------------------------------------------------------------- | ||||
# Cluster Validation | ||||
# --------------------------------------------------------------------------- | ||||
context "source cluster validation" do | ||||
let(:valid_mapping_item) do | ||||
FactoryBot.build(:transformation_mapping_item, :source => vmware_cluster, :destination => openstack_cluster) | ||||
|
@@ -46,6 +49,9 @@ | |||
end | ||||
end | ||||
|
||||
# --------------------------------------------------------------------------- | ||||
# Datastore Validation | ||||
# --------------------------------------------------------------------------- | ||||
context "datastore validation" do | ||||
let(:ems_vmware) { FactoryBot.create(:ems_vmware) } | ||||
let(:vmware_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_vmware) } | ||||
|
@@ -100,4 +106,82 @@ | |||
end | ||||
end | ||||
end | ||||
|
||||
# --------------------------------------------------------------------------- | ||||
# Network Validation | ||||
# --------------------------------------------------------------------------- | ||||
context "Network validation" do | ||||
let(:ems_vmware) { FactoryBot.create(:ems_vmware) } | ||||
let(:vmware_cluster) { FactoryBot.create(:ems_cluster, :ext_management_system => ems_vmware) } | ||||
thearifismail marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
let(:ems_redhat) { FactoryBot.create(:ems_redhat) } | ||||
thearifismail marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Same
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
|
||||
let(:ems_ops) { FactoryBot.create(:ems_openstack) } | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could just be
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
let(:cloud_tenant) { FactoryBot.create(:cloud_tenant_openstack, :ext_management_system => ems_ops) } | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't used by the |
||||
|
||||
# source network | ||||
context "source vmware network" do | ||||
let(:src_vmware_host) { FactoryBot.create(:host_vmware, :ems_cluster => vmware_cluster) } | ||||
let(:src_switch) { FactoryBot.create(:switch, :host => src_vmware_host) } | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you can actually set |
||||
let(:src_lan) { FactoryBot.create(:lan, :switch => src_switch) } | ||||
|
||||
context "destination openstack" do | ||||
let(:dst_cloud_network) { FactoryBot.create(:cloud_network, :cloud_tenant => cloud_tenant) } | ||||
|
||||
let(:tmi_ops_cluster) { FactoryBot.create(:transformation_mapping_item, :source => vmware_cluster, :destination => cloud_tenant) } | ||||
let(:ops_mapping) { FactoryBot.create(:transformation_mapping, :transformation_mapping_items => [tmi_ops_cluster]) } | ||||
|
||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's an extra indentation here |
||||
src_switch.lans << [src_lan] | ||||
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 commentThe 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 commentThe 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 ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is a different context. |
||||
end | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say instead of doing it this way, you should use |
||||
|
||||
it "valid source" do | ||||
expect(valid_source.valid?).to be(true) | ||||
end | ||||
it "invalid source" do | ||||
expect(invalid_source.valid?).to be(false) | ||||
end | ||||
end | ||||
|
||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. This has to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
let(:dst_rh_lan) { FactoryBot.create(:lan, :switch=> dst_rh_switch) } | ||||
|
||||
let(:tmi_cluster) { FactoryBot.create(:transformation_mapping_item, :source => vmware_cluster, :destination => redhat_cluster) } | ||||
|
||||
let(:rh_mapping) { FactoryBot.create(:transformation_mapping, :transformation_mapping_items => [tmi_cluster]) } | ||||
|
||||
context "source validation" do | ||||
let(:valid_lan) { FactoryBot.create(:transformation_mapping_item, :source => src_lan, :destination => dst_rh_lan, :transformation_mapping_id => rh_mapping.id) } | ||||
let(:invalid_lan) { FactoryBot.build(:transformation_mapping_item, :source => dst_rh_lan, :destination => src_lan, :transformation_mapping_id => rh_mapping.id) } | ||||
|
||||
before do | ||||
src_switch.lans << [src_lan] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, not needed |
||||
src_vmware_host.switches << [src_switch] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||
vmware_cluster.hosts << [src_vmware_host] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||||
|
||||
dst_rh_switch.lans << [dst_rh_lan] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||||
dst_rh_host.switches << [dst_rh_switch] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||||
redhat_cluster.hosts << [dst_rh_host] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed |
||||
end | ||||
|
||||
it "valid rhev lan" do | ||||
expect(valid_lan.valid?).to be(true) | ||||
end | ||||
it "invalid rhev lan" do | ||||
expect(invalid_lan.valid?).to be(false) | ||||
end | ||||
end | ||||
end | ||||
end | ||||
end | ||||
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.
This is a duplicate
manageiq/spec/models/transformation_mapping_item_spec.rb
Line 2 in 2ae1efb
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.