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.
Files changed (221) hide show
  1. data/CHANGELOG.md +24 -5
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +20 -20
  4. data/bench/benchapp/Gemfile +17 -20
  5. data/bench/benchapp/config.ru +2 -2
  6. data/bench/benchapp/settings/settings.yml +3 -3
  7. data/bench/blobapp/Gemfile +16 -13
  8. data/bench/blobapp/config.ru +2 -2
  9. data/bench/blobapp/settings/settings.yml +5 -3
  10. data/bench/lib/bench.rb +35 -32
  11. data/bench/lib/bench/session.rb +9 -1
  12. data/bench/scripts/blob_cud_script.rb +13 -17
  13. data/bench/scripts/cud_script.rb +11 -12
  14. data/bench/scripts/helpers.rb +5 -7
  15. data/bench/scripts/query_md_script.rb +18 -12
  16. data/bench/scripts/query_only_script.rb +19 -11
  17. data/bench/scripts/query_script.rb +17 -13
  18. data/bench/scripts/test_query_script.rb +46 -17
  19. data/bench/scripts/test_source_script.rb +7 -7
  20. data/commands/commands/dtach_commands/dtach_install.rb +44 -16
  21. data/commands/commands/rhoconnect/spec.rb +13 -9
  22. data/commands/commands/rhoconnect/version.rb +6 -0
  23. data/commands/execute.rb +10 -6
  24. data/doc/deploying.txt +75 -13
  25. data/doc/install.txt +3 -3
  26. data/doc/push-client-setup.txt +1 -1
  27. data/doc/rest-api.txt +4 -23
  28. data/doc/rhoconnect-redis-stack.txt +26 -7
  29. data/doc/settings.txt +9 -3
  30. data/examples/simple/Gemfile +3 -1
  31. data/examples/simple/application.rb +5 -0
  32. data/examples/simple/config.ru +3 -2
  33. data/examples/simple/my_server.rb +14 -0
  34. data/examples/simple/settings/settings.yml +1 -0
  35. data/generators/templates/application/Gemfile +4 -4
  36. data/generators/templates/application/application.rb +4 -0
  37. data/generators/templates/application/settings/settings.yml +4 -1
  38. data/installer/unix-like/create_texts.rb +39 -1
  39. data/installer/unix-like/rho_connect_install_constants.rb +1 -1
  40. data/installer/utils/package_upload/repos.rake +7 -5
  41. data/lib/rhoconnect.rb +3 -2
  42. data/lib/rhoconnect/api/app/ans_login.rb +3 -0
  43. data/lib/rhoconnect/api/app/bulk_data.rb +6 -0
  44. data/lib/rhoconnect/api/{source → app}/fast_delete.rb +1 -1
  45. data/lib/rhoconnect/api/{source → app}/fast_insert.rb +2 -2
  46. data/lib/rhoconnect/api/{source → app}/fast_update.rb +2 -2
  47. data/lib/rhoconnect/api/app/login.rb +5 -0
  48. data/lib/rhoconnect/api/{source → app}/push_deletes.rb +1 -1
  49. data/lib/rhoconnect/api/{source → app}/push_objects.rb +1 -1
  50. data/lib/rhoconnect/api/app/query.rb +4 -0
  51. data/lib/rhoconnect/api/app/queue_updates.rb +94 -0
  52. data/lib/rhoconnect/api/app/search.rb +4 -0
  53. data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -0
  54. data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -0
  55. data/lib/rhoconnect/api/client/create.rb +7 -0
  56. data/lib/rhoconnect/api/client/get_client_params.rb +2 -1
  57. data/lib/rhoconnect/api/client/list_client_docs.rb +2 -1
  58. data/lib/rhoconnect/api/client/register.rb +12 -0
  59. data/lib/rhoconnect/api/client/reset.rb +5 -0
  60. data/lib/rhoconnect/api/{source → readstate}/set_refresh_time.rb +2 -1
  61. data/lib/rhoconnect/api/source/get_source_params.rb +3 -2
  62. data/lib/rhoconnect/api/source/list_sources.rb +2 -1
  63. data/lib/rhoconnect/api/source/update_source_params.rb +3 -3
  64. data/lib/rhoconnect/api/store/get_db_doc.rb +4 -0
  65. data/lib/rhoconnect/api/store/set_db_doc.rb +7 -0
  66. data/lib/rhoconnect/api/system/get_adapter.rb +4 -0
  67. data/lib/rhoconnect/api/{admin → system}/get_license_info.rb +2 -1
  68. data/lib/rhoconnect/api/system/login.rb +15 -0
  69. data/lib/rhoconnect/api/{admin → system}/reset.rb +3 -2
  70. data/lib/rhoconnect/api/system/save_adapter.rb +4 -0
  71. data/lib/rhoconnect/api/{admin → system}/stats.rb +2 -1
  72. data/lib/rhoconnect/api/user/create_user.rb +2 -2
  73. data/lib/rhoconnect/api/user/delete_client.rb +6 -0
  74. data/lib/rhoconnect/api/user/delete_user.rb +2 -1
  75. data/lib/rhoconnect/api/user/list_clients.rb +4 -0
  76. data/lib/rhoconnect/api/user/list_source_docs.rb +11 -0
  77. data/lib/rhoconnect/api/user/list_users.rb +1 -1
  78. data/lib/rhoconnect/api/user/ping.rb +7 -0
  79. data/lib/rhoconnect/api/user/show_user.rb +3 -0
  80. data/lib/rhoconnect/api/user/update_user.rb +3 -2
  81. data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -0
  82. data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -0
  83. data/lib/rhoconnect/app.rb +12 -2
  84. data/lib/rhoconnect/async.rb +6 -10
  85. data/lib/rhoconnect/bulk_data/bulk_data.rb +4 -4
  86. data/lib/rhoconnect/client.rb +10 -9
  87. data/lib/rhoconnect/client_sync.rb +24 -19
  88. data/lib/rhoconnect/document.rb +18 -4
  89. data/lib/rhoconnect/graph_helper.rb +4 -2
  90. data/lib/rhoconnect/jobs/bulk_data_job.rb +1 -1
  91. data/lib/rhoconnect/jobs/ping_job.rb +39 -29
  92. data/lib/rhoconnect/middleware/admin_user.rb +23 -0
  93. data/lib/rhoconnect/middleware/body_content_type_parser.rb +35 -0
  94. data/lib/rhoconnect/{cors.rb → middleware/cors.rb} +1 -0
  95. data/lib/rhoconnect/middleware/current_app.rb +16 -0
  96. data/lib/rhoconnect/middleware/current_request.rb +16 -0
  97. data/lib/rhoconnect/middleware/current_user.rb +17 -0
  98. data/lib/rhoconnect/middleware/helpers.rb +105 -0
  99. data/lib/rhoconnect/middleware/login_required.rb +22 -0
  100. data/lib/rhoconnect/{stats/middleware.rb → middleware/stats.rb} +5 -3
  101. data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +58 -0
  102. data/lib/rhoconnect/ping.rb +1 -0
  103. data/lib/rhoconnect/ping/apple.rb +18 -16
  104. data/lib/rhoconnect/ping/blackberry.rb +9 -9
  105. data/lib/rhoconnect/ping/rhoconnect_push.rb +45 -0
  106. data/lib/rhoconnect/server.rb +98 -91
  107. data/lib/rhoconnect/source.rb +5 -1
  108. data/lib/rhoconnect/source_sync.rb +4 -3
  109. data/lib/rhoconnect/stats/record.rb +15 -15
  110. data/lib/rhoconnect/store.rb +253 -75
  111. data/lib/rhoconnect/tasks.rb +3 -3
  112. data/lib/rhoconnect/version.rb +1 -1
  113. data/lib/rhoconnect/web-console/controllers/admins.js +1 -14
  114. data/lib/rhoconnect/web-console/models/adapter.js +18 -8
  115. data/lib/rhoconnect/web-console/models/client.js +15 -9
  116. data/lib/rhoconnect/web-console/models/doc.js +7 -11
  117. data/lib/rhoconnect/web-console/models/session.js +5 -2
  118. data/lib/rhoconnect/web-console/models/source.js +55 -36
  119. data/lib/rhoconnect/web-console/models/user.js +20 -11
  120. data/lib/rhoconnect/web-console/public/backbone.js +8 -2
  121. data/lib/rhoconnect/web-console/templates/index.erb +11 -5
  122. data/lib/rhoconnect/web-console/views/doc.js +6 -8
  123. data/lib/rhoconnect/web-console/views/edit_user.js +6 -3
  124. data/lib/rhoconnect/web-console/views/home.js +98 -25
  125. data/lib/rhoconnect/web-console/views/index.js +1 -1
  126. data/lib/rhoconnect/web-console/views/new_ping.js +6 -3
  127. data/lib/rhoconnect/web-console/views/server_doc.js +12 -4
  128. data/lib/rhoconnect/web-console/views/show_device.js +6 -3
  129. data/rhoconnect.gemspec +1 -2
  130. data/spec/api/{source → app}/fast_delete_spec.rb +4 -4
  131. data/spec/api/{source → app}/fast_insert_spec.rb +4 -4
  132. data/spec/api/{source → app}/fast_update_spec.rb +22 -6
  133. data/spec/api/{source → app}/push_deletes_spec.rb +2 -2
  134. data/spec/api/app/push_objects_spec.rb +45 -0
  135. data/spec/api/client/client_get_db_doc_spec.rb +31 -0
  136. data/spec/api/client/client_set_db_doc_spec.rb +14 -0
  137. data/spec/api/client/get_client_params_spec.rb +3 -2
  138. data/spec/api/client/list_client_docs_spec.rb +2 -2
  139. data/spec/api/{source → readstate}/set_refresh_time_spec.rb +15 -9
  140. data/spec/api/source/get_source_params_spec.rb +3 -2
  141. data/spec/api/source/list_sources_spec.rb +3 -9
  142. data/spec/api/source/update_source_params_spec.rb +4 -4
  143. data/spec/api/store/get_db_doc_spec.rb +32 -0
  144. data/spec/api/store/set_db_doc_spec.rb +43 -0
  145. data/spec/api/system/adapter_spec.rb +33 -0
  146. data/spec/api/{admin → system}/get_license_info_spec.rb +2 -5
  147. data/spec/api/{admin/get_api_token_spec.rb → system/login_spec.rb} +4 -11
  148. data/spec/api/{admin → system}/reset_spec.rb +2 -2
  149. data/spec/api/{admin → system}/stats_spec.rb +19 -13
  150. data/spec/api/user/create_user_spec.rb +15 -8
  151. data/spec/api/{client → user}/delete_client_spec.rb +3 -4
  152. data/spec/api/user/delete_user_spec.rb +33 -4
  153. data/spec/api/user/list_clients_spec.rb +30 -0
  154. data/spec/api/user/list_source_docs_spec.rb +35 -0
  155. data/spec/api/user/list_users_spec.rb +5 -6
  156. data/spec/api/{client → user}/ping_spec.rb +4 -6
  157. data/spec/api/user/show_user_spec.rb +14 -0
  158. data/spec/api/user/update_user_spec.rb +28 -10
  159. data/spec/api/user/user_get_db_doc_spec.rb +16 -0
  160. data/spec/api/user/user_set_db_doc_spec.rb +41 -0
  161. data/spec/apps/rhotestapp/application.rb +4 -0
  162. data/spec/apps/rhotestapp/settings/settings.yml +3 -1
  163. data/spec/bulk_data/bulk_data_spec.rb +13 -0
  164. data/spec/client_sync_spec.rb +41 -59
  165. data/spec/document_spec.rb +23 -0
  166. data/spec/javascripts/doc_view_spec.js +1 -1
  167. data/spec/javascripts/home_view_spec.js +10 -5
  168. data/spec/javascripts/index_view_spec.js +1 -1
  169. data/spec/jobs/ping_job_spec.rb +26 -0
  170. data/spec/perf/store_perf_spec.rb +1 -1
  171. data/spec/ping/android_spec.rb +0 -7
  172. data/spec/ping/apple_spec.rb +7 -0
  173. data/spec/ping/blackberry_spec.rb +10 -0
  174. data/spec/ping/rhoconnect_push_spec.rb +58 -0
  175. data/spec/server/cors_spec.rb +1 -1
  176. data/spec/server/server_spec.rb +152 -104
  177. data/spec/{stats/middleware_spec.rb → server/stats_spec.rb} +4 -5
  178. data/spec/server/x_domain_session_wrapper_spec.rb +3 -3
  179. data/spec/source_spec.rb +2 -2
  180. data/spec/source_sync_spec.rb +2 -0
  181. data/spec/spec_helper.rb +17 -3
  182. data/spec/stats/record_spec.rb +18 -19
  183. data/spec/store_spec.rb +51 -26
  184. data/spec/support/shared_examples.rb +4 -0
  185. data/spec/sync_states_spec.rb +2 -2
  186. metadata +104 -88
  187. data/bench/benchapp/Gemfile.lock +0 -87
  188. data/bench/blobapp/Gemfile.lock +0 -107
  189. data/bench/lib/testdata/5-data.txt +0 -8
  190. data/doc/release.txt +0 -41
  191. data/lib/rhoconnect/api/admin/get_api_token.rb +0 -14
  192. data/lib/rhoconnect/api/admin/login.rb +0 -6
  193. data/lib/rhoconnect/api/application/bulk_data.rb +0 -7
  194. data/lib/rhoconnect/api/application/clientcreate.rb +0 -8
  195. data/lib/rhoconnect/api/application/clientlogin.rb +0 -6
  196. data/lib/rhoconnect/api/application/clientregister.rb +0 -13
  197. data/lib/rhoconnect/api/application/clientreset.rb +0 -6
  198. data/lib/rhoconnect/api/application/query.rb +0 -7
  199. data/lib/rhoconnect/api/application/queue_updates.rb +0 -20
  200. data/lib/rhoconnect/api/application/search.rb +0 -6
  201. data/lib/rhoconnect/api/client/create_client.rb +0 -3
  202. data/lib/rhoconnect/api/client/delete_client.rb +0 -5
  203. data/lib/rhoconnect/api/client/list_clients.rb +0 -3
  204. data/lib/rhoconnect/api/client/ping.rb +0 -7
  205. data/lib/rhoconnect/api/source/get_adapter.rb +0 -3
  206. data/lib/rhoconnect/api/source/get_db_doc.rb +0 -7
  207. data/lib/rhoconnect/api/source/list_source_docs.rb +0 -10
  208. data/lib/rhoconnect/api/source/save_adapter.rb +0 -3
  209. data/lib/rhoconnect/api/source/set_db_doc.rb +0 -10
  210. data/lib/rhoconnect/api/source/upload_file.rb +0 -4
  211. data/lib/rhoconnect/body_content_type_parser.rb +0 -32
  212. data/lib/rhoconnect/x_domain_session_wrapper.rb +0 -53
  213. data/spec/api/admin/api_token_spec.rb +0 -13
  214. data/spec/api/client/create_client_spec.rb +0 -13
  215. data/spec/api/client/list_clients_spec.rb +0 -22
  216. data/spec/api/source/adapter_spec.rb +0 -29
  217. data/spec/api/source/get_db_doc_spec.rb +0 -21
  218. data/spec/api/source/list_source_docs_spec.rb +0 -25
  219. data/spec/api/source/push_objects_spec.rb +0 -27
  220. data/spec/api/source/set_db_doc_spec.rb +0 -32
  221. 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 #50
18
+ @create_count = 5
19
19
 
20
20
  @users = Bench.get_bench_users(config.concurrency)
21
- @users.each do |u|
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.base_url}/clientlogin", :content_type => :json do
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', :client_id => session.client_id,
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.base_url}/queue_updates" do
59
- body.merge!(Bench.get_image_data(create_objs)) # Add images to miltipart post
60
- end
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,@expected_md,create_objs)
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
 
@@ -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.base_url}/clientlogin", :content_type => :json do
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.get "clientcreate", "#{config.base_url}/clientcreate"
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", "#{config.base_url}/queue_updates", :content_type => :json do
52
- {:source_name => 'MockAdapter', :client_id => session.client_id,
53
- :create => create_objs, :version => 3}.to_json
54
- end
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
- count = get_all_objects(current_line,config,session,@expected_md,create_objs)
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)
@@ -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.base_url}/query" do
71
- {'source_name' => config.adapter_name, 'client_id' => session.client_id, 'p_size' => @datasize}
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.base_url}/query" do
86
- { 'source_name' => config.adapter_name,
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 = 2
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.base_url}/clientlogin", :content_type => :json do
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.get "clientcreate", "#{config.base_url}/clientcreate"
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.base_url}/query" do
29
- {'source_name' => 'MockAdapter', 'client_id' => client_id, 'p_size' => @datasize}
30
- end
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", "#{config.base_url}/query" do
38
- { 'source_name' => 'MockAdapter',
39
- 'client_id' => client_id,
40
- 'token' => token}
41
- end
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
- res = RestClient.post "#{config.base_url}/clientlogin",
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.get "#{config.base_url}/clientcreate", {:cookies => @cookies}
26
- puts "Created client ##{i}..."
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.base_url}/query" do
36
- {'source_name' => 'MockAdapter', 'client_id' => client_id, 'p_size' => @datasize}
37
- end
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", "#{config.base_url}/query" do
44
- { 'source_name' => 'MockAdapter',
45
- 'client_id' => client_id,
46
- 'token' => token}
47
- end
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.base_url}/clientlogin", :content_type => :json do
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.get "clientcreate", "#{config.base_url}/clientcreate"
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.base_url}/query" do
29
- {'source_name' => 'MockAdapter', 'client_id' => client_id, 'p_size' => @datasize}
30
- end
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
- session.last_result.verify_body([{:version => 3},{:token => token},
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
- sleep rand(10)
37
- session.get "ack-cud", "#{config.base_url}/query" do
38
- { 'source_name' => 'MockAdapter',
39
- 'client_id' => client_id,
40
- 'token' => token}
41
- end
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.base_url}/clientlogin", :content_type => :json do
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.get "clientcreate", "#{config.base_url}/clientcreate"
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
- session.post "clientregister", "#{config.base_url}/clientregister", :content_type => :json do
48
- {:device_type => "Apple", :device_pin => 'somepin123', :device_port => "device_port_111", :phone_id => 'unique_phone_id',
49
- :client_id => client_id}.to_json
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
- session.get "get-cud", "#{config.base_url}/query" do
53
- {'source_name' => 'RhoInternalBenchmarkAdapter', 'client_id' => session.client_id, 'p_size' => @datasize}
54
- end
55
- token = JSON.parse(session.last_result.body)[1]['token']
56
- session.get "ack-cud", "#{config.base_url}/query" do
57
- { 'source_name' => 'RhoInternalBenchmarkAdapter',
58
- 'client_id' => session.client_id,
59
- 'token' => token}
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
- session.last_result.verify_body([{:version => 3},{:token => ''},{:count => 0},
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}/api/source/save_adapter", :content_type => :json do
22
- {:api_token => @token, :attributes => {:adapter_url => @save_adapter_url}}.to_json
23
- end
24
- session.post "get_adapter", "#{config.host}/api/source/get_adapter", :content_type => :json do
25
- {:api_token => @token}.to_json
26
- end
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
- unless File.exists?('/tmp/dtach-0.8.tar.gz')
9
- require 'net/http'
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
- url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
12
- open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
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.directory?('/tmp/dtach-0.8')
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
- ENV['PREFIX'] and bin_dir = "#{ENV['PREFIX']}/bin" or bin_dir = "#{RedisRunner.prefix}bin"
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 #unless
29
- end #dtach_install
30
- end #do
56
+ end
57
+ end
58
+ end