-
Notifications
You must be signed in to change notification settings - Fork 900
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
Check ems_ref before uid_ems when saving VMs #18616
Changes from 1 commit
ae7a083
0838a11
3512eff
2673eec
8d348d5
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 |
---|---|---|
|
@@ -128,24 +128,14 @@ | |
EmsRefresh.save_vms_inventory(@ems, data) | ||
|
||
vms = Vm.all | ||
expect(vms.length).to eq(3) | ||
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 spec is now actually testing a VM with the same ems_ref and a new uid_ems get updated and not archived:
Since the second vm in the data payload has the same ems_ref as an active vm but with a different uid_ems. 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. Do the 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. The descriptions were pretty general, "handle dups in the raw data" doesn't really describe what it is expecting to happen. I'll update them to better describe the expected outcome. 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 |
||
|
||
disconnected, connected = vms.partition { |v| v.ems_id.nil? } | ||
expect(disconnected.length).to eq(1) | ||
expect(connected.length).to eq(2) | ||
|
||
d = disconnected.first | ||
c1, c2 = connected.sort_by(&:id) | ||
|
||
expect(d.id).to eq(@vm2.id) | ||
expect(d.uid_ems).to eq(@vm2.uid_ems) | ||
expect(vms.length).to eq(2) | ||
v1, v2 = vms.sort_by(&:id) | ||
|
||
expect(c1.id).to eq(@vm1.id) | ||
expect(c1.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v1.id).to eq(@vm1.id) | ||
expect(v1.uid_ems).to eq(@vm1.uid_ems) | ||
|
||
expect(c2.id).not_to eq(@vm1.id) | ||
expect(c2.id).not_to eq(@vm2.id) | ||
expect(c2.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v2.id).to eq(@vm2.id) | ||
expect(v2.uid_ems).to eq(@vm1.uid_ems) | ||
end | ||
end | ||
|
||
|
@@ -161,24 +151,14 @@ | |
EmsRefresh.save_vms_inventory(@ems, data) | ||
|
||
vms = Vm.all | ||
expect(vms.length).to eq(3) | ||
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 here:
So we're picking the existing VM with the same ems_ref and updating the uid_ems to match the new data |
||
|
||
disconnected, connected = vms.partition { |v| v.ems_id.nil? } | ||
expect(disconnected.length).to eq(1) | ||
expect(connected.length).to eq(2) | ||
|
||
d = disconnected.first | ||
c1, c2 = connected.sort_by(&:id) | ||
|
||
expect(d.id).to eq(@vm2.id) | ||
expect(d.uid_ems).to eq(@vm2.uid_ems) | ||
expect(vms.length).to eq(2) | ||
v1, v2 = vms.sort_by(&:id) | ||
|
||
expect(c1.id).to eq(@vm1.id) | ||
expect(c1.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v1.id).to eq(@vm1.id) | ||
expect(v1.uid_ems).to eq(@vm1.uid_ems) | ||
|
||
expect(c2.id).not_to eq(@vm1.id) | ||
expect(c2.id).not_to eq(@vm2.id) | ||
expect(c2.uid_ems).not_to eq(@vm1.uid_ems) | ||
expect(v2.id).to eq(@vm2.id) | ||
expect(v2.uid_ems).not_to eq(@vm1.uid_ems) | ||
end | ||
|
||
it "should handle dups in the raw data" do | ||
|
@@ -209,24 +189,14 @@ | |
EmsRefresh.save_vms_inventory(@ems, data) | ||
|
||
vms = Vm.all | ||
expect(vms.length).to eq(3) | ||
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. Here we are reconnecting one VM and updating the other:
|
||
|
||
disconnected, connected = vms.partition { |v| v.ems_id.nil? } | ||
expect(disconnected.length).to eq(1) | ||
expect(connected.length).to eq(2) | ||
|
||
d = disconnected.first | ||
c1, c2 = connected.sort_by(&:id) | ||
|
||
expect(d.id).to eq(@vm2.id) | ||
expect(d.uid_ems).to eq(@vm2.uid_ems) | ||
expect(vms.length).to eq(2) | ||
v1, v2 = vms.sort_by(&:id) | ||
|
||
expect(c1.id).to eq(@vm1.id) | ||
expect(c1.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v1.id).to eq(@vm1.id) | ||
expect(v1.uid_ems).to eq(@vm1.uid_ems) | ||
|
||
expect(c2.id).not_to eq(@vm1.id) | ||
expect(c2.id).not_to eq(@vm2.id) | ||
expect(c2.uid_ems).not_to eq(@vm1.uid_ems) | ||
expect(v2.id).to eq(@vm2.id) | ||
expect(v2.uid_ems).not_to eq(@vm2.uid_ems) | ||
end | ||
|
||
it "should handle dups in the raw data" do | ||
|
@@ -329,24 +299,14 @@ | |
EmsRefresh.save_vms_inventory(@ems, data) | ||
|
||
vms = Vm.all | ||
expect(vms.length).to eq(3) | ||
|
||
disconnected, connected = vms.partition { |v| v.ems_id.nil? } | ||
expect(disconnected.length).to eq(1) | ||
expect(connected.length).to eq(2) | ||
|
||
d = disconnected.first | ||
c1, c2 = connected.sort_by(&:id) | ||
|
||
expect(d.id).to eq(@vm2.id) | ||
expect(d.uid_ems).to eq(@vm2.uid_ems) | ||
expect(vms.length).to eq(2) | ||
v1, v2 = vms.sort_by(&:id) | ||
|
||
expect(c1.id).to eq(@vm1.id) | ||
expect(c1.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v1.id).to eq(@vm1.id) | ||
expect(v1.uid_ems).to eq(@vm1.uid_ems) | ||
|
||
expect(c2.id).not_to eq(@vm1.id) | ||
expect(c2.id).not_to eq(@vm2.id) | ||
expect(c2.uid_ems).to eq(@vm1.uid_ems) | ||
expect(v2.id).to eq(@vm2.id) | ||
expect(v2.uid_ems).not_to eq(@vm2.uid_ems) | ||
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.
If you need an array you can change the original index creation to do group_by instead of index_by
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 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.
Just be careful of your
&.
change below (just noticed)