Skip to content

Commit

Permalink
Merge pull request #16488 from carbonin/remove_replication_column_ord…
Browse files Browse the repository at this point in the history
…er_checks

Remove the column reordering tool and the schema structure validations
(cherry picked from commit 5deab50)
  • Loading branch information
Fryguy authored and simaishi committed Nov 17, 2017
1 parent 1fed527 commit 8257658
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 1,095 deletions.
12 changes: 0 additions & 12 deletions app/models/pglogical_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def self.find_by_id(to_find)

def save!
assert_different_region!
assert_valid_schemas!
id ? update_subscription : create_subscription
end

Expand Down Expand Up @@ -79,7 +78,6 @@ def disable
end

def enable
assert_valid_schemas!
pglogical.subscription_enable(id).check
end

Expand Down Expand Up @@ -220,16 +218,6 @@ def create_subscription
self
end

def assert_valid_schemas!
local_errors = ManageIQ::Schema::Checker.check_schema
raise local_errors if local_errors
find_password if password.nil?
with_remote_connection do |conn|
remote_errors = ManageIQ::Schema::Checker.check_schema(conn)
raise remote_errors if remote_errors
end
end

def assert_different_region!
if MiqRegionRemote.region_number_from_sequence == remote_region_number
raise "Subscriptions cannot be created to the same region as the current region"
Expand Down
35 changes: 0 additions & 35 deletions spec/models/pglogical_subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,35 +167,7 @@
end
end

def with_valid_schemas
allow(ManageIQ::Schema::Checker).to receive(:check_schema).and_return(nil)
end

def with_an_invalid_local_schema
allow(ManageIQ::Schema::Checker).to receive(:check_schema).with(no_args).and_return("Different local schema")
end

def with_an_invalid_remote_schema
connection = double(:connection)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(connection)
allow(ManageIQ::Schema::Checker).to receive(:check_schema).and_return(nil, "Different remote schema")
end

describe "#save!" do
it "raises when the local schema is invalid" do
with_an_invalid_local_schema
sub = described_class.new(:host => "some.host.example.com")
allow(sub).to receive(:assert_different_region!)
expect { sub.save! }.to raise_error(RuntimeError, "Different local schema")
end

it "raises when the remote schema is invalid" do
with_an_invalid_remote_schema
sub = described_class.new(:host => "some.host.example.com", :password => "1234")
allow(sub).to receive(:assert_different_region!)
expect { sub.save! }.to raise_error(RuntimeError, "Different remote schema")
end

it "raises when subscribing to the same region" do
allow(pglogical).to receive(:subscriptions).and_return([])
allow(pglogical).to receive(:enabled?).and_return(true)
Expand All @@ -212,7 +184,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:subscription_show_status).and_return(subscriptions.first)
allow(pglogical).to receive(:subscription_create).and_return(double(:check => nil))
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
with_valid_schemas

sub = described_class.new(:host => "test-2.example.com", :user => "root", :password => "1234")
allow(sub).to receive(:remote_region_number).and_return(remote_region1)
Expand All @@ -226,7 +197,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
allow(MiqRegionRemote).to receive(:region_number_from_sequence).and_return(2)
with_valid_schemas

# node created if we are not already a node
expect(MiqPglogical).to receive(:new).and_return(double(:node? => false))
Expand All @@ -253,7 +223,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
allow(MiqRegionRemote).to receive(:region_number_from_sequence).and_return(2)
with_valid_schemas

# node not created if we are already a node
expect(MiqPglogical).to receive(:new).and_return(double(:node? => true))
Expand Down Expand Up @@ -281,7 +250,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(pglogical).to receive(:subscription_show_status).and_return(subscriptions.first)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
with_valid_schemas

sub = described_class.find(:first)
sub.host = "other-host.example.com"
Expand All @@ -307,7 +275,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(pglogical).to receive(:subscription_show_status).and_return(subscriptions.first)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
with_valid_schemas

sub = described_class.find(:first)
sub.host = "other-host.example.com"
Expand All @@ -329,7 +296,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
allow(MiqRegionRemote).to receive(:region_number_from_sequence).and_return(2, 2, 3, 3)
with_valid_schemas

# node created
allow(pglogical).to receive(:enable)
Expand Down Expand Up @@ -365,7 +331,6 @@ def with_an_invalid_remote_schema
allow(pglogical).to receive(:enabled?).and_return(true)
allow(MiqRegionRemote).to receive(:with_remote_connection).and_yield(double(:connection))
allow(MiqRegionRemote).to receive(:region_number_from_sequence).and_return(2, 2, 3, 3, 4, 4)
with_valid_schemas

# node created
allow(pglogical).to receive(:enable)
Expand Down
112 changes: 0 additions & 112 deletions spec/tools/column_ordering/column_ordering_spec.rb

This file was deleted.

153 changes: 0 additions & 153 deletions spec/tools/column_ordering/data/metrics_04.sql

This file was deleted.

Loading

0 comments on commit 8257658

Please sign in to comment.