switchman 1.2.10 → 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/switchman/shard.rb +2 -2
- data/lib/switchman/active_record/connection_handler.rb +18 -9
- data/lib/switchman/active_record/connection_pool.rb +3 -0
- data/lib/switchman/active_record/query_cache.rb +6 -1
- data/lib/switchman/active_record/query_methods.rb +1 -1
- data/lib/switchman/connection_pool_proxy.rb +1 -1
- data/lib/switchman/r_spec_helper.rb +73 -61
- data/lib/switchman/test_helper.rb +8 -2
- data/lib/switchman/version.rb +1 -1
- data/lib/tasks/switchman.rake +5 -0
- data/spec/dummy/config/database.yml +2 -4
- data/spec/dummy/config/environments/development.rb +0 -4
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +12 -12
- data/spec/dummy/db/shard_120.sqlite3 +0 -0
- data/spec/dummy/db/shard_156.sqlite3 +0 -0
- data/spec/dummy/db/shard_193.sqlite3 +0 -0
- data/spec/dummy/db/shard_23.sqlite3 +0 -0
- data/spec/dummy/db/shard_234.sqlite3 +0 -0
- data/spec/dummy/db/shard_257.sqlite3 +0 -0
- data/spec/dummy/db/shard_277.sqlite3 +0 -0
- data/spec/dummy/db/shard_311.sqlite3 +0 -0
- data/spec/dummy/db/shard_324.sqlite3 +0 -0
- data/spec/dummy/db/shard_342.sqlite3 +0 -0
- data/spec/dummy/db/shard_375.sqlite3 +0 -0
- data/spec/dummy/db/shard_389.sqlite3 +0 -0
- data/spec/dummy/db/shard_428.sqlite3 +0 -0
- data/spec/dummy/db/shard_452.sqlite3 +0 -0
- data/spec/dummy/db/shard_462.sqlite3 +0 -0
- data/spec/dummy/db/shard_483.sqlite3 +0 -0
- data/spec/dummy/db/shard_508.sqlite3 +0 -0
- data/spec/dummy/db/shard_531.sqlite3 +0 -0
- data/spec/dummy/db/shard_554.sqlite3 +0 -0
- data/spec/dummy/db/shard_577.sqlite3 +0 -0
- data/spec/dummy/db/shard_58.sqlite3 +0 -0
- data/spec/dummy/db/shard_600.sqlite3 +0 -0
- data/spec/dummy/db/shard_623.sqlite3 +0 -0
- data/spec/dummy/db/shard_646.sqlite3 +0 -0
- data/spec/dummy/db/shard_668.sqlite3 +0 -0
- data/spec/dummy/db/shard_680.sqlite3 +0 -0
- data/spec/dummy/db/shard_708.sqlite3 +0 -0
- data/spec/dummy/db/shard_735.sqlite3 +0 -0
- data/spec/dummy/db/shard_753.sqlite3 +0 -0
- data/spec/dummy/db/shard_76.sqlite3 +0 -0
- data/spec/dummy/db/shard_802.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +7 -0
- data/spec/dummy/log/test.log +106293 -0
- data/spec/dummy/tmp/cache/313/970/shard%2F30 +1 -0
- data/spec/dummy/tmp/cache/316/980/shard%2F15 +1 -0
- data/spec/dummy/tmp/cache/317/9D0/shard%2F52 +1 -0
- data/spec/dummy/tmp/cache/31C/A40/shard%2F75 +1 -0
- data/spec/dummy/tmp/cache/345/E00/shard%2F500 +1 -0
- data/spec/dummy/tmp/cache/346/DF0/shard%2F321 +1 -0
- data/spec/dummy/tmp/cache/349/DE0/shard%2F126 +1 -0
- data/spec/dummy/tmp/cache/349/E10/shard%2F153 +0 -0
- data/spec/dummy/tmp/cache/349/E20/shard%2F243 +1 -0
- data/spec/dummy/tmp/cache/34A/E20/shard%2F154 +0 -0
- data/spec/dummy/tmp/cache/34A/E40/shard%2F172 +1 -0
- data/spec/dummy/tmp/cache/34A/E70/shard%2F523 +1 -0
- data/spec/dummy/tmp/cache/34A/EB0/shard%2F721 +1 -0
- data/spec/dummy/tmp/cache/34A/EC0/shard%2F730 +1 -0
- data/spec/dummy/tmp/cache/34B/E40/shard%2F245 +0 -0
- data/spec/dummy/tmp/cache/34B/E60/shard%2F425 +1 -0
- data/spec/dummy/tmp/cache/34B/EC0/shard%2F722 +1 -0
- data/spec/dummy/tmp/cache/34C/E50/shard%2F246 +0 -0
- data/spec/dummy/tmp/cache/34C/E80/shard%2F273 +1 -0
- data/spec/dummy/tmp/cache/34C/E90/shard%2F363 +0 -0
- data/spec/dummy/tmp/cache/34C/E90/shard%2F444 +1 -0
- data/spec/dummy/tmp/cache/34C/EA0/shard%2F615 +1 -0
- data/spec/dummy/tmp/cache/34C/F00/shard%2F750 +1 -0
- data/spec/dummy/tmp/cache/34D/E80/shard%2F265 +1 -0
- data/spec/dummy/tmp/cache/34D/ED0/shard%2F391 +1 -0
- data/spec/dummy/tmp/cache/34D/EE0/shard%2F724 +1 -0
- data/spec/dummy/tmp/cache/34E/ED0/shard%2F383 +1 -0
- data/spec/dummy/tmp/cache/34E/EF0/shard%2F725 +1 -0
- data/spec/dummy/tmp/cache/34E/F00/shard%2F653 +1 -0
- data/spec/dummy/tmp/cache/34F/EE0/shard%2F546 +1 -0
- data/spec/dummy/tmp/cache/34F/F00/shard%2F807 +1 -0
- data/spec/dummy/tmp/cache/34F/F30/shard%2F672 +1 -0
- data/spec/dummy/tmp/cache/350/EA0/shard%2F178 +1 -0
- data/spec/dummy/tmp/cache/350/EB0/shard%2F349 +1 -0
- data/spec/dummy/tmp/cache/350/F00/shard%2F718 +0 -0
- data/spec/dummy/tmp/cache/350/F40/shard%2F592 +1 -0
- data/spec/dummy/tmp/cache/351/F00/shard%2F386 +0 -0
- data/spec/dummy/tmp/cache/351/F10/shard%2F638 +1 -0
- data/spec/dummy/tmp/cache/351/F10/shard%2F719 +0 -0
- data/spec/dummy/tmp/cache/352/F10/shard%2F387 +0 -0
- data/spec/dummy/tmp/cache/352/F10/shard%2F468 +1 -0
- data/spec/dummy/tmp/cache/352/F30/shard%2F729 +1 -0
- data/spec/dummy/tmp/cache/353/F10/shard%2F298 +1 -0
- data/spec/dummy/tmp/cache/353/F50/shard%2F739 +1 -0
- data/spec/dummy/tmp/cache/354/F50/shard%2F569 +1 -0
- data/spec/dummy/tmp/cache/354/F80/shard%2F677 +1 -0
- data/spec/dummy/tmp/cache/354/F90/shard%2F767 +1 -0
- data/spec/dummy/tmp/cache/358/FE0/shard%2F699 +1 -0
- data/spec/dummy/tmp/cache/3A5/EA0/shard%2F10004 +1 -0
- data/spec/dummy/tmp/cache/3A6/F40/shard%2F10410 +1 -0
- data/spec/dummy/tmp/cache/3A7/F30/shard%2F10231 +1 -0
- data/spec/dummy/tmp/cache/3A8/F90/shard%2F10520 +1 -0
- data/spec/dummy/tmp/cache/3A9/F40/shard%2F10062 +1 -0
- data/spec/dummy/tmp/cache/3A9/F80/shard%2F10341 +1 -0
- data/spec/dummy/tmp/cache/3AA/F10/shard%2F10027 +1 -0
- data/spec/dummy/tmp/cache/3AA/F10/shard%2F10108 +1 -0
- data/spec/dummy/tmp/cache/3AA/FB0/shard%2F10441 +1 -0
- data/spec/dummy/tmp/cache/3AA/FC0/shard%2F10612 +1 -0
- data/spec/dummy/tmp/cache/3AB/010/shard%2F10730 +1 -0
- data/spec/dummy/tmp/cache/3AB/F70/shard%2F10154 +1 -0
- data/spec/dummy/tmp/cache/3AC/020/shard%2F10650 +1 -0
- data/spec/dummy/tmp/cache/3AC/FC0/shard%2F10272 +1 -0
- data/spec/dummy/tmp/cache/3AD/000/shard%2F10543 +1 -0
- data/spec/dummy/tmp/cache/3AD/F50/shard%2F10039 +1 -0
- data/spec/dummy/tmp/cache/3AD/F90/shard%2F10318 +1 -0
- data/spec/dummy/tmp/cache/3AD/FA0/shard%2F10246 +1 -0
- data/spec/dummy/tmp/cache/3AE/060/shard%2F10751 +1 -0
- data/spec/dummy/tmp/cache/3AE/FF0/shard%2F10364 +1 -0
- data/spec/dummy/tmp/cache/3AF/030/shard%2F10635 +1 -0
- data/spec/dummy/tmp/cache/3B0/FE0/shard%2F10177 +1 -0
- data/spec/dummy/tmp/cache/3B1/030/shard%2F10295 +1 -0
- data/spec/dummy/tmp/cache/3B1/040/shard%2F10466 +1 -0
- data/spec/dummy/tmp/cache/3B1/090/shard%2F10673 +1 -0
- data/spec/dummy/tmp/cache/3B2/070/shard%2F10566 +1 -0
- data/spec/dummy/tmp/cache/3B3/060/shard%2F10387 +1 -0
- data/spec/dummy/tmp/cache/3B5/0B0/shard%2F10497 +1 -0
- data/spec/dummy/tmp/cache/3B6/100/shard%2F10696 +1 -0
- data/spec/dummy/tmp/cache/3B7/0E0/shard%2F10589 +1 -0
- data/spec/dummy/tmp/cache/3BA/160/shard%2F10799 +1 -0
- data/spec/lib/action_controller/caching_spec.rb +4 -4
- data/spec/lib/active_record/abstract_adapter_spec.rb +1 -1
- data/spec/lib/active_record/association_spec.rb +83 -67
- data/spec/lib/active_record/attribute_methods_spec.rb +29 -29
- data/spec/lib/active_record/base_spec.rb +20 -20
- data/spec/lib/active_record/calculations_spec.rb +79 -59
- data/spec/lib/active_record/connection_handler_spec.rb +14 -14
- data/spec/lib/active_record/connection_pool_spec.rb +7 -7
- data/spec/lib/active_record/finder_methods_spec.rb +8 -8
- data/spec/lib/active_record/query_cache_spec.rb +38 -38
- data/spec/lib/active_record/query_methods_spec.rb +45 -45
- data/spec/lib/active_record/relation_spec.rb +8 -8
- data/spec/lib/active_record/spawn_methods_spec.rb +11 -11
- data/spec/lib/connection_pool_proxy_spec.rb +2 -2
- data/spec/lib/database_server_spec.rb +37 -37
- data/spec/lib/default_shard_spec.rb +3 -3
- data/spec/lib/r_spec_helper_spec.rb +33 -7
- data/spec/lib/rails_spec.rb +5 -5
- data/spec/lib/shackles_spec.rb +35 -35
- data/spec/models/shard_spec.rb +104 -104
- data/spec/spec_helper.rb +1 -1
- metadata +254 -29
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709172.785986:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405708977.5977442:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709563.027033:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709625.1911669:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056316.0856729:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054473.924482:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710273.4462678:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710688.486557:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710383.000582:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056335.05036:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_721;TI"database_server_id;TI" test;TI"default;TF:@created_atf1406058474.6726232:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_730;TI"database_server_id;TI"2;TI"default;TF:@created_atf1406062223.73001:@expires_in0
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056240.450111:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_722;TI"database_server_id;TI"1;TI"default;TF:@created_atf1406058475.311327:@expires_in0
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054155.994775:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056246.029251:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056444.206968:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_750;TI"database_server_id;TI" test;TI"default;TF:@created_atf1406062293.398787:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710918.94204:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056233.44187:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_724;TI"database_server_id;TI" test;TI"default;TF:@created_atf1406058508.056969:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056187.420893:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_725;TI"database_server_id;TI"1;TI"default;TF:@created_atf1406058508.1540139:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406057669.3963132:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056374.8069131:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406063237.6105049:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_672;TI"database_server_id;TI" test;TI"default;TF:@created_atf1406057695.824834:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710424.571912:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056002.214963:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056439.333903:@value":nil
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056449.031681:@value":nil
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056287.720922:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value{ I"id:ETi�I" name;TI"switchman_test_shard_729;TI"database_server_id;TI" test;TI"default;TF:@created_atf1406062223.7280169:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054467.519041:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406062223.446721:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056419.763446:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406057694.251876:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406062291.6416168:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406057711.1559649:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405708977.399206:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056240.6011572:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710688.293992:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056335.088819:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709625.038962:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056002.0330062:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709172.5864232:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710273.410322:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056246.067667:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056444.249256:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406062223.318319:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710383.047894:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406057669.4699311:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054156.148363:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056374.8466759:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405709562.825376:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054473.961097:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710918.851407:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406062291.6871822:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056187.366626:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056449.071837:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1405710424.610155:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406054467.704592:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056287.545137:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406057694.149458:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056419.803245:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056233.548882:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056316.127557:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406057710.8676522:@expires_in0
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1406056439.374727:@value":nil
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@value:nil:@created_atf1406063237.677971:@expires_in0
|
@@ -20,13 +20,13 @@ module Switchman
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should share the cache across shards on the same server" do
|
23
|
-
@shard1.activate{ subject.cache_store }.
|
24
|
-
|
23
|
+
expect(@shard1.activate{ subject.cache_store }).
|
24
|
+
to eq @shard3.activate{ subject.cache_store }
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should not share the cache across shards on different servers" do
|
28
|
-
@shard1.activate{ subject.cache_store }.
|
29
|
-
|
28
|
+
expect(@shard1.activate{ subject.cache_store }).
|
29
|
+
not_to eq @shard2.activate{ subject.cache_store }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -9,7 +9,7 @@ module Switchman
|
|
9
9
|
conn = @shard1.activate{ User.connection }
|
10
10
|
Time.stubs(:now).returns(conn.last_query_at + 1.minute)
|
11
11
|
@shard1.activate{ User.create! }
|
12
|
-
conn.last_query_at.
|
12
|
+
expect(conn.last_query_at).to eq Time.now
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -16,34 +16,34 @@ module Switchman
|
|
16
16
|
|
17
17
|
it "should associate built objects with parent shard" do
|
18
18
|
a1 = @user1.appendages.build
|
19
|
-
a1.shard.
|
19
|
+
expect(a1.shard).to eq @shard1
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should associate created objects with parent shard" do
|
23
23
|
a1 = @user1.appendages.create!
|
24
|
-
a1.shard.
|
24
|
+
expect(a1.shard).to eq @shard1
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should set shard value to parent for association scope" do
|
28
28
|
scope = @user1.appendages
|
29
29
|
scope = ::Rails.version < '4' ? scope.scoped : scope.scope
|
30
|
-
scope.shard_value.
|
31
|
-
scope.shard_source_value.
|
30
|
+
expect(scope.shard_value).to eq @user1
|
31
|
+
expect(scope.shard_source_value).to eq :association
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should find by id through association" do
|
35
35
|
a1 = @user1.appendages.create!
|
36
36
|
|
37
|
-
@user1.appendages.find(a1.id).
|
38
|
-
|
37
|
+
expect(@user1.appendages.find(a1.id)).to eq a1
|
38
|
+
expect { @user2.appendages.find(a1.id) }.to raise_exception(::ActiveRecord::RecordNotFound)
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "transaction" do
|
42
42
|
it "should activate the owner's shard and start the transaction on that shard" do
|
43
43
|
base_value = @user1.shard.activate { User.connection.open_transactions }
|
44
44
|
@user1.appendages.transaction(:requires_new => true) do
|
45
|
-
Shard.current.
|
46
|
-
User.connection.open_transactions.
|
45
|
+
expect(Shard.current).to eq @shard1
|
46
|
+
expect(User.connection.open_transactions).to eq base_value + 1
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -51,42 +51,58 @@ module Switchman
|
|
51
51
|
it "should get the record size" do
|
52
52
|
a1 = @user1.appendages.create!
|
53
53
|
a2 = @user1.appendages.build
|
54
|
-
@user1.appendages.size.
|
54
|
+
expect(@user1.appendages.size).to eq 2
|
55
55
|
@user1.reload
|
56
|
-
@user1.appendages.size.
|
56
|
+
expect(@user1.appendages.size).to eq 1
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should reverse the association" do
|
60
60
|
a1 = @user1.appendages.create!
|
61
61
|
a1.reload
|
62
|
-
a1.user.shard.
|
63
|
-
a1.user.
|
62
|
+
expect(a1.user.shard).to eq @shard1
|
63
|
+
expect(a1.user).to eq @user1
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should work with has_many through associations" do
|
67
67
|
a1 = @user1.appendages.create!
|
68
68
|
d1 = a1.digits.create!
|
69
|
-
d1.shard.
|
69
|
+
expect(d1.shard).to eq @shard1
|
70
70
|
|
71
71
|
if ::Rails.version < '4'
|
72
|
-
@user1.digits.scoped.shard_value.
|
72
|
+
expect(@user1.digits.scoped.shard_value).to eq @user1
|
73
73
|
else
|
74
|
-
@user1.digits.scope.shard_value.
|
74
|
+
expect(@user1.digits.scope.shard_value).to eq @user1
|
75
|
+
end
|
76
|
+
expect(@user1.digits.find(d1.id)).to eq d1
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should resolve include? correctly for a has_many :through" do
|
80
|
+
@shard1.activate do
|
81
|
+
child = @user1.children.create!
|
82
|
+
@grandchild = child.children.create!
|
83
|
+
@user1.reload
|
84
|
+
expect(@user1.grandchildren.loaded?).to eq false
|
85
|
+
expect(@user1.grandchildren.include?(@grandchild)).to eq true
|
86
|
+
end
|
87
|
+
@shard2.activate do
|
88
|
+
fake = User.create!(id: @grandchild.local_id)
|
89
|
+
@user1.reload
|
90
|
+
expect(@user1.grandchildren.loaded?).to eq false
|
91
|
+
expect(@user1.grandchildren.include?(fake)).to eq false
|
75
92
|
end
|
76
|
-
@user1.digits.find(d1.id).should == d1
|
77
93
|
end
|
78
94
|
|
79
95
|
it "shard should be changeable, and change conditions when it is changed" do
|
80
96
|
a1 = @user1.appendages.create!
|
81
97
|
relation = @user1.appendages.where(:id => a1).shard(@shard1)
|
82
|
-
relation.shard_value.
|
83
|
-
relation.shard_source_value.
|
84
|
-
relation.where_values.detect{|v| v.left.name == "id"}.right.
|
98
|
+
expect(relation.shard_value).to eq @shard1
|
99
|
+
expect(relation.shard_source_value).to eq :explicit
|
100
|
+
expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a1.local_id
|
85
101
|
|
86
102
|
relation = @user1.appendages.where(:id => a1).shard(@shard2)
|
87
|
-
relation.shard_value.
|
88
|
-
relation.shard_source_value.
|
89
|
-
relation.where_values.detect{|v| v.left.name == "id"}.right.
|
103
|
+
expect(relation.shard_value).to eq @shard2
|
104
|
+
expect(relation.shard_source_value).to eq :explicit
|
105
|
+
expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a1.global_id
|
90
106
|
end
|
91
107
|
|
92
108
|
it "should transpose predicates correctly" do
|
@@ -94,12 +110,12 @@ module Switchman
|
|
94
110
|
a2 = @user2.appendages.create!
|
95
111
|
|
96
112
|
relation = @user1.appendages.where(:id => a2)
|
97
|
-
relation.shard_value.
|
98
|
-
relation.where_values.detect{|v| v.left.name == "id"}.right.
|
113
|
+
expect(relation.shard_value).to eq @user1
|
114
|
+
expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq a2.global_id
|
99
115
|
|
100
116
|
relation = @user1.appendages.where(:id => [a1, a2])
|
101
|
-
relation.shard_value.
|
102
|
-
relation.where_values.detect{|v| v.left.name == "id"}.right.
|
117
|
+
expect(relation.shard_value).to eq @user1
|
118
|
+
expect(relation.where_values.detect{|v| v.left.name == "id"}.right).to eq [a1.local_id, a2.global_id]
|
103
119
|
end
|
104
120
|
|
105
121
|
it "should properly set up a cross-shard-category query" do
|
@@ -107,12 +123,12 @@ module Switchman
|
|
107
123
|
mirror_user = MirrorUser.create!
|
108
124
|
relation = mirror_user.association(:user)
|
109
125
|
relation = ::Rails.version < '4' ? relation.scoped : relation.scope
|
110
|
-
relation.shard_value.
|
126
|
+
expect(relation.shard_value).to eq Shard.default
|
111
127
|
if ::Rails.version < '4'
|
112
|
-
relation.where_values.first.right.
|
128
|
+
expect(relation.where_values.first.right).to eq mirror_user.global_id
|
113
129
|
else
|
114
|
-
relation.where_values.first.right.
|
115
|
-
relation.bind_values.map(&:last).
|
130
|
+
expect(relation.where_values.first.right).to be_a(Arel::Nodes::BindParam)
|
131
|
+
expect(relation.bind_values.map(&:last)).to eq [mirror_user.global_id]
|
116
132
|
end
|
117
133
|
end
|
118
134
|
end
|
@@ -122,22 +138,22 @@ module Switchman
|
|
122
138
|
@shard1.activate{ Appendage.create!(:user_id => @user1, :value => 1) }
|
123
139
|
@shard2.activate{ Appendage.create!(:user => @user1, :value => 2) }
|
124
140
|
|
125
|
-
@user1.appendages.to_a.map(&:value).
|
141
|
+
expect(@user1.appendages.to_a.map(&:value)).to eq [1]
|
126
142
|
|
127
143
|
@user1.reload
|
128
144
|
@user1.associated_shards = [@shard1, @shard2]
|
129
|
-
@user1.appendages.to_a.map(&:value).sort.
|
145
|
+
expect(@user1.appendages.to_a.map(&:value).sort).to eq [1, 2]
|
130
146
|
end
|
131
147
|
|
132
148
|
it "follow shards for has_many :through" do
|
133
149
|
@shard1.activate{ a1 = Appendage.create!(:user_id => @user1); a1.digits.create!(:value => 1) }
|
134
150
|
@shard2.activate{ a2 = Appendage.create!(:user_id => @user1); a2.digits.create!(:value => 2) }
|
135
151
|
|
136
|
-
@user1.digits.to_a.map(&:value).
|
152
|
+
expect(@user1.digits.to_a.map(&:value)).to eq [1]
|
137
153
|
|
138
154
|
@user1.reload
|
139
155
|
@user1.associated_shards = [@shard1, @shard2]
|
140
|
-
@user1.digits.to_a.map(&:value).sort.
|
156
|
+
expect(@user1.digits.to_a.map(&:value).sort).to eq [1, 2]
|
141
157
|
end
|
142
158
|
|
143
159
|
it "should include the shard in scopes created by associations" do
|
@@ -146,10 +162,10 @@ module Switchman
|
|
146
162
|
@shard1.activate{ Appendage.create!(:user_id => @user1, :value => 1) }
|
147
163
|
@shard2.activate{ Appendage.create!(:user => @user1) }
|
148
164
|
|
149
|
-
@user1.appendages.has_no_value.to_a.count.
|
165
|
+
expect(@user1.appendages.has_no_value.to_a.count).to eq 1
|
150
166
|
|
151
167
|
@user1.reload
|
152
|
-
@shard2.activate {@user1.appendages.has_no_value.to_a.count.
|
168
|
+
@shard2.activate {expect(@user1.appendages.has_no_value.to_a.count).to eq 1}
|
153
169
|
end
|
154
170
|
|
155
171
|
it "should include the shard in scopes created by has_many :through associations" do
|
@@ -158,10 +174,10 @@ module Switchman
|
|
158
174
|
@shard1.activate{ a1 = Appendage.create!(:user_id => @user1); a1.digits.create! }
|
159
175
|
@shard2.activate{ a2 = Appendage.create!(:user_id => @user1); a2.digits.create!(:value => 2) }
|
160
176
|
|
161
|
-
@user1.digits.has_no_value.count.
|
177
|
+
expect(@user1.digits.has_no_value.count).to eq 1
|
162
178
|
|
163
179
|
@user1.reload
|
164
|
-
@shard2.activate {@user1.digits.has_no_value.to_a.count.
|
180
|
+
@shard2.activate {expect(@user1.digits.has_no_value.to_a.count).to eq 1}
|
165
181
|
end
|
166
182
|
|
167
183
|
it "should work with calculations in scopes created by associations" do
|
@@ -171,10 +187,10 @@ module Switchman
|
|
171
187
|
@shard2.activate{ Appendage.create!(:user => @user1); @user1.appendages.create!(:value => 2) }
|
172
188
|
|
173
189
|
@user1.reload
|
174
|
-
@user1.appendages.has_value.sum(:value).
|
190
|
+
expect(@user1.appendages.has_value.sum(:value)).to eq 3
|
175
191
|
|
176
192
|
@user1.reload
|
177
|
-
@shard2.activate {@user1.appendages.has_value.sum(:value).
|
193
|
+
@shard2.activate {expect(@user1.appendages.has_value.sum(:value)).to eq 3}
|
178
194
|
end
|
179
195
|
|
180
196
|
it "should work with calculations in scopes created by has_many :through associations" do
|
@@ -182,9 +198,9 @@ module Switchman
|
|
182
198
|
@shard1.activate{ a1 = Appendage.create!(:user_id => @user1); a1.digits.create!; a1.digits.create!(:value => 1) }
|
183
199
|
@shard2.activate{ a2 = Appendage.create!(:user_id => @user1); a2.digits.create!(:value => 2) }
|
184
200
|
|
185
|
-
@user1.digits.has_value.sum(:value).
|
201
|
+
expect(@user1.digits.has_value.sum(:value)).to eq 3
|
186
202
|
@user1.reload
|
187
|
-
@shard2.activate {@user1.digits.has_value.sum(:value).
|
203
|
+
@shard2.activate {expect(@user1.digits.has_value.sum(:value)).to eq 3}
|
188
204
|
end
|
189
205
|
|
190
206
|
it "should be able to explicitly set the shard and still work with named scopes" do
|
@@ -193,22 +209,22 @@ module Switchman
|
|
193
209
|
@shard1.activate{ a1 = Appendage.create!(:user_id => @user1); a1.digits.create! }
|
194
210
|
@shard2.activate{ a2 = Appendage.create!(:user_id => @user1); a2.digits.create!(:value => 2) }
|
195
211
|
|
196
|
-
@user1.digits.shard(@shard1).has_no_value.to_a.count.
|
197
|
-
@user1.digits.shard(@shard2).has_no_value.to_a.count.
|
212
|
+
expect(@user1.digits.shard(@shard1).has_no_value.to_a.count).to eq 1
|
213
|
+
expect(@user1.digits.shard(@shard2).has_no_value.to_a.count).to eq 0
|
198
214
|
|
199
215
|
@user1.reload
|
200
216
|
|
201
|
-
@user1.digits.has_no_value.shard(@shard1).to_a.count.
|
202
|
-
@user1.digits.has_no_value.shard(@shard2).to_a.count.
|
217
|
+
expect(@user1.digits.has_no_value.shard(@shard1).to_a.count).to eq 1
|
218
|
+
expect(@user1.digits.has_no_value.shard(@shard2).to_a.count).to eq 0
|
203
219
|
end
|
204
220
|
|
205
221
|
describe "unsharded associations" do
|
206
222
|
it "should be able to create an unsharded new record through a collection" do
|
207
223
|
root = @user2.roots.create!
|
208
224
|
root.reload
|
209
|
-
root.shard.
|
210
|
-
root.user_id.
|
211
|
-
root.user.
|
225
|
+
expect(root.shard).to eq Shard.default
|
226
|
+
expect(root.user_id).to eq @user2.global_id
|
227
|
+
expect(root.user).to eq @user2
|
212
228
|
end
|
213
229
|
end
|
214
230
|
|
@@ -216,7 +232,7 @@ module Switchman
|
|
216
232
|
it "should identify an implied shard value based on the foreign id" do
|
217
233
|
@shard1.activate do
|
218
234
|
@appendage = Appendage.create!(:user_id => @user2.global_id)
|
219
|
-
@appendage.reload.user.
|
235
|
+
expect(@appendage.reload.user).to eq @user2
|
220
236
|
end
|
221
237
|
end
|
222
238
|
|
@@ -228,8 +244,8 @@ module Switchman
|
|
228
244
|
copy.shard = @user1.shard
|
229
245
|
copy.save!
|
230
246
|
copy.reload
|
231
|
-
copy.user.shard.
|
232
|
-
copy.user.
|
247
|
+
expect(copy.user.shard).to eq @shard1
|
248
|
+
expect(copy.user).to eq @user1
|
233
249
|
end
|
234
250
|
end
|
235
251
|
end
|
@@ -244,7 +260,7 @@ module Switchman
|
|
244
260
|
appendages = Appendage.includes(:user).to_a
|
245
261
|
@user1.delete
|
246
262
|
|
247
|
-
appendages.map(&:user).sort.
|
263
|
+
expect(appendages.map(&:user).sort).to eq [@user1, @user2, user3].sort
|
248
264
|
end
|
249
265
|
|
250
266
|
it "should preload belongs_to :through associations across shards" do
|
@@ -257,7 +273,7 @@ module Switchman
|
|
257
273
|
digits = Digit.includes(:user).to_a
|
258
274
|
@user1.delete
|
259
275
|
|
260
|
-
digits.map(&:user).sort.
|
276
|
+
expect(digits.map(&:user).sort).to eq [@user1, @user2].sort
|
261
277
|
end
|
262
278
|
|
263
279
|
it "should preload has_many associations across associated shards" do
|
@@ -269,14 +285,14 @@ module Switchman
|
|
269
285
|
|
270
286
|
begin
|
271
287
|
users = User.where(:id => [@user1, @user2]).includes(:appendages).to_a
|
272
|
-
users.each {|u| u.appendages.loaded
|
288
|
+
users.each {|u| expect(u.appendages.loaded?).to eq true}
|
273
289
|
|
274
290
|
u1 = users.detect {|u| u.id == @user1.id}
|
275
291
|
u2 = users.detect {|u| u.id == @user2.id}
|
276
292
|
|
277
293
|
a1.delete
|
278
|
-
u1.appendages.sort.
|
279
|
-
u2.appendages.
|
294
|
+
expect(u1.appendages.sort).to eq [a1, a2].sort
|
295
|
+
expect(u2.appendages).to be_empty
|
280
296
|
ensure
|
281
297
|
User.associated_shards_map = nil
|
282
298
|
end
|
@@ -305,15 +321,15 @@ module Switchman
|
|
305
321
|
|
306
322
|
begin
|
307
323
|
users = User.where(:id => [@user1, @user2]).includes(:digits).to_a
|
308
|
-
users.each {|u| u.digits.loaded
|
324
|
+
users.each {|u| expect(u.digits.loaded?).to eq true}
|
309
325
|
|
310
326
|
u1 = users.detect {|u| u.id == @user1.id}
|
311
327
|
u2 = users.detect {|u| u.id == @user2.id}
|
312
328
|
|
313
329
|
d1.delete
|
314
330
|
|
315
|
-
u1.digits.sort.
|
316
|
-
u2.digits.
|
331
|
+
expect(u1.digits.sort).to eq [d1, d2, d3].sort
|
332
|
+
expect(u2.digits).to eq [d7]
|
317
333
|
ensure
|
318
334
|
User.associated_shards_map = nil
|
319
335
|
Appendage.associated_shards_map = nil
|
@@ -327,27 +343,27 @@ module Switchman
|
|
327
343
|
feature = Feature.create!(:owner => appendage)
|
328
344
|
|
329
345
|
feature.reload
|
330
|
-
feature.owner.
|
331
|
-
feature.owner_id.
|
332
|
-
feature.owner_type.
|
346
|
+
expect(feature.owner).to eq appendage
|
347
|
+
expect(feature.owner_id).to eq appendage.id
|
348
|
+
expect(feature.owner_type).to eq "Appendage"
|
333
349
|
|
334
350
|
feature.owner = @user1
|
335
351
|
feature.save!
|
336
352
|
|
337
353
|
feature.reload
|
338
|
-
feature.owner_id.
|
339
|
-
feature.owner_type.
|
354
|
+
expect(feature.owner_id).to eq @user1.global_id
|
355
|
+
expect(feature.owner_type).to eq "User"
|
340
356
|
end
|
341
357
|
|
342
358
|
it "should work with multi-shard associations" do
|
343
359
|
@shard1.activate{ Feature.create!(:owner => @user1, :value => 1) }
|
344
360
|
@shard2.activate{ Feature.create!(:owner => @user1, :value => 2) }
|
345
361
|
|
346
|
-
@user1.features.to_a.map(&:value).
|
362
|
+
expect(@user1.features.to_a.map(&:value)).to eq [1]
|
347
363
|
|
348
364
|
@user1.reload
|
349
365
|
@user1.associated_shards = [@shard1, @shard2]
|
350
|
-
@user1.features.to_a.map(&:value).sort.
|
366
|
+
expect(@user1.features.to_a.map(&:value).sort).to eq [1, 2]
|
351
367
|
end
|
352
368
|
end
|
353
369
|
end
|