rhoconnect 4.0.4 → 5.1.1
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 +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/models/js_base_spec.rb
CHANGED
|
@@ -1,155 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative '../../lib/rhoconnect'
|
|
2
|
+
require_relative '../../lib/rhoconnect/server'
|
|
3
|
+
require_relative '../spec_helper'
|
|
3
4
|
|
|
4
5
|
describe "Rhoconnect::Model::JsBase" do
|
|
5
6
|
include Rhoconnect
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
before(:each) do
|
|
9
|
-
Rhoconnect::Server.set :environment, :test
|
|
10
|
-
Rhoconnect::Server.set :secret, "secure!"
|
|
11
|
-
Rhoconnect.use_node = true
|
|
12
|
-
Rhoconnect.bootstrap(get_testapp_path)
|
|
13
|
-
end
|
|
8
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
before(:each) do
|
|
11
|
+
Rhoconnect::Server.set :environment, :test
|
|
12
|
+
Rhoconnect::Server.set :secret, "secure!"
|
|
13
|
+
Rhoconnect.use_node = true
|
|
14
|
+
Rhoconnect.bootstrap(get_testapp_path)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def app
|
|
18
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after(:each) do
|
|
22
|
+
Rhoconnect::Node.kill_process
|
|
23
|
+
Source.valid_doctypes.delete('tmpdoc'.to_sym)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should load settings for model" do
|
|
27
|
+
@s = Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id})
|
|
28
|
+
@s.poll_interval.should == 100
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should call js model method explicitly" do
|
|
32
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
33
|
+
res = js.login
|
|
34
|
+
res.should == "success"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should print warning if model function not found" do
|
|
38
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
39
|
+
res = js.foo
|
|
40
|
+
res.should == "foo method not defined for JsSample"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should call currentUser from model" do
|
|
44
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
45
|
+
res = js.getUser
|
|
46
|
+
res.should == 'testuser'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should call stashResult from model" do
|
|
50
|
+
data = { '0' => {'name' => '0'}, '1' => {'name' => '1'} }
|
|
51
|
+
Source.define_valid_doctypes(['tmpdoc'.to_sym])
|
|
52
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
53
|
+
js.inject_tmpdoc('tmpdoc')
|
|
54
|
+
js.testStashResult
|
|
55
|
+
js.get_data('tmpdoc').should == data
|
|
56
|
+
end
|
|
18
57
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
58
|
+
it "should test non-nil result from query" do
|
|
59
|
+
data = {'1' => {'name' => 'iPhone'}}
|
|
60
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
61
|
+
js.do_query(test_non_hash: true)
|
|
62
|
+
js.get_data(:md).should == {}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should call getData for a model" do
|
|
66
|
+
data = {'1' => {'name' => 'iPhone'}}
|
|
67
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
68
|
+
js.do_query
|
|
69
|
+
js.testGetModelData.should == data
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should call partitionName for a model" do
|
|
73
|
+
JsSample.partition_name('testuser').should == 'testuser_partition'
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "exceptions" do
|
|
77
|
+
it "should raise ruby Rhoconnect::Model::Exception" do
|
|
78
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
79
|
+
lambda {
|
|
80
|
+
js.testRaiseException
|
|
81
|
+
}.should raise_error(Rhoconnect::Model::Exception, /some custom message/)
|
|
22
82
|
end
|
|
23
83
|
|
|
24
|
-
it "should
|
|
25
|
-
|
|
26
|
-
|
|
84
|
+
it "should raise ruby Rhoconnect::Model::LoginException" do
|
|
85
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
86
|
+
lambda {
|
|
87
|
+
js.testRaiseLoginException
|
|
88
|
+
}.should raise_error(Rhoconnect::Model::LoginException, /some login message/)
|
|
27
89
|
end
|
|
28
90
|
|
|
29
|
-
it "should
|
|
91
|
+
it "should raise ruby Rhoconnect::Model::LogoffException" do
|
|
30
92
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
31
|
-
|
|
32
|
-
|
|
93
|
+
lambda {
|
|
94
|
+
js.testRaiseLogoffException
|
|
95
|
+
}.should raise_error(Rhoconnect::Model::LogoffException, /some logoff message/)
|
|
33
96
|
end
|
|
34
97
|
|
|
35
|
-
it "should
|
|
98
|
+
it "should raise ruby Rhoconnect::Model::ServerTimeoutException" do
|
|
36
99
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
37
|
-
|
|
38
|
-
|
|
100
|
+
lambda {
|
|
101
|
+
js.testRaiseTimeoutException
|
|
102
|
+
}.should raise_error(Rhoconnect::Model::ServerTimeoutException, /some timeout message/)
|
|
39
103
|
end
|
|
40
104
|
|
|
41
|
-
it "should
|
|
105
|
+
it "should raise ruby Rhoconnect::Model::ServerErrorException" do
|
|
42
106
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
43
|
-
|
|
44
|
-
|
|
107
|
+
lambda {
|
|
108
|
+
js.testRaiseErrorException
|
|
109
|
+
}.should raise_error(Rhoconnect::Model::ServerErrorException, /some error message/)
|
|
45
110
|
end
|
|
46
111
|
|
|
47
|
-
it "should
|
|
48
|
-
data = { '0' => {'name' => '0'}, '1' => {'name' => '1'} }
|
|
49
|
-
Source.define_valid_doctypes(['tmpdoc'.to_sym])
|
|
112
|
+
it "should raise ruby Rhoconnect::Model::ObjectConflictErrorException" do
|
|
50
113
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
114
|
+
lambda {
|
|
115
|
+
js.testRaiseConflictException
|
|
116
|
+
}.should raise_error(Rhoconnect::Model::ObjectConflictErrorException, /some object conflict message/)
|
|
54
117
|
end
|
|
55
118
|
|
|
56
|
-
it "should
|
|
57
|
-
data = {'1' => {'name' => 'iPhone'}}
|
|
119
|
+
it "should raise an exception during a regular adapter method" do
|
|
58
120
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
59
|
-
|
|
60
|
-
|
|
121
|
+
lambda {
|
|
122
|
+
js.do_query(raise_an_error: true)
|
|
123
|
+
}.should raise_error(Rhoconnect::Model::ServerErrorException, /query error occured/)
|
|
61
124
|
end
|
|
125
|
+
end
|
|
62
126
|
|
|
63
|
-
|
|
64
|
-
|
|
127
|
+
context "Store" do
|
|
128
|
+
it "should call getValue" do
|
|
129
|
+
Store.put_value('foo', 'bar')
|
|
65
130
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
66
|
-
js.
|
|
67
|
-
|
|
131
|
+
res = js.testGetValue
|
|
132
|
+
res.should == 'bar'
|
|
68
133
|
end
|
|
69
134
|
|
|
70
|
-
it "should call
|
|
71
|
-
JsSample.
|
|
135
|
+
it "should call putValue" do
|
|
136
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
137
|
+
js.testPutValue('foo', 'baz')
|
|
138
|
+
Store.get_value('foo').should == 'baz'
|
|
72
139
|
end
|
|
73
140
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "should raise ruby Rhoconnect::Model::LoginException" do
|
|
83
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
84
|
-
lambda {
|
|
85
|
-
js.testRaiseLoginException
|
|
86
|
-
}.should raise_error(Rhoconnect::Model::LoginException, /some login message/)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should raise ruby Rhoconnect::Model::LogoffException" do
|
|
90
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
91
|
-
lambda {
|
|
92
|
-
js.testRaiseLogoffException
|
|
93
|
-
}.should raise_error(Rhoconnect::Model::LogoffException, /some logoff message/)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should raise ruby Rhoconnect::Model::ServerTimeoutException" do
|
|
97
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
98
|
-
lambda {
|
|
99
|
-
js.testRaiseTimeoutException
|
|
100
|
-
}.should raise_error(Rhoconnect::Model::ServerTimeoutException, /some timeout message/)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "should raise ruby Rhoconnect::Model::ServerErrorException" do
|
|
104
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
105
|
-
lambda {
|
|
106
|
-
js.testRaiseErrorException
|
|
107
|
-
}.should raise_error(Rhoconnect::Model::ServerErrorException, /some error message/)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should raise ruby Rhoconnect::Model::ObjectConflictErrorException" do
|
|
111
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
112
|
-
lambda {
|
|
113
|
-
js.testRaiseConflictException
|
|
114
|
-
}.should raise_error(Rhoconnect::Model::ObjectConflictErrorException, /some object conflict message/)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "should raise an exception during a regular adapter method" do
|
|
118
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
119
|
-
lambda {
|
|
120
|
-
js.do_query(raise_an_error: true)
|
|
121
|
-
}.should raise_error(Rhoconnect::Model::ServerErrorException, /query error occured/)
|
|
122
|
-
end
|
|
141
|
+
it "should call getData" do
|
|
142
|
+
data = {'1' => {'name' => 'iPhone'}}
|
|
143
|
+
Store.put_data('foo', data)
|
|
144
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
145
|
+
res = js.testGetData
|
|
146
|
+
res.should == data
|
|
123
147
|
end
|
|
124
148
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
res.should == 'bar'
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
it "should call putValue" do
|
|
134
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
135
|
-
js.testPutValue('foo', 'baz')
|
|
136
|
-
Store.get_value('foo').should == 'baz'
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "should call getData" do
|
|
140
|
-
data = {'1' => {'name' => 'iPhone'}}
|
|
141
|
-
Store.put_data('foo', data)
|
|
142
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
143
|
-
res = js.testGetData
|
|
144
|
-
res.should == data
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it "should call putData" do
|
|
148
|
-
data = {'1' => {'name' => 'iPhone'}}
|
|
149
|
-
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
150
|
-
res = js.testPutData('foo', data)
|
|
151
|
-
Store.get_data('foo').should == data
|
|
152
|
-
end
|
|
149
|
+
it "should call putData" do
|
|
150
|
+
data = {'1' => {'name' => 'iPhone'}}
|
|
151
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
|
152
|
+
res = js.testPutData('foo', data)
|
|
153
|
+
Store.get_data('foo').should == data
|
|
153
154
|
end
|
|
154
155
|
end
|
|
155
156
|
end
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'perf_spec_helper')
|
|
2
2
|
|
|
3
3
|
describe "BulkData Performance" do
|
|
4
|
-
|
|
5
|
-
before(:each) do
|
|
6
|
-
basedir = File.join(File.dirname(__FILE__),'..','apps','rhotestapp')
|
|
7
|
-
Rhoconnect.bootstrap(basedir) do |rhoconnect|
|
|
8
|
-
rhoconnect.vendor_directory = File.join(basedir,'..','vendor')
|
|
9
|
-
end
|
|
10
|
-
end
|
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
before(:each) do
|
|
7
|
+
basedir = File.join(File.dirname(__FILE__),'..','apps','rhotestapp')
|
|
8
|
+
Rhoconnect.bootstrap(basedir) do |rhoconnect|
|
|
9
|
+
rhoconnect.vendor_directory = File.join(basedir,'..','vendor')
|
|
14
10
|
end
|
|
11
|
+
end
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
start = lap_timer('generate data',start)
|
|
20
|
-
set_state('test_db_storage' => @data)
|
|
21
|
-
start = lap_timer('set_state masterdoc',start)
|
|
22
|
-
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
|
23
|
-
:state => :inprogress,
|
|
24
|
-
:app_id => @a.id,
|
|
25
|
-
:user_id => @u.id,
|
|
26
|
-
:sources => [@s_fields[:name]])
|
|
27
|
-
do_bulk_data_job("data_name" => data.name)
|
|
28
|
-
lap_timer('BulkDataJob.perform duration',start)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
13
|
+
after(:each) do
|
|
14
|
+
delete_data_directory
|
|
15
|
+
end
|
|
31
16
|
|
|
17
|
+
it "should generate sqlite bulk data for 1000 objects (6000 attributes)" do
|
|
18
|
+
start = start_timer
|
|
19
|
+
@data = get_test_data(1000)
|
|
20
|
+
start = lap_timer('generate data',start)
|
|
21
|
+
set_state('test_db_storage' => @data)
|
|
22
|
+
start = lap_timer('set_state masterdoc',start)
|
|
23
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
|
24
|
+
:state => :inprogress,
|
|
25
|
+
:app_id => @a.id,
|
|
26
|
+
:user_id => @u.id,
|
|
27
|
+
:sources => [@s_fields[:name]])
|
|
28
|
+
do_bulk_data_job("data_name" => data.name)
|
|
29
|
+
lap_timer('BulkDataJob.perform duration',start)
|
|
30
|
+
end
|
|
32
31
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
|
2
1
|
require 'ffaker'
|
|
2
|
+
require_relative '../spec_helper'
|
|
3
3
|
|
|
4
4
|
def get_test_data(num=1000)
|
|
5
|
-
file = File.join(
|
|
5
|
+
file = File.join(SPEC_PATH, "testdata","#{num}-data.txt")
|
|
6
6
|
data = nil
|
|
7
7
|
if File.exists?(file)
|
|
8
8
|
data = open(file, 'r') {|f| Marshal.load(f)}
|
|
@@ -17,12 +17,12 @@ end
|
|
|
17
17
|
|
|
18
18
|
private
|
|
19
19
|
|
|
20
|
-
PREFIX = ["Account", "Administrative", "Advertising", "Assistant", "Banking", "Business Systems",
|
|
21
|
-
"Computer", "Distribution", "IT", "Electronics", "Environmental", "Financial", "General", "Head",
|
|
22
|
-
"Laboratory", "Maintenance", "Medical", "Production", "Quality Assurance", "Software", "Technical",
|
|
20
|
+
PREFIX = ["Account", "Administrative", "Advertising", "Assistant", "Banking", "Business Systems",
|
|
21
|
+
"Computer", "Distribution", "IT", "Electronics", "Environmental", "Financial", "General", "Head",
|
|
22
|
+
"Laboratory", "Maintenance", "Medical", "Production", "Quality Assurance", "Software", "Technical",
|
|
23
23
|
"Chief", "Senior"] unless defined? PREFIX
|
|
24
|
-
SUFFIX = ["Clerk", "Analyst", "Manager", "Supervisor", "Plant Manager", "Mechanic", "Technician", "Engineer",
|
|
25
|
-
"Director", "Superintendent", "Specialist", "Technologist", "Estimator", "Scientist", "Foreman", "Nurse",
|
|
24
|
+
SUFFIX = ["Clerk", "Analyst", "Manager", "Supervisor", "Plant Manager", "Mechanic", "Technician", "Engineer",
|
|
25
|
+
"Director", "Superintendent", "Specialist", "Technologist", "Estimator", "Scientist", "Foreman", "Nurse",
|
|
26
26
|
"Worker", "Helper", "Intern", "Sales", "Mechanic", "Planner", "Recruiter", "Officer", "Superintendent",
|
|
27
27
|
"Vice President", "Buyer", "Production Supervisor", "Chef", "Accountant", "Executive"] unless defined? SUFFIX
|
|
28
28
|
|
|
@@ -1,152 +1,152 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'perf_spec_helper')
|
|
2
2
|
|
|
3
3
|
describe "Rhoconnect Performance" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
|
5
|
+
|
|
6
|
+
it "should process get/put/delete for 10000 records (60000 elements)" do
|
|
7
|
+
@data = get_test_data(10000)
|
|
8
|
+
start = start_timer
|
|
9
|
+
Store.put_data('mdoc',@data).should == true
|
|
10
|
+
start = lap_timer('put_data duration',start)
|
|
11
|
+
Store.get_data('mdoc').should == @data
|
|
12
|
+
start = lap_timer('get_data duration',start)
|
|
13
|
+
Store.rename('mdoc','mdoc_copy')
|
|
14
|
+
start = lap_timer("rename doc duration", start)
|
|
15
|
+
Store.clone('mdoc_copy','mdoc_copy1')
|
|
16
|
+
start = lap_timer("clone doc duration", start)
|
|
17
|
+
Store.delete_objects('mdoc_copy',@data.keys[0,2])
|
|
18
|
+
start = lap_timer("delete_objects duration", start)
|
|
19
|
+
Store.delete_data('mdoc_copy1',@data)
|
|
20
|
+
start = lap_timer("delete_data duration", start)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should process update_objects in a set of 10000 records (60000 elements)" do
|
|
24
|
+
@data = get_test_data(10000)
|
|
25
|
+
updated_key = @data.keys[21]
|
|
26
|
+
@update_data = {}
|
|
27
|
+
@update_data[updated_key] = @data[updated_key].clone
|
|
28
|
+
@update_data[updated_key]['Phone'] = 'updated phone SADD'
|
|
29
|
+
@update_data[updated_key]['Phone1'] = 'updated phone SREM and SADD'
|
|
30
|
+
expected = @data.clone
|
|
31
|
+
expected.merge!(@update_data)
|
|
32
|
+
|
|
33
|
+
Store.put_data('mdoc',@data).should == true
|
|
34
|
+
start = start_timer
|
|
35
|
+
Store.update_objects('mdoc', @update_data)
|
|
36
|
+
lap_timer("update_objects duration", start)
|
|
37
|
+
Store.get_data('mdoc').should == expected
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should process 1000 update_objects in a set of 10000 records (60000 elements)" do
|
|
41
|
+
@data = get_test_data(10000)
|
|
42
|
+
updated_keys = @data.keys[2001..3000]
|
|
43
|
+
@update_data = {}
|
|
44
|
+
updated_keys.each do |updated_key|
|
|
26
45
|
@update_data[updated_key] = @data[updated_key].clone
|
|
27
46
|
@update_data[updated_key]['Phone'] = 'updated phone SADD'
|
|
28
47
|
@update_data[updated_key]['Phone1'] = 'updated phone SREM and SADD'
|
|
29
|
-
expected = @data.clone
|
|
30
|
-
expected.merge!(@update_data)
|
|
31
|
-
|
|
32
|
-
Store.put_data('mdoc',@data).should == true
|
|
33
|
-
start = start_timer
|
|
34
|
-
Store.update_objects('mdoc', @update_data)
|
|
35
|
-
lap_timer("update_objects duration", start)
|
|
36
|
-
Store.get_data('mdoc').should == expected
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should process 1000 update_objects in a set of 10000 records (60000 elements)" do
|
|
40
|
-
@data = get_test_data(10000)
|
|
41
|
-
updated_keys = @data.keys[2001..3000]
|
|
42
|
-
@update_data = {}
|
|
43
|
-
updated_keys.each do |updated_key|
|
|
44
|
-
@update_data[updated_key] = @data[updated_key].clone
|
|
45
|
-
@update_data[updated_key]['Phone'] = 'updated phone SADD'
|
|
46
|
-
@update_data[updated_key]['Phone1'] = 'updated phone SREM and SADD'
|
|
47
|
-
end
|
|
48
|
-
expected = @data.dup
|
|
49
|
-
expected.merge!(@update_data)
|
|
50
|
-
|
|
51
|
-
Store.put_data('mdoc',@data).should == true
|
|
52
|
-
start = start_timer
|
|
53
|
-
Store.update_objects('mdoc', @update_data)
|
|
54
|
-
lap_timer("update_objects duration", start)
|
|
55
|
-
|
|
56
|
-
Store.get_data('mdoc').should == expected
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should process single attribute diff for 10000-record doc" do
|
|
60
|
-
@data = get_test_data(10000)
|
|
61
|
-
@data1 = get_test_data(10000)
|
|
62
|
-
@data1['950']['Phone1'] = 'This is changed'
|
|
63
|
-
expected = {'950' => {'Phone1' => 'This is changed'}}
|
|
64
|
-
@s.put_data(:md,@data1).should == true
|
|
65
|
-
@c.put_data(:cd,@data).should == true
|
|
66
|
-
start = start_timer
|
|
67
|
-
cs = create_sync_handler
|
|
68
|
-
token,progress_count,total_count,res = cs.send_new_page
|
|
69
|
-
lap_timer('compute_page duration', start)
|
|
70
|
-
@c.get_data(:page).should == expected
|
|
71
|
-
res['insert'].should == expected
|
|
72
|
-
res['delete'].should == {'950' => {'Phone1' => @data['950']['Phone1']}}
|
|
73
48
|
end
|
|
49
|
+
expected = @data.dup
|
|
50
|
+
expected.merge!(@update_data)
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
expected = {'950' => {'Phone1' => 'This is changed'}}
|
|
80
|
-
@s.put_data(:md,@data1).should == true
|
|
81
|
-
@c.put_data(:cd,@data).should == true
|
|
82
|
-
start = start_timer
|
|
83
|
-
cs = create_sync_handler
|
|
84
|
-
token,progress_count,total_count,res = cs.send_new_page_bruteforce
|
|
85
|
-
lap_timer('compute_page duration', start)
|
|
86
|
-
@c.get_data(:page).should == expected
|
|
87
|
-
res['insert'].should == expected
|
|
88
|
-
res['delete'].should == {'950' => {'Phone1' => @data['950']['Phone1']}}
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should process full-sync for 5000-record doc" do
|
|
92
|
-
@data = get_test_data(5000)
|
|
93
|
-
@s.put_data(:md,@data).should == true
|
|
94
|
-
start = start_timer
|
|
95
|
-
params = { :p_size => 5000 }
|
|
96
|
-
cs = create_sync_handler params
|
|
97
|
-
token,progress_count,total_count,res = cs.send_new_page
|
|
98
|
-
lap_timer('compute_page duration', start)
|
|
99
|
-
@c.get_data(:page).should == @data
|
|
100
|
-
res['insert'].should == @data
|
|
101
|
-
res['delete'].should == nil
|
|
102
|
-
end
|
|
52
|
+
Store.put_data('mdoc',@data).should == true
|
|
53
|
+
start = start_timer
|
|
54
|
+
Store.update_objects('mdoc', @update_data)
|
|
55
|
+
lap_timer("update_objects duration", start)
|
|
103
56
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@s.put_data(:md,@data).should == true
|
|
107
|
-
start = start_timer
|
|
108
|
-
params = { :p_size => 5000 }
|
|
109
|
-
cs = create_sync_handler params
|
|
110
|
-
token,progress_count,total_count,res = cs.send_new_page_bruteforce
|
|
111
|
-
lap_timer('compute_page duration', start)
|
|
112
|
-
@c.get_data(:page).should == @data
|
|
113
|
-
res['insert'].should == @data
|
|
114
|
-
res['delete'].should == nil
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "should process worst-case sync scenario there every attrib of every object is changed for 5000-record doc" do
|
|
118
|
-
@data = generate_fake_data(5000,true)
|
|
119
|
-
sleep(1.5)
|
|
120
|
-
@data1 = generate_fake_data(5000,true)
|
|
121
|
-
@s.put_data(:md,@data).should == true
|
|
122
|
-
@c.put_data(:cd,@data1).should == true
|
|
123
|
-
start = start_timer
|
|
124
|
-
params = { :p_size => 5000 }
|
|
125
|
-
cs = create_sync_handler params
|
|
126
|
-
token,progress_count,total_count,res = cs.send_new_page
|
|
127
|
-
lap_timer('compute_page duration', start)
|
|
128
|
-
@c.get_data(:page).should == @data
|
|
129
|
-
@c.get_data(:cd).should == @s.get_data(:md)
|
|
130
|
-
res['insert'].should == @data
|
|
131
|
-
res['delete'].should == @data1
|
|
132
|
-
end
|
|
57
|
+
Store.get_data('mdoc').should == expected
|
|
58
|
+
end
|
|
133
59
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
60
|
+
it "should process single attribute diff for 10000-record doc" do
|
|
61
|
+
@data = get_test_data(10000)
|
|
62
|
+
@data1 = get_test_data(10000)
|
|
63
|
+
@data1['950']['Phone1'] = 'This is changed'
|
|
64
|
+
expected = {'950' => {'Phone1' => 'This is changed'}}
|
|
65
|
+
@s.put_data(:md,@data1).should == true
|
|
66
|
+
@c.put_data(:cd,@data).should == true
|
|
67
|
+
start = start_timer
|
|
68
|
+
cs = create_sync_handler
|
|
69
|
+
token,progress_count,total_count,res = cs.send_new_page
|
|
70
|
+
lap_timer('compute_page duration', start)
|
|
71
|
+
@c.get_data(:page).should == expected
|
|
72
|
+
res['insert'].should == expected
|
|
73
|
+
res['delete'].should == {'950' => {'Phone1' => @data['950']['Phone1']}}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should process single attribute diff for 10000-record doc using brute-force approach" do
|
|
77
|
+
@data = get_test_data(10000)
|
|
78
|
+
@data1 = get_test_data(10000)
|
|
79
|
+
@data1['950']['Phone1'] = 'This is changed'
|
|
80
|
+
expected = {'950' => {'Phone1' => 'This is changed'}}
|
|
81
|
+
@s.put_data(:md,@data1).should == true
|
|
82
|
+
@c.put_data(:cd,@data).should == true
|
|
83
|
+
start = start_timer
|
|
84
|
+
cs = create_sync_handler
|
|
85
|
+
token,progress_count,total_count,res = cs.send_new_page_bruteforce
|
|
86
|
+
lap_timer('compute_page duration', start)
|
|
87
|
+
@c.get_data(:page).should == expected
|
|
88
|
+
res['insert'].should == expected
|
|
89
|
+
res['delete'].should == {'950' => {'Phone1' => @data['950']['Phone1']}}
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should process full-sync for 5000-record doc" do
|
|
93
|
+
@data = get_test_data(5000)
|
|
94
|
+
@s.put_data(:md,@data).should == true
|
|
95
|
+
start = start_timer
|
|
96
|
+
params = { :p_size => 5000 }
|
|
97
|
+
cs = create_sync_handler params
|
|
98
|
+
token,progress_count,total_count,res = cs.send_new_page
|
|
99
|
+
lap_timer('compute_page duration', start)
|
|
100
|
+
@c.get_data(:page).should == @data
|
|
101
|
+
res['insert'].should == @data
|
|
102
|
+
res['delete'].should == nil
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "should process full-sync for 5000-record doc using brute-force approach" do
|
|
106
|
+
@data = get_test_data(5000)
|
|
107
|
+
@s.put_data(:md,@data).should == true
|
|
108
|
+
start = start_timer
|
|
109
|
+
params = { :p_size => 5000 }
|
|
110
|
+
cs = create_sync_handler params
|
|
111
|
+
token,progress_count,total_count,res = cs.send_new_page_bruteforce
|
|
112
|
+
lap_timer('compute_page duration', start)
|
|
113
|
+
@c.get_data(:page).should == @data
|
|
114
|
+
res['insert'].should == @data
|
|
115
|
+
res['delete'].should == nil
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "should process worst-case sync scenario there every attrib of every object is changed for 5000-record doc" do
|
|
119
|
+
@data = generate_fake_data(5000,true)
|
|
120
|
+
sleep(1.5)
|
|
121
|
+
@data1 = generate_fake_data(5000,true)
|
|
122
|
+
@s.put_data(:md,@data).should == true
|
|
123
|
+
@c.put_data(:cd,@data1).should == true
|
|
124
|
+
start = start_timer
|
|
125
|
+
params = { :p_size => 5000 }
|
|
126
|
+
cs = create_sync_handler params
|
|
127
|
+
token,progress_count,total_count,res = cs.send_new_page
|
|
128
|
+
lap_timer('compute_page duration', start)
|
|
129
|
+
@c.get_data(:page).should == @data
|
|
130
|
+
@c.get_data(:cd).should == @s.get_data(:md)
|
|
131
|
+
res['insert'].should == @data
|
|
132
|
+
res['delete'].should == @data1
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "should process worst-case sync scenario there every attrib of every object is changed for 5000-record doc using brute-force approach" do
|
|
136
|
+
@data = generate_fake_data(5000,true)
|
|
137
|
+
sleep(1.5)
|
|
138
|
+
@data1 = generate_fake_data(5000,true)
|
|
139
|
+
@s.put_data(:md,@data).should == true
|
|
140
|
+
@c.put_data(:cd,@data1).should == true
|
|
141
|
+
start = start_timer
|
|
142
|
+
params = { :p_size => 5000 }
|
|
143
|
+
cs = create_sync_handler params
|
|
144
|
+
token,progress_count,total_count,res = cs.send_new_page_bruteforce
|
|
145
|
+
lap_timer('compute_page duration', start)
|
|
146
|
+
@c.get_data(:page).should == @data
|
|
147
|
+
@c.get_data(:cd).should == @s.get_data(:md)
|
|
148
|
+
res['insert'].should == @data
|
|
149
|
+
res['delete'].should == @data1
|
|
150
150
|
end
|
|
151
151
|
|
|
152
152
|
# helper
|
|
@@ -155,5 +155,4 @@ describe "Rhoconnect Performance" do
|
|
|
155
155
|
@model = Rhoconnect::Model::Base.create(@s)
|
|
156
156
|
Rhoconnect::Handler::Query::Runner.new(@model, @c, rh, params)
|
|
157
157
|
end
|
|
158
|
-
|
|
159
158
|
end
|