rhoconnect 4.0.4 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +54 -5
- data/CREDITS +219 -219
- data/Gemfile +2 -2
- data/Gemfile.lock +68 -79
- data/Rakefile +1 -2
- data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/spec_helper.rb +3 -3
- data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
- data/bench/blobapp/spec/spec_helper.rb +3 -3
- data/bench/lib/bench/runner.rb +1 -69
- data/bench/lib/bench.rb +18 -18
- data/bench/spec/mock_adapter_spec.rb +54 -55
- data/bench/spec/mock_client_spec.rb +47 -48
- data/bench/spec/result_spec.rb +41 -44
- data/bench/spec/utils_spec.rb +24 -25
- data/commands/generators/app.rb +7 -5
- data/commands/generators/controller.rb +7 -5
- data/commands/generators/model.rb +7 -5
- data/commands/generators/source.rb +7 -5
- data/commands/parser.rb +1 -1
- data/commands/redis/redis_download.rb +1 -1
- data/doc/async-jobs.txt +9 -9
- data/doc/supported-platforms.txt +0 -2
- data/generators/rhoconnect.rb +92 -212
- data/generators/templates/application/rcgemfile +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +14 -16
- data/generators/templates/application/spec/js_spec.rb +20 -20
- data/generators/templates/application/spec/spec_helper.rb +1 -1
- data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
- data/generators/templates/source/models/ruby/model_spec.rb +17 -17
- data/install.sh +10 -21
- data/installer/unix-like/rho_connect_install_constants.rb +5 -5
- data/installer/unix-like/rho_connect_install_installers.rb +4 -4
- data/installer/utils/constants.rb +6 -6
- data/installer/utils/nix_install_test.rb +29 -29
- data/installer/utils/package_upload/repos.rake +16 -26
- data/js-adapters/node.rb +4 -4
- data/js-adapters/node_channel.rb +4 -8
- data/lib/rhoconnect/db_adapter.rb +13 -13
- data/lib/rhoconnect/handler/changes/engine.rb +1 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
- data/lib/rhoconnect/license.rb +7 -7
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
- data/lib/rhoconnect/ping/apple.rb +4 -4
- data/lib/rhoconnect/server.rb +2 -2
- data/lib/rhoconnect/source.rb +2 -2
- data/lib/rhoconnect/store.rb +12 -6
- data/lib/rhoconnect/utilities.rb +2 -2
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect.rb +6 -4
- data/rhoconnect.gemspec +5 -6
- data/spec/api/api_helper.rb +1 -1
- data/spec/api/app/fast_delete_spec.rb +22 -22
- data/spec/api/app/fast_insert_spec.rb +23 -23
- data/spec/api/app/fast_update_spec.rb +63 -63
- data/spec/api/app/push_deletes_spec.rb +11 -13
- data/spec/api/app/push_objects_spec.rb +39 -39
- data/spec/api/client/client_get_db_doc_spec.rb +29 -29
- data/spec/api/client/client_set_db_doc_spec.rb +11 -11
- data/spec/api/client/get_client_params_spec.rb +29 -29
- data/spec/api/client/list_client_docs_spec.rb +32 -34
- data/spec/api/client/reset_spec.rb +30 -30
- data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
- data/spec/api/source/get_source_params_spec.rb +32 -34
- data/spec/api/source/list_sources_spec.rb +13 -13
- data/spec/api/source/update_source_params_spec.rb +19 -19
- data/spec/api/store/get_db_doc_spec.rb +27 -27
- data/spec/api/store/set_db_doc_spec.rb +38 -38
- data/spec/api/system/adapter_spec.rb +27 -29
- data/spec/api/system/get_license_info_spec.rb +11 -11
- data/spec/api/system/login_spec.rb +37 -37
- data/spec/api/system/reset_spec.rb +15 -15
- data/spec/api/system/stats_spec.rb +70 -71
- data/spec/api/user/create_user_spec.rb +37 -37
- data/spec/api/user/delete_client_spec.rb +7 -7
- data/spec/api/user/delete_user_spec.rb +62 -62
- data/spec/api/user/list_clients_spec.rb +24 -24
- data/spec/api/user/list_source_docs_spec.rb +29 -29
- data/spec/api/user/list_users_spec.rb +22 -22
- data/spec/api/user/ping_spec.rb +18 -18
- data/spec/api/user/show_user_spec.rb +10 -10
- data/spec/api/user/update_user_spec.rb +43 -43
- data/spec/api/user/user_get_db_doc_spec.rb +12 -12
- data/spec/api/user/user_set_db_doc_spec.rb +37 -37
- data/spec/api_token_spec.rb +8 -8
- data/spec/app_spec.rb +18 -17
- data/spec/apps/jstestapp/settings/settings.yml +2 -0
- data/spec/async_spec.rb +9 -11
- data/spec/bulk_data/bulk_data_spec.rb +120 -120
- data/spec/cli/cli_spec.rb +50 -53
- data/spec/client_spec.rb +105 -105
- data/spec/client_sync_spec.rb +529 -528
- data/spec/controllers/js_base_spec.rb +147 -141
- data/spec/doc/doc_spec.rb +51 -52
- data/spec/document_spec.rb +58 -58
- data/spec/dynamic_adapter_spec.rb +33 -36
- data/spec/generator/generator_spec.rb +76 -42
- data/spec/jobs/bulk_data_job_spec.rb +101 -102
- data/spec/jobs/ping_job_spec.rb +176 -177
- data/spec/jobs/source_job_spec.rb +24 -25
- data/spec/license_spec.rb +54 -55
- data/spec/models/js_base_spec.rb +121 -120
- data/spec/perf/bulk_data_perf_spec.rb +23 -24
- data/spec/perf/perf_spec_helper.rb +7 -7
- data/spec/perf/store_perf_spec.rb +139 -140
- data/spec/ping/apple_spec.rb +65 -65
- data/spec/ping/gcm_spec.rb +83 -84
- data/spec/ping/rhoconnect_push_spec.rb +52 -53
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
- data/spec/read_state_spec.rb +24 -25
- data/spec/rhoconnect_spec.rb +7 -7
- data/spec/server/server_spec.rb +664 -662
- data/spec/server/stats_spec.rb +12 -12
- data/spec/source_adapter_spec.rb +124 -125
- data/spec/source_spec.rb +148 -149
- data/spec/source_sync_spec.rb +736 -736
- data/spec/spec_helper.rb +4 -5
- data/spec/stats/record_spec.rb +22 -21
- data/spec/store_orm_spec.rb +48 -48
- data/spec/store_spec.rb +428 -426
- data/spec/support/shared_examples.rb +5 -7
- data/spec/sync_states_spec.rb +67 -67
- data/spec/test_methods_spec.rb +121 -123
- data/spec/testdata/10000-data.txt +0 -0
- data/spec/testdata/5000-data.txt +0 -0
- data/spec/user_spec.rb +102 -102
- data/tasks/redis.rake +3 -3
- metadata +154 -195
- data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
- data/bench/benchapp/tmp/restart.txt +0 -0
- data/bench/blobapp/settings/license.key.bak +0 -2
- data/bench/blobapp/tmp/restart.txt +0 -0
- data/bench/lib/testdata/1-data.txt +0 -0
- data/bench/lib/testdata/10-data.txt +0 -0
- data/bench/lib/testdata/2-data.txt +0 -0
- data/bench/lib/testdata/250-data.txt +0 -0
- data/bench/lib/testdata/5-blob_data.txt +0 -0
- data/bench/lib/testdata/5-data.txt +0 -0
- data/bench/lib/testdata/50-data.txt +0 -0
- data/bench/lib/testdata/500-data.txt +0 -0
- data/doc/protocol.html +0 -1993
- data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
- data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
- data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
- data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
- data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
- data/spec/coverage/rcov/index.html +0 -88
- data/spec/generator/generator_spec_helper.rb +0 -9
@@ -1,41 +1,41 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
2
2
|
|
3
3
|
describe "RhoconnectApiUserSetDbDoc" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
4
|
+
include_examples "ApiHelper"
|
5
|
+
|
6
|
+
it "should set user's db document by doc key and data" do
|
7
|
+
data = {'1' => {'foo' => 'bar'}}
|
8
|
+
dockey = 'myuserdoc'
|
9
|
+
sdocname = @s2.docname(dockey)
|
10
|
+
|
11
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
12
|
+
last_response.should be_ok
|
13
|
+
verify_result(sdocname => data)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should append data to the user's db document by doc name and data" do
|
17
|
+
data = {'1' => {'foo' => 'bar'}}
|
18
|
+
data2 = {'2' => {'foo1' => 'bar1'}}
|
19
|
+
data3 = data.merge(data2)
|
20
|
+
dockey = 'abc:abc'
|
21
|
+
sdocname = @s2.docname(dockey)
|
22
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
23
|
+
last_response.should be_ok
|
24
|
+
verify_result(sdocname => data)
|
25
|
+
|
26
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
27
|
+
last_response.should be_ok
|
28
|
+
verify_result(sdocname => data3)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should error out in ateempt to set a db doc for a non-existent user" do
|
32
|
+
data = {'1' => {'foo' => 'bar'}}
|
33
|
+
data2 = {'2' => {'foo1' => 'bar1'}}
|
34
|
+
data3 = data.merge(data2)
|
35
|
+
dockey = 'abc:abc'
|
36
|
+
sdocname = @s2.docname(dockey)
|
37
|
+
post "/rc/#{Rhoconnect::API_VERSION}/users/invalid_user/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
38
|
+
last_response.status.should == 500
|
39
|
+
last_response.should_not be_ok
|
40
|
+
end
|
41
41
|
end
|
data/spec/api_token_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
2
|
|
3
3
|
describe "ApiToken" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
5
|
+
|
6
|
+
it "should generate api token with user" do
|
7
|
+
token = ApiToken.create(:user_id => @u.id)
|
8
|
+
token.value.length.should == 32
|
9
|
+
token.user_id.should == @u.id
|
10
|
+
token.user.login.should == @u.login
|
11
|
+
token.delete
|
12
12
|
end
|
13
13
|
end
|
data/spec/app_spec.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
2
|
|
3
3
|
describe "App" do
|
4
|
-
|
5
|
-
it "should create app with fields" do
|
6
|
-
@a.id.should == @a_fields[:name]
|
7
|
-
@a1 = App.load(@a_fields[:name])
|
8
|
-
@a1.id.should == @a.id
|
9
|
-
@a1.name.should == @a_fields[:name]
|
10
|
-
end
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
11
5
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
it "should create app with fields" do
|
7
|
+
@a.id.should == @a_fields[:name]
|
8
|
+
@a1 = App.load(@a_fields[:name])
|
9
|
+
@a1.id.should == @a.id
|
10
|
+
@a1.name.should == @a_fields[:name]
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should add source adapters" do
|
14
|
+
@a1 = App.load(@a_fields[:name])
|
15
|
+
@a1.sources.sort.should == ["FixedSchemaAdapter", "JsSample", "OtherAdapter", "SampleAdapter", "SimpleAdapter"]
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
it "should force environment default and override setting" do
|
19
|
+
poll_interval_default = Rhoconnect.source_config('OtherAdapter')[:poll_interval]
|
20
|
+
poll_interval_default.should == 201
|
21
|
+
poll_interval_override = Rhoconnect.source_config('SimpleAdapter')[:poll_interval]
|
22
|
+
poll_interval_override.should == 600
|
23
23
|
end
|
24
|
+
|
24
25
|
end
|
data/spec/async_spec.rb
CHANGED
@@ -3,17 +3,15 @@ require File.join(File.dirname(__FILE__),'api','api_helper')
|
|
3
3
|
# these specs are executed only with Async support
|
4
4
|
if not defined?(JRUBY_VERSION)
|
5
5
|
describe "BasicEventMachineTest with Threads" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
operation_res.should == 1
|
16
|
-
end
|
6
|
+
it "should run EventMachine gracefully and schedule callback execution in thread" do
|
7
|
+
f = Fiber.current
|
8
|
+
operation = proc { res = 1 }
|
9
|
+
operation_res = 0
|
10
|
+
callback = proc { |proc_res| operation_res = proc_res; f.resume }
|
11
|
+
EventMachine.defer operation, callback
|
12
|
+
Fiber.yield
|
13
|
+
# this code should be executed only after the thread's return
|
14
|
+
operation_res.should == 1
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -1,132 +1,132 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
2
2
|
|
3
3
|
describe "BulkData" do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
7
|
-
@s1 = Source.load(@s1_fields[:name], @s_params)
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:each) do
|
11
|
-
delete_data_directory
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return true if bulk data is completed" do
|
15
|
-
dbfile = create_datafile(File.join(@a.name,@u.id.to_s),@u.id.to_s)
|
16
|
-
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
17
|
-
:state => :completed,
|
18
|
-
:app_id => @a.id,
|
19
|
-
:user_id => @u.id,
|
20
|
-
:sources => [@s_fields[:name]])
|
21
|
-
data.dbfile = dbfile
|
22
|
-
data.completed?.should == true
|
23
|
-
end
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
24
5
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:user_id => @u.id,
|
30
|
-
:sources => [@s_fields[:name]])
|
31
|
-
data.completed?.should == false
|
32
|
-
end
|
6
|
+
before(:each) do
|
7
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
8
|
+
@s1 = Source.load(@s1_fields[:name], @s_params)
|
9
|
+
end
|
33
10
|
|
34
|
-
|
11
|
+
after(:each) do
|
12
|
+
delete_data_directory
|
13
|
+
end
|
35
14
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
15
|
+
it "should return true if bulk data is completed" do
|
16
|
+
dbfile = create_datafile(File.join(@a.name,@u.id.to_s),@u.id.to_s)
|
17
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
18
|
+
:state => :completed,
|
19
|
+
:app_id => @a.id,
|
20
|
+
:user_id => @u.id,
|
21
|
+
:sources => [@s_fields[:name]])
|
22
|
+
data.dbfile = dbfile
|
23
|
+
data.completed?.should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return false if bulk data isn't completed" do
|
27
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
28
|
+
:state => :inprogress,
|
29
|
+
:app_id => @a.id,
|
30
|
+
:user_id => @u.id,
|
31
|
+
:sources => [@s_fields[:name]])
|
32
|
+
data.completed?.should == false
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should expire_bulk_data from a source adapter" do
|
36
|
+
|
37
|
+
@model = Rhoconnect::Model::Base.create(@s)
|
38
|
+
@engine = Rhoconnect::Handler::Query::Engine.new(@model, lambda { @model.query }, {})
|
39
|
+
time = Time.now.to_i + 10000
|
40
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
41
|
+
:state => :inprogress,
|
42
|
+
:app_id => @a.id,
|
43
|
+
:user_id => @u.id,
|
44
|
+
:sources => [@s_fields[:name]],
|
45
|
+
:refresh_time => time)
|
46
|
+
@model.expire_bulk_data
|
47
|
+
data = BulkData.load(bulk_data_docname(@a.id,@u.id))
|
48
|
+
data.refresh_time.should <= Time.now.to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should enqueue sqlite db type" do
|
52
|
+
BulkData.enqueue
|
53
|
+
Resque.peek(:bulk_data).should == {"args"=>[{}],
|
54
|
+
"class"=>"Rhoconnect::BulkDataJob"}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should generate correct bulk data name for user partition" do
|
58
|
+
BulkData.get_name(:user,@c.user_id).should == File.join(@a_fields[:name],@u_fields[:login],@u_fields[:login])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should generate correct bulk data name for app partition" do
|
62
|
+
BulkData.get_name(:app,@c.user_id).should ==
|
63
|
+
File.join(@a_fields[:name],@a_fields[:name])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have ordered sources list by priority" do
|
67
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
68
|
+
:state => :inprogress,
|
69
|
+
:app_id => @a.id,
|
70
|
+
:user_id => @u.id,
|
71
|
+
:sources => @a.partition_sources(:user, @u.id))
|
72
|
+
|
73
|
+
data.sources[0, -1].should == ["SampleAdapter", "JsSample", "FixedSchemaAdapter"]
|
74
|
+
p1 = Source.load("SampleAdapter", {:app_id => data.app_id, :user_id => data.user_id}).priority
|
75
|
+
p2 = Source.load("JsSample", {:app_id => data.app_id, :user_id => data.user_id}).priority
|
76
|
+
p1.should < p2
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should process_sources for bulk data" do
|
80
|
+
current = Time.now.to_i
|
81
|
+
@s.read_state.refresh_time = current
|
82
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
83
|
+
:state => :inprogress,
|
84
|
+
:app_id => @a.id,
|
85
|
+
:user_id => @u.id,
|
86
|
+
:sources => [@s_fields[:name], @s1_fields[:name]])
|
87
|
+
data.process_sources
|
88
|
+
@s.read_state.refresh_time.should > current + @s_fields[:poll_interval].to_i
|
89
|
+
@s1.read_state.refresh_time.should > current + @s1_fields[:poll_interval].to_i
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should process specific sources for bulk data" do
|
93
|
+
current = Time.now.to_i
|
94
|
+
@s.read_state.refresh_time = current
|
95
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
96
|
+
:state => :inprogress,
|
97
|
+
:app_id => @a.id,
|
98
|
+
:user_id => @u.id,
|
99
|
+
:sources => [@s1_fields[:name]])
|
100
|
+
data.process_sources
|
101
|
+
@s.read_state.refresh_time.should <= current
|
102
|
+
@s1.read_state.refresh_time.should > current + @s1_fields[:poll_interval].to_i
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should delete source masterdoc copy on delete" do
|
106
|
+
set_state('test_db_storage' => @data)
|
107
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
108
|
+
:state => :inprogress,
|
109
|
+
:app_id => @a.id,
|
110
|
+
:user_id => @u.id,
|
111
|
+
:sources => [@s_fields[:name]])
|
112
|
+
data.process_sources
|
113
|
+
verify_doc_result(@s, :md_copy => @data)
|
114
|
+
data.delete
|
115
|
+
verify_doc_result(@s, {:md_copy => {},
|
116
|
+
:md => @data})
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should escape bulk data url" do
|
120
|
+
name = 'a b'
|
121
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,name),
|
107
122
|
:state => :inprogress,
|
108
123
|
:app_id => @a.id,
|
109
|
-
:user_id =>
|
124
|
+
:user_id => name,
|
110
125
|
:sources => [@s_fields[:name]])
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
:md => @data})
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should escape bulk data url" do
|
119
|
-
name = 'a b'
|
120
|
-
data = BulkData.create(:name => bulk_data_docname(@a.id,name),
|
121
|
-
:state => :inprogress,
|
122
|
-
:app_id => @a.id,
|
123
|
-
:user_id => name,
|
124
|
-
:sources => [@s_fields[:name]])
|
125
|
-
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,name))
|
126
|
-
data = BulkData.load(bulk_data_docname(@a.id,name))
|
127
|
-
data.url.should match /a%20b/
|
128
|
-
data.delete
|
129
|
-
end
|
126
|
+
do_bulk_data_job("data_name" => bulk_data_docname(@a.id,name))
|
127
|
+
data = BulkData.load(bulk_data_docname(@a.id,name))
|
128
|
+
data.url.should match /a%20b/
|
129
|
+
data.delete
|
130
130
|
end
|
131
131
|
|
132
132
|
def create_datafile(dir,name)
|
data/spec/cli/cli_spec.rb
CHANGED
@@ -41,10 +41,29 @@ describe "RhoconnectCommandLineInterface" do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
# Captures $stdout and $stderr into strings
|
45
|
+
def capture_io
|
46
|
+
require 'stringio'
|
47
|
+
|
48
|
+
orig_stdout, orig_stderr = $stdout, $stderr
|
49
|
+
captured_stdout, captured_stderr = StringIO.new, StringIO.new
|
50
|
+
$stdout, $stderr = captured_stdout, captured_stderr
|
51
|
+
|
52
|
+
yield
|
53
|
+
|
54
|
+
return captured_stdout.string, captured_stderr.string
|
55
|
+
ensure
|
56
|
+
$stdout = orig_stdout
|
57
|
+
$stderr = orig_stderr
|
58
|
+
end
|
59
|
+
|
60
|
+
def run_in_sandbox
|
61
|
+
Dir.mktmpdir do |tmp_dir|
|
62
|
+
Dir.chdir(tmp_dir) do
|
63
|
+
# Run example in a sandbox on the file system
|
64
|
+
yield
|
65
|
+
end
|
66
|
+
end
|
48
67
|
end
|
49
68
|
|
50
69
|
after(:each) do
|
@@ -52,70 +71,48 @@ describe "RhoconnectCommandLineInterface" do
|
|
52
71
|
puts "\nExecuting 'rhoconnect stop' command ..." if pid
|
53
72
|
Execute.start ["stop"] # 'rhoconnect stop'
|
54
73
|
File.exist?("/tmp/rhoconnect.pid").should == false
|
55
|
-
`ps -p #{pid} -o pid=`.should be_empty if pid
|
56
|
-
end
|
57
|
-
|
58
|
-
after(:all) do
|
59
|
-
Dir.chdir @cur_dir
|
60
|
-
FileUtils.remove_entry @tmpdir
|
74
|
+
# `ps -p #{pid} -o pid=`.should be_empty if pid
|
61
75
|
end
|
62
76
|
|
63
77
|
it "'rhoconnect help' cmd should display list of available commands" do
|
64
|
-
|
65
|
-
out =
|
66
|
-
|
67
|
-
Execute.start ["help"] # 'rhoconnect help'
|
68
|
-
ensure
|
69
|
-
$stdout = STDOUT
|
78
|
+
run_in_sandbox do
|
79
|
+
out = capture_io{ Execute.start ["help"] }.join ''
|
80
|
+
out.strip.should start_with "Commands:"
|
70
81
|
end
|
71
|
-
out.string.strip.should start_with "Commands:"
|
72
82
|
end
|
73
83
|
|
74
84
|
it "'rhoconnect version' cmd should display gem version" do
|
75
|
-
|
76
|
-
out =
|
77
|
-
|
78
|
-
Execute.start ["version"] # 'rhoconnect version'
|
79
|
-
ensure
|
80
|
-
$stdout = STDOUT
|
85
|
+
run_in_sandbox do
|
86
|
+
out = capture_io{ Execute.start ["version"] }.join ''
|
87
|
+
out.strip.should == Rhoconnect::VERSION
|
81
88
|
end
|
82
|
-
out.string.strip.should == Rhoconnect::VERSION
|
83
89
|
end
|
84
90
|
|
85
91
|
it "'rhoconnect routes' cmd should display list of available routes" do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
out = StringIO.new
|
92
|
-
$stdout = out
|
93
|
-
Execute.start ["routes"] # 'rhoconnect routes'
|
94
|
-
ensure
|
95
|
-
$stdout = STDOUT
|
96
|
-
Dir.chdir @prev_dir
|
92
|
+
Dir.chdir(File.join(File.dirname(__FILE__), "..", "apps", "rhotestapp")) do
|
93
|
+
out = capture_io{ Execute.start ['routes'] }.join ''
|
94
|
+
out.strip.should include("SampleAdapterController: /app/v1/SampleAdapter")
|
95
|
+
out.strip.should include("FixedSchemaAdapterController: /app/v1/FixedSchemaAdapter")
|
96
|
+
out.strip.should_not include("FooAdapterController: /app/v1/FooAdapter")
|
97
97
|
end
|
98
|
-
out.string.strip.should include("SampleAdapterController: /app/v1/SampleAdapter")
|
99
|
-
out.string.strip.should include("FixedSchemaAdapterController: /app/v1/FixedSchemaAdapter")
|
100
|
-
out.string.strip.should_not include("FooAdapterController: /app/v1/FooAdapter")
|
101
98
|
end
|
102
99
|
|
103
100
|
it "'rhoconnect start' cmd should start blank app from any directory" do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
101
|
+
run_in_sandbox do
|
102
|
+
thread = Thread.new do
|
103
|
+
puts "Executing 'rhoconnect start' command ..."
|
104
|
+
# Array of params expected
|
105
|
+
Execute.start ["start"] # 'rhoconnect start'
|
106
|
+
end
|
107
|
+
30.times do
|
108
|
+
sleep 1
|
109
|
+
raise "'rhoconnect start' failed to start with exception" if thread.status.nil?
|
110
|
+
break if File.exist?("/tmp/rhoconnect.pid")
|
111
|
+
end
|
112
|
+
File.exist?("/tmp/rhoconnect.pid").should == true
|
113
|
+
pid = `cat /tmp/rhoconnect.pid`
|
114
|
+
puts "Rhoconnect app is running with pid=#{pid}"
|
115
|
+
`ps -p #{pid} -o pid=`.should_not be_empty
|
113
116
|
end
|
114
|
-
|
115
|
-
File.exist?("/tmp/rhoconnect.pid").should == true
|
116
|
-
pid = `cat /tmp/rhoconnect.pid`
|
117
|
-
puts "Rhoconnect app is running with pid=#{pid}"
|
118
|
-
`ps -p #{pid} -o pid=`.should_not be_empty
|
119
117
|
end
|
120
|
-
|
121
118
|
end
|