forked from ManageIQ/manageiq-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the local configuration script sources for embedded ansible
We stopped creating these in ManageIQ/manageiq#19056
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
db/migrate/20190726204302_remove_local_default_embedded_ansible_repos.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
57 changes: 57 additions & 0 deletions
57
spec/migrations/20190726204302_remove_local_default_embedded_ansible_repos_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |