switchman 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/models/switchman/shard.rb +10 -3
- data/db/switchman_test.sqlite3 +0 -0
- data/lib/switchman/active_record/association.rb +36 -10
- data/lib/switchman/active_record/base.rb +9 -5
- data/lib/switchman/active_record/calculations.rb +12 -11
- data/lib/switchman/active_record/connection_handler.rb +102 -47
- data/lib/switchman/active_record/connection_pool.rb +3 -64
- data/lib/switchman/active_record/finder_methods.rb +1 -1
- data/lib/switchman/active_record/query_methods.rb +50 -25
- data/lib/switchman/active_record/relation.rb +5 -5
- data/lib/switchman/active_record/spawn_methods.rb +76 -29
- data/lib/switchman/connection_pool_proxy.rb +3 -1
- data/lib/switchman/database_server.rb +4 -2
- data/lib/switchman/engine.rb +8 -5
- data/lib/switchman/r_spec_helper.rb +14 -6
- data/lib/switchman/rails.rb +7 -9
- data/lib/switchman/test_helper.rb +4 -3
- data/lib/switchman/version.rb +1 -1
- data/spec/dummy/app/models/appendage.rb +2 -4
- data/spec/dummy/app/models/digit.rb +2 -4
- data/spec/dummy/app/models/feature.rb +0 -2
- data/spec/dummy/app/models/user.rb +0 -2
- data/spec/dummy/config/application.rb +0 -6
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/config/environments/development.rb +2 -9
- data/spec/dummy/config/environments/production.rb +2 -3
- data/spec/dummy/config/environments/test.rb +2 -11
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/dummy/db/schema.rb +32 -29
- data/spec/dummy/db/switchman_test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +23 -0
- data/spec/dummy/log/test.log +36056 -86392
- data/spec/dummy/tmp/cache/2E3/840/shard%2F3 +0 -0
- data/spec/dummy/tmp/cache/2E4/850/shard%2F4 +0 -0
- data/spec/dummy/tmp/cache/2E6/870/shard%2F6 +0 -0
- data/spec/dummy/tmp/cache/2E7/880/shard%2F7 +0 -0
- data/spec/dummy/tmp/cache/{346/D90/shard%2F105 → 313/970/shard%2F30} +1 -1
- data/spec/dummy/tmp/cache/314/990/shard%2F40 +0 -0
- data/spec/dummy/tmp/cache/{31C/A40/shard%2F75 → 315/970/shard%2F14} +1 -1
- data/spec/dummy/tmp/cache/315/9A0/shard%2F41 +0 -0
- data/spec/dummy/tmp/cache/315/9B0/shard%2F50 +0 -0
- data/spec/dummy/tmp/cache/317/9C0/shard%2F43 +0 -0
- data/spec/dummy/tmp/cache/318/9B0/shard%2F26 +0 -0
- data/spec/dummy/tmp/cache/318/9D0/shard%2F44 +0 -0
- data/spec/dummy/tmp/cache/319/9C0/shard%2F27 +0 -0
- data/spec/dummy/tmp/cache/31A/9F0/shard%2F46 +0 -0
- data/spec/dummy/tmp/cache/31C/A20/shard%2F57 +0 -0
- data/spec/dummy/tmp/cache/31D/A20/shard%2F49 +0 -0
- data/spec/dummy/tmp/cache/349/E10/shard%2F153 +0 -0
- data/spec/dummy/tmp/cache/34A/E20/shard%2F154 +0 -0
- data/spec/dummy/tmp/cache/{345/DC0/shard%2F140 → 34A/E50/shard%2F181} +1 -1
- data/spec/dummy/tmp/cache/{318/A00/shard%2F71 → 34E/E70/shard%2F167} +1 -1
- data/spec/dummy/tmp/cache/375/530/shard%2F3200 +1 -0
- data/spec/dummy/tmp/cache/376/510/shard%2F2202 +1 -0
- data/spec/dummy/tmp/cache/376/520/shard%2F2211 +1 -0
- data/spec/dummy/tmp/cache/376/530/shard%2F2220 +1 -0
- data/spec/dummy/tmp/cache/377/4F0/shard%2F2014 +0 -0
- data/spec/dummy/tmp/cache/377/520/shard%2F2203 +1 -0
- data/spec/dummy/tmp/cache/377/530/shard%2F2212 +1 -0
- data/spec/dummy/tmp/cache/377/550/shard%2F2230 +1 -0
- data/spec/dummy/tmp/cache/377/550/shard%2F3040 +1 -0
- data/spec/dummy/tmp/cache/378/500/shard%2F2015 +0 -0
- data/spec/dummy/tmp/cache/378/520/shard%2F3005 +1 -0
- data/spec/dummy/tmp/cache/378/550/shard%2F2222 +1 -0
- data/spec/dummy/tmp/cache/378/560/shard%2F3122 +1 -0
- data/spec/dummy/tmp/cache/378/5A0/shard%2F2510 +1 -0
- data/spec/dummy/tmp/cache/378/5B0/shard%2F2600 +2 -0
- data/spec/dummy/tmp/cache/379/530/shard%2F3006 +1 -0
- data/spec/dummy/tmp/cache/379/540/shard%2F2205 +1 -0
- data/spec/dummy/tmp/cache/379/550/shard%2F2214 +1 -0
- data/spec/dummy/tmp/cache/379/560/shard%2F2223 +1 -0
- data/spec/dummy/tmp/cache/379/560/shard%2F3033 +1 -0
- data/spec/dummy/tmp/cache/379/560/shard%2F3114 +1 -0
- data/spec/dummy/tmp/cache/379/570/shard%2F3042 +1 -0
- data/spec/dummy/tmp/cache/379/580/shard%2F3051 +1 -0
- data/spec/dummy/tmp/cache/379/590/shard%2F3060 +1 -0
- data/spec/dummy/tmp/cache/379/5C0/shard%2F2601 +2 -0
- data/spec/dummy/tmp/cache/379/5D0/shard%2F2610 +2 -0
- data/spec/dummy/tmp/cache/37A/540/shard%2F3007 +1 -0
- data/spec/dummy/tmp/cache/37A/570/shard%2F2224 +1 -0
- data/spec/dummy/tmp/cache/37A/570/shard%2F3034 +1 -0
- data/spec/dummy/tmp/cache/37A/580/shard%2F3043 +1 -0
- data/spec/dummy/tmp/cache/37A/590/shard%2F3052 +1 -0
- data/spec/dummy/tmp/cache/37A/590/shard%2F3214 +1 -0
- data/spec/dummy/tmp/cache/37A/5A0/shard%2F3061 +1 -0
- data/spec/dummy/tmp/cache/37A/5B0/shard%2F3070 +1 -0
- data/spec/dummy/tmp/cache/37A/5E0/shard%2F2530 +0 -0
- data/spec/dummy/tmp/cache/37A/5F0/shard%2F2701 +0 -0
- data/spec/dummy/tmp/cache/37B/540/shard%2F2027 +1 -0
- data/spec/dummy/tmp/cache/37B/570/shard%2F3026 +1 -0
- data/spec/dummy/tmp/cache/37B/5C0/shard%2F2261 +1 -0
- data/spec/dummy/tmp/cache/37B/5C0/shard%2F2504 +1 -0
- data/spec/dummy/tmp/cache/37B/5C0/shard%2F3152 +1 -0
- data/spec/dummy/tmp/cache/37B/5D0/shard%2F2513 +1 -0
- data/spec/dummy/tmp/cache/37B/5E0/shard%2F2603 +2 -0
- data/spec/dummy/tmp/cache/37B/5F0/shard%2F2531 +0 -0
- data/spec/dummy/tmp/cache/37B/5F0/shard%2F2612 +2 -0
- data/spec/dummy/tmp/cache/37B/610/shard%2F2630 +2 -0
- data/spec/dummy/tmp/cache/37B/630/shard%2F2810 +2 -0
- data/spec/dummy/tmp/cache/37C/580/shard%2F2217 +1 -0
- data/spec/dummy/tmp/cache/37C/580/shard%2F3108 +1 -0
- data/spec/dummy/tmp/cache/37C/590/shard%2F3036 +1 -0
- data/spec/dummy/tmp/cache/37C/5A0/shard%2F3045 +1 -0
- data/spec/dummy/tmp/cache/37C/5B0/shard%2F3054 +1 -0
- data/spec/dummy/tmp/cache/37C/5C0/shard%2F3063 +1 -0
- data/spec/dummy/tmp/cache/37C/5D0/shard%2F2262 +1 -0
- data/spec/dummy/tmp/cache/37C/5D0/shard%2F3072 +0 -0
- data/spec/dummy/tmp/cache/37C/5E0/shard%2F2190 +1 -0
- data/spec/dummy/tmp/cache/37C/5F0/shard%2F2604 +2 -0
- data/spec/dummy/tmp/cache/37C/600/shard%2F2370 +1 -0
- data/spec/dummy/tmp/cache/37C/600/shard%2F2613 +2 -0
- data/spec/dummy/tmp/cache/37C/620/shard%2F2631 +2 -0
- data/spec/dummy/tmp/cache/37D/5A0/shard%2F3037 +1 -0
- data/spec/dummy/tmp/cache/37D/5B0/shard%2F3046 +1 -0
- data/spec/dummy/tmp/cache/37D/5C0/shard%2F3055 +1 -0
- data/spec/dummy/tmp/cache/37D/5D0/shard%2F2254 +1 -0
- data/spec/dummy/tmp/cache/37D/5D0/shard%2F3064 +1 -0
- data/spec/dummy/tmp/cache/37D/5E0/shard%2F3073 +1 -0
- data/spec/dummy/tmp/cache/37D/5F0/shard%2F2191 +1 -0
- data/spec/dummy/tmp/cache/37D/600/shard%2F2524 +1 -0
- data/spec/dummy/tmp/cache/37D/610/shard%2F2371 +1 -0
- data/spec/dummy/tmp/cache/37D/620/shard%2F2380 +1 -0
- data/spec/dummy/tmp/cache/37D/620/shard%2F2461 +1 -0
- data/spec/dummy/tmp/cache/37D/630/shard%2F2470 +1 -0
- data/spec/dummy/tmp/cache/37D/650/shard%2F2650 +0 -0
- data/spec/dummy/tmp/cache/37E/5B0/shard%2F2228 +1 -0
- data/spec/dummy/tmp/cache/37E/5D0/shard%2F3137 +1 -0
- data/spec/dummy/tmp/cache/37E/5F0/shard%2F2264 +1 -0
- data/spec/dummy/tmp/cache/37E/610/shard%2F2525 +1 -0
- data/spec/dummy/tmp/cache/37E/610/shard%2F2606 +2 -0
- data/spec/dummy/tmp/cache/37E/620/shard%2F2615 +2 -0
- data/spec/dummy/tmp/cache/37E/620/shard%2F3182 +0 -0
- data/spec/dummy/tmp/cache/37E/630/shard%2F2624 +2 -0
- data/spec/dummy/tmp/cache/37E/630/shard%2F2705 +1 -0
- data/spec/dummy/tmp/cache/37E/640/shard%2F2633 +0 -0
- data/spec/dummy/tmp/cache/37E/650/shard%2F2723 +1 -0
- data/spec/dummy/tmp/cache/37F/5C0/shard%2F2229 +1 -0
- data/spec/dummy/tmp/cache/37F/5C0/shard%2F3039 +1 -0
- data/spec/dummy/tmp/cache/37F/5E0/shard%2F3057 +1 -0
- data/spec/dummy/tmp/cache/37F/5F0/shard%2F3066 +1 -0
- data/spec/dummy/tmp/cache/37F/600/shard%2F3075 +1 -0
- data/spec/dummy/tmp/cache/37F/610/shard%2F2193 +1 -0
- data/spec/dummy/tmp/cache/37F/620/shard%2F2607 +2 -0
- data/spec/dummy/tmp/cache/37F/620/shard%2F3093 +1 -0
- data/spec/dummy/tmp/cache/37F/630/shard%2F2373 +1 -0
- data/spec/dummy/tmp/cache/37F/630/shard%2F2535 +0 -0
- data/spec/dummy/tmp/cache/37F/630/shard%2F2616 +2 -0
- data/spec/dummy/tmp/cache/37F/640/shard%2F2382 +1 -0
- data/spec/dummy/tmp/cache/37F/640/shard%2F2625 +2 -0
- data/spec/dummy/tmp/cache/37F/650/shard%2F2634 +0 -0
- data/spec/dummy/tmp/cache/380/5F0/shard%2F3058 +1 -0
- data/spec/dummy/tmp/cache/380/600/shard%2F3067 +1 -0
- data/spec/dummy/tmp/cache/380/600/shard%2F3148 +0 -0
- data/spec/dummy/tmp/cache/380/610/shard%2F2509 +1 -0
- data/spec/dummy/tmp/cache/380/610/shard%2F3076 +1 -0
- data/spec/dummy/tmp/cache/380/630/shard%2F2527 +1 -0
- data/spec/dummy/tmp/cache/380/640/shard%2F2374 +1 -0
- data/spec/dummy/tmp/cache/380/640/shard%2F2536 +0 -0
- data/spec/dummy/tmp/cache/380/660/shard%2F2473 +1 -0
- data/spec/dummy/tmp/cache/380/670/shard%2F2482 +1 -0
- data/spec/dummy/tmp/cache/380/670/shard%2F2806 +2 -0
- data/spec/dummy/tmp/cache/{2E9/8A0/shard%2F9 → 380/680/shard%2F2653} +1 -1
- data/spec/dummy/tmp/cache/380/6A0/shard%2F2671 +1 -0
- data/spec/dummy/tmp/cache/380/6A0/shard%2F2752 +2 -0
- data/spec/dummy/tmp/cache/380/6B0/shard%2F2761 +2 -0
- data/spec/dummy/tmp/cache/381/600/shard%2F2249 +1 -0
- data/spec/dummy/tmp/cache/381/610/shard%2F3149 +0 -0
- data/spec/dummy/tmp/cache/381/640/shard%2F2609 +2 -0
- data/spec/dummy/tmp/cache/381/640/shard%2F3095 +0 -0
- data/spec/dummy/tmp/cache/381/650/shard%2F3185 +1 -0
- data/spec/dummy/tmp/cache/381/660/shard%2F2627 +2 -0
- data/spec/dummy/tmp/cache/381/670/shard%2F2636 +1 -0
- data/spec/dummy/tmp/cache/381/680/shard%2F2807 +2 -0
- data/spec/dummy/tmp/cache/381/690/shard%2F2573 +1 -0
- data/spec/dummy/tmp/cache/381/6B0/shard%2F2591 +2 -0
- data/spec/dummy/tmp/cache/381/6B0/shard%2F2753 +2 -0
- data/spec/dummy/tmp/cache/381/6F0/shard%2F2870 +1 -0
- data/spec/dummy/tmp/cache/382/620/shard%2F3069 +1 -0
- data/spec/dummy/tmp/cache/382/640/shard%2F2196 +1 -0
- data/spec/dummy/tmp/cache/382/650/shard%2F3096 +0 -0
- data/spec/dummy/tmp/cache/382/650/shard%2F3177 +1 -0
- data/spec/dummy/tmp/cache/382/660/shard%2F2376 +1 -0
- data/spec/dummy/tmp/cache/382/670/shard%2F2628 +2 -0
- data/spec/dummy/tmp/cache/382/6A0/shard%2F2493 +1 -0
- data/spec/dummy/tmp/cache/382/6C0/shard%2F2592 +2 -0
- data/spec/dummy/tmp/cache/382/6C0/shard%2F2835 +1 -0
- data/spec/dummy/tmp/cache/383/650/shard%2F2197 +1 -0
- data/spec/dummy/tmp/cache/383/670/shard%2F2377 +1 -0
- data/spec/dummy/tmp/cache/383/670/shard%2F2458 +1 -0
- data/spec/dummy/tmp/cache/383/680/shard%2F2548 +1 -0
- data/spec/dummy/tmp/cache/383/690/shard%2F2476 +1 -0
- data/spec/dummy/tmp/cache/383/6A0/shard%2F2809 +2 -0
- data/spec/dummy/tmp/cache/383/6C0/shard%2F2746 +1 -0
- data/spec/dummy/tmp/cache/383/6D0/shard%2F2755 +2 -0
- data/spec/dummy/tmp/cache/383/6E0/shard%2F2764 +2 -0
- data/spec/dummy/tmp/cache/383/700/shard%2F2782 +2 -0
- data/spec/dummy/tmp/cache/383/700/shard%2F2863 +1 -0
- data/spec/dummy/tmp/cache/384/6A0/shard%2F2477 +1 -0
- data/spec/dummy/tmp/cache/384/6E0/shard%2F2594 +2 -0
- data/spec/dummy/tmp/cache/384/6E0/shard%2F2756 +2 -0
- data/spec/dummy/tmp/cache/384/6F0/shard%2F2684 +0 -0
- data/spec/dummy/tmp/cache/384/6F0/shard%2F2765 +2 -0
- data/spec/dummy/tmp/cache/384/710/shard%2F2864 +1 -0
- data/spec/dummy/tmp/cache/384/720/shard%2F2873 +1 -0
- data/spec/dummy/tmp/cache/385/670/shard%2F2199 +1 -0
- data/spec/dummy/tmp/cache/385/690/shard%2F2379 +1 -0
- data/spec/dummy/tmp/cache/385/6F0/shard%2F2595 +2 -0
- data/spec/dummy/tmp/cache/385/710/shard%2F2694 +1 -0
- data/spec/dummy/tmp/cache/386/6B0/shard%2F3199 +1 -0
- data/spec/dummy/tmp/cache/386/6C0/shard%2F2479 +1 -0
- data/spec/dummy/tmp/cache/386/700/shard%2F2758 +2 -0
- data/spec/dummy/tmp/cache/386/720/shard%2F2776 +2 -0
- data/spec/dummy/tmp/cache/386/730/shard%2F2866 +1 -0
- data/spec/dummy/tmp/cache/387/710/shard%2F2597 +2 -0
- data/spec/dummy/tmp/cache/388/720/shard%2F2598 +2 -0
- data/spec/dummy/tmp/cache/389/750/shard%2F2779 +2 -0
- data/spec/dummy/tmp/cache/389/760/shard%2F2869 +1 -0
- data/spec/dummy/tmp/cache/3A2/E80/shard%2F10010 +1 -0
- data/spec/dummy/tmp/cache/3A6/F80/shard%2F13200 +1 -0
- data/spec/dummy/tmp/cache/3A8/F70/shard%2F12203 +1 -0
- data/spec/dummy/tmp/cache/3A8/F80/shard%2F12212 +1 -0
- data/spec/dummy/tmp/cache/3A9/F50/shard%2F12015 +1 -0
- data/spec/dummy/tmp/cache/3A9/FC0/shard%2F12240 +1 -0
- data/spec/dummy/tmp/cache/3A9/FF0/shard%2F12510 +1 -0
- data/spec/dummy/tmp/cache/3AA/F10/shard%2F10027 +1 -0
- data/spec/dummy/tmp/cache/3AA/F80/shard%2F13006 +1 -0
- data/spec/dummy/tmp/cache/3AA/FB0/shard%2F12223 +1 -0
- data/spec/dummy/tmp/cache/3AA/FD0/shard%2F13132 +1 -0
- data/spec/dummy/tmp/cache/3AB/F70/shard%2F10073 +1 -0
- data/spec/dummy/tmp/cache/3AB/F70/shard%2F10154 +1 -0
- data/spec/dummy/tmp/cache/3AB/FC0/shard%2F13115 +1 -0
- data/spec/dummy/tmp/cache/3AC/050/shard%2F12702 +1 -0
- data/spec/dummy/tmp/cache/3AC/FB0/shard%2F13017 +1 -0
- data/spec/dummy/tmp/cache/3AD/010/shard%2F12253 +1 -0
- data/spec/dummy/tmp/cache/3AD/020/shard%2F12262 +1 -0
- data/spec/dummy/tmp/cache/3AE/040/shard%2F12191 +1 -0
- data/spec/dummy/tmp/cache/3AF/060/shard%2F12525 +1 -0
- data/spec/dummy/tmp/cache/3AF/0B0/shard%2F12651 +1 -0
- data/spec/dummy/tmp/cache/3B0/010/shard%2F12229 +1 -0
- data/spec/dummy/tmp/cache/3B0/080/shard%2F13183 +1 -0
- data/spec/dummy/tmp/cache/3B0/0A0/shard%2F12634 +1 -0
- data/spec/dummy/tmp/cache/3B1/070/shard%2F13166 +1 -0
- data/spec/dummy/tmp/cache/3B1/090/shard%2F12536 +1 -0
- data/spec/dummy/tmp/cache/3B1/0C0/shard%2F12563 +1 -0
- data/spec/dummy/tmp/cache/3B1/0D0/shard%2F12491 +1 -0
- data/spec/dummy/tmp/cache/3B1/0F0/shard%2F12833 +1 -0
- data/spec/dummy/tmp/cache/3B2/000/shard%2F10179 +1 -0
- data/spec/dummy/tmp/cache/3B2/060/shard%2F13149 +1 -0
- data/spec/dummy/tmp/cache/3B2/140/shard%2F12870 +1 -0
- data/spec/dummy/tmp/cache/3B3/0A0/shard%2F13096 +1 -0
- data/spec/dummy/tmp/cache/3B3/0F0/shard%2F12736 +1 -0
- data/spec/dummy/tmp/cache/3B4/090/shard%2F13079 +1 -0
- data/spec/dummy/tmp/cache/3B4/0A0/shard%2F12197 +1 -0
- data/spec/dummy/tmp/cache/3B4/0E0/shard%2F12719 +1 -0
- data/spec/dummy/tmp/cache/3B5/160/shard%2F12864 +1 -0
- data/spec/dummy/tmp/cache/3B6/150/shard%2F12685 +1 -0
- data/spec/dummy/tmp/cache/3B7/140/shard%2F12668 +1 -0
- data/spec/dummy/tmp/cache/3B9/150/shard%2F12499 +1 -0
- data/spec/lib/active_record/association_spec.rb +21 -11
- data/spec/lib/active_record/finder_methods_spec.rb +1 -1
- data/spec/lib/active_record/query_cache_spec.rb +63 -43
- data/spec/lib/active_record/query_methods_spec.rb +6 -5
- data/spec/lib/active_record/relation_spec.rb +1 -1
- data/spec/lib/active_record/spawn_methods_spec.rb +5 -4
- data/spec/lib/connection_pool_proxy_spec.rb +2 -0
- data/spec/lib/database_server_spec.rb +18 -6
- data/spec/lib/shackles_spec.rb +8 -6
- metadata +512 -59
- data/spec/dummy/tmp/cache/317/9E0/shard%2F61 +0 -0
- data/spec/dummy/tmp/cache/318/9F0/shard%2F62 +0 -0
- data/spec/dummy/tmp/cache/31A/A10/shard%2F64 +0 -0
- data/spec/dummy/tmp/cache/31A/A20/shard%2F73 +0 -0
- data/spec/dummy/tmp/cache/31B/A20/shard%2F65 +0 -0
- data/spec/dummy/tmp/cache/31B/A30/shard%2F74 +0 -0
- data/spec/dummy/tmp/cache/31D/A30/shard%2F58 +0 -0
- data/spec/dummy/tmp/cache/31D/A40/shard%2F67 +0 -0
- data/spec/dummy/tmp/cache/31E/A40/shard%2F59 +0 -0
- data/spec/dummy/tmp/cache/31E/A50/shard%2F68 +0 -0
- data/spec/dummy/tmp/cache/320/A80/shard%2F79 +0 -0
- data/spec/dummy/tmp/cache/344/D70/shard%2F103 +0 -0
- data/spec/dummy/tmp/cache/345/D80/shard%2F104 +0 -0
- data/spec/dummy/tmp/cache/349/DE0/shard%2F126 +0 -0
- data/spec/dummy/tmp/cache/34A/DF0/shard%2F127 +0 -0
- data/spec/dummy/tmp/cache/34B/E00/shard%2F128 +0 -1
- data/spec/dummy/tmp/cache/34B/E10/shard%2F137 +0 -0
- data/spec/dummy/tmp/cache/34C/E20/shard%2F138 +0 -0
- data/spec/dummy/tmp/cache/34C/E80/shard%2F192 +0 -0
|
@@ -2,6 +2,8 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
module Switchman
|
|
4
4
|
describe ConnectionPoolProxy do
|
|
5
|
+
include RSpecHelper
|
|
6
|
+
|
|
5
7
|
it "should not share connections for sqlite shards on the same db" do
|
|
6
8
|
@db = DatabaseServer.create(:config => { :adapter => 'sqlite3', :database => ':memory:' })
|
|
7
9
|
@sqlite_shard1 = @db.shards.create!
|
|
@@ -66,12 +66,20 @@ module Switchman
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "should be able to create a new sqlite shard from a given server" do
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
db = DatabaseServer.create(:config => { :adapter => 'sqlite3', :database => '%{shard_name}', :shard_name => ':memory:' })
|
|
70
|
+
begin
|
|
71
|
+
create_shard(db)
|
|
72
|
+
ensure
|
|
73
|
+
db.destroy
|
|
74
|
+
end
|
|
71
75
|
end
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
context "non-transactional" do
|
|
78
|
+
self.use_transactional_fixtures = ::ActiveRecord::Base.connection.supports_ddl_transactions?
|
|
79
|
+
|
|
80
|
+
it "should be able to create a new shard from the default db" do
|
|
81
|
+
create_shard(Shard.default.database_server)
|
|
82
|
+
end
|
|
75
83
|
end
|
|
76
84
|
|
|
77
85
|
it "should be able to create a new shard from a db server that doesn't have any shards" do
|
|
@@ -79,8 +87,12 @@ module Switchman
|
|
|
79
87
|
pending 'A "real" database"' unless %w{MySQL Mysql2 PostgreSQL}.include?(adapter)
|
|
80
88
|
|
|
81
89
|
# So, it's really the same server, but we want separate connections
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
db = DatabaseServer.create(:config => Shard.default.database_server.config)
|
|
91
|
+
begin
|
|
92
|
+
create_shard(db)
|
|
93
|
+
ensure
|
|
94
|
+
db.destroy
|
|
95
|
+
end
|
|
84
96
|
end
|
|
85
97
|
|
|
86
98
|
class MyException < Exception; end
|
data/spec/lib/shackles_spec.rb
CHANGED
|
@@ -23,11 +23,13 @@ module Switchman
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should correctly set up pools for sharding categories" do
|
|
26
|
-
models = ::ActiveRecord::Base.connection_handler.
|
|
27
|
-
default_pools =
|
|
26
|
+
models = ::ActiveRecord::Base.connection_handler.send(:class_to_pool)
|
|
27
|
+
default_pools = {}
|
|
28
|
+
models.each_pair { |k, v| default_pools[k] = v.current_pool }
|
|
28
29
|
::Shackles.activate(:slave_that_no_one_else_uses) do
|
|
29
|
-
models = ::ActiveRecord::Base.connection_handler.
|
|
30
|
-
pools =
|
|
30
|
+
models = ::ActiveRecord::Base.connection_handler.send(:class_to_pool)
|
|
31
|
+
pools = {}
|
|
32
|
+
models.each_pair { |k, v| pools[k] = v.current_pool }
|
|
31
33
|
default_pools.keys.sort.should == pools.keys.sort
|
|
32
34
|
default_pools.keys.each do |model|
|
|
33
35
|
default_pools[model].should_not == pools[model]
|
|
@@ -71,7 +73,7 @@ module Switchman
|
|
|
71
73
|
|
|
72
74
|
u = User.create!
|
|
73
75
|
Shard.default.database_server.expects(:unshackle).once.returns([])
|
|
74
|
-
User.
|
|
76
|
+
User.lock.first
|
|
75
77
|
Shard.default.database_server.expects(:unshackle).once.returns([])
|
|
76
78
|
lambda { u.lock! }.should raise_error(::ActiveRecord::RecordNotFound)
|
|
77
79
|
ensure
|
|
@@ -143,7 +145,7 @@ module Switchman
|
|
|
143
145
|
end
|
|
144
146
|
|
|
145
147
|
def actual_connection_count
|
|
146
|
-
::ActiveRecord::Base.connection_pool.current_pool.instance_variable_get(:@reserved_connections).
|
|
148
|
+
::ActiveRecord::Base.connection_pool.current_pool.instance_variable_get(:@reserved_connections).size
|
|
147
149
|
end
|
|
148
150
|
|
|
149
151
|
it "should really return active connections to the pool in all envs" do
|