naf 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +17 -0
- data/LICENSE +2 -0
- data/README.rdoc +22 -0
- data/RELEASE_NOTES.rdoc +18 -0
- data/Rakefile +43 -0
- data/app/assets/images/bg-grad.png +0 -0
- data/app/assets/images/clock.png +0 -0
- data/app/assets/images/control_play_blue.png +0 -0
- data/app/assets/images/down_arrow.gif +0 -0
- data/app/assets/images/papertrail_job.png +0 -0
- data/app/assets/images/papertrail_machine.png +0 -0
- data/app/assets/images/papertrail_machine_runner.png +0 -0
- data/app/assets/images/terminate.png +0 -0
- data/app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_0_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_glass_0_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_0_f4f4f4_1x100.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/up_arrow.gif +0 -0
- data/app/assets/javascripts/dataTablesTemplates/applications.js +94 -0
- data/app/assets/javascripts/dataTablesTemplates/jobs.js +163 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js +60 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runners.js +82 -0
- data/app/assets/javascripts/dataTablesTemplates/machines.js +93 -0
- data/app/assets/javascripts/date.js +104 -0
- data/app/assets/javascripts/iso8601.js +41 -0
- data/app/assets/javascripts/jquery.dataTables.custom.js +62 -0
- data/app/assets/javascripts/jquery.dataTables.js +6862 -0
- data/app/assets/javascripts/naf.js +30 -0
- data/app/assets/javascripts/underscore.js +713 -0
- data/app/assets/stylesheets/jquery_ui/jquery-ui-1.8.5.custom.css.erb +572 -0
- data/app/assets/stylesheets/min_naf.css +14 -0
- data/app/assets/stylesheets/min_naf/layout.css.scss +355 -0
- data/app/assets/stylesheets/naf.css +14 -0
- data/app/assets/stylesheets/naf/layout.css.scss +497 -0
- data/app/controllers/naf/affinities_controller.rb +61 -0
- data/app/controllers/naf/application_controller.rb +43 -0
- data/app/controllers/naf/application_schedule_affinity_tabs_controller.rb +75 -0
- data/app/controllers/naf/applications_controller.rb +153 -0
- data/app/controllers/naf/historical_job_affinity_tabs_controller.rb +65 -0
- data/app/controllers/naf/historical_jobs_controller.rb +159 -0
- data/app/controllers/naf/janitorial_assignments_controller.rb +77 -0
- data/app/controllers/naf/logger_names_controller.rb +58 -0
- data/app/controllers/naf/logger_styles_controller.rb +59 -0
- data/app/controllers/naf/machine_affinity_slots_controller.rb +69 -0
- data/app/controllers/naf/machine_runner_invocations_controller.rb +59 -0
- data/app/controllers/naf/machine_runners_controller.rb +26 -0
- data/app/controllers/naf/machines_controller.rb +95 -0
- data/app/helpers/naf/application_helper.rb +275 -0
- data/app/models/log4r/papertrail_outputter.rb +19 -0
- data/app/models/logical/naf/application.rb +183 -0
- data/app/models/logical/naf/construction_zone/ad_hoc_work_order.rb +22 -0
- data/app/models/logical/naf/construction_zone/application_schedule_work_order.rb +15 -0
- data/app/models/logical/naf/construction_zone/application_work_order.rb +25 -0
- data/app/models/logical/naf/construction_zone/boss.rb +123 -0
- data/app/models/logical/naf/construction_zone/foreman.rb +53 -0
- data/app/models/logical/naf/construction_zone/proletariat.rb +40 -0
- data/app/models/logical/naf/construction_zone/work_order.rb +100 -0
- data/app/models/logical/naf/create_infrastructure.rb +48 -0
- data/app/models/logical/naf/job.rb +357 -0
- data/app/models/logical/naf/job_creator.rb +155 -0
- data/app/models/logical/naf/job_fetcher.rb +167 -0
- data/app/models/logical/naf/job_statuses/errored.rb +27 -0
- data/app/models/logical/naf/job_statuses/finished.rb +26 -0
- data/app/models/logical/naf/job_statuses/finished_less_minute.rb +25 -0
- data/app/models/logical/naf/job_statuses/queued.rb +32 -0
- data/app/models/logical/naf/job_statuses/running.rb +34 -0
- data/app/models/logical/naf/job_statuses/terminated.rb +25 -0
- data/app/models/logical/naf/job_statuses/waiting.rb +43 -0
- data/app/models/logical/naf/machine.rb +85 -0
- data/app/models/logical/naf/machine_runner.rb +46 -0
- data/app/models/logical/naf/machine_runner_invocation.rb +50 -0
- data/app/models/logical/naf/pickler.rb +74 -0
- data/app/models/logical/naf/unpickler.rb +98 -0
- data/app/models/naf/affinity.rb +145 -0
- data/app/models/naf/affinity_classification.rb +44 -0
- data/app/models/naf/application.rb +100 -0
- data/app/models/naf/application_run_group_restriction.rb +39 -0
- data/app/models/naf/application_schedule.rb +181 -0
- data/app/models/naf/application_schedule_affinity_tab.rb +86 -0
- data/app/models/naf/application_schedule_prerequisite.rb +50 -0
- data/app/models/naf/application_type.rb +72 -0
- data/app/models/naf/by_historical_job_id.rb +86 -0
- data/app/models/naf/historical_job.rb +334 -0
- data/app/models/naf/historical_job_affinity_tab.rb +61 -0
- data/app/models/naf/historical_job_prerequisite.rb +19 -0
- data/app/models/naf/janitorial_archive_assignment.rb +36 -0
- data/app/models/naf/janitorial_assignment.rb +37 -0
- data/app/models/naf/janitorial_create_assignment.rb +36 -0
- data/app/models/naf/janitorial_drop_assignment.rb +36 -0
- data/app/models/naf/logger_level.rb +21 -0
- data/app/models/naf/logger_name.rb +23 -0
- data/app/models/naf/logger_style.rb +58 -0
- data/app/models/naf/logger_style_name.rb +28 -0
- data/app/models/naf/machine.rb +257 -0
- data/app/models/naf/machine_affinity_slot.rb +78 -0
- data/app/models/naf/machine_runner.rb +51 -0
- data/app/models/naf/machine_runner_invocation.rb +71 -0
- data/app/models/naf/naf_base.rb +9 -0
- data/app/models/naf/queued_job.rb +164 -0
- data/app/models/naf/running_job.rb +80 -0
- data/app/models/process/naf/application.rb +164 -0
- data/app/models/process/naf/janitor.rb +117 -0
- data/app/models/process/naf/machine_manager.rb +150 -0
- data/app/models/process/naf/machine_upgrader.rb +112 -0
- data/app/models/process/naf/runner.rb +539 -0
- data/app/views/naf/affinities/_form.html.erb +50 -0
- data/app/views/naf/affinities/edit.html.erb +11 -0
- data/app/views/naf/affinities/index.html.erb +57 -0
- data/app/views/naf/affinities/new.html.erb +15 -0
- data/app/views/naf/affinities/show.html.erb +48 -0
- data/app/views/naf/application_schedule_affinity_tabs/_form.html.erb +31 -0
- data/app/views/naf/application_schedule_affinity_tabs/edit.html.erb +12 -0
- data/app/views/naf/application_schedule_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/applications/_application_schedule.html.erb +80 -0
- data/app/views/naf/applications/_application_schedule_prerequisites.html.erb +14 -0
- data/app/views/naf/applications/_form.html.erb +109 -0
- data/app/views/naf/applications/_search_container.html.erb +94 -0
- data/app/views/naf/applications/_show.html.erb +34 -0
- data/app/views/naf/applications/edit.html.erb +11 -0
- data/app/views/naf/applications/index.html.erb +51 -0
- data/app/views/naf/applications/index.json.erb +11 -0
- data/app/views/naf/applications/new.html.erb +11 -0
- data/app/views/naf/applications/show.html.erb +203 -0
- data/app/views/naf/datatable.html.erb +49 -0
- data/app/views/naf/historical_job_affinity_tabs/_form.html.erb +36 -0
- data/app/views/naf/historical_job_affinity_tabs/edit.html.erb +11 -0
- data/app/views/naf/historical_job_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/historical_jobs/_form.html.erb +94 -0
- data/app/views/naf/historical_jobs/_runners.html.erb +22 -0
- data/app/views/naf/historical_jobs/_search_container.html.erb +140 -0
- data/app/views/naf/historical_jobs/edit.html.erb +11 -0
- data/app/views/naf/historical_jobs/index.html.erb +48 -0
- data/app/views/naf/historical_jobs/index.json.erb +26 -0
- data/app/views/naf/historical_jobs/new.html.erb +61 -0
- data/app/views/naf/historical_jobs/show.html.erb +201 -0
- data/app/views/naf/janitorial_assignments/_form.html.erb +38 -0
- data/app/views/naf/janitorial_assignments/_rows.html.erb +17 -0
- data/app/views/naf/janitorial_assignments/edit.html.erb +11 -0
- data/app/views/naf/janitorial_assignments/index.html.erb +56 -0
- data/app/views/naf/janitorial_assignments/index.js.erb +1 -0
- data/app/views/naf/janitorial_assignments/new.html.erb +11 -0
- data/app/views/naf/layouts/jquery_datatables.json.erb +6 -0
- data/app/views/naf/logger_names/_form.html.erb +18 -0
- data/app/views/naf/logger_names/edit.html.erb +11 -0
- data/app/views/naf/logger_names/new.html.erb +11 -0
- data/app/views/naf/logger_names/show.html.erb +44 -0
- data/app/views/naf/logger_styles/_form.html.erb +30 -0
- data/app/views/naf/logger_styles/_logger_style_names.html.erb +19 -0
- data/app/views/naf/logger_styles/edit.html.erb +11 -0
- data/app/views/naf/logger_styles/new.html.erb +11 -0
- data/app/views/naf/logger_styles/show.html.erb +48 -0
- data/app/views/naf/machine_affinity_slots/_form.html.erb +36 -0
- data/app/views/naf/machine_affinity_slots/edit.html.erb +11 -0
- data/app/views/naf/machine_affinity_slots/new.html.erb +11 -0
- data/app/views/naf/machine_runner_invocations/_filter.html.erb +21 -0
- data/app/views/naf/machine_runner_invocations/index.html.erb +36 -0
- data/app/views/naf/machine_runner_invocations/index.json.erb +16 -0
- data/app/views/naf/machine_runner_invocations/show.html.erb +91 -0
- data/app/views/naf/machine_runners/index.html.erb +82 -0
- data/app/views/naf/machine_runners/index.json.erb +16 -0
- data/app/views/naf/machine_runners/show.html.erb +113 -0
- data/app/views/naf/machines/_filter.html.erb +26 -0
- data/app/views/naf/machines/_form.html.erb +62 -0
- data/app/views/naf/machines/_show.html.erb +169 -0
- data/app/views/naf/machines/edit.html.erb +11 -0
- data/app/views/naf/machines/index.html.erb +51 -0
- data/app/views/naf/machines/index.json.erb +23 -0
- data/app/views/naf/machines/new.html.erb +11 -0
- data/app/views/naf/machines/show.html.erb +92 -0
- data/app/views/naf/record.html.erb +46 -0
- data/app/views/naf/shared/_application.html.erb +50 -0
- data/app/views/naf/shared/_information_container.html.erb +19 -0
- data/app/views/naf/shared/_select_per_page.html.erb +72 -0
- data/ci/test-build.sh +17 -0
- data/ci/travis.sh +26 -0
- data/config/initializers/naf.rb +3 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20120820023848_naf_schema.rb +413 -0
- data/doc/README_FOR_APP +2 -0
- data/lib/generators/naf_generator.rb +45 -0
- data/lib/generators/templates/config/logging/af.yml +26 -0
- data/lib/generators/templates/config/logging/naf.yml +22 -0
- data/lib/generators/templates/config/logging/nafjob.yml +16 -0
- data/lib/generators/templates/config/logging/nafrunner.yml +17 -0
- data/lib/generators/templates/naf.rb +11 -0
- data/lib/generators/templates/naf_layout.html.erb +15 -0
- data/lib/naf.rb +48 -0
- data/lib/naf/configuration.rb +23 -0
- data/lib/naf/engine.rb +18 -0
- data/lib/naf/version.rb +3 -0
- data/lib/tasks/naf_tasks.rake +370 -0
- data/naf.gemspec +30 -0
- data/script/rails +10 -0
- data/spec/controllers/naf/affinities_controller_spec.rb +79 -0
- data/spec/controllers/naf/application_controller_spec.rb +10 -0
- data/spec/controllers/naf/application_schedule_affinity_tabs_controller_spec.rb +106 -0
- data/spec/controllers/naf/applications_controller_spec.rb +109 -0
- data/spec/controllers/naf/historical_job_affinity_tabs_controller_spec.rb +96 -0
- data/spec/controllers/naf/historical_jobs_controller_spec.rb +19 -0
- data/spec/controllers/naf/machine_affinity_slots_controller_spec.rb +109 -0
- data/spec/controllers/naf/machines_controller_spec.rb +74 -0
- data/spec/dummy/.gitignore +12 -0
- data/spec/dummy/README +19 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +14 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/my_script.rb +8 -0
- data/spec/dummy/app/models/other/base.rb.sample +10 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/naf_layout.html.erb +15 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database-non_primary.yml +20 -0
- data/spec/dummy/config/database-primary.yml +16 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/naf.rb.non_primary +4 -0
- data/spec/dummy/config/initializers/naf.rb.primary +3 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/logging/af.yml +26 -0
- data/spec/dummy/config/logging/naf.yml +22 -0
- data/spec/dummy/config/logging/nafjob.yml +16 -0
- data/spec/dummy/config/logging/nafrunner.yml +17 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitignore +2 -0
- data/spec/dummy/lib/tasks/dummy.rake +60 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/naf.rb +433 -0
- data/spec/helpers/naf/application_helper_spec.rb +0 -0
- data/spec/models/logical/naf/application_spec.rb +69 -0
- data/spec/models/logical/naf/job_creator_spec.rb +32 -0
- data/spec/models/logical/naf/job_fetcher_spec.rb +140 -0
- data/spec/models/logical/naf/job_spec.rb +282 -0
- data/spec/models/logical/naf/machine_spec.rb +61 -0
- data/spec/models/naf/affinity_classification_spec.rb +56 -0
- data/spec/models/naf/affinity_spec.rb +100 -0
- data/spec/models/naf/application_run_group_restriction_spec.rb +57 -0
- data/spec/models/naf/application_schedule_affinity_tab_spec.rb +85 -0
- data/spec/models/naf/application_schedule_prerequisite_spec.rb +35 -0
- data/spec/models/naf/application_schedule_spec.rb +166 -0
- data/spec/models/naf/application_spec.rb +128 -0
- data/spec/models/naf/application_type_spec.rb +104 -0
- data/spec/models/naf/historical_job_affinity_tab_spec.rb +59 -0
- data/spec/models/naf/historical_job_prerequisite_spec.rb +25 -0
- data/spec/models/naf/historical_job_spec.rb +334 -0
- data/spec/models/naf/logger_level_spec.rb +34 -0
- data/spec/models/naf/logger_name_spec.rb +35 -0
- data/spec/models/naf/logger_style_name_spec.rb +39 -0
- data/spec/models/naf/logger_style_spec.rb +89 -0
- data/spec/models/naf/machine_affinity_slot_spec.rb +77 -0
- data/spec/models/naf/machine_runner_invocation_spec.rb +38 -0
- data/spec/models/naf/machine_runner_spec.rb +37 -0
- data/spec/models/naf/machine_spec.rb +425 -0
- data/spec/models/naf/naf_base_spec.rb +14 -0
- data/spec/models/naf/queued_job_spec.rb +171 -0
- data/spec/models/naf/running_job_spec.rb +107 -0
- data/spec/models/process/naf/application_spec.rb +8 -0
- data/spec/models/process/naf/janitor_spec.rb +10 -0
- data/spec/models/process/naf/runner_spec.rb +10 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/engine_routing.rb +27 -0
- data/spec/support/script_spec_helper.rb +58 -0
- metadata +590 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Logical
|
|
4
|
+
module Naf
|
|
5
|
+
|
|
6
|
+
describe Machine do
|
|
7
|
+
let(:physical_machine) { FactoryGirl.create(:machine) }
|
|
8
|
+
let(:physical_machine_two) { FactoryGirl.create(:machine_two) }
|
|
9
|
+
let(:columns) { [:id,
|
|
10
|
+
:server_name,
|
|
11
|
+
:server_address,
|
|
12
|
+
:server_note,
|
|
13
|
+
:enabled,
|
|
14
|
+
:process_pool_size,
|
|
15
|
+
:last_checked_schedules_at,
|
|
16
|
+
:last_seen_alive_at,
|
|
17
|
+
:log_level,
|
|
18
|
+
:affinities,
|
|
19
|
+
:marked_down] }
|
|
20
|
+
|
|
21
|
+
it "to_hash should return with the specified columns" do
|
|
22
|
+
logical_machine = Machine.new(physical_machine)
|
|
23
|
+
logical_machine.to_hash.keys.should eql(columns)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should alias the thread_pool_size method, as process_pool_size" do
|
|
27
|
+
logical_machine = Machine.new(physical_machine)
|
|
28
|
+
logical_machine.should_receive(:thread_pool_size).and_return(5)
|
|
29
|
+
logical_machine.process_pool_size
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should render last_checked_schedules_at nicely" do
|
|
33
|
+
physical_machine.mark_checked_schedule
|
|
34
|
+
logical_machine = Machine.new(physical_machine)
|
|
35
|
+
logical_machine.should_receive(:time_ago_in_words).and_return("")
|
|
36
|
+
logical_machine.last_checked_schedules_at.split(',').first.should =~ /ago$/
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should render last_seen_alive_at nicely" do
|
|
40
|
+
physical_machine.mark_alive
|
|
41
|
+
logical_machine = Machine.new(physical_machine)
|
|
42
|
+
logical_machine.should_receive(:time_ago_in_words).and_return("")
|
|
43
|
+
logical_machine.last_seen_alive_at.split(',').first.should =~ /ago$/
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context "Class Methods," do
|
|
47
|
+
it "all should return an array of logical wrappers around machines" do
|
|
48
|
+
machine = physical_machine
|
|
49
|
+
machine_two = physical_machine_two
|
|
50
|
+
|
|
51
|
+
logical_machine = Machine.new(machine)
|
|
52
|
+
Machine.all.map(&:id).should include(machine.id)
|
|
53
|
+
Machine.all.map(&:id).should include(machine_two.id)
|
|
54
|
+
Machine.all.should be_a(Array)
|
|
55
|
+
Machine.all.should have(2).items
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe AffinityClassification do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:affinity_classification_name].each do |a|
|
|
7
|
+
it { should allow_mass_assignment_of(a) }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
[:id,
|
|
11
|
+
:created_at].each do |a|
|
|
12
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#---------------------
|
|
16
|
+
# *** Associations ***
|
|
17
|
+
#+++++++++++++++++++++
|
|
18
|
+
|
|
19
|
+
it { should have_many(:affinities) }
|
|
20
|
+
|
|
21
|
+
#--------------------
|
|
22
|
+
# *** Validations ***
|
|
23
|
+
#++++++++++++++++++++
|
|
24
|
+
|
|
25
|
+
it { should validate_presence_of(:affinity_classification_name) }
|
|
26
|
+
|
|
27
|
+
#----------------------
|
|
28
|
+
# *** Class Methods ***
|
|
29
|
+
#++++++++++++++++++++++
|
|
30
|
+
|
|
31
|
+
describe "#purpose" do
|
|
32
|
+
let!(:purpose_affinity_classification) { FactoryGirl.create(:purpose_affinity_classification) }
|
|
33
|
+
|
|
34
|
+
it "return the purpose affinity classification" do
|
|
35
|
+
::Naf::AffinityClassification.purpose.should == purpose_affinity_classification
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "#location" do
|
|
40
|
+
let!(:location_affinity_classification) { FactoryGirl.create(:location_affinity_classification) }
|
|
41
|
+
|
|
42
|
+
it "return the location affinity classification" do
|
|
43
|
+
::Naf::AffinityClassification.location.should == location_affinity_classification
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "#application" do
|
|
48
|
+
let!(:application_affinity_classification) { FactoryGirl.create(:application_affinity_classification) }
|
|
49
|
+
|
|
50
|
+
it "return the application affinity classification" do
|
|
51
|
+
::Naf::AffinityClassification.application.should == application_affinity_classification
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe Affinity do
|
|
5
|
+
let!(:normal) { FactoryGirl.create(:normal_affinity) }
|
|
6
|
+
let(:canary) { FactoryGirl.create(:canary_affinity) }
|
|
7
|
+
let(:perennial) { FactoryGirl.create(:perennial_affinity) }
|
|
8
|
+
|
|
9
|
+
# Mass-assignment
|
|
10
|
+
[:affinity_classification_id,
|
|
11
|
+
:affinity_name,
|
|
12
|
+
:selectable,
|
|
13
|
+
:affinity_short_name,
|
|
14
|
+
:affinity_note].each do |a|
|
|
15
|
+
it { should allow_mass_assignment_of(a) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
[:id,
|
|
19
|
+
:created_at,
|
|
20
|
+
:updated_at].each do |a|
|
|
21
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#---------------------
|
|
25
|
+
# *** Associations ***
|
|
26
|
+
#+++++++++++++++++++++
|
|
27
|
+
|
|
28
|
+
it { should belong_to(:affinity_classification) }
|
|
29
|
+
it { should have_many(:application_schedule_affinity_tabs) }
|
|
30
|
+
it { should have_many(:machine_affinity_slots) }
|
|
31
|
+
|
|
32
|
+
#--------------------
|
|
33
|
+
# *** Validations ***
|
|
34
|
+
#++++++++++++++++++++
|
|
35
|
+
|
|
36
|
+
it { should validate_presence_of(:affinity_classification_id) }
|
|
37
|
+
it { should validate_presence_of(:affinity_name) }
|
|
38
|
+
it { should validate_uniqueness_of(:affinity_short_name) }
|
|
39
|
+
|
|
40
|
+
['', 'aa', 'aA', 'Aa', 'AA', '_a', 'a1', 'A1', '_9'].each do |v|
|
|
41
|
+
it { should allow_value(v).for(:affinity_short_name) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
['1_', '3A', '9a'].each do |v|
|
|
45
|
+
it { should_not allow_value(v).for(:affinity_short_name) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context "keeps with the starting seed rows for the table" do
|
|
49
|
+
it "for normal" do
|
|
50
|
+
normal.id.should == 1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "for canary" do
|
|
54
|
+
canary.id.should == 2
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "for perennial" do
|
|
58
|
+
perennial.id.should == 3
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "with regard to creation" do
|
|
63
|
+
let(:invalid_affinity) { FactoryGirl.build(:affinity, affinity_name: "") }
|
|
64
|
+
|
|
65
|
+
it "it should not be valid with an empty name" do
|
|
66
|
+
invalid_affinity.save.should_not be_true
|
|
67
|
+
invalid_affinity.should have(2).errors_on(:affinity_name)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#--------------------
|
|
72
|
+
# *** Delegations ***
|
|
73
|
+
#++++++++++++++++++++
|
|
74
|
+
|
|
75
|
+
context "with regard to delegation" do
|
|
76
|
+
let(:classification) { normal.affinity_classification }
|
|
77
|
+
|
|
78
|
+
it "should delegate the affinity_classfication_name method" do
|
|
79
|
+
classification.should_receive(:affinity_classification_name)
|
|
80
|
+
normal.affinity_classification_name
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
#----------------------
|
|
85
|
+
# *** Class Methods ***
|
|
86
|
+
#++++++++++++++++++++++
|
|
87
|
+
|
|
88
|
+
describe "#selectable" do
|
|
89
|
+
before do
|
|
90
|
+
canary.update_attributes!(selectable: false)
|
|
91
|
+
perennial.update_attributes!(selectable: false)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "return only selectable affinities" do
|
|
95
|
+
::Naf::Affinity.selectable.should == [normal]
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationRunGroupRestriction do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:application_run_group_restriction_name].each do |a|
|
|
7
|
+
it { should allow_mass_assignment_of(a) }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
[:id,
|
|
11
|
+
:created_at].each do |a|
|
|
12
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#---------------------
|
|
16
|
+
# *** Associations ***
|
|
17
|
+
#+++++++++++++++++++++
|
|
18
|
+
|
|
19
|
+
it { should have_many(:application_schedules) }
|
|
20
|
+
it { should have_many(:historical_jobs) }
|
|
21
|
+
|
|
22
|
+
#--------------------
|
|
23
|
+
# *** Validations ***
|
|
24
|
+
#++++++++++++++++++++
|
|
25
|
+
|
|
26
|
+
it { should validate_presence_of(:application_run_group_restriction_name) }
|
|
27
|
+
|
|
28
|
+
#----------------------
|
|
29
|
+
# *** Class Methods ***
|
|
30
|
+
#++++++++++++++++++++++
|
|
31
|
+
|
|
32
|
+
describe "#no_limit" do
|
|
33
|
+
let!(:no_limit) { FactoryGirl.create(:no_limit) }
|
|
34
|
+
|
|
35
|
+
it "return the no limit group restriction" do
|
|
36
|
+
::Naf::ApplicationRunGroupRestriction.no_limit.should == no_limit
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe "#limited_per_machine" do
|
|
41
|
+
let!(:limited_per_machine) { FactoryGirl.create(:limited_per_machine) }
|
|
42
|
+
|
|
43
|
+
it "return the limited per machine group restriction" do
|
|
44
|
+
::Naf::ApplicationRunGroupRestriction.limited_per_machine.should == limited_per_machine
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#limited_per_all_machines" do
|
|
49
|
+
let!(:limited_per_all_machines) { FactoryGirl.create(:limited_per_all_machines) }
|
|
50
|
+
|
|
51
|
+
it "return the limited per all machines group restriction" do
|
|
52
|
+
::Naf::ApplicationRunGroupRestriction.limited_per_all_machines.should == limited_per_all_machines
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationScheduleAffinityTab do
|
|
5
|
+
let!(:tab) { FactoryGirl.create(:normal_app_schedule_affinity_tab) }
|
|
6
|
+
|
|
7
|
+
# Mass-assignment
|
|
8
|
+
[:application_schedule_id,
|
|
9
|
+
:affinity_id,
|
|
10
|
+
:affinity_parameter].each do |a|
|
|
11
|
+
it { should allow_mass_assignment_of(a) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
[:id,
|
|
15
|
+
:created_at].each do |a|
|
|
16
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#---------------------
|
|
20
|
+
# *** Associations ***
|
|
21
|
+
#+++++++++++++++++++++
|
|
22
|
+
|
|
23
|
+
it { should belong_to(:application_schedule) }
|
|
24
|
+
it { should belong_to(:affinity) }
|
|
25
|
+
|
|
26
|
+
#--------------------
|
|
27
|
+
# *** Validations ***
|
|
28
|
+
#++++++++++++++++++++
|
|
29
|
+
|
|
30
|
+
it { should validate_presence_of(:application_schedule_id) }
|
|
31
|
+
it { should validate_presence_of(:affinity_id) }
|
|
32
|
+
|
|
33
|
+
#--------------------
|
|
34
|
+
# *** Delegations ***
|
|
35
|
+
#++++++++++++++++++++
|
|
36
|
+
|
|
37
|
+
context "with regard to delegation" do
|
|
38
|
+
context "to affinity" do
|
|
39
|
+
let!(:affinity) { tab.affinity }
|
|
40
|
+
|
|
41
|
+
it "should delegate affinity name" do
|
|
42
|
+
affinity.should_receive(:affinity_name)
|
|
43
|
+
tab.affinity_name
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should delegate affinity_classification_name" do
|
|
47
|
+
affinity.should_receive(:affinity_classification_name)
|
|
48
|
+
tab.affinity_classification_name
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "to application schedule" do
|
|
53
|
+
let(:schedule) { tab.application_schedule }
|
|
54
|
+
|
|
55
|
+
it "should call the title method" do
|
|
56
|
+
schedule.should_receive(:title)
|
|
57
|
+
tab.script_title
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
#-------------------------
|
|
63
|
+
# *** Instance Methods ***
|
|
64
|
+
#+++++++++++++++++++++++++
|
|
65
|
+
|
|
66
|
+
describe "#script_title" do
|
|
67
|
+
it "return the application schedule title" do
|
|
68
|
+
tab.application_schedule.application.title = 'App Schedule 1'
|
|
69
|
+
tab.script_title.should == 'App Schedule 1'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "#application" do
|
|
74
|
+
it "return the application when present" do
|
|
75
|
+
tab.application.should == tab.application_schedule.application
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "return nil when application not present" do
|
|
79
|
+
tab.application_schedule.application = nil
|
|
80
|
+
tab.application.should == nil
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationSchedulePrerequisite do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:application_schedule_id,
|
|
7
|
+
:prerequisite_application_schedule_id].each do |a|
|
|
8
|
+
it { should allow_mass_assignment_of(a) }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
[:id,
|
|
12
|
+
:created_at].each do |a|
|
|
13
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
#---------------------
|
|
17
|
+
# *** Associations ***
|
|
18
|
+
#+++++++++++++++++++++
|
|
19
|
+
|
|
20
|
+
it { should belong_to(:application_schedule) }
|
|
21
|
+
it { should belong_to(:prerequisite_application_schedule) }
|
|
22
|
+
|
|
23
|
+
#--------------------
|
|
24
|
+
# *** Validations ***
|
|
25
|
+
#++++++++++++++++++++
|
|
26
|
+
|
|
27
|
+
it { should validate_presence_of(:prerequisite_application_schedule_id) }
|
|
28
|
+
|
|
29
|
+
describe "uniqueness"do
|
|
30
|
+
subject { FactoryGirl.create(:schedule_prerequisite) }
|
|
31
|
+
it { should validate_uniqueness_of(:application_schedule_id).scoped_to(:prerequisite_application_schedule_id) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe ApplicationSchedule do
|
|
5
|
+
let!(:schedule) { FactoryGirl.create(:schedule) }
|
|
6
|
+
|
|
7
|
+
# Mass-assignment
|
|
8
|
+
[:application_id,
|
|
9
|
+
:application_run_group_restriction_id,
|
|
10
|
+
:application_run_group_name,
|
|
11
|
+
:run_interval,
|
|
12
|
+
:priority,
|
|
13
|
+
:visible,
|
|
14
|
+
:enabled,
|
|
15
|
+
:run_start_minute,
|
|
16
|
+
:application_run_group_limit,
|
|
17
|
+
:application_schedule_prerequisites_attributes,
|
|
18
|
+
:enqueue_backlogs].each do |a|
|
|
19
|
+
it { should allow_mass_assignment_of(a) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
[:id,
|
|
23
|
+
:created_at,
|
|
24
|
+
:updated_at].each do |a|
|
|
25
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
#---------------------
|
|
29
|
+
# *** Associations ***
|
|
30
|
+
#+++++++++++++++++++++
|
|
31
|
+
|
|
32
|
+
it { should belong_to(:application) }
|
|
33
|
+
it { should belong_to(:application_run_group_restriction) }
|
|
34
|
+
it { should have_many(:application_schedule_affinity_tabs) }
|
|
35
|
+
it { should have_many(:affinities) }
|
|
36
|
+
it { should have_many(:application_schedule_prerequisites) }
|
|
37
|
+
it { should have_many(:prerequisites) }
|
|
38
|
+
|
|
39
|
+
#--------------------
|
|
40
|
+
# *** Validations ***
|
|
41
|
+
#++++++++++++++++++++
|
|
42
|
+
|
|
43
|
+
it { should validate_presence_of(:application_run_group_restriction_id) }
|
|
44
|
+
|
|
45
|
+
[-2147483647, 2147483646, 0].each do |v|
|
|
46
|
+
it { should allow_value(v).for(:priority) }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
[-2147483648, 2147483647, 1.0, nil].each do |v|
|
|
50
|
+
it { should_not allow_value(v).for(:priority) }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
#--------------------
|
|
54
|
+
# *** Delegations ***
|
|
55
|
+
#++++++++++++++++++++
|
|
56
|
+
|
|
57
|
+
context "with regards to delegation" do
|
|
58
|
+
it "should delegate the title method" do
|
|
59
|
+
schedule.application.should_receive(:title)
|
|
60
|
+
schedule.title
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should delegate the application_run_group_restriction_name method" do
|
|
64
|
+
schedule.application_run_group_restriction.
|
|
65
|
+
should_receive(:application_run_group_restriction_name)
|
|
66
|
+
schedule.application_run_group_restriction_name
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#----------------------
|
|
71
|
+
# *** Class Methods ***
|
|
72
|
+
#++++++++++++++++++++++
|
|
73
|
+
|
|
74
|
+
describe "#exact_schedules" do
|
|
75
|
+
it "return schedule when run_start_minute is set" do
|
|
76
|
+
schedule.update_attributes!(run_start_minute: 1, run_interval: nil)
|
|
77
|
+
::Naf::ApplicationSchedule.exact_schedules.should == [schedule]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "return no schedules when run_start_minute is not set" do
|
|
81
|
+
schedule.update_attributes!(run_start_minute: nil, run_interval: nil)
|
|
82
|
+
::Naf::ApplicationSchedule.exact_schedules.should == []
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "#relative_schedules" do
|
|
87
|
+
it "return schedule when run_interval is set" do
|
|
88
|
+
schedule.update_attributes!(run_interval: 60)
|
|
89
|
+
::Naf::ApplicationSchedule.relative_schedules.should == [schedule]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "return no schedules when run_interval is not set" do
|
|
93
|
+
schedule.update_attributes!(run_interval: nil)
|
|
94
|
+
::Naf::ApplicationSchedule.relative_schedules.should == []
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
#-------------------------
|
|
99
|
+
# *** Instance Methods ***
|
|
100
|
+
#+++++++++++++++++++++++++
|
|
101
|
+
|
|
102
|
+
describe "#to_s" do
|
|
103
|
+
before do
|
|
104
|
+
schedule.application.title = 'App1'
|
|
105
|
+
schedule.save!
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "return correct parsing of app" do
|
|
109
|
+
schedule.to_s.should == "::Naf::ApplicationSchedule<ENABLED, id: #{schedule.id}, " +
|
|
110
|
+
"\"App1\", start every: 1 minutes>"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "#visible_enabled_check" do
|
|
115
|
+
let(:error_messages) { {
|
|
116
|
+
visible: ['must be true, or set enabled to false'],
|
|
117
|
+
enabled: ['must be false, if visible is set to false']
|
|
118
|
+
} }
|
|
119
|
+
|
|
120
|
+
before do
|
|
121
|
+
schedule.visible = false
|
|
122
|
+
schedule.visible_enabled_check
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "add errors to schedule" do
|
|
126
|
+
schedule.errors.messages.should == error_messages
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe "#enabled_application_id_unique" do
|
|
131
|
+
let(:error_message) { {
|
|
132
|
+
application_id: ['is enabled and has already been taken']
|
|
133
|
+
} }
|
|
134
|
+
|
|
135
|
+
it "return nil if enabled is false" do
|
|
136
|
+
schedule.enabled = false
|
|
137
|
+
schedule.enabled_application_id_unique.should == nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it "return nil if enabled is false" do
|
|
141
|
+
schedule2 = FactoryGirl.create(:schedule)
|
|
142
|
+
schedule2.application_id = schedule.application_id
|
|
143
|
+
schedule2.enabled_application_id_unique
|
|
144
|
+
|
|
145
|
+
schedule2.errors.messages.should == error_message
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
describe "#run_interval_at_time_check" do
|
|
150
|
+
let(:error_messages) { {
|
|
151
|
+
run_interval: ['or Run start minute must be nil'],
|
|
152
|
+
run_start_minute: ['or Run interval must be nil']
|
|
153
|
+
} }
|
|
154
|
+
|
|
155
|
+
before do
|
|
156
|
+
schedule.run_start_minute = 1
|
|
157
|
+
schedule.run_interval_at_time_check
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "add errors to schedule" do
|
|
161
|
+
schedule.errors.messages.should == error_messages
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
end
|
|
166
|
+
end
|