Skip to content

Commit

Permalink
Remove the local configuration script sources for embedded ansible
Browse files Browse the repository at this point in the history
We stopped creating these in ManageIQ/manageiq#19056
  • Loading branch information
carbonin committed Aug 2, 2019
1 parent 7b756c5 commit b156ca9
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class RemoveLocalDefaultEmbeddedAnsibleRepos < ActiveRecord::Migration[5.1]
class ConfigurationScriptSource < ActiveRecord::Base
include ActiveRecord::IdRegions
self.inheritance_column = :_type_disabled # disable STI
end

class GitRepository < ActiveRecord::Base; end

CONFIGURATION_SCRIPT_TYPE = "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource".freeze

def up
css = ConfigurationScriptSource.in_my_region.where(:type => CONFIGURATION_SCRIPT_TYPE).where("scm_url LIKE ? OR scm_url = ?", "%/content/ansible_consolidated", "file:///var/lib/awx_consolidated_source")

GitRepository.where(:id => css.pluck(:git_repository_id).compact).delete_all
css.delete_all
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require_migration

describe RemoveLocalDefaultEmbeddedAnsibleRepos do
let(:configuration_script_source_stub) { migration_stub(:ConfigurationScriptSource) }
let(:git_repository_stub) { migration_stub(:GitRepository) }
let(:embedded_ansible_source_type) { "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource" }
let(:ansible_tower_source_type) { "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScriptSource" }

migration_context :up do
it "removes configuration script sources at /var/lib/awx_consolidated_source" do
source = configuration_script_source_stub.create!(
:type => embedded_ansible_source_type,
:scm_url => "file:///var/lib/awx_consolidated_source"
)

migrate

expect(configuration_script_source_stub.find_by(:id => source.id)).to be_nil
end

it "removes configuration script sources at /content/ansible_consolidated" do
source = configuration_script_source_stub.create!(
:type => embedded_ansible_source_type,
:scm_url => "file:///home/ncarboni/Source/manageiq/content/ansible_consolidated"
)

migrate

expect(configuration_script_source_stub.find_by(:id => source.id)).to be_nil
end

it "removes related git repositories" do
repo = git_repository_stub.create!(:url => "file:///home/ncarboni/Source/manageiq/content/ansible_consolidated")
source = configuration_script_source_stub.create!(
:type => embedded_ansible_source_type,
:scm_url => "file:///home/ncarboni/Source/manageiq/content/ansible_consolidated",
:git_repository_id => repo.id
)

migrate

expect(configuration_script_source_stub.find_by(:id => source.id)).to be_nil
expect(git_repository_stub.find_by(:id => repo.id)).to be_nil
end

it "doesn't remove sources for ansible tower" do
tower_source = configuration_script_source_stub.create!(
:type => ansible_tower_source_type,
:scm_url => "file:///home/ncarboni/Source/manageiq/content/ansible_consolidated"
)

migrate

expect(configuration_script_source_stub.find_by(:id => tower_source.id)).to_not be_nil
end
end
end

0 comments on commit b156ca9

Please sign in to comment.