From 982623960e183eb6e3524ddfe027fbd57797794c Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 11 Aug 2017 10:37:03 +0200 Subject: [PATCH] Test all the refresh settings by the AWS stubbed refreshers Test all the refresh settings by the AWS stubbed refreshers --- .../cloud_manager/stubbed_refresher_spec.rb | 27 +++++++++---------- .../network_manager/stubbed_refresher_spec.rb | 9 ++++--- .../ebs/stubbed_refresher_spec.rb | 10 +++---- .../s3/stubbed_refresher_spec.rb | 12 +++++---- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb index dacc03416..1976125e4 100644 --- a/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/cloud_manager/stubbed_refresher_spec.rb @@ -1,7 +1,9 @@ require_relative '../aws_helper' require_relative '../aws_stubs' +require_relative '../aws_refresher_spec_common' describe ManageIQ::Providers::Amazon::NetworkManager::Refresher do + include AwsRefresherSpecCommon include AwsStubs describe "refresh" do @@ -12,21 +14,18 @@ EvmSpecHelper.local_miq_server(:zone => Zone.seed) end - # Test all kinds of refreshes, DTO refresh, DTO with batch saving and the original refresh - [{:inventory_object_refresh => true}, - {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, - {:inventory_object_refresh => false}].each do |inventory_object_settings| - context "with settings #{inventory_object_settings}" do + (AwsRefresherSpecCommon::ALL_GRAPH_REFRESH_SETTINGS + AwsRefresherSpecCommon::ALL_OLD_REFRESH_SETTINGS + ).each do |settings| + context "with settings #{settings}" do before :each do - settings = OpenStruct.new - settings.inventory_object_refresh = inventory_object_settings[:inventory_object_refresh] - settings.inventory_object_saving_strategy = inventory_object_settings[:inventory_object_saving_strategy] - settings.get_private_images = true - settings.get_shared_images = false - settings.get_public_images = false - - allow(Settings.ems_refresh).to receive(:ec2).and_return(settings) - @inventory_object_settings = inventory_object_settings + stub_refresh_settings( + settings.merge( + :get_private_images => true, + :get_shared_images => false, + :get_public_images => false + ) + ) + @inventory_object_settings = settings end it "2 refreshes, first creates all entities, second updates all entitites" do diff --git a/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb index a33e769d5..37f2bbd7b 100644 --- a/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/network_manager/stubbed_refresher_spec.rb @@ -1,7 +1,9 @@ require_relative '../aws_helper' require_relative '../aws_stubs' +require_relative '../aws_refresher_spec_common' describe ManageIQ::Providers::Amazon::NetworkManager::Refresher do + include AwsRefresherSpecCommon include AwsStubs describe "refresh" do @@ -13,12 +15,11 @@ end # Test all kinds of refreshes, DTO refresh, DTO with batch saving and the original refresh - [{:inventory_object_refresh => true}, - {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, - {:inventory_object_refresh => false}].each do |settings| + (AwsRefresherSpecCommon::ALL_GRAPH_REFRESH_SETTINGS + AwsRefresherSpecCommon::ALL_OLD_REFRESH_SETTINGS + ).each do |settings| context "with settings #{settings}" do before :each do - allow(Settings.ems_refresh).to receive(:ec2_network).and_return(settings) + stub_refresh_settings(settings) end it "2 refreshes, first creates all entities, second updates all entitites" do diff --git a/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb index fdee24d62..77e7c294a 100644 --- a/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/storage_manager/ebs/stubbed_refresher_spec.rb @@ -1,7 +1,9 @@ require_relative '../../aws_helper' require_relative '../../aws_stubs' +require_relative '../../aws_refresher_spec_common' describe ManageIQ::Providers::Amazon::StorageManager::Ebs::Refresher do + include AwsRefresherSpecCommon include AwsStubs describe "refresh" do @@ -16,13 +18,11 @@ FactoryGirl.create(:vm_amazon, :ext_management_system => @ems, :ems_ref => "instance_0", :hardware => hardware) end - # Test all kinds of refreshes, DTO refresh, DTO with batch saving and the original refresh - [{:inventory_object_refresh => true}, - {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, - {:inventory_object_refresh => false}].each do |settings| + (AwsRefresherSpecCommon::ALL_GRAPH_REFRESH_SETTINGS + AwsRefresherSpecCommon::ALL_OLD_REFRESH_SETTINGS + ).each do |settings| context "with settings #{settings}" do before :each do - allow(Settings.ems_refresh).to receive(:ec2_ebs_storage).and_return(settings) + stub_refresh_settings(settings) end it "2 refreshes, first creates all entities, second updates all entitites" do diff --git a/spec/models/manageiq/providers/amazon/storage_manager/s3/stubbed_refresher_spec.rb b/spec/models/manageiq/providers/amazon/storage_manager/s3/stubbed_refresher_spec.rb index c94b845cd..504a1db8e 100644 --- a/spec/models/manageiq/providers/amazon/storage_manager/s3/stubbed_refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/storage_manager/s3/stubbed_refresher_spec.rb @@ -1,10 +1,14 @@ require_relative '../../aws_helper' require_relative '../../aws_stubs' +require_relative '../../aws_refresher_spec_common' describe ManageIQ::Providers::Amazon::StorageManager::S3::Refresher do + include AwsRefresherSpecCommon include AwsStubs before do + stub_settings_merge(:prototype => {:amazon => {:s3 => true }}) + skip("AWS S3 is disabled") unless ::Settings.prototype.amazon.s3 EvmSpecHelper.local_miq_server(:zone => Zone.seed) end @@ -17,13 +21,11 @@ end describe "refresh" do - # Test all kinds of refreshes - [{:inventory_object_refresh => true}, - {:inventory_object_saving_strategy => :recursive, :inventory_object_refresh => true}, - {:inventory_object_refresh => false}].each do |settings| + (AwsRefresherSpecCommon::ALL_GRAPH_REFRESH_SETTINGS + AwsRefresherSpecCommon::ALL_OLD_REFRESH_SETTINGS + ).each do |settings| context "with settings #{settings}" do before :each do - allow(Settings.ems_refresh).to receive(:s3).and_return(settings) + stub_refresh_settings(settings) end it "2 refreshes, first creates all entities, second updates all entitites" do