rhoconnect 4.0.4 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +54 -5
- data/CREDITS +219 -219
- data/Gemfile +2 -2
- data/Gemfile.lock +68 -79
- data/Rakefile +1 -2
- data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/spec_helper.rb +3 -3
- data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
- data/bench/blobapp/spec/spec_helper.rb +3 -3
- data/bench/lib/bench/runner.rb +1 -69
- data/bench/lib/bench.rb +18 -18
- data/bench/spec/mock_adapter_spec.rb +54 -55
- data/bench/spec/mock_client_spec.rb +47 -48
- data/bench/spec/result_spec.rb +41 -44
- data/bench/spec/utils_spec.rb +24 -25
- data/commands/generators/app.rb +7 -5
- data/commands/generators/controller.rb +7 -5
- data/commands/generators/model.rb +7 -5
- data/commands/generators/source.rb +7 -5
- data/commands/parser.rb +1 -1
- data/commands/redis/redis_download.rb +1 -1
- data/doc/async-jobs.txt +9 -9
- data/doc/supported-platforms.txt +0 -2
- data/generators/rhoconnect.rb +92 -212
- data/generators/templates/application/rcgemfile +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +14 -16
- data/generators/templates/application/spec/js_spec.rb +20 -20
- data/generators/templates/application/spec/spec_helper.rb +1 -1
- data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
- data/generators/templates/source/models/ruby/model_spec.rb +17 -17
- data/install.sh +10 -21
- data/installer/unix-like/rho_connect_install_constants.rb +5 -5
- data/installer/unix-like/rho_connect_install_installers.rb +4 -4
- data/installer/utils/constants.rb +6 -6
- data/installer/utils/nix_install_test.rb +29 -29
- data/installer/utils/package_upload/repos.rake +16 -26
- data/js-adapters/node.rb +4 -4
- data/js-adapters/node_channel.rb +4 -8
- data/lib/rhoconnect/db_adapter.rb +13 -13
- data/lib/rhoconnect/handler/changes/engine.rb +1 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
- data/lib/rhoconnect/license.rb +7 -7
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
- data/lib/rhoconnect/ping/apple.rb +4 -4
- data/lib/rhoconnect/server.rb +2 -2
- data/lib/rhoconnect/source.rb +2 -2
- data/lib/rhoconnect/store.rb +12 -6
- data/lib/rhoconnect/utilities.rb +2 -2
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect.rb +6 -4
- data/rhoconnect.gemspec +5 -6
- data/spec/api/api_helper.rb +1 -1
- data/spec/api/app/fast_delete_spec.rb +22 -22
- data/spec/api/app/fast_insert_spec.rb +23 -23
- data/spec/api/app/fast_update_spec.rb +63 -63
- data/spec/api/app/push_deletes_spec.rb +11 -13
- data/spec/api/app/push_objects_spec.rb +39 -39
- data/spec/api/client/client_get_db_doc_spec.rb +29 -29
- data/spec/api/client/client_set_db_doc_spec.rb +11 -11
- data/spec/api/client/get_client_params_spec.rb +29 -29
- data/spec/api/client/list_client_docs_spec.rb +32 -34
- data/spec/api/client/reset_spec.rb +30 -30
- data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
- data/spec/api/source/get_source_params_spec.rb +32 -34
- data/spec/api/source/list_sources_spec.rb +13 -13
- data/spec/api/source/update_source_params_spec.rb +19 -19
- data/spec/api/store/get_db_doc_spec.rb +27 -27
- data/spec/api/store/set_db_doc_spec.rb +38 -38
- data/spec/api/system/adapter_spec.rb +27 -29
- data/spec/api/system/get_license_info_spec.rb +11 -11
- data/spec/api/system/login_spec.rb +37 -37
- data/spec/api/system/reset_spec.rb +15 -15
- data/spec/api/system/stats_spec.rb +70 -71
- data/spec/api/user/create_user_spec.rb +37 -37
- data/spec/api/user/delete_client_spec.rb +7 -7
- data/spec/api/user/delete_user_spec.rb +62 -62
- data/spec/api/user/list_clients_spec.rb +24 -24
- data/spec/api/user/list_source_docs_spec.rb +29 -29
- data/spec/api/user/list_users_spec.rb +22 -22
- data/spec/api/user/ping_spec.rb +18 -18
- data/spec/api/user/show_user_spec.rb +10 -10
- data/spec/api/user/update_user_spec.rb +43 -43
- data/spec/api/user/user_get_db_doc_spec.rb +12 -12
- data/spec/api/user/user_set_db_doc_spec.rb +37 -37
- data/spec/api_token_spec.rb +8 -8
- data/spec/app_spec.rb +18 -17
- data/spec/apps/jstestapp/settings/settings.yml +2 -0
- data/spec/async_spec.rb +9 -11
- data/spec/bulk_data/bulk_data_spec.rb +120 -120
- data/spec/cli/cli_spec.rb +50 -53
- data/spec/client_spec.rb +105 -105
- data/spec/client_sync_spec.rb +529 -528
- data/spec/controllers/js_base_spec.rb +147 -141
- data/spec/doc/doc_spec.rb +51 -52
- data/spec/document_spec.rb +58 -58
- data/spec/dynamic_adapter_spec.rb +33 -36
- data/spec/generator/generator_spec.rb +76 -42
- data/spec/jobs/bulk_data_job_spec.rb +101 -102
- data/spec/jobs/ping_job_spec.rb +176 -177
- data/spec/jobs/source_job_spec.rb +24 -25
- data/spec/license_spec.rb +54 -55
- data/spec/models/js_base_spec.rb +121 -120
- data/spec/perf/bulk_data_perf_spec.rb +23 -24
- data/spec/perf/perf_spec_helper.rb +7 -7
- data/spec/perf/store_perf_spec.rb +139 -140
- data/spec/ping/apple_spec.rb +65 -65
- data/spec/ping/gcm_spec.rb +83 -84
- data/spec/ping/rhoconnect_push_spec.rb +52 -53
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
- data/spec/read_state_spec.rb +24 -25
- data/spec/rhoconnect_spec.rb +7 -7
- data/spec/server/server_spec.rb +664 -662
- data/spec/server/stats_spec.rb +12 -12
- data/spec/source_adapter_spec.rb +124 -125
- data/spec/source_spec.rb +148 -149
- data/spec/source_sync_spec.rb +736 -736
- data/spec/spec_helper.rb +4 -5
- data/spec/stats/record_spec.rb +22 -21
- data/spec/store_orm_spec.rb +48 -48
- data/spec/store_spec.rb +428 -426
- data/spec/support/shared_examples.rb +5 -7
- data/spec/sync_states_spec.rb +67 -67
- data/spec/test_methods_spec.rb +121 -123
- data/spec/testdata/10000-data.txt +0 -0
- data/spec/testdata/5000-data.txt +0 -0
- data/spec/user_spec.rb +102 -102
- data/tasks/redis.rake +3 -3
- metadata +154 -195
- data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
- data/bench/benchapp/tmp/restart.txt +0 -0
- data/bench/blobapp/settings/license.key.bak +0 -2
- data/bench/blobapp/tmp/restart.txt +0 -0
- data/bench/lib/testdata/1-data.txt +0 -0
- data/bench/lib/testdata/10-data.txt +0 -0
- data/bench/lib/testdata/2-data.txt +0 -0
- data/bench/lib/testdata/250-data.txt +0 -0
- data/bench/lib/testdata/5-blob_data.txt +0 -0
- data/bench/lib/testdata/5-data.txt +0 -0
- data/bench/lib/testdata/50-data.txt +0 -0
- data/bench/lib/testdata/500-data.txt +0 -0
- data/doc/protocol.html +0 -1993
- data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
- data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
- data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
- data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
- data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
- data/spec/coverage/rcov/index.html +0 -88
- data/spec/generator/generator_spec_helper.rb +0 -9
data/spec/client_spec.rb
CHANGED
@@ -4,125 +4,125 @@ STATS_RECORD_RESOLUTION = 2 unless defined? STATS_RECORD_RESOLUTION
|
|
4
4
|
STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
|
5
5
|
|
6
6
|
describe "Client" do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should create client with fields" do
|
13
|
-
@c.id.length.should == 32
|
14
|
-
@c.device_type.should == @c_fields[:device_type]
|
15
|
-
end
|
7
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
16
8
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@c.device_port.should == '100'
|
21
|
-
end
|
9
|
+
before(:each) do
|
10
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
11
|
+
end
|
22
12
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@u.clients.members.should == [@c.id]
|
28
|
-
end
|
13
|
+
it "should create client with fields" do
|
14
|
+
@c.id.length.should == 32
|
15
|
+
@c.device_type.should == @c_fields[:device_type]
|
16
|
+
end
|
29
17
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
18
|
+
it "should update_fields for a client" do
|
19
|
+
@c.update_fields({:device_type => 'android',:device_port => 100})
|
20
|
+
@c.device_type.should == 'android'
|
21
|
+
@c.device_port.should == '100'
|
22
|
+
end
|
36
23
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
it "should create client with user_id" do
|
25
|
+
Store.get_value('client:count').should == "1"
|
26
|
+
@c.id.length.should == 32
|
27
|
+
@c.user_id.should == @c_fields[:user_id]
|
28
|
+
@u.clients.members.should == [@c.id]
|
29
|
+
end
|
43
30
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
31
|
+
it "should raise exception if source_name is nil" do
|
32
|
+
@c.source_name = nil
|
33
|
+
lambda {
|
34
|
+
@c.doc_suffix('foo')
|
35
|
+
}.should raise_error(InvalidSourceNameError, 'Invalid Source Name For Client')
|
36
|
+
end
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
it "should raise exception if license seats exceeded" do
|
39
|
+
Store.put_value(License::CLIENT_DOCKEY,100)
|
40
|
+
lambda { Client.create(@c_fields,{}) }.should raise_error(
|
41
|
+
LicenseSeatsExceededException, "WARNING: Maximum # of devices exceeded for this license."
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should free seat when client is deleted" do
|
46
|
+
current = Store.get_value(License::CLIENT_DOCKEY).to_i
|
47
|
+
@c.delete
|
48
|
+
Store.get_value('client:count').should == '0'
|
49
|
+
Store.get_value(License::CLIENT_DOCKEY).to_i.should == current - 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should delete client and all associated documents" do
|
53
|
+
@c.put_data(:cd, @data)
|
54
|
+
docname = @c.docname(:cd)
|
55
|
+
store_index = @c.store_index(:cd)
|
56
|
+
@c.delete
|
57
|
+
Store.get_store(store_index).exists?(docname).should == false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should switch client user and remove existing documents" do
|
61
|
+
prevdocname = @c.docname(:cd)
|
62
|
+
prev_store_index = @c.store_index(:cd)
|
63
|
+
@c.put_data(:cd, @data)
|
64
|
+
verify_doc_result(@c, :cd => @data)
|
65
|
+
User.create({:login => 'user2'})
|
66
|
+
@c.switch_user('user2')
|
67
|
+
verify_doc_result(@c, :cd => {})
|
68
|
+
Store.get_store(prev_store_index).get_data(prevdocname).should == {}
|
69
|
+
@u.clients.members.should == []
|
70
|
+
@c.user_id.should == 'user2'
|
71
|
+
User.load('user2').clients.members.should == [@c.id]
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should create cd as masterdoc clone" do
|
75
|
+
@s.put_data(:md_copy, @data)
|
76
|
+
@c.put_data(:cd, {'foo' => {'bar' => 'abc'}})
|
77
|
+
@c.update_clientdoc([@s_fields[:name]])
|
78
|
+
verify_doc_result(@c, :cd => @data)
|
79
|
+
verify_doc_result(@s, :md_copy => @data)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should update client schema_sha1" do
|
83
|
+
@s.put_data(:md_copy, @data)
|
84
|
+
@s.put_value(:schema_sha1, 'foobar')
|
85
|
+
@c.put_data(:cd, {'foo' => {'bar' => 'abc'}})
|
86
|
+
@c.update_clientdoc([@s_fields[:name]])
|
87
|
+
verify_doc_result(@c, :cd => @data)
|
88
|
+
verify_doc_result(@s, :md_copy => @data)
|
89
|
+
verify_doc_result(@c, :schema_sha1 => 'foobar')
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "Client Stats" do
|
93
|
+
|
94
|
+
before(:each) do
|
95
|
+
Rhoconnect::Stats::Record.reset('clients')
|
57
96
|
end
|
58
97
|
|
59
|
-
|
60
|
-
|
61
|
-
prev_store_index = @c.store_index(:cd)
|
62
|
-
@c.put_data(:cd, @data)
|
63
|
-
verify_doc_result(@c, :cd => @data)
|
64
|
-
User.create({:login => 'user2'})
|
65
|
-
@c.switch_user('user2')
|
66
|
-
verify_doc_result(@c, :cd => {})
|
67
|
-
Store.get_store(prev_store_index).get_data(prevdocname).should == {}
|
68
|
-
@u.clients.members.should == []
|
69
|
-
@c.user_id.should == 'user2'
|
70
|
-
User.load('user2').clients.members.should == [@c.id]
|
98
|
+
after(:each) do
|
99
|
+
Rhoconnect::Stats::Record.reset('clients')
|
71
100
|
end
|
72
101
|
|
73
|
-
|
74
|
-
|
75
|
-
@c.put_data(:cd, {'foo' => {'bar' => 'abc'}})
|
76
|
-
@c.update_clientdoc([@s_fields[:name]])
|
77
|
-
verify_doc_result(@c, :cd => @data)
|
78
|
-
verify_doc_result(@s, :md_copy => @data)
|
102
|
+
after(:all) do
|
103
|
+
Store.flush_data('stat:clients*')
|
79
104
|
end
|
80
105
|
|
81
|
-
it "should
|
82
|
-
|
83
|
-
|
84
|
-
@
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
106
|
+
it "should increment clients stats on create" do
|
107
|
+
Time.stub(:now).and_return(10)
|
108
|
+
Rhoconnect.stats = true
|
109
|
+
@c_fields.delete(:id)
|
110
|
+
Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
111
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
112
|
+
Store.get_value('client:count').should == "2"
|
113
|
+
Rhoconnect.stats = false
|
89
114
|
end
|
90
115
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
after(:all) do
|
102
|
-
Store.flush_data('stat:clients*')
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should increment clients stats on create" do
|
106
|
-
Time.stub!(:now).and_return(10)
|
107
|
-
Rhoconnect.stats = true
|
108
|
-
@c_fields.delete(:id)
|
109
|
-
Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
110
|
-
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
111
|
-
Store.get_value('client:count').should == "2"
|
112
|
-
Rhoconnect.stats = false
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should decrement clients stats on delete" do
|
116
|
-
Time.stub!(:now).and_return(10)
|
117
|
-
Rhoconnect.stats = true
|
118
|
-
@c_fields.delete(:id)
|
119
|
-
c = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
120
|
-
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
121
|
-
c.delete
|
122
|
-
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["1:10"]
|
123
|
-
Store.get_value('client:count').should == "1"
|
124
|
-
Rhoconnect.stats = false
|
125
|
-
end
|
116
|
+
it "should decrement clients stats on delete" do
|
117
|
+
Time.stub(:now).and_return(10)
|
118
|
+
Rhoconnect.stats = true
|
119
|
+
@c_fields.delete(:id)
|
120
|
+
c = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
121
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
122
|
+
c.delete
|
123
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["1:10"]
|
124
|
+
Store.get_value('client:count').should == "1"
|
125
|
+
Rhoconnect.stats = false
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|