rhoconnect 4.0.4 → 5.1.1

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