Sha256: 703049f9416d87b8ea71d8f9cbdccf21205c94d880ce133e989845435433e9ee
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "when the database is replicated" do before(:each) do Octopus.stub!(:env).and_return("production_replicated") @proxy = Octopus::Proxy.new(Octopus.config()) clean_connection_proxy() end it "should have the replicated attribute as true" do @proxy.replicated.should be_true end it "should initialize the list of shards" do @proxy.instance_variable_get(:@slaves_list).should == ["slave1", "slave2", "slave3", "slave4"] end it "should send all writes/reads queries to master when you have a replicated model" do u = User.create!(:name => "Replicated") User.count.should == 1 User.find(u.id).should == u end it "should send read queries to slaves, when you have a replicated model, using a round robin algorithm" do u = Cat.create!(:name => "master") c = Client.create!(:name => "client_master") [:slave4, :slave1, :slave2, :slave3].each do |sym| Cat.using(sym).create!(:name => "Replicated_#{sym}") end Client.find(:first).should_not be_nil Cat.find(:first).name.should == "Replicated_slave1" Client.find(:first).should_not be_nil Cat.find(:first).name.should == "Replicated_slave2" Client.find(:first).should_not be_nil Cat.find(:first).name.should == "Replicated_slave3" Client.find(:first).should_not be_nil Cat.find(:first).name.should == "Replicated_slave4" Client.find(:first).should_not be_nil Cat.find(:first).name.should == "Replicated_slave1" Client.find(:first).should_not be_nil [:slave4, :slave1, :slave2, :slave3].each do |sym| Cat.using(sym).find_by_name("master").should be_false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ar-octopus-0.0.10 | spec/octopus/replication_specs.rb |
ar-octopus-0.0.9 | spec/octopus/replication_specs.rb |