rhoconnect 3.2.1 → 3.3.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +24 -5
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -20
- data/bench/benchapp/Gemfile +17 -20
- data/bench/benchapp/config.ru +2 -2
- data/bench/benchapp/settings/settings.yml +3 -3
- data/bench/blobapp/Gemfile +16 -13
- data/bench/blobapp/config.ru +2 -2
- data/bench/blobapp/settings/settings.yml +5 -3
- data/bench/lib/bench.rb +35 -32
- data/bench/lib/bench/session.rb +9 -1
- data/bench/scripts/blob_cud_script.rb +13 -17
- data/bench/scripts/cud_script.rb +11 -12
- data/bench/scripts/helpers.rb +5 -7
- data/bench/scripts/query_md_script.rb +18 -12
- data/bench/scripts/query_only_script.rb +19 -11
- data/bench/scripts/query_script.rb +17 -13
- data/bench/scripts/test_query_script.rb +46 -17
- data/bench/scripts/test_source_script.rb +7 -7
- data/commands/commands/dtach_commands/dtach_install.rb +44 -16
- data/commands/commands/rhoconnect/spec.rb +13 -9
- data/commands/commands/rhoconnect/version.rb +6 -0
- data/commands/execute.rb +10 -6
- data/doc/deploying.txt +75 -13
- data/doc/install.txt +3 -3
- data/doc/push-client-setup.txt +1 -1
- data/doc/rest-api.txt +4 -23
- data/doc/rhoconnect-redis-stack.txt +26 -7
- data/doc/settings.txt +9 -3
- data/examples/simple/Gemfile +3 -1
- data/examples/simple/application.rb +5 -0
- data/examples/simple/config.ru +3 -2
- data/examples/simple/my_server.rb +14 -0
- data/examples/simple/settings/settings.yml +1 -0
- data/generators/templates/application/Gemfile +4 -4
- data/generators/templates/application/application.rb +4 -0
- data/generators/templates/application/settings/settings.yml +4 -1
- data/installer/unix-like/create_texts.rb +39 -1
- data/installer/unix-like/rho_connect_install_constants.rb +1 -1
- data/installer/utils/package_upload/repos.rake +7 -5
- data/lib/rhoconnect.rb +3 -2
- data/lib/rhoconnect/api/app/ans_login.rb +3 -0
- data/lib/rhoconnect/api/app/bulk_data.rb +6 -0
- data/lib/rhoconnect/api/{source → app}/fast_delete.rb +1 -1
- data/lib/rhoconnect/api/{source → app}/fast_insert.rb +2 -2
- data/lib/rhoconnect/api/{source → app}/fast_update.rb +2 -2
- data/lib/rhoconnect/api/app/login.rb +5 -0
- data/lib/rhoconnect/api/{source → app}/push_deletes.rb +1 -1
- data/lib/rhoconnect/api/{source → app}/push_objects.rb +1 -1
- data/lib/rhoconnect/api/app/query.rb +4 -0
- data/lib/rhoconnect/api/app/queue_updates.rb +94 -0
- data/lib/rhoconnect/api/app/search.rb +4 -0
- data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -0
- data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/client/create.rb +7 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +2 -1
- data/lib/rhoconnect/api/client/list_client_docs.rb +2 -1
- data/lib/rhoconnect/api/client/register.rb +12 -0
- data/lib/rhoconnect/api/client/reset.rb +5 -0
- data/lib/rhoconnect/api/{source → readstate}/set_refresh_time.rb +2 -1
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -2
- data/lib/rhoconnect/api/source/list_sources.rb +2 -1
- data/lib/rhoconnect/api/source/update_source_params.rb +3 -3
- data/lib/rhoconnect/api/store/get_db_doc.rb +4 -0
- data/lib/rhoconnect/api/store/set_db_doc.rb +7 -0
- data/lib/rhoconnect/api/system/get_adapter.rb +4 -0
- data/lib/rhoconnect/api/{admin → system}/get_license_info.rb +2 -1
- data/lib/rhoconnect/api/system/login.rb +15 -0
- data/lib/rhoconnect/api/{admin → system}/reset.rb +3 -2
- data/lib/rhoconnect/api/system/save_adapter.rb +4 -0
- data/lib/rhoconnect/api/{admin → system}/stats.rb +2 -1
- data/lib/rhoconnect/api/user/create_user.rb +2 -2
- data/lib/rhoconnect/api/user/delete_client.rb +6 -0
- data/lib/rhoconnect/api/user/delete_user.rb +2 -1
- data/lib/rhoconnect/api/user/list_clients.rb +4 -0
- data/lib/rhoconnect/api/user/list_source_docs.rb +11 -0
- data/lib/rhoconnect/api/user/list_users.rb +1 -1
- data/lib/rhoconnect/api/user/ping.rb +7 -0
- data/lib/rhoconnect/api/user/show_user.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +3 -2
- data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -0
- data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -0
- data/lib/rhoconnect/app.rb +12 -2
- data/lib/rhoconnect/async.rb +6 -10
- data/lib/rhoconnect/bulk_data/bulk_data.rb +4 -4
- data/lib/rhoconnect/client.rb +10 -9
- data/lib/rhoconnect/client_sync.rb +24 -19
- data/lib/rhoconnect/document.rb +18 -4
- data/lib/rhoconnect/graph_helper.rb +4 -2
- data/lib/rhoconnect/jobs/bulk_data_job.rb +1 -1
- data/lib/rhoconnect/jobs/ping_job.rb +39 -29
- data/lib/rhoconnect/middleware/admin_user.rb +23 -0
- data/lib/rhoconnect/middleware/body_content_type_parser.rb +35 -0
- data/lib/rhoconnect/{cors.rb → middleware/cors.rb} +1 -0
- data/lib/rhoconnect/middleware/current_app.rb +16 -0
- data/lib/rhoconnect/middleware/current_request.rb +16 -0
- data/lib/rhoconnect/middleware/current_user.rb +17 -0
- data/lib/rhoconnect/middleware/helpers.rb +105 -0
- data/lib/rhoconnect/middleware/login_required.rb +22 -0
- data/lib/rhoconnect/{stats/middleware.rb → middleware/stats.rb} +5 -3
- data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +58 -0
- data/lib/rhoconnect/ping.rb +1 -0
- data/lib/rhoconnect/ping/apple.rb +18 -16
- data/lib/rhoconnect/ping/blackberry.rb +9 -9
- data/lib/rhoconnect/ping/rhoconnect_push.rb +45 -0
- data/lib/rhoconnect/server.rb +98 -91
- data/lib/rhoconnect/source.rb +5 -1
- data/lib/rhoconnect/source_sync.rb +4 -3
- data/lib/rhoconnect/stats/record.rb +15 -15
- data/lib/rhoconnect/store.rb +253 -75
- data/lib/rhoconnect/tasks.rb +3 -3
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect/web-console/controllers/admins.js +1 -14
- data/lib/rhoconnect/web-console/models/adapter.js +18 -8
- data/lib/rhoconnect/web-console/models/client.js +15 -9
- data/lib/rhoconnect/web-console/models/doc.js +7 -11
- data/lib/rhoconnect/web-console/models/session.js +5 -2
- data/lib/rhoconnect/web-console/models/source.js +55 -36
- data/lib/rhoconnect/web-console/models/user.js +20 -11
- data/lib/rhoconnect/web-console/public/backbone.js +8 -2
- data/lib/rhoconnect/web-console/templates/index.erb +11 -5
- data/lib/rhoconnect/web-console/views/doc.js +6 -8
- data/lib/rhoconnect/web-console/views/edit_user.js +6 -3
- data/lib/rhoconnect/web-console/views/home.js +98 -25
- data/lib/rhoconnect/web-console/views/index.js +1 -1
- data/lib/rhoconnect/web-console/views/new_ping.js +6 -3
- data/lib/rhoconnect/web-console/views/server_doc.js +12 -4
- data/lib/rhoconnect/web-console/views/show_device.js +6 -3
- data/rhoconnect.gemspec +1 -2
- data/spec/api/{source → app}/fast_delete_spec.rb +4 -4
- data/spec/api/{source → app}/fast_insert_spec.rb +4 -4
- data/spec/api/{source → app}/fast_update_spec.rb +22 -6
- data/spec/api/{source → app}/push_deletes_spec.rb +2 -2
- data/spec/api/app/push_objects_spec.rb +45 -0
- data/spec/api/client/client_get_db_doc_spec.rb +31 -0
- data/spec/api/client/client_set_db_doc_spec.rb +14 -0
- data/spec/api/client/get_client_params_spec.rb +3 -2
- data/spec/api/client/list_client_docs_spec.rb +2 -2
- data/spec/api/{source → readstate}/set_refresh_time_spec.rb +15 -9
- data/spec/api/source/get_source_params_spec.rb +3 -2
- data/spec/api/source/list_sources_spec.rb +3 -9
- data/spec/api/source/update_source_params_spec.rb +4 -4
- data/spec/api/store/get_db_doc_spec.rb +32 -0
- data/spec/api/store/set_db_doc_spec.rb +43 -0
- data/spec/api/system/adapter_spec.rb +33 -0
- data/spec/api/{admin → system}/get_license_info_spec.rb +2 -5
- data/spec/api/{admin/get_api_token_spec.rb → system/login_spec.rb} +4 -11
- data/spec/api/{admin → system}/reset_spec.rb +2 -2
- data/spec/api/{admin → system}/stats_spec.rb +19 -13
- data/spec/api/user/create_user_spec.rb +15 -8
- data/spec/api/{client → user}/delete_client_spec.rb +3 -4
- data/spec/api/user/delete_user_spec.rb +33 -4
- data/spec/api/user/list_clients_spec.rb +30 -0
- data/spec/api/user/list_source_docs_spec.rb +35 -0
- data/spec/api/user/list_users_spec.rb +5 -6
- data/spec/api/{client → user}/ping_spec.rb +4 -6
- data/spec/api/user/show_user_spec.rb +14 -0
- data/spec/api/user/update_user_spec.rb +28 -10
- data/spec/api/user/user_get_db_doc_spec.rb +16 -0
- data/spec/api/user/user_set_db_doc_spec.rb +41 -0
- data/spec/apps/rhotestapp/application.rb +4 -0
- data/spec/apps/rhotestapp/settings/settings.yml +3 -1
- data/spec/bulk_data/bulk_data_spec.rb +13 -0
- data/spec/client_sync_spec.rb +41 -59
- data/spec/document_spec.rb +23 -0
- data/spec/javascripts/doc_view_spec.js +1 -1
- data/spec/javascripts/home_view_spec.js +10 -5
- data/spec/javascripts/index_view_spec.js +1 -1
- data/spec/jobs/ping_job_spec.rb +26 -0
- data/spec/perf/store_perf_spec.rb +1 -1
- data/spec/ping/android_spec.rb +0 -7
- data/spec/ping/apple_spec.rb +7 -0
- data/spec/ping/blackberry_spec.rb +10 -0
- data/spec/ping/rhoconnect_push_spec.rb +58 -0
- data/spec/server/cors_spec.rb +1 -1
- data/spec/server/server_spec.rb +152 -104
- data/spec/{stats/middleware_spec.rb → server/stats_spec.rb} +4 -5
- data/spec/server/x_domain_session_wrapper_spec.rb +3 -3
- data/spec/source_spec.rb +2 -2
- data/spec/source_sync_spec.rb +2 -0
- data/spec/spec_helper.rb +17 -3
- data/spec/stats/record_spec.rb +18 -19
- data/spec/store_spec.rb +51 -26
- data/spec/support/shared_examples.rb +4 -0
- data/spec/sync_states_spec.rb +2 -2
- metadata +104 -88
- data/bench/benchapp/Gemfile.lock +0 -87
- data/bench/blobapp/Gemfile.lock +0 -107
- data/bench/lib/testdata/5-data.txt +0 -8
- data/doc/release.txt +0 -41
- data/lib/rhoconnect/api/admin/get_api_token.rb +0 -14
- data/lib/rhoconnect/api/admin/login.rb +0 -6
- data/lib/rhoconnect/api/application/bulk_data.rb +0 -7
- data/lib/rhoconnect/api/application/clientcreate.rb +0 -8
- data/lib/rhoconnect/api/application/clientlogin.rb +0 -6
- data/lib/rhoconnect/api/application/clientregister.rb +0 -13
- data/lib/rhoconnect/api/application/clientreset.rb +0 -6
- data/lib/rhoconnect/api/application/query.rb +0 -7
- data/lib/rhoconnect/api/application/queue_updates.rb +0 -20
- data/lib/rhoconnect/api/application/search.rb +0 -6
- data/lib/rhoconnect/api/client/create_client.rb +0 -3
- data/lib/rhoconnect/api/client/delete_client.rb +0 -5
- data/lib/rhoconnect/api/client/list_clients.rb +0 -3
- data/lib/rhoconnect/api/client/ping.rb +0 -7
- data/lib/rhoconnect/api/source/get_adapter.rb +0 -3
- data/lib/rhoconnect/api/source/get_db_doc.rb +0 -7
- data/lib/rhoconnect/api/source/list_source_docs.rb +0 -10
- data/lib/rhoconnect/api/source/save_adapter.rb +0 -3
- data/lib/rhoconnect/api/source/set_db_doc.rb +0 -10
- data/lib/rhoconnect/api/source/upload_file.rb +0 -4
- data/lib/rhoconnect/body_content_type_parser.rb +0 -32
- data/lib/rhoconnect/x_domain_session_wrapper.rb +0 -53
- data/spec/api/admin/api_token_spec.rb +0 -13
- data/spec/api/client/create_client_spec.rb +0 -13
- data/spec/api/client/list_clients_spec.rb +0 -22
- data/spec/api/source/adapter_spec.rb +0 -29
- data/spec/api/source/get_db_doc_spec.rb +0 -21
- data/spec/api/source/list_source_docs_spec.rb +0 -25
- data/spec/api/source/push_objects_spec.rb +0 -27
- data/spec/api/source/set_db_doc_spec.rb +0 -32
- data/spec/api/source/upload_file_spec.rb +0 -26
@@ -15,12 +15,10 @@ Bench.config do |config|
|
|
15
15
|
config.set_server_state("test_db_storage:application:#{config.user_name}",{})
|
16
16
|
|
17
17
|
@create_objects = []
|
18
|
-
@create_count = 5
|
18
|
+
@create_count = 5
|
19
19
|
|
20
20
|
@users = Bench.get_bench_users(config.concurrency)
|
21
|
-
@users.each
|
22
|
-
Bench.create_user(u.user_name, u.password)
|
23
|
-
end
|
21
|
+
@users.each { |u| Bench.create_user(u.user_name, u.password) }
|
24
22
|
|
25
23
|
config.concurrency.times do |i|
|
26
24
|
@create_objects << []
|
@@ -38,31 +36,29 @@ Bench.config do |config|
|
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
41
|
-
|
42
39
|
Bench.test do |config, session|
|
43
40
|
sleep rand(10)
|
44
|
-
|
45
41
|
user = @users[session.thread_id]
|
46
|
-
session.post "clientlogin", "#{config.
|
42
|
+
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
47
43
|
{:login => user.user_name, :password => user.password}.to_json
|
48
44
|
end
|
45
|
+
|
49
46
|
sleep rand(10)
|
50
|
-
|
51
|
-
session.get "clientcreate", "#{config.base_url}/clientcreate"
|
47
|
+
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
52
48
|
session.client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
53
49
|
create_objs = @create_objects[session.thread_id][session.iteration]
|
54
|
-
body = { :cud => {:source_name => 'BlobAdapter',
|
55
|
-
:blob_fields => ['img_file-rhoblob'],
|
56
|
-
:create => create_objs, :version => 3}.to_json
|
50
|
+
body = { :cud => {:source_name => 'BlobAdapter',
|
51
|
+
:blob_fields => ['img_file-rhoblob'], :create => create_objs}.to_json
|
57
52
|
}
|
58
|
-
session.post "create-object", "#{config.
|
59
|
-
|
60
|
-
|
53
|
+
session.post "create-object", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}/queue_updates",
|
54
|
+
{:content_type => :json, 'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
55
|
+
body.merge!(Bench.get_image_data(create_objs)) # Add images to miltipart post
|
56
|
+
end
|
61
57
|
session.last_result.verify_code(200)
|
62
|
-
sleep rand(10)
|
63
58
|
|
59
|
+
sleep rand(10)
|
64
60
|
bench_log "#{session.log_prefix} User \"#{user.user_name}\": Loop to get available objects ..."
|
65
|
-
count = get_all_objects(current_line,config,session
|
61
|
+
count = get_all_objects(current_line, config, session, @expected_md, create_objs)
|
66
62
|
bench_log "#{session.log_prefix} User \"#{user.user_name}\": Got #{count} available objects ..."
|
67
63
|
end
|
68
64
|
|
data/bench/scripts/cud_script.rb
CHANGED
@@ -3,7 +3,7 @@ bench_log "Simulate creating multiple objects"
|
|
3
3
|
|
4
4
|
Bench.config do |config|
|
5
5
|
config.concurrency = 5
|
6
|
-
config.iterations = 2
|
6
|
+
config.iterations = 2
|
7
7
|
config.user_name = "benchuser"
|
8
8
|
config.password = "password"
|
9
9
|
config.adapter_name = 'MockAdapter'
|
@@ -38,25 +38,25 @@ end
|
|
38
38
|
|
39
39
|
Bench.test do |config,session|
|
40
40
|
sleep rand(10)
|
41
|
-
|
42
41
|
user = @users[session.thread_id]
|
43
|
-
session.post "clientlogin", "#{config.
|
42
|
+
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
44
43
|
{:login => user.user_name, :password => user.password}.to_json
|
45
|
-
end
|
44
|
+
end
|
46
45
|
sleep rand(10)
|
47
46
|
|
48
|
-
session.
|
47
|
+
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
49
48
|
session.client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
50
49
|
create_objs = @create_objects[session.thread_id][session.iteration]
|
51
|
-
session.post "create-object",
|
52
|
-
{
|
53
|
-
|
54
|
-
|
50
|
+
session.post "create-object",
|
51
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}/queue_updates",
|
52
|
+
{:content_type => :json, 'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
53
|
+
{:create => create_objs}.to_json
|
54
|
+
end
|
55
55
|
session.last_result.verify_code(200)
|
56
56
|
sleep rand(10)
|
57
57
|
|
58
58
|
bench_log "#{session.log_prefix} User \"#{user.user_name}\": Loop to get available objects ..."
|
59
|
-
|
59
|
+
count = get_all_objects(current_line,config,session,@expected_md,create_objs)
|
60
60
|
bench_log "#{session.log_prefix} User \"#{user.user_name}\": Got #{count} available objects ..."
|
61
61
|
end
|
62
62
|
|
@@ -84,8 +84,7 @@ Bench.verify do |config,sessions|
|
|
84
84
|
|
85
85
|
master_doc = {}
|
86
86
|
@users.each do |user|
|
87
|
-
user_doc = config.get_server_state(
|
88
|
-
source_docname(user.user_name, 'MockAdapter',:md))
|
87
|
+
user_doc = config.get_server_state(source_docname(user.user_name, 'MockAdapter',:md))
|
89
88
|
master_doc.merge!(user_doc)
|
90
89
|
end
|
91
90
|
Bench.verify_error = Bench.compare_and_log(@expected_md, master_doc, current_line)
|
data/bench/scripts/helpers.rb
CHANGED
@@ -64,11 +64,11 @@ module BenchHelpers
|
|
64
64
|
|
65
65
|
def current_line
|
66
66
|
caller(1)[0].to_s
|
67
|
-
end
|
67
|
+
end
|
68
68
|
|
69
69
|
def get_all_objects(caller,config,session,expected_md,create_objs=nil,timeout=10)
|
70
|
-
session.get "get-cud", "#{config.
|
71
|
-
{'
|
70
|
+
session.get "get-cud", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}" do
|
71
|
+
{'client_id' => session.client_id, 'p_size' => @datasize}
|
72
72
|
end
|
73
73
|
sleep rand(timeout)
|
74
74
|
token = JSON.parse(session.last_result.body)[1]['token']
|
@@ -82,10 +82,8 @@ module BenchHelpers
|
|
82
82
|
|
83
83
|
while token != '' do
|
84
84
|
sleep rand(timeout)
|
85
|
-
session.get "ack-cud", "#{config.
|
86
|
-
{
|
87
|
-
'client_id' => session.client_id,
|
88
|
-
'token' => token}
|
85
|
+
session.get "ack-cud", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}" do
|
86
|
+
{'client_id' => session.client_id, 'token' => token}
|
89
87
|
end
|
90
88
|
session.last_result.verify_code(200)
|
91
89
|
verify_count(session,caller+"\n"+current_line)
|
@@ -7,10 +7,11 @@ bench_log "Run sync session, forces source adapter query on every sync request"
|
|
7
7
|
@ack_token = "[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":%i},{\"total_count\":%i},{}]"
|
8
8
|
|
9
9
|
Bench.config do |config|
|
10
|
-
config.concurrency =
|
10
|
+
config.concurrency = 5
|
11
11
|
config.iterations = 2
|
12
12
|
config.user_name = "benchuser"
|
13
13
|
config.password = "password"
|
14
|
+
config.adapter_name = 'MockAdapter'
|
14
15
|
config.get_test_server
|
15
16
|
config.reset_app
|
16
17
|
config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
|
@@ -19,26 +20,31 @@ end
|
|
19
20
|
|
20
21
|
Bench.test do |config,session|
|
21
22
|
sleep rand(10)
|
22
|
-
session.post "clientlogin", "#{config.
|
23
|
+
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
23
24
|
{:login => config.user_name, :password => config.password}.to_json
|
24
|
-
end
|
25
|
+
end
|
26
|
+
|
25
27
|
sleep rand(10)
|
26
|
-
session.
|
28
|
+
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
27
29
|
client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
28
|
-
session.get "get-cud",
|
29
|
-
{
|
30
|
-
|
30
|
+
session.get "get-cud",
|
31
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
32
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
33
|
+
{'p_size' => @datasize}
|
34
|
+
end
|
35
|
+
|
31
36
|
sleep rand(10)
|
32
37
|
token = JSON.parse(session.last_result.body)[1]['token']
|
33
38
|
session.last_result.verify_body([{:version => 3},{:token => token},
|
34
39
|
{:count => @datasize},{:progress_count => 0},{:total_count => @datasize},
|
35
40
|
{:insert => @expected}].to_json)
|
41
|
+
|
36
42
|
sleep rand(10)
|
37
|
-
session.get "ack-cud",
|
38
|
-
{
|
39
|
-
|
40
|
-
'token' => token}
|
41
|
-
|
43
|
+
session.get "ack-cud",
|
44
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
45
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
46
|
+
{'token' => token}
|
47
|
+
end
|
42
48
|
session.last_result.verify_code(200)
|
43
49
|
session.last_result.verify_body([{:version => 3},{:token => ''},{:count => 0},
|
44
50
|
{:progress_count => @datasize},{:total_count => @datasize},{}].to_json)
|
@@ -13,38 +13,46 @@ Bench.config do |config|
|
|
13
13
|
config.iterations = 2
|
14
14
|
config.user_name = "benchuser"
|
15
15
|
config.password = "password"
|
16
|
+
config.adapter_name = 'MockAdapter'
|
16
17
|
config.get_test_server
|
17
18
|
config.reset_app
|
18
19
|
config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
|
19
20
|
config.reset_refresh_time('MockAdapter')
|
20
|
-
|
21
|
+
|
22
|
+
res = RestClient.post "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login",
|
21
23
|
{:login => config.user_name, :password => config.password}, :content_type => :json
|
22
24
|
res.cookies['rhoconnect_session'] = CGI.escape(res.cookies['rhoconnect_session'])
|
23
25
|
@cookies = res.cookies
|
26
|
+
|
24
27
|
(config.concurrency*config.iterations).times do |i|
|
25
|
-
create = RestClient.
|
26
|
-
|
28
|
+
create = RestClient.post "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients",
|
29
|
+
'', {:cookies => @cookies}
|
27
30
|
@clients << JSON.parse(create.body)['client']['client_id']
|
31
|
+
puts "Created client ##{i} ..."
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
Bench.test do |config,session|
|
32
36
|
client_id = @clients[session.thread_id*config.iterations+session.iteration]
|
33
37
|
session.cookies = @cookies
|
38
|
+
|
34
39
|
sleep rand(10)
|
35
|
-
session.get "get-cud", "#{config.
|
36
|
-
{'
|
37
|
-
|
40
|
+
session.get "get-cud", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
41
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
42
|
+
{'p_size' => @datasize}
|
43
|
+
end
|
44
|
+
|
38
45
|
token = JSON.parse(session.last_result.body)[1]['token']
|
39
46
|
session.last_result.verify_body([{:version => 3},{:token => token},
|
40
47
|
{:count => @datasize},{:progress_count => 0},{:total_count => @datasize},
|
41
48
|
{:insert => @expected}].to_json)
|
49
|
+
|
42
50
|
sleep rand(10)
|
43
|
-
session.get "ack-cud",
|
44
|
-
{
|
45
|
-
|
46
|
-
'token' => token}
|
47
|
-
|
51
|
+
session.get "ack-cud",
|
52
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
53
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
54
|
+
{'token' => token}
|
55
|
+
end
|
48
56
|
session.last_result.verify_code(200)
|
49
57
|
session.last_result.verify_body([{:version => 3},{:token => ''},{:count => 0},
|
50
58
|
{:progress_count => @datasize},{:total_count => @datasize},{}].to_json)
|
@@ -11,6 +11,7 @@ Bench.config do |config|
|
|
11
11
|
config.iterations = 2
|
12
12
|
config.user_name = "benchuser"
|
13
13
|
config.password = "password"
|
14
|
+
config.adapter_name = 'MockAdapter'
|
14
15
|
config.get_test_server
|
15
16
|
config.reset_app
|
16
17
|
config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
|
@@ -19,27 +20,30 @@ end
|
|
19
20
|
|
20
21
|
Bench.test do |config,session|
|
21
22
|
sleep rand(10)
|
22
|
-
session.post "clientlogin", "#{config.
|
23
|
+
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
23
24
|
{:login => config.user_name, :password => config.password}.to_json
|
24
25
|
end
|
26
|
+
|
25
27
|
sleep rand(10)
|
26
|
-
session.
|
28
|
+
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
27
29
|
client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
28
|
-
session.get "get-cud", "#{config.
|
29
|
-
{'
|
30
|
-
|
30
|
+
session.get "get-cud", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
31
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
32
|
+
{'p_size' => @datasize}
|
33
|
+
end
|
34
|
+
|
31
35
|
sleep rand(10)
|
32
36
|
token = JSON.parse(session.last_result.body)[1]['token']
|
33
|
-
|
37
|
+
session.last_result.verify_body([{:version => 3},{:token => token},
|
34
38
|
{:count => @datasize},{:progress_count => 0},{:total_count => @datasize},
|
35
39
|
{:insert => @expected}].to_json)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
'token' => token}
|
41
|
-
|
40
|
+
|
41
|
+
sleep rand(10)
|
42
|
+
session.get "ack-cud", "#{config.host}/app/#{Rhoconnect::API_VERSION}/#{config.adapter_name}",
|
43
|
+
{'X-RhoConnect-CLIENT-ID' => client_id} do
|
44
|
+
{'token' => token}
|
45
|
+
end
|
42
46
|
session.last_result.verify_code(200)
|
43
47
|
session.last_result.verify_body([{:version => 3},{:token => ''},{:count => 0},
|
44
48
|
{:progress_count => @datasize},{:total_count => @datasize},{}].to_json)
|
45
|
-
end
|
49
|
+
end
|
@@ -20,7 +20,7 @@ Bench.config do |config|
|
|
20
20
|
config.reset_app
|
21
21
|
@expected = Bench.get_test_data(@datasize)
|
22
22
|
config.set_server_state("test_db_storage:application:#{config.user_name}",@expected)
|
23
|
-
config.reset_refresh_time('RhoInternalBenchmarkAdapter', 0)
|
23
|
+
#config.reset_refresh_time('RhoInternalBenchmarkAdapter', 0)
|
24
24
|
config.set_simulate_time('RhoInternalBenchmarkAdapter', Bench.simtime)
|
25
25
|
end
|
26
26
|
end
|
@@ -38,27 +38,56 @@ Bench.synchronize do |config|
|
|
38
38
|
end
|
39
39
|
|
40
40
|
Bench.test do |config,session|
|
41
|
-
session.post "clientlogin", "#{config.
|
41
|
+
session.post "clientlogin", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/app/login", :content_type => :json do
|
42
42
|
{:login => config.user_name, :password => config.password}.to_json
|
43
43
|
end
|
44
|
-
session.
|
44
|
+
session.post "clientcreate", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients"
|
45
45
|
client_id = JSON.parse(session.last_result.body)['client']['client_id']
|
46
46
|
session.client_id = client_id
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
|
48
|
+
session.post "clientregister", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/clients/#{session.client_id}/register",
|
49
|
+
{:content_type => :json} do
|
50
|
+
{:device_type => "Apple", :device_pin => 'somepin123', :device_port => "device_port_111",
|
51
|
+
:phone_id => 'unique_phone_id'}.to_json
|
52
|
+
end
|
53
|
+
|
54
|
+
pagesize = @datasize
|
55
|
+
pagesize = @datasize/10 if @datasize > 1000
|
56
|
+
session.get "get-cud",
|
57
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter",
|
58
|
+
{'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
59
|
+
{'p_size' => pagesize}
|
60
|
+
end
|
61
|
+
token = JSON.parse(session.last_result.body)[1]['token']
|
62
|
+
while (token != '') do
|
63
|
+
session.get "ack-cud",
|
64
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter",
|
65
|
+
{'X-RhoConnect-CLIENT-ID' => session.client_id} do
|
66
|
+
{'token' => token,
|
67
|
+
'p_size' => pagesize}
|
68
|
+
end
|
69
|
+
token = JSON.parse(session.last_result.body)[1]['token']
|
70
|
+
session.last_result.verify_code(200)
|
50
71
|
end
|
72
|
+
|
73
|
+
obj_to_delete = @expected.keys[rand(@datasize - 1)]
|
74
|
+
@expected.delete(obj_to_delete)
|
75
|
+
@datasize = @datasize - 1
|
76
|
+
session.delete "delete_object",
|
77
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter/#{obj_to_delete}",
|
78
|
+
{'X-RhoConnect-CLIENT-ID' => session.client_id}
|
79
|
+
session.last_result.verify_code(200)
|
51
80
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
81
|
+
obj_to_delete = @expected.keys[rand(@datasize - 1)]
|
82
|
+
@expected.delete(obj_to_delete)
|
83
|
+
@datasize = @datasize - 1
|
84
|
+
session.post "push_deletes",
|
85
|
+
"#{config.host}/app/#{Rhoconnect::API_VERSION}/RhoInternalBenchmarkAdapter/push_deletes",
|
86
|
+
{'X-RhoConnect-API-TOKEN' => config.token, :content_type => :json} do
|
87
|
+
{:user_id => config.user_name,
|
88
|
+
:rebuild_md => false,
|
89
|
+
:objects => [obj_to_delete]
|
90
|
+
}.to_json
|
60
91
|
end
|
61
92
|
session.last_result.verify_code(200)
|
62
|
-
|
63
|
-
{:progress_count => @datasize},{:total_count => @datasize},{}].to_json)
|
64
|
-
end
|
93
|
+
end
|
@@ -18,10 +18,10 @@ end
|
|
18
18
|
|
19
19
|
|
20
20
|
Bench.test do |config,session|
|
21
|
-
session.post "save_adapter", "#{config.host}/
|
22
|
-
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
21
|
+
session.post "save_adapter", "#{config.host}/rc/#{Rhoconnect::API_VERSION}/system/appserver",
|
22
|
+
{'X-RhoConnect-API-TOKEN' => @token, :content_type => :json } do
|
23
|
+
{:attributes => {:adapter_url => @save_adapter_url}}.to_json
|
24
|
+
end
|
25
|
+
session.get "get_adapter", "#{config.host}/api/source/get_adapter",
|
26
|
+
{'X-RhoConnect-API-TOKEN' => @token, :content_type => :json }
|
27
|
+
end
|
@@ -1,3 +1,32 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
def fetch(uri_str, limit = 10)
|
4
|
+
raise ArgumentError, 'Too many HTTP redirects' if limit == 0
|
5
|
+
|
6
|
+
url = URI(uri_str)
|
7
|
+
response = Net::HTTP.get_response(url)
|
8
|
+
|
9
|
+
case response
|
10
|
+
when Net::HTTPOK then
|
11
|
+
Net::HTTP.start(url.host, url.port) do |http|
|
12
|
+
download_file = open("dtach-0.8.tar.gz", "wb")
|
13
|
+
begin
|
14
|
+
http.request_get(url.path) do |resp|
|
15
|
+
resp.read_body { |segment| download_file.write(segment) }
|
16
|
+
end
|
17
|
+
ensure
|
18
|
+
download_file.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
when Net::HTTPRedirection then
|
22
|
+
location = response['location']
|
23
|
+
puts "Redirected to #{location}"
|
24
|
+
fetch(location, limit - 1)
|
25
|
+
else
|
26
|
+
puts "Failed to download dtach-0.8.tar.gz file. Response code: #{response.value}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
1
30
|
Execute.define_task do
|
2
31
|
desc 'dtach-install', 'Install dtach 0.8 from source'
|
3
32
|
def dtach_install
|
@@ -5,26 +34,25 @@ Execute.define_task do
|
|
5
34
|
|
6
35
|
unless windows?
|
7
36
|
Dir.chdir('/tmp/')
|
8
|
-
|
9
|
-
|
37
|
+
system "rm /tmp/dtach-0.8.tar.gz" if File.exists?('/tmp/dtach-0.8.tar.gz')
|
38
|
+
system "rm -rf /tmp/dtach-0.8" if File.directory?('/tmp/dtach-0.8')
|
10
39
|
|
11
|
-
|
12
|
-
|
13
|
-
end #do
|
40
|
+
uri_str = "http://sourceforge.net/projects/dtach/files/dtach/0.8/dtach-0.8.tar.gz"
|
41
|
+
fetch(uri_str, limit = 10)
|
14
42
|
|
15
|
-
unless File.
|
16
|
-
system('tar xzf dtach-0.8.tar.gz')
|
17
|
-
end #unless
|
43
|
+
raise "Failed to download dtach-0.8.tar.gz file." unless File.exists?('dtach-0.8.tar.gz') && File.stat('dtach-0.8.tar.gz').size != 0
|
18
44
|
|
19
|
-
|
20
|
-
|
21
|
-
mk_bin_dir(bin_dir)
|
22
|
-
|
45
|
+
system('tar xzf dtach-0.8.tar.gz')
|
23
46
|
Dir.chdir('/tmp/dtach-0.8/')
|
24
47
|
system 'cd /tmp/dtach-0.8/ && ./configure && make'
|
25
|
-
system "cp /tmp/dtach-0.8/dtach #{bin_dir}"
|
26
48
|
|
49
|
+
ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
|
50
|
+
mk_bin_dir(bin_dir)
|
51
|
+
system "sudo cp /tmp/dtach-0.8/dtach #{bin_dir}"
|
52
|
+
|
53
|
+
system "rm /tmp/dtach-0.8.tar.gz"
|
54
|
+
system "rm -rf /tmp/dtach-0.8"
|
27
55
|
puts "Dtach successfully installed to #{bin_dir}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|