cuboid 0.0.0 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +0 -0
- data/Gemfile +22 -5
- data/LICENSE.md +22 -0
- data/README.md +158 -19
- data/Rakefile +56 -3
- data/config/paths.yml +15 -0
- data/cuboid.gemspec +61 -23
- data/lib/cuboid/application/parts/data.rb +18 -0
- data/lib/cuboid/application/parts/report.rb +29 -0
- data/lib/cuboid/application/parts/state.rb +274 -0
- data/lib/cuboid/application/runtime.rb +25 -0
- data/lib/cuboid/application.rb +326 -0
- data/lib/cuboid/banner.rb +13 -0
- data/lib/cuboid/data/application.rb +52 -0
- data/lib/cuboid/data.rb +86 -0
- data/lib/cuboid/error.rb +9 -0
- data/lib/cuboid/option_group.rb +129 -0
- data/lib/cuboid/option_groups/datastore.rb +23 -0
- data/lib/cuboid/option_groups/dispatcher.rb +38 -0
- data/lib/cuboid/option_groups/output.rb +14 -0
- data/lib/cuboid/option_groups/paths.rb +184 -0
- data/lib/cuboid/option_groups/report.rb +39 -0
- data/lib/cuboid/option_groups/rpc.rb +105 -0
- data/lib/cuboid/option_groups/scheduler.rb +27 -0
- data/lib/cuboid/option_groups/snapshot.rb +13 -0
- data/lib/cuboid/option_groups/system.rb +10 -0
- data/lib/cuboid/option_groups.rb +8 -0
- data/lib/cuboid/options.rb +254 -0
- data/lib/cuboid/processes/dispatchers.rb +140 -0
- data/lib/cuboid/processes/executables/base.rb +54 -0
- data/lib/cuboid/processes/executables/dispatcher.rb +5 -0
- data/lib/cuboid/processes/executables/instance.rb +12 -0
- data/lib/cuboid/processes/executables/rest_service.rb +13 -0
- data/lib/cuboid/processes/executables/scheduler.rb +5 -0
- data/lib/cuboid/processes/helpers/dispatchers.rb +23 -0
- data/lib/cuboid/processes/helpers/instances.rb +39 -0
- data/lib/cuboid/processes/helpers/processes.rb +23 -0
- data/lib/cuboid/processes/helpers/schedulers.rb +23 -0
- data/lib/cuboid/processes/helpers.rb +4 -0
- data/lib/cuboid/processes/instances.rb +203 -0
- data/lib/cuboid/processes/manager.rb +262 -0
- data/lib/cuboid/processes/schedulers.rb +128 -0
- data/lib/cuboid/processes.rb +13 -0
- data/lib/cuboid/report.rb +220 -0
- data/lib/cuboid/rest/server/instance_helpers.rb +99 -0
- data/lib/cuboid/rest/server/routes/dispatcher.rb +41 -0
- data/lib/cuboid/rest/server/routes/grid.rb +41 -0
- data/lib/cuboid/rest/server/routes/instances.rb +131 -0
- data/lib/cuboid/rest/server/routes/scheduler.rb +140 -0
- data/lib/cuboid/rest/server.rb +165 -0
- data/lib/cuboid/rpc/client/base.rb +58 -0
- data/lib/cuboid/rpc/client/dispatcher.rb +58 -0
- data/lib/cuboid/rpc/client/instance/service.rb +37 -0
- data/lib/cuboid/rpc/client/instance.rb +100 -0
- data/lib/cuboid/rpc/client/scheduler.rb +46 -0
- data/lib/cuboid/rpc/client.rb +3 -0
- data/lib/cuboid/rpc/serializer.rb +92 -0
- data/lib/cuboid/rpc/server/active_options.rb +38 -0
- data/lib/cuboid/rpc/server/application_wrapper.rb +138 -0
- data/lib/cuboid/rpc/server/base.rb +63 -0
- data/lib/cuboid/rpc/server/dispatcher/node.rb +247 -0
- data/lib/cuboid/rpc/server/dispatcher/service.rb +145 -0
- data/lib/cuboid/rpc/server/dispatcher.rb +317 -0
- data/lib/cuboid/rpc/server/instance.rb +338 -0
- data/lib/cuboid/rpc/server/output.rb +92 -0
- data/lib/cuboid/rpc/server/scheduler.rb +482 -0
- data/lib/cuboid/ruby/array.rb +17 -0
- data/lib/cuboid/ruby/hash.rb +41 -0
- data/lib/cuboid/ruby/object.rb +32 -0
- data/lib/cuboid/ruby.rb +4 -0
- data/lib/cuboid/snapshot.rb +186 -0
- data/lib/cuboid/state/application.rb +309 -0
- data/lib/cuboid/state/options.rb +27 -0
- data/lib/cuboid/state.rb +94 -0
- data/lib/cuboid/support/buffer/autoflush.rb +61 -0
- data/lib/cuboid/support/buffer/base.rb +91 -0
- data/lib/cuboid/support/buffer.rb +3 -0
- data/lib/cuboid/support/cache/base.rb +226 -0
- data/lib/cuboid/support/cache/least_cost_replacement.rb +77 -0
- data/lib/cuboid/support/cache/least_recently_pushed.rb +21 -0
- data/lib/cuboid/support/cache/least_recently_used.rb +31 -0
- data/lib/cuboid/support/cache/preference.rb +31 -0
- data/lib/cuboid/support/cache/random_replacement.rb +20 -0
- data/lib/cuboid/support/cache.rb +7 -0
- data/lib/cuboid/support/crypto/rsa_aes_cbc.rb +86 -0
- data/lib/cuboid/support/crypto.rb +2 -0
- data/lib/cuboid/support/database/base.rb +177 -0
- data/lib/cuboid/support/database/categorized_queue.rb +195 -0
- data/lib/cuboid/support/database/hash.rb +300 -0
- data/lib/cuboid/support/database/queue.rb +149 -0
- data/lib/cuboid/support/database.rb +5 -0
- data/lib/cuboid/support/filter/base.rb +110 -0
- data/lib/cuboid/support/filter/set.rb +29 -0
- data/lib/cuboid/support/filter.rb +3 -0
- data/lib/cuboid/support/glob.rb +27 -0
- data/lib/cuboid/support/mixins/observable.rb +99 -0
- data/lib/cuboid/support/mixins/parts.rb +20 -0
- data/lib/cuboid/support/mixins/profiler.rb +93 -0
- data/lib/cuboid/support/mixins/spec_instances.rb +65 -0
- data/lib/cuboid/support/mixins/terminal.rb +57 -0
- data/lib/cuboid/support/mixins.rb +8 -0
- data/lib/cuboid/support.rb +11 -0
- data/lib/cuboid/system/platforms/linux.rb +26 -0
- data/lib/cuboid/system/platforms/mixins/unix.rb +46 -0
- data/lib/cuboid/system/platforms/osx.rb +25 -0
- data/lib/cuboid/system/platforms/windows.rb +81 -0
- data/lib/cuboid/system/platforms.rb +84 -0
- data/lib/cuboid/system/slots.rb +143 -0
- data/lib/cuboid/system.rb +119 -0
- data/lib/cuboid/ui/output.rb +52 -0
- data/lib/cuboid/ui/output_interface/abstract.rb +68 -0
- data/lib/cuboid/ui/output_interface/controls.rb +84 -0
- data/lib/cuboid/ui/output_interface/error_logging.rb +119 -0
- data/lib/cuboid/ui/output_interface/implemented.rb +58 -0
- data/lib/cuboid/ui/output_interface/personalization.rb +62 -0
- data/lib/cuboid/ui/output_interface.rb +43 -0
- data/lib/cuboid/utilities.rb +155 -0
- data/lib/cuboid/version.rb +4 -3
- data/lib/cuboid.rb +96 -4
- data/lib/version +1 -0
- data/logs/error-3207383.log +106 -0
- data/logs/error-3207482.log +106 -0
- data/logs/error-3208344.log +109 -0
- data/logs/error-3208460.log +106 -0
- data/logs/error-903730.log +105 -0
- data/logs/error-903846.log +105 -0
- data/logs/error-904783.log +108 -0
- data/logs/error-905101.log +105 -0
- data/logs/placeholder +0 -0
- data/spec/cuboid/application/parts/data_spec.rb +12 -0
- data/spec/cuboid/application/parts/report_spec.rb +6 -0
- data/spec/cuboid/application/parts/state_spec.rb +192 -0
- data/spec/cuboid/application/runtime_spec.rb +21 -0
- data/spec/cuboid/application_spec.rb +37 -0
- data/spec/cuboid/data/application_spec.rb +22 -0
- data/spec/cuboid/data_spec.rb +47 -0
- data/spec/cuboid/error_spec.rb +23 -0
- data/spec/cuboid/option_groups/datastore_spec.rb +54 -0
- data/spec/cuboid/option_groups/dispatcher_spec.rb +12 -0
- data/spec/cuboid/option_groups/output_spec.rb +11 -0
- data/spec/cuboid/option_groups/paths_spec.rb +184 -0
- data/spec/cuboid/option_groups/report_spec.rb +26 -0
- data/spec/cuboid/option_groups/rpc_spec.rb +53 -0
- data/spec/cuboid/option_groups/snapshot_spec.rb +26 -0
- data/spec/cuboid/option_groups/system.rb +12 -0
- data/spec/cuboid/options_spec.rb +218 -0
- data/spec/cuboid/report_spec.rb +221 -0
- data/spec/cuboid/rest/server_spec.rb +1205 -0
- data/spec/cuboid/rpc/client/base_spec.rb +151 -0
- data/spec/cuboid/rpc/client/dispatcher_spec.rb +13 -0
- data/spec/cuboid/rpc/client/instance_spec.rb +38 -0
- data/spec/cuboid/rpc/server/active_options_spec.rb +21 -0
- data/spec/cuboid/rpc/server/base_spec.rb +60 -0
- data/spec/cuboid/rpc/server/dispatcher/node_spec.rb +222 -0
- data/spec/cuboid/rpc/server/dispatcher/service_spec.rb +112 -0
- data/spec/cuboid/rpc/server/dispatcher_spec.rb +317 -0
- data/spec/cuboid/rpc/server/instance_spec.rb +307 -0
- data/spec/cuboid/rpc/server/output_spec.rb +32 -0
- data/spec/cuboid/rpc/server/scheduler_spec.rb +400 -0
- data/spec/cuboid/ruby/array_spec.rb +77 -0
- data/spec/cuboid/ruby/hash_spec.rb +63 -0
- data/spec/cuboid/ruby/object_spec.rb +22 -0
- data/spec/cuboid/snapshot_spec.rb +123 -0
- data/spec/cuboid/state/application_spec.rb +538 -0
- data/spec/cuboid/state/options_spec.rb +37 -0
- data/spec/cuboid/state_spec.rb +53 -0
- data/spec/cuboid/support/buffer/autoflush_spec.rb +78 -0
- data/spec/cuboid/support/buffer/base_spec.rb +193 -0
- data/spec/cuboid/support/cache/least_cost_replacement_spec.rb +61 -0
- data/spec/cuboid/support/cache/least_recently_pushed_spec.rb +90 -0
- data/spec/cuboid/support/cache/least_recently_used_spec.rb +80 -0
- data/spec/cuboid/support/cache/preference_spec.rb +37 -0
- data/spec/cuboid/support/cache/random_replacement_spec.rb +42 -0
- data/spec/cuboid/support/crypto/rsa_aes_cbc_spec.rb +28 -0
- data/spec/cuboid/support/database/categorized_queue_spec.rb +327 -0
- data/spec/cuboid/support/database/hash_spec.rb +204 -0
- data/spec/cuboid/support/database/scheduler_spec.rb +325 -0
- data/spec/cuboid/support/filter/set_spec.rb +19 -0
- data/spec/cuboid/support/glob_spec.rb +75 -0
- data/spec/cuboid/support/mixins/observable_spec.rb +95 -0
- data/spec/cuboid/system/platforms/linux_spec.rb +31 -0
- data/spec/cuboid/system/platforms/osx_spec.rb +32 -0
- data/spec/cuboid/system/platforms/windows_spec.rb +41 -0
- data/spec/cuboid/system/slots_spec.rb +202 -0
- data/spec/cuboid/system_spec.rb +105 -0
- data/spec/cuboid/utilities_spec.rb +131 -0
- data/spec/spec_helper.rb +46 -0
- data/spec/support/factories/placeholder +0 -0
- data/spec/support/factories/scan_report.rb +18 -0
- data/spec/support/fixtures/empty/placeholder +0 -0
- data/spec/support/fixtures/executables/node.rb +50 -0
- data/spec/support/fixtures/mock_app/test_service.rb +64 -0
- data/spec/support/fixtures/mock_app.rb +61 -0
- data/spec/support/fixtures/services/echo.rb +64 -0
- data/spec/support/helpers/framework.rb +3 -0
- data/spec/support/helpers/matchers.rb +5 -0
- data/spec/support/helpers/misc.rb +3 -0
- data/spec/support/helpers/paths.rb +15 -0
- data/spec/support/helpers/request_helpers.rb +38 -0
- data/spec/support/helpers/requires.rb +8 -0
- data/spec/support/helpers/resets.rb +52 -0
- data/spec/support/helpers/web_server.rb +15 -0
- data/spec/support/lib/factory.rb +107 -0
- data/spec/support/lib/web_server_client.rb +41 -0
- data/spec/support/lib/web_server_dispatcher.rb +25 -0
- data/spec/support/lib/web_server_manager.rb +118 -0
- data/spec/support/logs/Dispatcher - 3204062-27546.log +6 -0
- data/spec/support/logs/Dispatcher - 3207166-30195.log +6 -0
- data/spec/support/logs/Dispatcher - 3207418-16491.log +6 -0
- data/spec/support/logs/Dispatcher - 3207420-23797.log +6 -0
- data/spec/support/logs/Dispatcher - 3207424-64333.log +6 -0
- data/spec/support/logs/Dispatcher - 3207427-50621.log +10 -0
- data/spec/support/logs/Dispatcher - 3207429-15351.log +10 -0
- data/spec/support/logs/Dispatcher - 3207432-3685.log +10 -0
- data/spec/support/logs/Dispatcher - 3207436-43126.log +10 -0
- data/spec/support/logs/Dispatcher - 3207438-58131.log +10 -0
- data/spec/support/logs/Dispatcher - 3207440-32187.log +10 -0
- data/spec/support/logs/Dispatcher - 3207654-42085.log +6 -0
- data/spec/support/logs/Dispatcher - 3207769-16303.log +6 -0
- data/spec/support/logs/Dispatcher - 3207771-31196.log +6 -0
- data/spec/support/logs/Dispatcher - 3207773-53419.log +6 -0
- data/spec/support/logs/Dispatcher - 3207775-17015.log +6 -0
- data/spec/support/logs/Dispatcher - 3207787-56572.log +6 -0
- data/spec/support/logs/Dispatcher - 3207799-41227.log +6 -0
- data/spec/support/logs/Dispatcher - 3207815-49397.log +6 -0
- data/spec/support/logs/Dispatcher - 3207817-13826.log +6 -0
- data/spec/support/logs/Dispatcher - 3207819-46821.log +6 -0
- data/spec/support/logs/Dispatcher - 3207821-37991.log +6 -0
- data/spec/support/logs/Dispatcher - 3207825-52955.log +6 -0
- data/spec/support/logs/Dispatcher - 3207829-12122.log +6 -0
- data/spec/support/logs/Dispatcher - 3207831-58485.log +16 -0
- data/spec/support/logs/Dispatcher - 3207833-47083.log +14 -0
- data/spec/support/logs/Dispatcher - 3207837-53679.log +10 -0
- data/spec/support/logs/Dispatcher - 3207847-12037.log +16 -0
- data/spec/support/logs/Dispatcher - 3207852-64296.log +14 -0
- data/spec/support/logs/Dispatcher - 3207858-56473.log +10 -0
- data/spec/support/logs/Dispatcher - 3207864-26736.log +6 -0
- data/spec/support/logs/Dispatcher - 3207866-24113.log +6 -0
- data/spec/support/logs/Dispatcher - 3207870-6896.log +6 -0
- data/spec/support/logs/Dispatcher - 3207873-16434.log +6 -0
- data/spec/support/logs/Dispatcher - 3207885-31058.log +6 -0
- data/spec/support/logs/Dispatcher - 3207891-19927.log +6 -0
- data/spec/support/logs/Dispatcher - 3207897-41533.log +6 -0
- data/spec/support/logs/Dispatcher - 3207903-26815.log +6 -0
- data/spec/support/logs/Dispatcher - 3207909-25294.log +6 -0
- data/spec/support/logs/Dispatcher - 3207929-51610.log +6 -0
- data/spec/support/logs/Dispatcher - 3207990-8943.log +16 -0
- data/spec/support/logs/Dispatcher - 3208000-30657.log +14 -0
- data/spec/support/logs/Dispatcher - 3208010-54017.log +10 -0
- data/spec/support/logs/Dispatcher - 3208041-58792.log +16 -0
- data/spec/support/logs/Dispatcher - 3208047-50811.log +14 -0
- data/spec/support/logs/Dispatcher - 3208051-52018.log +10 -0
- data/spec/support/logs/Dispatcher - 3208067-46852.log +6 -0
- data/spec/support/logs/Dispatcher - 3208075-56209.log +6 -0
- data/spec/support/logs/Dispatcher - 3208088-4783.log +6 -0
- data/spec/support/logs/Dispatcher - 3208100-47518.log +6 -0
- data/spec/support/logs/Dispatcher - 3208115-25109.log +6 -0
- data/spec/support/logs/Dispatcher - 3208127-46551.log +6 -0
- data/spec/support/logs/Dispatcher - 3208133-2576.log +6 -0
- data/spec/support/logs/Dispatcher - 3208138-25988.log +6 -0
- data/spec/support/logs/Dispatcher - 3208299-19611.log +6 -0
- data/spec/support/logs/Dispatcher - 3208330-35076.log +6 -0
- data/spec/support/logs/Dispatcher - 3208340-32759.log +6 -0
- data/spec/support/logs/Dispatcher - 903393-34771.log +6 -0
- data/spec/support/logs/Dispatcher - 903765-19862.log +6 -0
- data/spec/support/logs/Dispatcher - 903767-43611.log +6 -0
- data/spec/support/logs/Dispatcher - 903770-34337.log +6 -0
- data/spec/support/logs/Dispatcher - 903774-7484.log +10 -0
- data/spec/support/logs/Dispatcher - 903777-5256.log +10 -0
- data/spec/support/logs/Dispatcher - 903780-12391.log +10 -0
- data/spec/support/logs/Dispatcher - 903782-54621.log +10 -0
- data/spec/support/logs/Dispatcher - 903786-46071.log +10 -0
- data/spec/support/logs/Dispatcher - 903794-48819.log +10 -0
- data/spec/support/logs/Dispatcher - 903906-54562.log +6 -0
- data/spec/support/logs/Dispatcher - 904068-37293.log +6 -0
- data/spec/support/logs/Dispatcher - 904070-53492.log +6 -0
- data/spec/support/logs/Dispatcher - 904073-27607.log +6 -0
- data/spec/support/logs/Dispatcher - 904075-41641.log +6 -0
- data/spec/support/logs/Dispatcher - 904099-53541.log +6 -0
- data/spec/support/logs/Dispatcher - 904112-10508.log +6 -0
- data/spec/support/logs/Dispatcher - 904132-5791.log +6 -0
- data/spec/support/logs/Dispatcher - 904141-56406.log +6 -0
- data/spec/support/logs/Dispatcher - 904147-21550.log +6 -0
- data/spec/support/logs/Dispatcher - 904149-20120.log +6 -0
- data/spec/support/logs/Dispatcher - 904155-33639.log +6 -0
- data/spec/support/logs/Dispatcher - 904161-53730.log +6 -0
- data/spec/support/logs/Dispatcher - 904169-49991.log +16 -0
- data/spec/support/logs/Dispatcher - 904172-39635.log +14 -0
- data/spec/support/logs/Dispatcher - 904192-9525.log +10 -0
- data/spec/support/logs/Dispatcher - 904206-3529.log +16 -0
- data/spec/support/logs/Dispatcher - 904211-16856.log +14 -0
- data/spec/support/logs/Dispatcher - 904216-49974.log +10 -0
- data/spec/support/logs/Dispatcher - 904228-16891.log +6 -0
- data/spec/support/logs/Dispatcher - 904231-34999.log +6 -0
- data/spec/support/logs/Dispatcher - 904236-50872.log +6 -0
- data/spec/support/logs/Dispatcher - 904238-25464.log +6 -0
- data/spec/support/logs/Dispatcher - 904251-43339.log +6 -0
- data/spec/support/logs/Dispatcher - 904256-18461.log +6 -0
- data/spec/support/logs/Dispatcher - 904266-59699.log +6 -0
- data/spec/support/logs/Dispatcher - 904279-17401.log +6 -0
- data/spec/support/logs/Dispatcher - 904289-48953.log +6 -0
- data/spec/support/logs/Dispatcher - 904309-22599.log +6 -0
- data/spec/support/logs/Dispatcher - 904386-44447.log +16 -0
- data/spec/support/logs/Dispatcher - 904409-51015.log +14 -0
- data/spec/support/logs/Dispatcher - 904420-34336.log +10 -0
- data/spec/support/logs/Dispatcher - 904455-24852.log +16 -0
- data/spec/support/logs/Dispatcher - 904459-54769.log +14 -0
- data/spec/support/logs/Dispatcher - 904464-49280.log +10 -0
- data/spec/support/logs/Dispatcher - 904490-41571.log +6 -0
- data/spec/support/logs/Dispatcher - 904495-62362.log +6 -0
- data/spec/support/logs/Dispatcher - 904517-14314.log +6 -0
- data/spec/support/logs/Dispatcher - 904529-30060.log +6 -0
- data/spec/support/logs/Dispatcher - 904538-61870.log +6 -0
- data/spec/support/logs/Dispatcher - 904553-59343.log +6 -0
- data/spec/support/logs/Dispatcher - 904563-59027.log +6 -0
- data/spec/support/logs/Dispatcher - 904576-62144.log +6 -0
- data/spec/support/logs/Dispatcher - 904742-2935.log +6 -0
- data/spec/support/logs/Dispatcher - 904771-62183.log +6 -0
- data/spec/support/logs/Dispatcher - 904780-13353.log +6 -0
- data/spec/support/logs/Instance - 3208178-11741.error.log +106 -0
- data/spec/support/logs/Instance - 3208181-15143.error.log +106 -0
- data/spec/support/logs/Instance - 3208183-7742.error.log +106 -0
- data/spec/support/logs/Instance - 904628-41184.error.log +105 -0
- data/spec/support/logs/Instance - 904631-38626.error.log +105 -0
- data/spec/support/logs/Instance - 904634-37879.error.log +105 -0
- data/spec/support/logs/Scheduler - 3203309-65225.log +3 -0
- data/spec/support/logs/Scheduler - 3203315-52999.log +6 -0
- data/spec/support/logs/Scheduler - 3204127-50400.log +3 -0
- data/spec/support/logs/Scheduler - 3204138-29313.log +6 -0
- data/spec/support/logs/Scheduler - 3204154-9476.log +4 -0
- data/spec/support/logs/Scheduler - 3204163-52855.log +1 -0
- data/spec/support/logs/Scheduler - 3204175-31574.log +3 -0
- data/spec/support/logs/Scheduler - 3204194-7097.log +6 -0
- data/spec/support/logs/Scheduler - 3204251-11724.log +3 -0
- data/spec/support/logs/Scheduler - 3204262-10820.log +4 -0
- data/spec/support/logs/Scheduler - 3207131-48958.log +3 -0
- data/spec/support/logs/Scheduler - 3207138-8974.log +6 -0
- data/spec/support/logs/Scheduler - 3207187-62652.log +3 -0
- data/spec/support/logs/Scheduler - 3207197-19207.log +6 -0
- data/spec/support/logs/Scheduler - 3207218-27080.log +4 -0
- data/spec/support/logs/Scheduler - 3207228-4393.log +1 -0
- data/spec/support/logs/Scheduler - 3207240-7381.log +3 -0
- data/spec/support/logs/Scheduler - 3207252-53772.log +6 -0
- data/spec/support/logs/Scheduler - 3207306-56622.log +3 -0
- data/spec/support/logs/Scheduler - 3207318-9939.log +6 -0
- data/spec/support/logs/Scheduler - 3207342-36988.log +3 -0
- data/spec/support/logs/Scheduler - 3207352-31746.log +6 -0
- data/spec/support/logs/Scheduler - 3207383-56973.log +4 -0
- data/spec/support/logs/Scheduler - 3207400-19390.log +6 -0
- data/spec/support/logs/Scheduler - 3207442-63021.log +1 -0
- data/spec/support/logs/Scheduler - 3207445-42476.log +1 -0
- data/spec/support/logs/Scheduler - 3207450-45489.log +1 -0
- data/spec/support/logs/Scheduler - 3207453-18262.log +1 -0
- data/spec/support/logs/Scheduler - 3207458-47234.log +1 -0
- data/spec/support/logs/Scheduler - 3207462-5628.log +1 -0
- data/spec/support/logs/Scheduler - 3207464-14620.log +3 -0
- data/spec/support/logs/Scheduler - 3207468-4793.log +6 -0
- data/spec/support/logs/Scheduler - 3207482-45268.log +4 -0
- data/spec/support/logs/Scheduler - 3207494-44991.log +1 -0
- data/spec/support/logs/Scheduler - 3207498-21429.log +1 -0
- data/spec/support/logs/Scheduler - 3207503-54136.log +1 -0
- data/spec/support/logs/Scheduler - 3207507-43714.log +1 -0
- data/spec/support/logs/Scheduler - 3207512-38735.log +3 -0
- data/spec/support/logs/Scheduler - 3207516-64075.log +1 -0
- data/spec/support/logs/Scheduler - 3207523-26974.log +1 -0
- data/spec/support/logs/Scheduler - 3207527-30807.log +1 -0
- data/spec/support/logs/Scheduler - 3208261-26059.log +16 -0
- data/spec/support/logs/Scheduler - 3208278-13735.log +6 -0
- data/spec/support/logs/Scheduler - 3208287-55638.log +6 -0
- data/spec/support/logs/Scheduler - 3208303-38465.log +6 -0
- data/spec/support/logs/Scheduler - 3208334-43532.log +3 -0
- data/spec/support/logs/Scheduler - 3208344-20376.log +5 -0
- data/spec/support/logs/Scheduler - 3208351-38224.log +1 -0
- data/spec/support/logs/Scheduler - 3208355-9843.log +1 -0
- data/spec/support/logs/Scheduler - 3208357-43942.log +1 -0
- data/spec/support/logs/Scheduler - 3208360-58330.log +1 -0
- data/spec/support/logs/Scheduler - 3208363-23807.log +1 -0
- data/spec/support/logs/Scheduler - 3208366-29256.log +1 -0
- data/spec/support/logs/Scheduler - 3208369-25684.log +1 -0
- data/spec/support/logs/Scheduler - 3208372-28479.log +3 -0
- data/spec/support/logs/Scheduler - 3208382-34006.log +3 -0
- data/spec/support/logs/Scheduler - 3208396-57942.log +3 -0
- data/spec/support/logs/Scheduler - 3208402-34617.log +3 -0
- data/spec/support/logs/Scheduler - 3208406-31477.log +4 -0
- data/spec/support/logs/Scheduler - 3208418-25154.log +1 -0
- data/spec/support/logs/Scheduler - 3208423-3948.log +4 -0
- data/spec/support/logs/Scheduler - 3208428-21648.log +1 -0
- data/spec/support/logs/Scheduler - 3208434-64685.log +1 -0
- data/spec/support/logs/Scheduler - 3208440-58157.log +16 -0
- data/spec/support/logs/Scheduler - 3208460-6293.log +4 -0
- data/spec/support/logs/Scheduler - 3208467-29409.log +1 -0
- data/spec/support/logs/Scheduler - 3208470-12825.log +1 -0
- data/spec/support/logs/Scheduler - 3208473-52401.log +1 -0
- data/spec/support/logs/Scheduler - 3208476-6567.log +1 -0
- data/spec/support/logs/Scheduler - 3208480-28476.log +3 -0
- data/spec/support/logs/Scheduler - 3208488-36893.log +1 -0
- data/spec/support/logs/Scheduler - 3208490-11932.log +1 -0
- data/spec/support/logs/Scheduler - 3208493-56676.log +1 -0
- data/spec/support/logs/Scheduler - 3208509-46176.log +1 -0
- data/spec/support/logs/Scheduler - 3208513-14321.log +1 -0
- data/spec/support/logs/Scheduler - 3208517-10539.log +1 -0
- data/spec/support/logs/Scheduler - 3208521-30079.log +2 -0
- data/spec/support/logs/Scheduler - 903345-9616.log +3 -0
- data/spec/support/logs/Scheduler - 903353-58507.log +6 -0
- data/spec/support/logs/Scheduler - 903417-55835.log +3 -0
- data/spec/support/logs/Scheduler - 903427-18261.log +6 -0
- data/spec/support/logs/Scheduler - 903439-36633.log +4 -0
- data/spec/support/logs/Scheduler - 903455-41936.log +1 -0
- data/spec/support/logs/Scheduler - 903506-60484.log +3 -0
- data/spec/support/logs/Scheduler - 903519-10519.log +6 -0
- data/spec/support/logs/Scheduler - 903593-8109.log +3 -0
- data/spec/support/logs/Scheduler - 903614-61308.log +6 -0
- data/spec/support/logs/Scheduler - 903667-39623.log +3 -0
- data/spec/support/logs/Scheduler - 903683-35117.log +6 -0
- data/spec/support/logs/Scheduler - 903730-34262.log +4 -0
- data/spec/support/logs/Scheduler - 903747-57287.log +6 -0
- data/spec/support/logs/Scheduler - 903798-40499.log +1 -0
- data/spec/support/logs/Scheduler - 903801-5479.log +1 -0
- data/spec/support/logs/Scheduler - 903806-11293.log +1 -0
- data/spec/support/logs/Scheduler - 903811-52201.log +1 -0
- data/spec/support/logs/Scheduler - 903813-54636.log +1 -0
- data/spec/support/logs/Scheduler - 903827-5581.log +1 -0
- data/spec/support/logs/Scheduler - 903830-48439.log +3 -0
- data/spec/support/logs/Scheduler - 903835-17198.log +6 -0
- data/spec/support/logs/Scheduler - 903846-28718.log +4 -0
- data/spec/support/logs/Scheduler - 903855-45172.log +1 -0
- data/spec/support/logs/Scheduler - 903864-11909.log +1 -0
- data/spec/support/logs/Scheduler - 903869-1794.log +1 -0
- data/spec/support/logs/Scheduler - 903873-59405.log +1 -0
- data/spec/support/logs/Scheduler - 903880-3155.log +3 -0
- data/spec/support/logs/Scheduler - 903887-52240.log +1 -0
- data/spec/support/logs/Scheduler - 903889-27541.log +1 -0
- data/spec/support/logs/Scheduler - 903895-16003.log +1 -0
- data/spec/support/logs/Scheduler - 904706-61946.log +16 -0
- data/spec/support/logs/Scheduler - 904725-2441.log +6 -0
- data/spec/support/logs/Scheduler - 904736-12992.log +6 -0
- data/spec/support/logs/Scheduler - 904744-61626.log +6 -0
- data/spec/support/logs/Scheduler - 904774-45665.log +3 -0
- data/spec/support/logs/Scheduler - 904783-51443.log +5 -0
- data/spec/support/logs/Scheduler - 904791-45170.log +1 -0
- data/spec/support/logs/Scheduler - 904793-58901.log +1 -0
- data/spec/support/logs/Scheduler - 904801-2336.log +1 -0
- data/spec/support/logs/Scheduler - 904803-10954.log +1 -0
- data/spec/support/logs/Scheduler - 904806-25343.log +1 -0
- data/spec/support/logs/Scheduler - 904810-23633.log +1 -0
- data/spec/support/logs/Scheduler - 904814-27547.log +1 -0
- data/spec/support/logs/Scheduler - 904819-53508.log +3 -0
- data/spec/support/logs/Scheduler - 904826-41103.log +3 -0
- data/spec/support/logs/Scheduler - 904835-20113.log +3 -0
- data/spec/support/logs/Scheduler - 904866-61722.log +3 -0
- data/spec/support/logs/Scheduler - 904878-18373.log +4 -0
- data/spec/support/logs/Scheduler - 904999-46113.log +1 -0
- data/spec/support/logs/Scheduler - 905011-23507.log +4 -0
- data/spec/support/logs/Scheduler - 905017-8299.log +1 -0
- data/spec/support/logs/Scheduler - 905028-51728.log +1 -0
- data/spec/support/logs/Scheduler - 905031-16092.log +16 -0
- data/spec/support/logs/Scheduler - 905101-65244.log +4 -0
- data/spec/support/logs/Scheduler - 905224-20698.log +1 -0
- data/spec/support/logs/Scheduler - 905234-53973.log +1 -0
- data/spec/support/logs/Scheduler - 905241-48042.log +1 -0
- data/spec/support/logs/Scheduler - 905334-30796.log +1 -0
- data/spec/support/logs/Scheduler - 905337-14399.log +3 -0
- data/spec/support/logs/Scheduler - 905350-31560.log +1 -0
- data/spec/support/logs/Scheduler - 905353-63541.log +1 -0
- data/spec/support/logs/Scheduler - 905359-22685.log +1 -0
- data/spec/support/logs/Scheduler - 905362-31483.log +1 -0
- data/spec/support/logs/Scheduler - 905365-28301.log +1 -0
- data/spec/support/logs/Scheduler - 905369-51335.log +1 -0
- data/spec/support/logs/Scheduler - 905373-43552.log +2 -0
- data/spec/support/logs/error-3206970.log +801 -0
- data/spec/support/logs/error-903103.log +797 -0
- data/spec/support/logs/output_spec_3206970.log +390 -0
- data/spec/support/logs/output_spec_903103.log +390 -0
- data/spec/support/logs/placeholder +0 -0
- data/spec/support/pems/cacert.pem +37 -0
- data/spec/support/pems/client/cert.pem +37 -0
- data/spec/support/pems/client/foo-cert.pem +39 -0
- data/spec/support/pems/client/foo-key.pem +51 -0
- data/spec/support/pems/client/key.pem +51 -0
- data/spec/support/pems/server/cert.pem +37 -0
- data/spec/support/pems/server/key.pem +51 -0
- data/spec/support/reports/010223f6102d7d7ef50d7061f5a7c120.crf +0 -0
- data/spec/support/reports/0efcc0441bc58e27299737fc0e8bdb4a.crf +0 -0
- data/spec/support/reports/1444c78cae8a70d9a8f64a5b84579248.crf +0 -0
- data/spec/support/reports/16d1cdae64bbcf0b2083bc1870940fe8.crf +0 -0
- data/spec/support/reports/22cd328dd5adf2e5830db3eaf3e6d2fa.crf +0 -0
- data/spec/support/reports/26f5f97b84015ea1b3ebfaa04e6863f2.crf +0 -0
- data/spec/support/reports/40d544db82e9be4328c8bb16f2abbe96.crf +0 -0
- data/spec/support/reports/432466f64ec7b3a9e3a51e6c0c0f2b68.crf +0 -0
- data/spec/support/reports/493d52465fdd74388e1c1769e738fe0a.crf +0 -0
- data/spec/support/reports/49593f3c7dcff9466cebd4a3f71df16e.crf +0 -0
- data/spec/support/reports/4a875ccf578b82ea8af0661d09a0c9a2.crf +0 -0
- data/spec/support/reports/4fe265d0f318a758fff8f9c117d85c70.crf +0 -0
- data/spec/support/reports/5405af2d7e6bdba82761b3deb0316abb.crf +0 -0
- data/spec/support/reports/5801342bc5e7553ca065d9fc76b80a31.crf +0 -0
- data/spec/support/reports/5ca817d21692604d643a1ec4b9d698f8.crf +0 -0
- data/spec/support/reports/60a48dd87c16aaba48705cfa1102e6f0.crf +0 -0
- data/spec/support/reports/61b93d5be434e58e8286bc24375df5a6.crf +0 -0
- data/spec/support/reports/62ae63c7a653ccc450a042c83be6272e.crf +0 -0
- data/spec/support/reports/6dfba35f84478f2f8740989650e5c9b2.crf +0 -0
- data/spec/support/reports/72d8ff7e33ea0a4fa3208de46060ecb4.crf +0 -0
- data/spec/support/reports/7e73587e8be563c70f2864bb9982d4ac.crf +0 -0
- data/spec/support/reports/8a20cd9e7ea1f083c463f85990e48b9d.crf +0 -0
- data/spec/support/reports/8e22c8f69d18bfdc387ac2e2c73fd994.crf +0 -0
- data/spec/support/reports/99de7d4c926e154d9df18bbb66044360.crf +0 -0
- data/spec/support/reports/a8cda3f125d6de78da7e601e17ae02e0.crf +0 -0
- data/spec/support/reports/aa6b3e0cabbfa8f622cc3faa5e70d82d.crf +0 -0
- data/spec/support/reports/ad7582cad690ca1f6ec5529766dacecd.crf +0 -0
- data/spec/support/reports/af253c3c9e54c7efc1eb19a1ba0bc45b.crf +0 -0
- data/spec/support/reports/b57af832ae733e1a4182138f8373029d.crf +0 -0
- data/spec/support/reports/c266644ae90cff19058101b06c2410bd.crf +0 -0
- data/spec/support/reports/c684686518f8bb5af1fc05632b2ee3a1.crf +0 -0
- data/spec/support/reports/d0de163911157b30b56076653a01bd04.crf +0 -0
- data/spec/support/reports/d11cb8c19f0ef398e393e461d48fab49.crf +0 -0
- data/spec/support/reports/d29486b6155119827e12d512f38cf1a5.crf +0 -0
- data/spec/support/reports/d6348fa0f269cef7861d8a55ccb817b8.crf +0 -0
- data/spec/support/reports/d68cddd22874664f66ea296768de93cb.crf +0 -0
- data/spec/support/reports/d73172a30f03f6e4f73e77a379876368.crf +0 -0
- data/spec/support/reports/e0113960b4015876416519d1e36c6174.crf +0 -0
- data/spec/support/reports/e684ad3b2061330bf8016b0cda4c8aeb.crf +0 -0
- data/spec/support/reports/e6bec3c23e6367f309a43b6faec6c1af.crf +0 -0
- data/spec/support/reports/eadbebf5e6e8a2b325cdc82a4a667d1a.crf +0 -0
- data/spec/support/reports/fe4ca4a133464c018e8405dd73064f04.crf +0 -0
- data/spec/support/reports/placeholder +0 -0
- data/spec/support/shared/application.rb +10 -0
- data/spec/support/shared/component/options/base.rb +187 -0
- data/spec/support/shared/component.rb +31 -0
- data/spec/support/shared/option_group.rb +98 -0
- data/spec/support/shared/support/cache.rb +419 -0
- data/spec/support/shared/support/filter.rb +143 -0
- data/spec/support/shared/system/platforms/base.rb +25 -0
- data/spec/support/shared/system/platforms/mixins/unix.rb +37 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_34_27 +0200 7757c257352bfa7abdfc764fa978115c.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_34_41 +0200 30367c49c18c17b84f6cdbfad6fe8209.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_35_24 +0200 0faa83c7ec023eca9e68e959b2b6a991.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_35_38 +0200 e61c3dae449133e330c24f9d1d34bc17.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_45_36 +0200 ef5b013868ce241f47ebef4f0ee96d23.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_45_42 +0200 ae63b2e851a211039d4dfa999bfc1f79.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-11-28 11_45_45 +0200 59a5d8a5ef5de0937e0d8a697d3a06cb.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_10_45 +0200 7534324302d1127f33460417057c0d99.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_10_59 +0200 2e45425f623e46a876531b65ff3319d4.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_14_43 +0200 d570989be752d5e9f930379a7f861028.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_14_57 +0200 37fe4c6328f04448257e962065d49d05.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_25_10 +0200 728fc33e7947c9dc606d69d7b9202dbc.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_25_15 +0200 cde4edd9a05a4183ff301d157654cb30.csf +0 -0
- data/spec/support/snapshots/Cuboid 2021-12-26 08_25_17 +0200 e47c2b6d6354bca5f07fd2903aefd262.csf +0 -0
- data/spec/support/snapshots/placeholder +0 -0
- metadata +1222 -23
- data/.gitignore +0 -8
- data/bin/console +0 -15
- data/bin/setup +0 -8
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cuboid::System::Slots do
|
4
|
+
subject { system.slots }
|
5
|
+
let(:system) { Cuboid::System.instance }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
subject.reset
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#available' do
|
12
|
+
context 'when OptionGroups::system#max_slots is set' do
|
13
|
+
before do
|
14
|
+
Cuboid::Options.system.max_slots = 5
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'uses it to calculate available slots' do
|
18
|
+
expect(subject.available).to eq 5
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when some slots have been used' do
|
22
|
+
it 'subtracts them' do
|
23
|
+
allow(subject).to receive(:used).and_return( 2 )
|
24
|
+
expect(subject.available).to eq 3
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when OptionGroups::system#max_slots is not set' do
|
30
|
+
before do
|
31
|
+
Cuboid::Options.system.max_slots = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'uses #available_auto' do
|
35
|
+
expect(subject).to receive(:available_auto).and_return( 25 )
|
36
|
+
expect(subject.available).to eq 25
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#available_auto' do
|
42
|
+
before do
|
43
|
+
Cuboid::Options.system.max_slots = nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'calculates slots based on available resources' do
|
47
|
+
expect(subject).to receive(:available_in_memory).and_return( 25 )
|
48
|
+
expect(subject).to receive(:available_in_cpu).and_return( 25 )
|
49
|
+
expect(subject).to receive(:available_in_disk).and_return( 25 )
|
50
|
+
|
51
|
+
expect(subject.available).to eq 25
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when restricted by memory' do
|
55
|
+
it 'bases the calculation on memory slots' do
|
56
|
+
expect(subject).to receive(:available_in_memory).and_return( 10 )
|
57
|
+
expect(subject).to receive(:available_in_cpu).and_return( 25 )
|
58
|
+
expect(subject).to receive(:available_in_disk).and_return( 20 )
|
59
|
+
|
60
|
+
expect(subject.available).to eq 10
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when restricted by CPUs' do
|
65
|
+
it 'bases the calculation on CPU slots' do
|
66
|
+
expect(subject).to receive(:available_in_memory).and_return( 10 )
|
67
|
+
expect(subject).to receive(:available_in_cpu).and_return( 5 )
|
68
|
+
expect(subject).to receive(:available_in_disk).and_return( 20 )
|
69
|
+
|
70
|
+
expect(subject.available).to eq 5
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when restricted by disk space' do
|
75
|
+
it 'bases the calculation on disk space' do
|
76
|
+
expect(subject).to receive(:available_in_memory).and_return( 10 )
|
77
|
+
expect(subject).to receive(:available_in_cpu).and_return( 5 )
|
78
|
+
expect(subject).to receive(:available_in_disk).and_return( 4 )
|
79
|
+
|
80
|
+
expect(subject.available).to eq 4
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#used' do
|
86
|
+
it 'returns the amount of active instances' do
|
87
|
+
expect(subject.used).to eq 0
|
88
|
+
|
89
|
+
subject.use Process.pid
|
90
|
+
expect(subject.used).to eq 1
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when a process dies' do
|
94
|
+
it 'gets removed from the count'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#total' do
|
99
|
+
it 'sums up free and used slots' do
|
100
|
+
expect(subject).to receive(:available).and_return( 3 )
|
101
|
+
expect(subject).to receive(:used).and_return( 5 )
|
102
|
+
|
103
|
+
expect(subject.total).to eq 8
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#available_in_memory' do
|
108
|
+
it 'returns amount of free memory slots' do
|
109
|
+
expect(subject).to receive(:unallocated_memory).and_return( subject.memory_size * 2 )
|
110
|
+
|
111
|
+
expect(subject.available_in_memory).to eq 2
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#available_in_cpu' do
|
116
|
+
it 'returns amount of free CPUs splots' do
|
117
|
+
expect(system).to receive(:cpu_count).and_return( 12 )
|
118
|
+
expect(subject).to receive(:used).and_return( 5 )
|
119
|
+
|
120
|
+
expect(subject.available_in_cpu).to eq 7
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#unallocated_memory' do
|
125
|
+
context 'when there are no scans running' do
|
126
|
+
it 'returns the amount of free memory' do
|
127
|
+
free = subject.memory_size * 2
|
128
|
+
|
129
|
+
expect(system).to receive(:memory_free).and_return( free )
|
130
|
+
|
131
|
+
expect(subject.unallocated_memory).to eq free
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when there are scans running' do
|
136
|
+
context 'using part of their allocation' do
|
137
|
+
it 'removes their allocated slots' do
|
138
|
+
used_allocation = subject.memory_size / 3
|
139
|
+
|
140
|
+
expect(system).to receive(:memory_free).and_return( subject.memory_size * 2 - used_allocation )
|
141
|
+
|
142
|
+
subject.use 123
|
143
|
+
expect(subject).to receive(:remaining_memory_for).with(123).and_return( subject.memory_size - used_allocation )
|
144
|
+
|
145
|
+
expect(subject.unallocated_memory).to eq subject.memory_size
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe '#remaining_memory_for' do
|
152
|
+
it 'returns the amount of allocated memory available to the scan' do
|
153
|
+
expect(system).to receive(:memory_for_process_group).with(123).and_return( subject.memory_size / 3 )
|
154
|
+
expect(subject.remaining_memory_for(123)).to eq( subject.memory_size - subject.memory_size / 3 )
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#unallocated_disk_space' do
|
159
|
+
context 'when there are no scans running' do
|
160
|
+
it 'returns the amount of free disk space' do
|
161
|
+
free = subject.disk_space * 2
|
162
|
+
|
163
|
+
expect(system).to receive(:disk_space_free).and_return( free )
|
164
|
+
|
165
|
+
expect(subject.unallocated_disk_space).to eq free
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'when there are scans running' do
|
170
|
+
context 'using part of their allocation' do
|
171
|
+
it 'removes their allocated slots' do
|
172
|
+
used_allocation = subject.disk_space / 3
|
173
|
+
|
174
|
+
expect(system).to receive(:disk_space_free).and_return( subject.disk_space * 2 - used_allocation )
|
175
|
+
|
176
|
+
subject.use 123
|
177
|
+
expect(subject).to receive(:remaining_disk_space_for).with(123).and_return( subject.disk_space - used_allocation )
|
178
|
+
|
179
|
+
expect(subject.unallocated_disk_space.to_i).to eq subject.disk_space.to_i
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#remaining_disk_space_for' do
|
186
|
+
it 'returns the amount of allocated disk space available to the scan' do
|
187
|
+
expect(system).to receive(:disk_space_for_process).with(123).and_return( subject.disk_space / 3 )
|
188
|
+
expect(subject.remaining_disk_space_for(123)).to eq( subject.disk_space - subject.disk_space / 3 )
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '#memory_size' do
|
193
|
+
before do
|
194
|
+
Cuboid::Options.reset
|
195
|
+
end
|
196
|
+
let(:memory_size) { subject.memory_size }
|
197
|
+
|
198
|
+
it 'is approx 0.2GB with default options' do
|
199
|
+
expect(memory_size).to eq MockApp.max_memory
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cuboid::System do
|
4
|
+
subject { described_class.instance }
|
5
|
+
|
6
|
+
describe '#utilization' do
|
7
|
+
it 'returns the utilization ratio of the system'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#max_utilization?' do
|
11
|
+
context 'when #utilization is 1' do
|
12
|
+
it 'returns true' do
|
13
|
+
expect(subject).to receive(:utilization).and_return( 1 )
|
14
|
+
expect(subject).to be_max_utilization
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when #utilization is < 1' do
|
19
|
+
it 'returns false' do
|
20
|
+
expect(subject).to receive(:utilization).and_return( 0.2 )
|
21
|
+
expect(subject).to_not be_max_utilization
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#memory_free' do
|
27
|
+
it 'delegates to #platform' do
|
28
|
+
expect(subject.platform).to receive(:memory_free).and_return(10)
|
29
|
+
expect(subject.memory_free).to eq 10
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#memory_for_process_group' do
|
34
|
+
it 'delegates to #platform' do
|
35
|
+
expect(subject.platform).to receive(:memory_for_process_group).with(123).and_return(10)
|
36
|
+
expect(subject.memory_for_process_group(123)).to eq 10
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#disk_space_free' do
|
41
|
+
it 'delegates to #platform' do
|
42
|
+
expect(subject.platform).to receive(:disk_space_free).and_return(10)
|
43
|
+
expect(subject.disk_space_free).to eq 10
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#disk_space_for_process' do
|
48
|
+
it 'delegates to #platform' do
|
49
|
+
expect(subject.platform).to receive(:disk_space_for_process).with(123).and_return(10)
|
50
|
+
expect(subject.disk_space_for_process(123)).to eq 10
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#disk_directory' do
|
55
|
+
it "delegates to #platform" do
|
56
|
+
expect(subject.platform).to receive(:disk_directory).and_return('10')
|
57
|
+
expect(subject.disk_directory).to eq '10'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#cpu_count' do
|
62
|
+
it 'delegates to #platform' do
|
63
|
+
expect(subject.platform).to receive(:cpu_count).and_return(10)
|
64
|
+
expect(subject.cpu_count).to eq 10
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#platform' do
|
69
|
+
it 'returns the current platform' do
|
70
|
+
platform_stub = Class.new do
|
71
|
+
def self.current?
|
72
|
+
true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
subject.platforms.unshift platform_stub
|
77
|
+
|
78
|
+
expect(subject.platform).to be_instance_of platform_stub
|
79
|
+
|
80
|
+
subject.platforms.delete platform_stub
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the platform could not be identified' do
|
84
|
+
it 'raises error' do
|
85
|
+
subject.platforms.each do |platform|
|
86
|
+
expect(platform).to receive(:current?).and_return(false)
|
87
|
+
end
|
88
|
+
|
89
|
+
expect do
|
90
|
+
subject.platform
|
91
|
+
end.to raise_error "Unsupported platform: #{RUBY_PLATFORM}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#platforms' do
|
97
|
+
it 'returns all supported platforms' do
|
98
|
+
expect(subject.platforms.map(&:to_s).sort).to eq [
|
99
|
+
described_class::Platforms::Linux,
|
100
|
+
described_class::Platforms::OSX,
|
101
|
+
described_class::Platforms::Windows
|
102
|
+
].map(&:to_s).sort
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Subject
|
4
|
+
include Cuboid::UI::Output
|
5
|
+
include Cuboid::Utilities
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Cuboid::Utilities do
|
9
|
+
|
10
|
+
subject { Subject.new }
|
11
|
+
|
12
|
+
let(:response) { Factory[:response] }
|
13
|
+
let(:page) { Factory[:page] }
|
14
|
+
|
15
|
+
describe '#caller_name' do
|
16
|
+
it 'returns the filename of the caller' do
|
17
|
+
expect(subject.caller_name).to eq('example')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#caller_path' do
|
22
|
+
it 'returns the filepath of the caller' do
|
23
|
+
expect(subject.caller_path).to eq(Kernel.caller.first.match( /^(.+):\d/ )[1])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#port_available?' do
|
28
|
+
context 'when a port is available' do
|
29
|
+
it 'returns true' do
|
30
|
+
expect(subject.port_available?( 7777 )).to be_truthy
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when a port is not available' do
|
35
|
+
it 'returns true' do
|
36
|
+
s = TCPServer.new( "127.0.0.1", 7777 )
|
37
|
+
expect(subject.port_available?( 7777 )).to be_falsey
|
38
|
+
s.close
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#random_seed' do
|
44
|
+
it 'returns a random string' do
|
45
|
+
expect(subject.random_seed).to be_kind_of String
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#seconds_to_hms' do
|
50
|
+
it 'converts seconds to HOURS:MINUTES:SECONDS' do
|
51
|
+
expect(subject.seconds_to_hms( 0 )).to eq('00:00:00')
|
52
|
+
expect(subject.seconds_to_hms( 1 )).to eq('00:00:01')
|
53
|
+
expect(subject.seconds_to_hms( 60 )).to eq('00:01:00')
|
54
|
+
expect(subject.seconds_to_hms( 60*60 )).to eq('01:00:00')
|
55
|
+
expect(subject.seconds_to_hms( 60*60 + 60 + 1 )).to eq('01:01:01')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#hms_to_seconds' do
|
60
|
+
it 'converts seconds to HOURS:MINUTES:SECONDS' do
|
61
|
+
expect(subject.hms_to_seconds( '00:00:00' )).to eq(0)
|
62
|
+
expect(subject.hms_to_seconds( '00:00:01' )).to eq(1)
|
63
|
+
expect(subject.hms_to_seconds( '00:01:00' )).to eq(60)
|
64
|
+
expect(subject.hms_to_seconds( '01:00:00' )).to eq(60*60)
|
65
|
+
expect(subject.hms_to_seconds( '01:01:01')).to eq(60 * 60 + 60 + 1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#exception_jail' do
|
70
|
+
context 'when no error occurs' do
|
71
|
+
it 'returns the return value of the block' do
|
72
|
+
expect(subject.exception_jail { :stuff }).to eq(:stuff)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when a #{RuntimeError} occurs" do
|
77
|
+
context 'and raise_exception is' do
|
78
|
+
context 'default' do
|
79
|
+
it 're-raises the exception' do
|
80
|
+
expect do
|
81
|
+
subject.exception_jail { raise }
|
82
|
+
end.to raise_error RuntimeError
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'true' do
|
87
|
+
it 're-raises the exception' do
|
88
|
+
expect do
|
89
|
+
subject.exception_jail( true ) { raise }
|
90
|
+
end.to raise_error RuntimeError
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'false' do
|
95
|
+
it 'returns nil' do
|
96
|
+
expect(subject.exception_jail( false ) { raise }).to be_nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "when an #{Exception} occurs" do
|
103
|
+
context 'and raise_exception is' do
|
104
|
+
context 'default' do
|
105
|
+
it 'does not rescue it' do
|
106
|
+
expect do
|
107
|
+
subject.exception_jail { raise Exception }
|
108
|
+
end.to raise_error Exception
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'true' do
|
113
|
+
it 'does not rescue it' do
|
114
|
+
expect do
|
115
|
+
subject.exception_jail( true ) { raise Exception }
|
116
|
+
end.to raise_error Exception
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'false' do
|
121
|
+
it 'does not rescue it' do
|
122
|
+
expect do
|
123
|
+
subject.exception_jail( false ) { raise Exception }
|
124
|
+
end.to raise_error Exception
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
# require 'simplecov'
|
3
|
+
require 'faker'
|
4
|
+
|
5
|
+
require 'typhoeus'
|
6
|
+
require_relative '../lib/cuboid'
|
7
|
+
require_relative '../lib/cuboid/processes'
|
8
|
+
require_relative '../lib/cuboid/processes/helpers'
|
9
|
+
|
10
|
+
require_relative 'support/helpers/paths'
|
11
|
+
require_relative 'support/helpers/requires'
|
12
|
+
|
13
|
+
Dir.glob( "#{support_path}/{lib,helpers,shared,factories}/**/*.rb" ).each { |f| require f }
|
14
|
+
|
15
|
+
# Uncomment to show output from spawned processes.
|
16
|
+
Cuboid::Processes::Manager.preserve_output
|
17
|
+
|
18
|
+
RSpec::Core::MemoizedHelpers.module_eval do
|
19
|
+
alias to should
|
20
|
+
alias to_not should_not
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
25
|
+
config.run_all_when_everything_filtered = true
|
26
|
+
config.color = true
|
27
|
+
config.add_formatter :documentation
|
28
|
+
config.alias_example_to :expect_it
|
29
|
+
config.filter_run_when_matching focus: true
|
30
|
+
|
31
|
+
config.mock_with :rspec do |mocks|
|
32
|
+
mocks.yield_receiver_to_any_instance_implementation_blocks = true
|
33
|
+
end
|
34
|
+
|
35
|
+
config.before( :each ) do
|
36
|
+
reset_all
|
37
|
+
end
|
38
|
+
|
39
|
+
config.after( :each ) do
|
40
|
+
cleanup_instances
|
41
|
+
processes_killall
|
42
|
+
end
|
43
|
+
config.after( :all ) do
|
44
|
+
killall
|
45
|
+
end
|
46
|
+
end
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Factory.define :report_data do
|
2
|
+
|
3
|
+
{
|
4
|
+
application: MockApp,
|
5
|
+
seed: Cuboid::Utilities.random_seed,
|
6
|
+
options: Cuboid::Options.to_hash,
|
7
|
+
start_datetime: Time.now - 10_000,
|
8
|
+
finish_datetime: Time.now
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
Factory.define :report do
|
13
|
+
Cuboid::Report.new Factory[:report_data]
|
14
|
+
end
|
15
|
+
|
16
|
+
Factory.define :report_empty do
|
17
|
+
Cuboid::Report.new
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require Options.paths.lib + 'ui/output'
|
2
|
+
require Options.paths.lib + 'rpc/server/dispatcher'
|
3
|
+
require Options.paths.lib + 'processes/manager'
|
4
|
+
|
5
|
+
class Node < Cuboid::RPC::Server::Dispatcher::Node
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@options = Options.instance
|
9
|
+
|
10
|
+
methods.each do |m|
|
11
|
+
next if method( m ).owner != Cuboid::RPC::Server::Dispatcher::Node
|
12
|
+
self.class.send :private, m
|
13
|
+
self.class.send :public, m
|
14
|
+
end
|
15
|
+
|
16
|
+
@server = Cuboid::RPC::Server::Base.new
|
17
|
+
@server.add_async_check do |method|
|
18
|
+
# methods that expect a block are async
|
19
|
+
method.parameters.flatten.include?( :block )
|
20
|
+
end
|
21
|
+
@server.add_handler( 'node', self )
|
22
|
+
|
23
|
+
super @options, @server
|
24
|
+
|
25
|
+
@server.start
|
26
|
+
end
|
27
|
+
|
28
|
+
def url
|
29
|
+
@server.url
|
30
|
+
end
|
31
|
+
|
32
|
+
def shutdown
|
33
|
+
Arachni::Reactor.global.delay 1 do
|
34
|
+
Process.kill( 'KILL', Process.pid )
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def connect_to_peer( url )
|
39
|
+
self.class.connect_to_peer( url )
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.connect_to_peer( url )
|
43
|
+
c = Cuboid::RPC::Client::Base.new( url )
|
44
|
+
Arachni::RPC::Proxy.new( c, 'node' )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Arachni::Reactor.global.run do
|
49
|
+
Node.new
|
50
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'cuboid/rpc/server/dispatcher'
|
2
|
+
|
3
|
+
class TestService < Cuboid::RPC::Server::Dispatcher::Service
|
4
|
+
|
5
|
+
private :instances
|
6
|
+
public :instances
|
7
|
+
|
8
|
+
def test_dispatcher
|
9
|
+
dispatcher.class == Cuboid::RPC::Server::Dispatcher
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_opts
|
13
|
+
dispatcher.instance_eval{ @options } == options
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_node
|
17
|
+
node.class == Cuboid::RPC::Server::Dispatcher::Node
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_map_instances( &block )
|
21
|
+
each = proc do |instance, iterator|
|
22
|
+
iterator.return [instance.url, instance.token]
|
23
|
+
end
|
24
|
+
after = proc { |i| block.call Hash[i] }
|
25
|
+
|
26
|
+
map_instances( each, after )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_each_instance
|
30
|
+
i = 0
|
31
|
+
each_instance do |instance, iterator|
|
32
|
+
i += 1
|
33
|
+
instance.options.set( authorized_by: "test_#{i}@test.com") { |p| iterator.next }
|
34
|
+
end
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_iterator_for
|
39
|
+
iterator_for( instances ).class == Arachni::Reactor::Iterator
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_connect_to_dispatcher( url, &block )
|
43
|
+
connect_to_dispatcher( url ).alive? { |b| block.call b }
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_connect_to_instance( *args, &block )
|
47
|
+
connect_to_instance( *args ).busy?{ |b| block.call !!b }
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_defer( *args, &block )
|
51
|
+
defer do
|
52
|
+
block.call args
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_run_asap( *args, &block )
|
57
|
+
run_asap { block.call args }
|
58
|
+
end
|
59
|
+
|
60
|
+
def echo( *args )
|
61
|
+
args
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative 'mock_app/test_service'
|
2
|
+
|
3
|
+
class MockApp < Cuboid::Application
|
4
|
+
|
5
|
+
# This app is going to be using a max of 2 threads.
|
6
|
+
provision_cores 2
|
7
|
+
# This app is going to be using a max of 200MB of RAM.
|
8
|
+
provision_memory 200 * 1024 * 1024
|
9
|
+
# This app is going to be using a max of 2GB of disk space.
|
10
|
+
provision_disk 2 * 1024 * 1024 * 1024
|
11
|
+
|
12
|
+
validate_options_with :do_validate_options
|
13
|
+
|
14
|
+
# Register event handlers.
|
15
|
+
handler_for :pause, :do_pause
|
16
|
+
handler_for :resume, :do_resume
|
17
|
+
handler_for :suspend, :do_suspend
|
18
|
+
handler_for :restore, :do_restore
|
19
|
+
handler_for :abort, :do_abort
|
20
|
+
|
21
|
+
# RPC, report and snapshot file.
|
22
|
+
serialize_with Marshal
|
23
|
+
|
24
|
+
dispatcher_service_for :test_service, TestService
|
25
|
+
|
26
|
+
# Execution entry point.
|
27
|
+
def run
|
28
|
+
ap __method__
|
29
|
+
report 'My results.'
|
30
|
+
|
31
|
+
sleep 5
|
32
|
+
end
|
33
|
+
|
34
|
+
def do_validate_options( options )
|
35
|
+
return true if !options.is_a?( Hash )
|
36
|
+
!options.include?( 'invalid' )
|
37
|
+
end
|
38
|
+
|
39
|
+
def do_pause
|
40
|
+
ap __method__
|
41
|
+
end
|
42
|
+
|
43
|
+
def do_resume
|
44
|
+
ap __method__
|
45
|
+
end
|
46
|
+
|
47
|
+
def do_suspend
|
48
|
+
# Write pending state and data to Cuboid::Data::Application.
|
49
|
+
ap __method__
|
50
|
+
end
|
51
|
+
|
52
|
+
def do_restore
|
53
|
+
# Restore special state and data from Cuboid::Data::Application.
|
54
|
+
ap __method__
|
55
|
+
end
|
56
|
+
|
57
|
+
def do_abort
|
58
|
+
ap __method__
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|