-
Notifications
You must be signed in to change notification settings - Fork 62
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
Host targeted refresh deleting and re-creating storage, switch, and lan records #336
Changes from all commits
7f9ada6
c395e41
5e83d3b
1a0117d
4acb9c9
e13ae6e
d3d2661
1b3c509
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module OvirtRefresherSpecCommon | ||
extend ActiveSupport::Concern | ||
|
||
def serialize_inventory(models = []) | ||
skip_attributes = %w(updated_on last_refresh_date updated_at last_updated finish_time) | ||
inventory = {} | ||
models.each do |model| | ||
inventory[model.name] = model.all.collect do |rec| | ||
rec.attributes.except(*skip_attributes) | ||
end.sort { |rec| rec["id"] } | ||
end | ||
inventory | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
require_relative 'ovirt_refresher_spec_common' | ||
|
||
describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Refresher do | ||
include OvirtRefresherSpecCommon | ||
|
||
describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Refresher 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. @borod108 why are these describe blocks duplicated? 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. For no good reason I can think off. |
||
before(:each) do | ||
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone | ||
|
@@ -26,8 +30,6 @@ | |
stub_const("OvirtSDK4::Connection", Spec::Support::OvirtSDK::ConnectionVCR) | ||
end | ||
|
||
COUNTED_MODELS = [CustomAttribute, EmsFolder, EmsCluster, Datacenter].freeze | ||
|
||
before(:each) do | ||
@inventory_wrapper_class = ManageIQ::Providers::Redhat::InfraManager::Inventory::Strategies::V4 | ||
|
||
|
@@ -42,29 +44,29 @@ def load_response_mock_for(filename) | |
YAML.load_file(File.join('spec', 'models', prefix, 'response_yamls', filename + '.yml')) | ||
end | ||
|
||
let(:models_for_host_target) { [ExtManagementSystem, EmsFolder, EmsCluster, Storage, HostStorage, Switch, HostSwitch, Lan, CustomAttribute] } | ||
|
||
it 'does not change the host when target refresh after full refresh' do | ||
stub_settings_merge(:ems_refresh => { :rhevm => {:inventory_object_refresh => true }}) | ||
|
||
EmsRefresh.refresh(@ems) | ||
@ems.reload | ||
|
||
saved_inventory = serialize_inventory(models_for_host_target) | ||
|
||
host = @ems.hosts.find_by(:ems_ref => "/api/hosts/f9dbfd16-3c79-4028-9304-9acf3b8857ba") | ||
saved_host = host_to_comparable_hash(host) | ||
saved_counted_models = COUNTED_MODELS.map { |m| [m.name, m.count] } | ||
saved_switches = host.switches.map { |switch| [switch.uid_ems, switch.name] } | ||
expect(host.networks.count).to eq(2) | ||
EmsRefresh.refresh(host) | ||
host.reload | ||
expect(host.networks.count).to eq(2) | ||
expect(saved_switches).to contain_exactly(*host.switches.map { |switch| a_collection_containing_exactly(switch.uid_ems, switch.name) }) | ||
|
||
expect(serialize_inventory(models_for_host_target)).to eq(saved_inventory) | ||
|
||
EmsRefresh.refresh(host) | ||
host.reload | ||
|
||
expect(host.switches.map { |switch| [switch.uid_ems, switch.name] }).to contain_exactly( | ||
a_collection_containing_exactly("00000000-0000-0000-0000-000000000009", "ovirtmgmt"), | ||
a_collection_containing_exactly("5c42817f-03fb-460e-a3ab-a8770553aeee", "vlan123t") | ||
) | ||
expect(host.networks.count).to eq(2) | ||
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. Just wondering, if we removed this maybe we should also remove the second refresh - (line 63-64) |
||
counted_models = COUNTED_MODELS.map { |m| [m.name, m.count] } | ||
expect(saved_host).to eq(host_to_comparable_hash(host)) | ||
expect(saved_counted_models).to eq(counted_models) | ||
end | ||
|
||
def host_to_comparable_hash(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 was comparing the wrong property: