rhoconnect 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +208 -0
- data/CREDITS +38 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +97 -0
- data/LICENSE +75 -0
- data/README.md +10 -0
- data/Rakefile +82 -0
- data/bench/bench +7 -0
- data/bench/bench_runner.rb +112 -0
- data/bench/benchapp/Gemfile +21 -0
- data/bench/benchapp/Gemfile.lock +76 -0
- data/bench/benchapp/Rakefile +22 -0
- data/bench/benchapp/application.rb +39 -0
- data/bench/benchapp/config.ru +36 -0
- data/bench/benchapp/settings/license.key +1 -0
- data/bench/benchapp/settings/settings.yml +20 -0
- data/bench/benchapp/sources/mock_adapter.rb +55 -0
- data/bench/benchapp/sources/queue_mock_adapter.rb +2 -0
- data/bench/benchapp/spec/sources/mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/sources/queue_mock_adapter_spec.rb +25 -0
- data/bench/benchapp/spec/spec_helper.rb +42 -0
- data/bench/blobapp/Gemfile +31 -0
- data/bench/blobapp/Gemfile.lock +103 -0
- data/bench/blobapp/Rakefile +25 -0
- data/bench/blobapp/application.rb +44 -0
- data/bench/blobapp/config.ru +36 -0
- data/bench/blobapp/settings/license.key +1 -0
- data/bench/blobapp/settings/settings.yml +16 -0
- data/bench/blobapp/sources/blob_adapter.rb +71 -0
- data/bench/blobapp/spec/sources/blob_adapter_spec.rb +25 -0
- data/bench/blobapp/spec/spec_helper.rb +42 -0
- data/bench/lib/bench/cli.rb +16 -0
- data/bench/lib/bench/logging.rb +13 -0
- data/bench/lib/bench/mock_client.rb +41 -0
- data/bench/lib/bench/result.rb +50 -0
- data/bench/lib/bench/runner.rb +107 -0
- data/bench/lib/bench/session.rb +67 -0
- data/bench/lib/bench/statistics.rb +56 -0
- data/bench/lib/bench/test_data.rb +98 -0
- data/bench/lib/bench/timer.rb +10 -0
- data/bench/lib/bench/utils.rb +49 -0
- data/bench/lib/bench.rb +129 -0
- data/bench/lib/testdata/100-data.txt +148 -0
- data/bench/lib/testdata/5-data.txt +9 -0
- data/bench/lib/testdata/images/icon.ico +0 -0
- data/bench/lib/testdata/images/icon.png +0 -0
- data/bench/lib/testdata/images/loading-Landscape.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeLeft.png +0 -0
- data/bench/lib/testdata/images/loading-LandscapeRight.png +0 -0
- data/bench/lib/testdata/images/loading-Portrait.png +0 -0
- data/bench/lib/testdata/images/loading-PortraitUpsideDown.png +0 -0
- data/bench/lib/testdata/images/loading.png +0 -0
- data/bench/lib/testdata/images/loading@2x.png +0 -0
- data/bench/run_bench.sh +42 -0
- data/bench/run_blob_script.sh +3 -0
- data/bench/run_cud_script.sh +3 -0
- data/bench/run_query_md_script.sh +3 -0
- data/bench/run_query_only_script.sh +3 -0
- data/bench/run_query_script.sh +3 -0
- data/bench/scripts/blob_cud_script.rb +98 -0
- data/bench/scripts/cud_script.rb +92 -0
- data/bench/scripts/helpers.rb +101 -0
- data/bench/scripts/query_md_script.rb +45 -0
- data/bench/scripts/query_only_script.rb +51 -0
- data/bench/scripts/query_script.rb +45 -0
- data/bench/spec/bench_spec_helper.rb +33 -0
- data/bench/spec/logging_spec.rb +15 -0
- data/bench/spec/mock_adapter_spec.rb +61 -0
- data/bench/spec/mock_client_spec.rb +65 -0
- data/bench/spec/result_spec.rb +61 -0
- data/bench/spec/utils_spec.rb +36 -0
- data/bin/rhoconnect +34 -0
- data/bin/rhoconnect-setup +84 -0
- data/doc/async-jobs.txt +69 -0
- data/doc/authentication.txt +76 -0
- data/doc/benchmarks.txt +168 -0
- data/doc/blob-sync.txt +130 -0
- data/doc/bulk-sync.txt +102 -0
- data/doc/client.txt +432 -0
- data/doc/command-line.txt +210 -0
- data/doc/contributing.txt +60 -0
- data/doc/deploying.txt +82 -0
- data/doc/install.txt +28 -0
- data/doc/introduction.txt +20 -0
- data/doc/licensing.txt +18 -0
- data/doc/metadata.txt +458 -0
- data/doc/migration.txt +182 -0
- data/doc/public/css/print.css +29 -0
- data/doc/public/css/screen.css +257 -0
- data/doc/public/css/style.css +20 -0
- data/doc/push.txt +135 -0
- data/doc/release.txt +41 -0
- data/doc/rest-api.txt +367 -0
- data/doc/source-adapters.txt +325 -0
- data/doc/stats-middleware.txt +69 -0
- data/doc/testing.txt +222 -0
- data/doc/tutorial.txt +315 -0
- data/doc/web-console.txt +35 -0
- data/examples/simple/Rakefile +14 -0
- data/examples/simple/application.rb +27 -0
- data/examples/simple/config.ru +49 -0
- data/examples/simple/settings/license.key +1 -0
- data/examples/simple/settings/settings.yml +23 -0
- data/examples/simple/sources/sample_adapter.rb +5 -0
- data/examples/simple/sources/simple_adapter.rb +5 -0
- data/generators/rhoconnect.rb +119 -0
- data/generators/templates/application/Gemfile +21 -0
- data/generators/templates/application/Rakefile +22 -0
- data/generators/templates/application/application.rb +39 -0
- data/generators/templates/application/config.ru +36 -0
- data/generators/templates/application/settings/license.key +1 -0
- data/generators/templates/application/settings/settings.yml +14 -0
- data/generators/templates/application/spec/spec_helper.rb +42 -0
- data/generators/templates/source/source_adapter.rb +47 -0
- data/generators/templates/source/source_spec.rb +25 -0
- data/install.sh +408 -0
- data/installer/unix-like/rho_connect_install_checkers.rb +140 -0
- data/installer/unix-like/rho_connect_install_constants.rb +51 -0
- data/installer/unix-like/rho_connect_install_debian.rb +63 -0
- data/installer/unix-like/rho_connect_install_dnd.rb +58 -0
- data/installer/unix-like/rho_connect_install_get_params.rb +30 -0
- data/installer/unix-like/rho_connect_install_installers.rb +142 -0
- data/installer/unix-like/rho_connect_install_utilities.rb +85 -0
- data/installer/unix-like/rho_connect_install_yum.rb +63 -0
- data/installer/unix-like/rhoinstaller.rb +89 -0
- data/installer/utils/create_texts.rb +366 -0
- data/installer/utils/install_test.rb +140 -0
- data/installer/windows/EnvVarUpdate.nsh +328 -0
- data/installer/windows/ServiceLib.nsh +369 -0
- data/installer/windows/configUi.ini +44 -0
- data/installer/windows/icon.ico +0 -0
- data/installer/windows/rhosync.nsi +418 -0
- data/installer/windows/uninstall.bat +7 -0
- data/lib/rhoconnect/api/admin/get_api_token.rb +14 -0
- data/lib/rhoconnect/api/admin/get_license_info.rb +8 -0
- data/lib/rhoconnect/api/admin/login.rb +6 -0
- data/lib/rhoconnect/api/admin/reset.rb +10 -0
- data/lib/rhoconnect/api/admin/stats.rb +21 -0
- data/lib/rhoconnect/api/application/bulk_data.rb +7 -0
- data/lib/rhoconnect/api/application/clientcreate.rb +8 -0
- data/lib/rhoconnect/api/application/clientlogin.rb +6 -0
- data/lib/rhoconnect/api/application/clientregister.rb +6 -0
- data/lib/rhoconnect/api/application/clientreset.rb +6 -0
- data/lib/rhoconnect/api/application/query.rb +7 -0
- data/lib/rhoconnect/api/application/queue_updates.rb +6 -0
- data/lib/rhoconnect/api/application/search.rb +6 -0
- data/lib/rhoconnect/api/client/create_client.rb +3 -0
- data/lib/rhoconnect/api/client/delete_client.rb +5 -0
- data/lib/rhoconnect/api/client/get_client_params.rb +3 -0
- data/lib/rhoconnect/api/client/list_client_docs.rb +12 -0
- data/lib/rhoconnect/api/client/list_clients.rb +3 -0
- data/lib/rhoconnect/api/client/ping.rb +7 -0
- data/lib/rhoconnect/api/source/get_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/get_db_doc.rb +7 -0
- data/lib/rhoconnect/api/source/get_source_params.rb +3 -0
- data/lib/rhoconnect/api/source/list_source_docs.rb +10 -0
- data/lib/rhoconnect/api/source/list_sources.rb +15 -0
- data/lib/rhoconnect/api/source/push_deletes.rb +8 -0
- data/lib/rhoconnect/api/source/push_objects.rb +8 -0
- data/lib/rhoconnect/api/source/save_adapter.rb +3 -0
- data/lib/rhoconnect/api/source/set_db_doc.rb +8 -0
- data/lib/rhoconnect/api/source/set_refresh_time.rb +8 -0
- data/lib/rhoconnect/api/source/upload_file.rb +4 -0
- data/lib/rhoconnect/api/user/create_user.rb +7 -0
- data/lib/rhoconnect/api/user/delete_user.rb +9 -0
- data/lib/rhoconnect/api/user/list_users.rb +3 -0
- data/lib/rhoconnect/api/user/update_user.rb +4 -0
- data/lib/rhoconnect/api_token.rb +19 -0
- data/lib/rhoconnect/app.rb +76 -0
- data/lib/rhoconnect/bulk_data/bulk_data.rb +88 -0
- data/lib/rhoconnect/bulk_data/syncdb.index.schema +4 -0
- data/lib/rhoconnect/bulk_data/syncdb.schema +41 -0
- data/lib/rhoconnect/bulk_data.rb +2 -0
- data/lib/rhoconnect/client.rb +96 -0
- data/lib/rhoconnect/client_sync.rb +412 -0
- data/lib/rhoconnect/console/app/helpers/auth_helper.rb +22 -0
- data/lib/rhoconnect/console/app/helpers/extensions.rb +19 -0
- data/lib/rhoconnect/console/app/helpers/helpers.rb +57 -0
- data/lib/rhoconnect/console/app/public/ThickBox.css +649 -0
- data/lib/rhoconnect/console/app/public/home.css +438 -0
- data/lib/rhoconnect/console/app/public/images/foot_logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/header_halo.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/land_separator.gif +0 -0
- data/lib/rhoconnect/console/app/public/images/landing_header.jpg +0 -0
- data/lib/rhoconnect/console/app/public/images/logo_rhoconnect.png +0 -0
- data/lib/rhoconnect/console/app/public/images/rhomobile_rhohub_logo.png +0 -0
- data/lib/rhoconnect/console/app/public/images/tabs_separator.png +0 -0
- data/lib/rhoconnect/console/app/public/jqplot/excanvas.min.js +35 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.cursor.js +952 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
- data/lib/rhoconnect/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
- data/lib/rhoconnect/console/app/public/main.css +7 -0
- data/lib/rhoconnect/console/app/public/reset.css +76 -0
- data/lib/rhoconnect/console/app/public/style.css +2201 -0
- data/lib/rhoconnect/console/app/public/text.txt +0 -0
- data/lib/rhoconnect/console/app/routes/adapter.rb +28 -0
- data/lib/rhoconnect/console/app/routes/auth.rb +29 -0
- data/lib/rhoconnect/console/app/routes/client.rb +31 -0
- data/lib/rhoconnect/console/app/routes/docs.rb +145 -0
- data/lib/rhoconnect/console/app/routes/heroku.rb +19 -0
- data/lib/rhoconnect/console/app/routes/home.rb +63 -0
- data/lib/rhoconnect/console/app/routes/timing.rb +242 -0
- data/lib/rhoconnect/console/app/routes/user.rb +117 -0
- data/lib/rhoconnect/console/app/views/adapter.erb +16 -0
- data/lib/rhoconnect/console/app/views/client.erb +30 -0
- data/lib/rhoconnect/console/app/views/content.erb +14 -0
- data/lib/rhoconnect/console/app/views/doc.erb +8 -0
- data/lib/rhoconnect/console/app/views/docdata.erb +28 -0
- data/lib/rhoconnect/console/app/views/docs.erb +30 -0
- data/lib/rhoconnect/console/app/views/edituser.erb +13 -0
- data/lib/rhoconnect/console/app/views/headermenu.erb +40 -0
- data/lib/rhoconnect/console/app/views/home.erb +24 -0
- data/lib/rhoconnect/console/app/views/index.erb +58 -0
- data/lib/rhoconnect/console/app/views/jqplot.erb +52 -0
- data/lib/rhoconnect/console/app/views/layout.erb +165 -0
- data/lib/rhoconnect/console/app/views/login.erb +26 -0
- data/lib/rhoconnect/console/app/views/newuser.erb +17 -0
- data/lib/rhoconnect/console/app/views/ping.erb +28 -0
- data/lib/rhoconnect/console/app/views/result.erb +11 -0
- data/lib/rhoconnect/console/app/views/rightboxlinks.erb +15 -0
- data/lib/rhoconnect/console/app/views/select_doc.erb +17 -0
- data/lib/rhoconnect/console/app/views/upload_doc.erb +23 -0
- data/lib/rhoconnect/console/app/views/user.erb +29 -0
- data/lib/rhoconnect/console/app/views/users.erb +12 -0
- data/lib/rhoconnect/console/rhoconnect_api.rb +245 -0
- data/lib/rhoconnect/console/server.rb +32 -0
- data/lib/rhoconnect/console.rb +3 -0
- data/lib/rhoconnect/cors.rb +229 -0
- data/lib/rhoconnect/credential.rb +9 -0
- data/lib/rhoconnect/db_adapter.rb +46 -0
- data/lib/rhoconnect/document.rb +49 -0
- data/lib/rhoconnect/dynamic_adapter.rb +91 -0
- data/lib/rhoconnect/generator.rb +1 -0
- data/lib/rhoconnect/jobs/bulk_data_job.rb +203 -0
- data/lib/rhoconnect/jobs/ping_job.rb +46 -0
- data/lib/rhoconnect/jobs/source_job.rb +16 -0
- data/lib/rhoconnect/license.rb +86 -0
- data/lib/rhoconnect/lock_ops.rb +11 -0
- data/lib/rhoconnect/model.rb +414 -0
- data/lib/rhoconnect/ping/android.rb +56 -0
- data/lib/rhoconnect/ping/apple.rb +52 -0
- data/lib/rhoconnect/ping/blackberry.rb +56 -0
- data/lib/rhoconnect/ping.rb +3 -0
- data/lib/rhoconnect/read_state.rb +31 -0
- data/lib/rhoconnect/rho_indifferent_access.rb +88 -0
- data/lib/rhoconnect/server/views/index.erb +13 -0
- data/lib/rhoconnect/server.rb +286 -0
- data/lib/rhoconnect/source.rb +289 -0
- data/lib/rhoconnect/source_adapter.rb +123 -0
- data/lib/rhoconnect/source_sync.rb +302 -0
- data/lib/rhoconnect/stats/middleware.rb +20 -0
- data/lib/rhoconnect/stats/record.rb +108 -0
- data/lib/rhoconnect/store.rb +232 -0
- data/lib/rhoconnect/tasks.rb +350 -0
- data/lib/rhoconnect/test_methods.rb +220 -0
- data/lib/rhoconnect/user.rb +95 -0
- data/lib/rhoconnect/version.rb +3 -0
- data/lib/rhoconnect/x_domain_session_wrapper.rb +53 -0
- data/lib/rhoconnect.rb +285 -0
- data/rhoconnect.gemspec +67 -0
- data/spec/api/admin/api_token_spec.rb +14 -0
- data/spec/api/admin/get_api_token_spec.rb +36 -0
- data/spec/api/admin/get_license_info_spec.rb +38 -0
- data/spec/api/admin/reset_spec.rb +22 -0
- data/spec/api/admin/stats_spec.rb +66 -0
- data/spec/api/api_helper.rb +21 -0
- data/spec/api/application/rhoconnect_api_spec.rb +548 -0
- data/spec/api/client/create_client_spec.rb +13 -0
- data/spec/api/client/delete_client_spec.rb +13 -0
- data/spec/api/client/get_client_params_spec.rb +18 -0
- data/spec/api/client/list_client_docs_spec.rb +32 -0
- data/spec/api/client/list_clients_spec.rb +22 -0
- data/spec/api/client/ping_spec.rb +23 -0
- data/spec/api/rhosync_api_spec.rb.orig +606 -0
- data/spec/api/source/adapter_spec.rb +29 -0
- data/spec/api/source/get_db_doc_spec.rb +21 -0
- data/spec/api/source/get_source_params_spec.rb +32 -0
- data/spec/api/source/list_source_docs_spec.rb +25 -0
- data/spec/api/source/list_sources_spec.rb +26 -0
- data/spec/api/source/push_deletes_spec.rb +18 -0
- data/spec/api/source/push_objects_spec.rb +27 -0
- data/spec/api/source/set_db_doc_spec.rb +19 -0
- data/spec/api/source/set_refresh_time_spec.rb +43 -0
- data/spec/api/source/upload_file_spec.rb +26 -0
- data/spec/api/user/create_user_spec.rb +16 -0
- data/spec/api/user/delete_user_spec.rb +36 -0
- data/spec/api/user/list_users_spec.rb +30 -0
- data/spec/api/user/update_user_spec.rb +31 -0
- data/spec/api_token_spec.rb +14 -0
- data/spec/app_spec.rb +18 -0
- data/spec/apps/emptyapp/application.rb +27 -0
- data/spec/apps/emptyapp/settings/license.key +1 -0
- data/spec/apps/emptyapp/settings/settings.yml +14 -0
- data/spec/apps/rhotestapp/Rakefile +1 -0
- data/spec/apps/rhotestapp/application.rb +19 -0
- data/spec/apps/rhotestapp/config.ru +1 -0
- data/spec/apps/rhotestapp/settings/apple_fake_cert.pem +1 -0
- data/spec/apps/rhotestapp/settings/license.key +1 -0
- data/spec/apps/rhotestapp/settings/settings.yml +36 -0
- data/spec/apps/rhotestapp/sources/base_adapter.rb +9 -0
- data/spec/apps/rhotestapp/sources/fixed_schema_adapter.rb +28 -0
- data/spec/apps/rhotestapp/sources/sample_adapter.rb +71 -0
- data/spec/apps/rhotestapp/sources/simple_adapter.rb +41 -0
- data/spec/apps/rhotestapp/sources/sub_adapter.rb +7 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem/mygem.rb +8 -0
- data/spec/apps/rhotestapp/vendor/mygem-0.1.0/lib/mygem.rb +1 -0
- data/spec/bulk_data/bulk_data_spec.rb +97 -0
- data/spec/client_spec.rb +124 -0
- data/spec/client_sync_spec.rb +774 -0
- data/spec/doc/base.html +72 -0
- data/spec/doc/doc_spec.rb +376 -0
- data/spec/doc/footer.html +4 -0
- data/spec/doc/header.html +30 -0
- data/spec/document_spec.rb +31 -0
- data/spec/dynamic_adapter_spec.rb +43 -0
- data/spec/factories/factories.rb +17 -0
- data/spec/generator/generator_spec.rb +58 -0
- data/spec/generator/generator_spec_helper.rb +9 -0
- data/spec/jobs/bulk_data_job_spec.rb +125 -0
- data/spec/jobs/ping_job_spec.rb +102 -0
- data/spec/jobs/source_job_spec.rb +29 -0
- data/spec/license_spec.rb +66 -0
- data/spec/model_spec.rb +273 -0
- data/spec/perf/bulk_data_perf_spec.rb +32 -0
- data/spec/perf/perf_spec_helper.rb +50 -0
- data/spec/perf/store_perf_spec.rb +27 -0
- data/spec/ping/android_spec.rb +91 -0
- data/spec/ping/apple_spec.rb +70 -0
- data/spec/ping/blackberry_spec.rb +62 -0
- data/spec/read_state_spec.rb +35 -0
- data/spec/rhosync_spec.rb +75 -0
- data/spec/server/cors_spec.rb +287 -0
- data/spec/server/server_spec.rb +470 -0
- data/spec/server/x_domain_session_wrapper_spec.rb +150 -0
- data/spec/source_adapter_spec.rb +125 -0
- data/spec/source_spec.rb +114 -0
- data/spec/source_sync_spec.rb +328 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +231 -0
- data/spec/stats/middleware_spec.rb +53 -0
- data/spec/stats/record_spec.rb +92 -0
- data/spec/store_spec.rb +251 -0
- data/spec/support/shared_examples.rb +168 -0
- data/spec/sync_states_spec.rb +72 -0
- data/spec/test_methods_spec.rb +134 -0
- data/spec/testdata/1000-data.txt +1414 -0
- data/spec/testdata/compressed/compress-data.txt +1 -0
- data/spec/testdata/upload1.txt +1 -0
- data/spec/testdata/upload2.txt +1 -0
- data/spec/user_spec.rb +139 -0
- data/tasks/redis.rake +206 -0
- metadata +706 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
class SimpleAdapter < SourceAdapter
|
2
|
+
# initialize method created by source generator (Rhoconnect version < 2.2.0)
|
3
|
+
def initialize(source,credential)
|
4
|
+
super(source,credential)
|
5
|
+
end
|
6
|
+
|
7
|
+
def login
|
8
|
+
unless _is_empty?(current_user.login)
|
9
|
+
true
|
10
|
+
else
|
11
|
+
raise SourceAdapterLoginException.new('Error logging in')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def query(params=nil)
|
16
|
+
@result
|
17
|
+
end
|
18
|
+
|
19
|
+
def search(params=nil,txt='')
|
20
|
+
params[:foo] = 'bar' # this is for 'chaining' test
|
21
|
+
if params['search'] == 'bar'
|
22
|
+
@result = {'obj'=>{'foo'=>'bar'}}
|
23
|
+
# this is for 'chaining' test, addind 'iPhone' to trogger Sample adapter search result
|
24
|
+
params['name'] = 'iPhone'
|
25
|
+
end
|
26
|
+
@result
|
27
|
+
end
|
28
|
+
|
29
|
+
def sync
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def create(create_hash)
|
34
|
+
'obj4'
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def _is_empty?(str)
|
39
|
+
str.length <= 0
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'mygem/mygem'
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'support', 'shared_examples')
|
3
|
+
|
4
|
+
describe "BulkData" do
|
5
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
6
|
+
before(:each) do
|
7
|
+
@s = Source.load(@s_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
|
24
|
+
|
25
|
+
it "should return false if bulk data isn't completed" do
|
26
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
27
|
+
:state => :inprogress,
|
28
|
+
:app_id => @a.id,
|
29
|
+
:user_id => @u.id,
|
30
|
+
:sources => [@s_fields[:name]])
|
31
|
+
data.completed?.should == false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should expire_bulk_data from a source adapter" do
|
35
|
+
adapter = SourceSync.new(@s).adapter
|
36
|
+
time = Time.now.to_i + 10000
|
37
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
38
|
+
:state => :inprogress,
|
39
|
+
:app_id => @a.id,
|
40
|
+
:user_id => @u.id,
|
41
|
+
:sources => [@s_fields[:name]],
|
42
|
+
:refresh_time => time)
|
43
|
+
adapter.expire_bulk_data
|
44
|
+
data = BulkData.load(bulk_data_docname(@a.id,@u.id))
|
45
|
+
data.refresh_time.should <= Time.now.to_i
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should enqueue sqlite db type" do
|
49
|
+
BulkData.enqueue
|
50
|
+
Resque.peek(:bulk_data).should == {"args"=>[{}],
|
51
|
+
"class"=>"Rhoconnect::BulkDataJob"}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should generate correct bulk data name for user partition" do
|
55
|
+
BulkData.get_name(:user,@c.user_id).should == File.join(@a_fields[:name],@u_fields[:login],@u_fields[:login])
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should generate correct bulk data name for app partition" do
|
59
|
+
BulkData.get_name(:app,@c.user_id).should ==
|
60
|
+
File.join(@a_fields[:name],@a_fields[:name])
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should process_sources for bulk data" do
|
64
|
+
current = Time.now.to_i
|
65
|
+
@s.read_state.refresh_time = current
|
66
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
67
|
+
:state => :inprogress,
|
68
|
+
:app_id => @a.id,
|
69
|
+
:user_id => @u.id,
|
70
|
+
:sources => [@s_fields[:name]])
|
71
|
+
data.process_sources
|
72
|
+
@s.read_state.refresh_time.should >= current + @s_fields[:poll_interval].to_i
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should delete source masterdoc copy on delete" do
|
76
|
+
set_state('test_db_storage' => @data)
|
77
|
+
data = BulkData.create(:name => bulk_data_docname(@a.id,@u.id),
|
78
|
+
:state => :inprogress,
|
79
|
+
:app_id => @a.id,
|
80
|
+
:user_id => @u.id,
|
81
|
+
:sources => [@s_fields[:name]])
|
82
|
+
data.process_sources
|
83
|
+
verify_result(@s.docname(:md_copy) => @data)
|
84
|
+
data.delete
|
85
|
+
verify_result(@s.docname(:md_copy) => {},
|
86
|
+
@s.docname(:md) => @data)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_datafile(dir,name)
|
91
|
+
dir = File.join(Rhoconnect.data_directory,dir)
|
92
|
+
FileUtils.mkdir_p(dir)
|
93
|
+
fname = File.join(dir,name+'.data')
|
94
|
+
File.open(fname,'wb') {|f| f.puts ''}
|
95
|
+
fname
|
96
|
+
end
|
97
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'support', 'shared_examples')
|
3
|
+
|
4
|
+
STATS_RECORD_RESOLUTION = 2 unless defined? STATS_RECORD_RESOLUTION
|
5
|
+
STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
|
6
|
+
|
7
|
+
describe "Client" do
|
8
|
+
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => false do
|
9
|
+
before(:each) do
|
10
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
11
|
+
end
|
12
|
+
|
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
|
17
|
+
|
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
|
23
|
+
|
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
|
30
|
+
|
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
|
37
|
+
|
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
|
+
docname = @c.docname(:cd)
|
54
|
+
set_state(docname => @data)
|
55
|
+
@c.delete
|
56
|
+
verify_result(docname => {})
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should switch client user and remove existing documents" do
|
60
|
+
docname = @c.docname(:cd)
|
61
|
+
set_state(docname => @data)
|
62
|
+
verify_result(@c.docname(:cd) => @data)
|
63
|
+
User.create({:login => 'user2'})
|
64
|
+
@c.switch_user('user2')
|
65
|
+
verify_result(@c.docname(:cd) => {},docname => {})
|
66
|
+
@u.clients.members.should == []
|
67
|
+
@c.user_id.should == 'user2'
|
68
|
+
User.load('user2').clients.members.should == [@c.id]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should create cd as masterdoc clone" do
|
72
|
+
set_state(@s.docname(:md_copy) => @data,
|
73
|
+
@c.docname(:cd) => {'foo' => {'bar' => 'abc'}})
|
74
|
+
@c.update_clientdoc([@s_fields[:name]])
|
75
|
+
verify_result(@c.docname(:cd) => @data,
|
76
|
+
@s.docname(:md_copy) => @data)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should update client schema_sha1" do
|
80
|
+
set_state(@s.docname(:md_copy) => @data,
|
81
|
+
@s.docname(:schema_sha1) => 'foobar',
|
82
|
+
@c.docname(:cd) => {'foo' => {'bar' => 'abc'}})
|
83
|
+
@c.update_clientdoc([@s_fields[:name]])
|
84
|
+
verify_result(@c.docname(:cd) => @data,
|
85
|
+
@s.docname(:md_copy) => @data,
|
86
|
+
@c.docname(:schema_sha1) => 'foobar')
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "Client Stats" do
|
90
|
+
|
91
|
+
before(:each) do
|
92
|
+
Rhoconnect::Stats::Record.reset('clients')
|
93
|
+
end
|
94
|
+
|
95
|
+
after(:each) do
|
96
|
+
Rhoconnect::Stats::Record.reset('clients')
|
97
|
+
end
|
98
|
+
|
99
|
+
after(:all) do
|
100
|
+
Store.flash_data('stat:clients*')
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should increment clients stats on create" do
|
104
|
+
Time.stub!(:now).and_return(10)
|
105
|
+
Rhoconnect.stats = true
|
106
|
+
Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
107
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
108
|
+
Store.get_value('client:count').should == "2"
|
109
|
+
Rhoconnect.stats = false
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should decrement clients stats on delete" do
|
113
|
+
Time.stub!(:now).and_return(10)
|
114
|
+
Rhoconnect.stats = true
|
115
|
+
c = Client.create(@c_fields,{:source_name => @s_fields[:name]})
|
116
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["2:10"]
|
117
|
+
c.delete
|
118
|
+
Rhoconnect::Stats::Record.range('clients',0,-1).should == ["1:10"]
|
119
|
+
Store.get_value('client:count').should == "1"
|
120
|
+
Rhoconnect.stats = false
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|