switchman 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521655.235334: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521681.65534: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521664.86255: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521665.039567: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521654.980878: @value" :nil
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1402521681.713449: @value" :nil
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ module Switchman
4
+ module ActiveRecord
5
+ describe AbstractAdapter do
6
+ include RSpecHelper
7
+
8
+ it "should update the connection's last_query_at on query" do
9
+ conn = @shard1.activate{ User.connection }
10
+ Time.stubs(:now).returns(conn.last_query_at + 1.minute)
11
+ @shard1.activate{ User.create! }
12
+ conn.last_query_at.should == Time.now
13
+ end
14
+ end
15
+ end
16
+ end
@@ -18,6 +18,64 @@ module Switchman
18
18
  lambda { User.count }.should_not raise_exception
19
19
  end
20
20
  end
21
+
22
+ describe "clear_idle_connections!" do
23
+ before do
24
+ pending 'A "real" database"' unless Shard.default.database_server.shareable?
25
+ @server = DatabaseServer.create(:config => Shard.default.database_server.config.dup)
26
+ @shard = @server.shards.create!
27
+ @conn, @pool = @shard.activate{ [User.connection, User.connection_pool.current_pool] }
28
+ end
29
+
30
+ it "should disconnect idle connections" do
31
+ @pool.checkin(@conn)
32
+ @conn.expects(:disconnect!).once
33
+ @pool.clear_idle_connections!(@conn.last_query_at + 1)
34
+ end
35
+
36
+ it "should remove idle connections" do
37
+ @pool.checkin(@conn)
38
+ @pool.clear_idle_connections!(@conn.last_query_at + 1)
39
+ @pool.connections.should be_empty
40
+ end
41
+
42
+ it "should not affect idle but checked out connections" do
43
+ @conn.expects(:disconnect!).never
44
+ @pool.clear_idle_connections!(@conn.last_query_at + 1)
45
+ end
46
+
47
+ it "should not affect checked in but recently active connections" do
48
+ @pool.checkin(@conn)
49
+ @conn.expects(:disconnect!).never
50
+ @pool.clear_idle_connections!(@conn.last_query_at - 1)
51
+ end
52
+ end
53
+
54
+ describe "release_connection" do
55
+ before do
56
+ pending 'A "real" database"' unless Shard.default.database_server.shareable?
57
+ @server = DatabaseServer.create(:config => Shard.default.database_server.config.dup)
58
+ @shard = @server.shards.create!
59
+ @pool = @shard.activate{ User.connection_pool.current_pool }
60
+ @timeout_was = @pool.spec.config[:idle_timeout]
61
+ end
62
+
63
+ after do
64
+ @pool.spec.config[:idle_timeout] = @timeout_was
65
+ end
66
+
67
+ it "should clear idle connections if idle timeout is configured" do
68
+ @pool.spec.config[:idle_timeout] = 1.minute
69
+ @pool.expects(:clear_idle_connections!).at_least_once
70
+ @pool.release_connection
71
+ end
72
+
73
+ it "should still work if idle timeout is not configured" do
74
+ @pool.spec.config[:idle_timeout] = nil
75
+ @pool.expects(:clear_idle_connections!).never
76
+ lambda { @pool.release_connection }.should_not raise_exception
77
+ end
78
+ end
21
79
  end
22
80
  end
23
81
  end
@@ -11,5 +11,12 @@ module Switchman
11
11
  ::ActiveRecord::Base.connection.should_not == @sqlite_shard2.activate { ::ActiveRecord::Base.connection }
12
12
  @sqlite_shard1.activate { ::ActiveRecord::Base.connection }.should_not == @sqlite_shard2.activate { ::ActiveRecord::Base.connection }
13
13
  end
14
+
15
+ it "should forward clear_idle_connections! to each of its pools" do
16
+ proxy = User.connection_pool
17
+ @shard1.activate{ proxy.current_pool.expects(:clear_idle_connections!).once }
18
+ @shard2.activate{ proxy.current_pool.expects(:clear_idle_connections!).once }
19
+ proxy.clear_idle_connections!(Time.now)
20
+ end
14
21
  end
15
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switchman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-30 00:00:00.000000000 Z
13
+ date: 2014-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -204,6 +204,9 @@ files:
204
204
  - spec/dummy/db/migrate/20140219183820_create_roots.rb
205
205
  - spec/dummy/db/schema.rb
206
206
  - spec/dummy/db/shard_4377.sqlite3
207
+ - spec/dummy/db/shard_4521.sqlite3
208
+ - spec/dummy/db/shard_4549.sqlite3
209
+ - spec/dummy/db/shard_4573.sqlite3
207
210
  - spec/dummy/db/switchman_test.sqlite3
208
211
  - spec/dummy/log/development.log
209
212
  - spec/dummy/log/test.log
@@ -629,7 +632,9 @@ files:
629
632
  - spec/dummy/tmp/cache/37F/650/shard%2F2634
630
633
  - spec/dummy/tmp/cache/37F/660/shard%2F3372
631
634
  - spec/dummy/tmp/cache/37F/670/shard%2F4353
635
+ - spec/dummy/tmp/cache/37F/680/shard%2F4524
632
636
  - spec/dummy/tmp/cache/37F/690/shard%2F4290
637
+ - spec/dummy/tmp/cache/37F/6C0/shard%2F4560
633
638
  - spec/dummy/tmp/cache/380/5C0/shard%2F1168
634
639
  - spec/dummy/tmp/cache/380/5E0/shard%2F1429
635
640
  - spec/dummy/tmp/cache/380/5F0/shard%2F1195
@@ -720,6 +725,7 @@ files:
720
725
  - spec/dummy/tmp/cache/382/690/shard%2F1674
721
726
  - spec/dummy/tmp/cache/382/6A0/shard%2F1845
722
727
  - spec/dummy/tmp/cache/382/6A0/shard%2F2493
728
+ - spec/dummy/tmp/cache/382/6A0/shard%2F4518
723
729
  - spec/dummy/tmp/cache/382/6B0/shard%2F3636
724
730
  - spec/dummy/tmp/cache/382/6B0/shard%2F4284
725
731
  - spec/dummy/tmp/cache/382/6C0/shard%2F2592
@@ -745,9 +751,11 @@ files:
745
751
  - spec/dummy/tmp/cache/383/690/shard%2F4177
746
752
  - spec/dummy/tmp/cache/383/6A0/shard%2F2809
747
753
  - spec/dummy/tmp/cache/383/6A0/shard%2F3376
754
+ - spec/dummy/tmp/cache/383/6B0/shard%2F4519
748
755
  - spec/dummy/tmp/cache/383/6C0/shard%2F1774
749
756
  - spec/dummy/tmp/cache/383/6C0/shard%2F2746
750
757
  - spec/dummy/tmp/cache/383/6D0/shard%2F2755
758
+ - spec/dummy/tmp/cache/383/6D0/shard%2F4537
751
759
  - spec/dummy/tmp/cache/383/6E0/shard%2F2764
752
760
  - spec/dummy/tmp/cache/383/6F0/shard%2F3907
753
761
  - spec/dummy/tmp/cache/383/6F0/shard%2F4393
@@ -768,6 +776,7 @@ files:
768
776
  - spec/dummy/tmp/cache/384/6F0/shard%2F2765
769
777
  - spec/dummy/tmp/cache/384/700/shard%2F1883
770
778
  - spec/dummy/tmp/cache/384/700/shard%2F3827
779
+ - spec/dummy/tmp/cache/384/700/shard%2F4556
771
780
  - spec/dummy/tmp/cache/384/710/shard%2F1892
772
781
  - spec/dummy/tmp/cache/384/710/shard%2F2864
773
782
  - spec/dummy/tmp/cache/384/720/shard%2F2873
@@ -781,6 +790,7 @@ files:
781
790
  - spec/dummy/tmp/cache/385/6F0/shard%2F2595
782
791
  - spec/dummy/tmp/cache/385/710/shard%2F2694
783
792
  - spec/dummy/tmp/cache/385/710/shard%2F3828
793
+ - spec/dummy/tmp/cache/385/710/shard%2F4557
784
794
  - spec/dummy/tmp/cache/386/690/shard%2F1399
785
795
  - spec/dummy/tmp/cache/386/6B0/shard%2F3199
786
796
  - spec/dummy/tmp/cache/386/6C0/shard%2F2479
@@ -909,6 +919,7 @@ files:
909
919
  - spec/dummy/tmp/cache/3B1/0E0/shard%2F13472
910
920
  - spec/dummy/tmp/cache/3B1/0F0/shard%2F12833
911
921
  - spec/dummy/tmp/cache/3B1/0F0/shard%2F14291
922
+ - spec/dummy/tmp/cache/3B1/0F0/shard%2F14534
912
923
  - spec/dummy/tmp/cache/3B2/000/shard%2F10179
913
924
  - spec/dummy/tmp/cache/3B2/050/shard%2F10386
914
925
  - spec/dummy/tmp/cache/3B2/060/shard%2F13149
@@ -932,6 +943,7 @@ files:
932
943
  - spec/dummy/tmp/cache/3B4/0B0/shard%2F11558
933
944
  - spec/dummy/tmp/cache/3B4/0E0/shard%2F10775
934
945
  - spec/dummy/tmp/cache/3B4/0E0/shard%2F12719
946
+ - spec/dummy/tmp/cache/3B4/100/shard%2F14519
935
947
  - spec/dummy/tmp/cache/3B4/110/shard%2F13394
936
948
  - spec/dummy/tmp/cache/3B4/130/shard%2F11873
937
949
  - spec/dummy/tmp/cache/3B4/160/shard%2F11981
@@ -950,6 +962,7 @@ files:
950
962
  - spec/dummy/tmp/cache/3B6/120/shard%2F11686
951
963
  - spec/dummy/tmp/cache/3B6/150/shard%2F12685
952
964
  - spec/dummy/tmp/cache/3B6/160/shard%2F13828
965
+ - spec/dummy/tmp/cache/3B6/160/shard%2F14557
953
966
  - spec/dummy/tmp/cache/3B7/100/shard%2F10688
954
967
  - spec/dummy/tmp/cache/3B7/110/shard%2F11669
955
968
  - spec/dummy/tmp/cache/3B7/140/shard%2F12668
@@ -1093,6 +1106,7 @@ files:
1093
1106
  - spec/dummy/tmp/cache/52E/CC0/shard_1898%3Akey
1094
1107
  - spec/dummy/tmp/cache/52F/D30/shard_1899%3Akey
1095
1108
  - spec/lib/action_controller/caching_spec.rb
1109
+ - spec/lib/active_record/abstract_adapter_spec.rb
1096
1110
  - spec/lib/active_record/association_spec.rb
1097
1111
  - spec/lib/active_record/attribute_methods_spec.rb
1098
1112
  - spec/lib/active_record/base_spec.rb
@@ -1132,7 +1146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1132
1146
  version: '0'
1133
1147
  requirements: []
1134
1148
  rubyforge_project:
1135
- rubygems_version: 2.2.0
1149
+ rubygems_version: 2.3.0
1136
1150
  signing_key:
1137
1151
  specification_version: 4
1138
1152
  summary: Rails 3 sharding magic
@@ -1166,6 +1180,9 @@ test_files:
1166
1180
  - spec/dummy/db/migrate/20140219183820_create_roots.rb
1167
1181
  - spec/dummy/db/schema.rb
1168
1182
  - spec/dummy/db/shard_4377.sqlite3
1183
+ - spec/dummy/db/shard_4521.sqlite3
1184
+ - spec/dummy/db/shard_4549.sqlite3
1185
+ - spec/dummy/db/shard_4573.sqlite3
1169
1186
  - spec/dummy/db/switchman_test.sqlite3
1170
1187
  - spec/dummy/log/development.log
1171
1188
  - spec/dummy/log/test.log
@@ -1592,7 +1609,9 @@ test_files:
1592
1609
  - spec/dummy/tmp/cache/37F/650/shard%2F2634
1593
1610
  - spec/dummy/tmp/cache/37F/660/shard%2F3372
1594
1611
  - spec/dummy/tmp/cache/37F/670/shard%2F4353
1612
+ - spec/dummy/tmp/cache/37F/680/shard%2F4524
1595
1613
  - spec/dummy/tmp/cache/37F/690/shard%2F4290
1614
+ - spec/dummy/tmp/cache/37F/6C0/shard%2F4560
1596
1615
  - spec/dummy/tmp/cache/380/5C0/shard%2F1168
1597
1616
  - spec/dummy/tmp/cache/380/5E0/shard%2F1429
1598
1617
  - spec/dummy/tmp/cache/380/5F0/shard%2F1195
@@ -1683,6 +1702,7 @@ test_files:
1683
1702
  - spec/dummy/tmp/cache/382/690/shard%2F1674
1684
1703
  - spec/dummy/tmp/cache/382/6A0/shard%2F1845
1685
1704
  - spec/dummy/tmp/cache/382/6A0/shard%2F2493
1705
+ - spec/dummy/tmp/cache/382/6A0/shard%2F4518
1686
1706
  - spec/dummy/tmp/cache/382/6B0/shard%2F3636
1687
1707
  - spec/dummy/tmp/cache/382/6B0/shard%2F4284
1688
1708
  - spec/dummy/tmp/cache/382/6C0/shard%2F2592
@@ -1708,9 +1728,11 @@ test_files:
1708
1728
  - spec/dummy/tmp/cache/383/690/shard%2F4177
1709
1729
  - spec/dummy/tmp/cache/383/6A0/shard%2F2809
1710
1730
  - spec/dummy/tmp/cache/383/6A0/shard%2F3376
1731
+ - spec/dummy/tmp/cache/383/6B0/shard%2F4519
1711
1732
  - spec/dummy/tmp/cache/383/6C0/shard%2F1774
1712
1733
  - spec/dummy/tmp/cache/383/6C0/shard%2F2746
1713
1734
  - spec/dummy/tmp/cache/383/6D0/shard%2F2755
1735
+ - spec/dummy/tmp/cache/383/6D0/shard%2F4537
1714
1736
  - spec/dummy/tmp/cache/383/6E0/shard%2F2764
1715
1737
  - spec/dummy/tmp/cache/383/6F0/shard%2F3907
1716
1738
  - spec/dummy/tmp/cache/383/6F0/shard%2F4393
@@ -1731,6 +1753,7 @@ test_files:
1731
1753
  - spec/dummy/tmp/cache/384/6F0/shard%2F2765
1732
1754
  - spec/dummy/tmp/cache/384/700/shard%2F1883
1733
1755
  - spec/dummy/tmp/cache/384/700/shard%2F3827
1756
+ - spec/dummy/tmp/cache/384/700/shard%2F4556
1734
1757
  - spec/dummy/tmp/cache/384/710/shard%2F1892
1735
1758
  - spec/dummy/tmp/cache/384/710/shard%2F2864
1736
1759
  - spec/dummy/tmp/cache/384/720/shard%2F2873
@@ -1744,6 +1767,7 @@ test_files:
1744
1767
  - spec/dummy/tmp/cache/385/6F0/shard%2F2595
1745
1768
  - spec/dummy/tmp/cache/385/710/shard%2F2694
1746
1769
  - spec/dummy/tmp/cache/385/710/shard%2F3828
1770
+ - spec/dummy/tmp/cache/385/710/shard%2F4557
1747
1771
  - spec/dummy/tmp/cache/386/690/shard%2F1399
1748
1772
  - spec/dummy/tmp/cache/386/6B0/shard%2F3199
1749
1773
  - spec/dummy/tmp/cache/386/6C0/shard%2F2479
@@ -1872,6 +1896,7 @@ test_files:
1872
1896
  - spec/dummy/tmp/cache/3B1/0E0/shard%2F13472
1873
1897
  - spec/dummy/tmp/cache/3B1/0F0/shard%2F12833
1874
1898
  - spec/dummy/tmp/cache/3B1/0F0/shard%2F14291
1899
+ - spec/dummy/tmp/cache/3B1/0F0/shard%2F14534
1875
1900
  - spec/dummy/tmp/cache/3B2/000/shard%2F10179
1876
1901
  - spec/dummy/tmp/cache/3B2/050/shard%2F10386
1877
1902
  - spec/dummy/tmp/cache/3B2/060/shard%2F13149
@@ -1895,6 +1920,7 @@ test_files:
1895
1920
  - spec/dummy/tmp/cache/3B4/0B0/shard%2F11558
1896
1921
  - spec/dummy/tmp/cache/3B4/0E0/shard%2F10775
1897
1922
  - spec/dummy/tmp/cache/3B4/0E0/shard%2F12719
1923
+ - spec/dummy/tmp/cache/3B4/100/shard%2F14519
1898
1924
  - spec/dummy/tmp/cache/3B4/110/shard%2F13394
1899
1925
  - spec/dummy/tmp/cache/3B4/130/shard%2F11873
1900
1926
  - spec/dummy/tmp/cache/3B4/160/shard%2F11981
@@ -1913,6 +1939,7 @@ test_files:
1913
1939
  - spec/dummy/tmp/cache/3B6/120/shard%2F11686
1914
1940
  - spec/dummy/tmp/cache/3B6/150/shard%2F12685
1915
1941
  - spec/dummy/tmp/cache/3B6/160/shard%2F13828
1942
+ - spec/dummy/tmp/cache/3B6/160/shard%2F14557
1916
1943
  - spec/dummy/tmp/cache/3B7/100/shard%2F10688
1917
1944
  - spec/dummy/tmp/cache/3B7/110/shard%2F11669
1918
1945
  - spec/dummy/tmp/cache/3B7/140/shard%2F12668
@@ -2056,6 +2083,7 @@ test_files:
2056
2083
  - spec/dummy/tmp/cache/52E/CC0/shard_1898%3Akey
2057
2084
  - spec/dummy/tmp/cache/52F/D30/shard_1899%3Akey
2058
2085
  - spec/lib/action_controller/caching_spec.rb
2086
+ - spec/lib/active_record/abstract_adapter_spec.rb
2059
2087
  - spec/lib/active_record/association_spec.rb
2060
2088
  - spec/lib/active_record/attribute_methods_spec.rb
2061
2089
  - spec/lib/active_record/base_spec.rb