Skip to content

Commit

Permalink
Implement archiving for graph refresh, run deletion tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Jul 19, 2017
1 parent d519de2 commit 7ecb614
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def initialize_inventory_collections(ems)
:builder_params => {:ems_id => ems.id},
:association => :container_projects,
:secondary_refs => {:by_name => [:name]},
:delete_method => :disconnect_inv,
)
initialize_custom_attributes_collections(ems.container_projects, %w(labels additional_attributes))

Expand Down Expand Up @@ -88,6 +89,7 @@ def initialize_inventory_collections(ems)
# TODO: old save matches on [:image_ref, :container_image_registry_id]
# TODO: should match on digest when available
:manager_ref => [:image_ref],
:delete_method => :disconnect_inv,
)
initialize_custom_attributes_collections(ems.container_images, %w(labels docker_labels))

Expand All @@ -99,6 +101,7 @@ def initialize_inventory_collections(ems)
:association => :container_groups,
:secondary_refs => {:by_namespace_and_name => [:namespace, :name]},
:attributes_blacklist => [:namespace],
:delete_method => :disconnect_inv,
)
initialize_container_conditions_collection(ems.container_groups)
initialize_custom_attributes_collections(ems.container_groups, %w(labels node_selectors))
Expand All @@ -109,6 +112,7 @@ def initialize_inventory_collections(ems)
:builder_params => {:ems_id => ems.id},
:association => :container_definitions,
# parser sets :ems_ref => "#{pod_id}_#{container_def.name}_#{container_def.image}"
:delete_method => :disconnect_inv,
)
@inv_collections[:container_volumes] =
::ManagerRefresh::InventoryCollection.new(
Expand All @@ -124,6 +128,7 @@ def initialize_inventory_collections(ems)
:builder_params => {:ems_id => ems.id},
:association => :containers,
# parser sets :ems_ref => "#{pod_id}_#{container.name}_#{container.image}"
:delete_method => :disconnect_inv,
)
@inv_collections[:container_port_configs] =
::ManagerRefresh::InventoryCollection.new(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
describe ManageIQ::Providers::Kubernetes::ContainerManager::Refresher do
# instantiated at the end, for both classical and graph refresh
shared_examples "kubernetes refresher VCR tests" do |check_tag_mapping: true|
let(:check_tag_mapping) { check_tag_mapping }

before(:each) do
allow(MiqServer).to receive(:my_zone).and_return("default")
auth = AuthToken.new(:name => "test", :auth_key => "valid-token")
Expand Down Expand Up @@ -28,8 +31,6 @@
)
end

let(:check_tag_mapping) { true }

def full_refresh_test
3.times do # Run three times to verify that second & third runs with existing data do not change anything
VCR.use_cassette(described_class.name.underscore) do # , :record => :new_episodes) do
Expand Down Expand Up @@ -61,22 +62,6 @@ def full_refresh_test
full_refresh_test
end

describe "graph refresh" do
let(:check_tag_mapping) { false } # TODO: pending implementation

it "will perform a full refresh with inventory_objects on k8s" do
stub_settings_merge(
:ems_refresh => {
:kubernetes => {
:inventory_object_refresh => true
}
}
)

full_refresh_test
end
end

def assert_table_counts
expect(ContainerGroup.count).to eq(2)
expect(ContainerNode.count).to eq(2)
Expand Down Expand Up @@ -528,3 +513,30 @@ def assert_disconnected(object)
expect(object.archived?).to be true
end
end

describe ManageIQ::Providers::Kubernetes::ContainerManager::Refresher do
context "classical refresh" do
before(:each) do
stub_settings_merge(
:ems_refresh => {:kubernetes => {:inventory_object_refresh => false}}
)

expect(ManageIQ::Providers::Kubernetes::ContainerManager::RefreshParser).not_to receive(:ems_inv_to_inv_collections)
end

include_examples "kubernetes refresher VCR tests"
end

context "graph refresh" do
before(:each) do
stub_settings_merge(
:ems_refresh => {:kubernetes => {:inventory_object_refresh => true}}
)

expect(ManageIQ::Providers::Kubernetes::ContainerManager::RefreshParser).not_to receive(:ems_inv_to_hashes)
end

# TODO: pending graph tag mapping implementation
include_examples "kubernetes refresher VCR tests", :check_tag_mapping => false
end
end

0 comments on commit 7ecb614

Please sign in to comment.