naf 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe NafBase do
|
5
|
+
describe "with regard to configuration" do
|
6
|
+
it "should inherit from the correct model_class" do
|
7
|
+
NafBase.superclass.should == Naf.model_class
|
8
|
+
end
|
9
|
+
it "should have the correctly set full table name prefix" do
|
10
|
+
NafBase.full_table_name_prefix.should == "#{::Naf.schema_name}."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe QueuedJob do
|
5
|
+
# Mass-assignment
|
6
|
+
[:application_id,
|
7
|
+
:application_type_id,
|
8
|
+
:command,
|
9
|
+
:application_run_group_restriction_id,
|
10
|
+
:application_run_group_name,
|
11
|
+
:application_run_group_limit,
|
12
|
+
:priority].each do |a|
|
13
|
+
it { should allow_mass_assignment_of(a) }
|
14
|
+
end
|
15
|
+
|
16
|
+
[:id,
|
17
|
+
:created_at,
|
18
|
+
:updated_at].each do |a|
|
19
|
+
it { should_not allow_mass_assignment_of(a) }
|
20
|
+
end
|
21
|
+
|
22
|
+
#---------------------
|
23
|
+
# *** Associations ***
|
24
|
+
#+++++++++++++++++++++
|
25
|
+
|
26
|
+
it { should belong_to(:historical_job) }
|
27
|
+
it { should belong_to(:application) }
|
28
|
+
it { should belong_to(:application_type) }
|
29
|
+
it { should belong_to(:application_run_group_restriction) }
|
30
|
+
|
31
|
+
#--------------------
|
32
|
+
# *** Validations ***
|
33
|
+
#++++++++++++++++++++
|
34
|
+
|
35
|
+
it { should validate_presence_of(:application_type_id) }
|
36
|
+
it { should validate_presence_of(:command) }
|
37
|
+
it { should validate_presence_of(:application_run_group_restriction_id) }
|
38
|
+
it { should validate_presence_of(:priority) }
|
39
|
+
|
40
|
+
#----------------------
|
41
|
+
# *** Class Methods ***
|
42
|
+
#++++++++++++++++++++++
|
43
|
+
|
44
|
+
describe "#order_by_priority" do
|
45
|
+
let!(:high_priority_job) { FactoryGirl.create(:queued_job, priority: 1) }
|
46
|
+
let!(:low_priority_job) { FactoryGirl.create(:queued_job, priority: 2) }
|
47
|
+
let!(:low_priority_job2) { FactoryGirl.create(:queued_job, priority: 2) }
|
48
|
+
|
49
|
+
it "return records in correct order" do
|
50
|
+
Naf::QueuedJob.order_by_priority.
|
51
|
+
should == [high_priority_job, low_priority_job, low_priority_job2]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#exclude_run_group_names" do
|
56
|
+
let!(:included_job) { FactoryGirl.create(:queued_job, application_run_group_name: 'test 1') }
|
57
|
+
let!(:excluded_job) { FactoryGirl.create(:queued_job, application_run_group_name: 'test 2') }
|
58
|
+
|
59
|
+
it "return queued jobs not included in the run group names" do
|
60
|
+
Naf::QueuedJob.exclude_run_group_names(['test 2']).
|
61
|
+
should == [included_job]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "return all queued jobs when run group names are not specified" do
|
65
|
+
Naf::QueuedJob.exclude_run_group_names([]).
|
66
|
+
should == [included_job, excluded_job]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#runnable_by_machine" do
|
71
|
+
let!(:included_job) { FactoryGirl.create(:queued_job, application_run_group_name: 'test 1') }
|
72
|
+
let!(:excluded_job) { FactoryGirl.create(:queued_job, application_run_group_name: 'test 2') }
|
73
|
+
|
74
|
+
it "return queued jobs not included in the run group names" do
|
75
|
+
Naf::QueuedJob.exclude_run_group_names(['test 2']).
|
76
|
+
should == [included_job]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "return all queued jobs when run group names are not specified" do
|
80
|
+
Naf::QueuedJob.exclude_run_group_names([]).
|
81
|
+
should == [included_job, excluded_job]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#prerequisites_finished" do
|
86
|
+
let!(:prerequesite_needed_historical_job) { FactoryGirl.create(:job, finished_at: nil) }
|
87
|
+
let!(:prerequesite_historical_job) { FactoryGirl.create(:job) }
|
88
|
+
let!(:historical_job) { FactoryGirl.create(:job) }
|
89
|
+
let!(:prerequesite_needed_queued_job) {
|
90
|
+
FactoryGirl.create(:queued_job, id: prerequesite_needed_historical_job.id,
|
91
|
+
historical_job: prerequesite_needed_historical_job)
|
92
|
+
}
|
93
|
+
let!(:queued_job) {
|
94
|
+
FactoryGirl.create(:queued_job, id: historical_job.id,
|
95
|
+
historical_job: historical_job)
|
96
|
+
}
|
97
|
+
let!(:prerequesite) {
|
98
|
+
FactoryGirl.create(:historical_job_prerequesite, prerequisite_historical_job: prerequesite_historical_job,
|
99
|
+
historical_job: prerequesite_needed_historical_job)
|
100
|
+
}
|
101
|
+
|
102
|
+
it "return queued jobs not included in the run group names" do
|
103
|
+
Naf::QueuedJob.prerequisites_finished.
|
104
|
+
should == [queued_job]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#weight_available_on_machine" do
|
109
|
+
let!(:machine) { mock_model(Machine) }
|
110
|
+
let!(:cpu_affinity_slot) { mock_model(MachineAffinitySlot, affinity_id: 4, affinity_parameter: 5.0) }
|
111
|
+
let!(:memory_affinity_slot) { mock_model(MachineAffinitySlot, affinity_id: 5, affinity_parameter: 5.0) }
|
112
|
+
let!(:queued_job) { FactoryGirl.create(:queued_job) }
|
113
|
+
|
114
|
+
before do
|
115
|
+
::Naf::RunningJob.any_instance.stub(:affinity_weights).
|
116
|
+
and_return(1 => 0.0, 2 => 0.0, 3 => 0.0, 4 => 1.0, 5 => 1.0)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "return queued job when machine has cpus left" do
|
120
|
+
memory_affinity_slot = mock_model(MachineAffinitySlot, affinity_id: 5, affinity_parameter: 0.0)
|
121
|
+
machine.stub(:machine_affinity_slots).and_return([cpu_affinity_slot, memory_affinity_slot])
|
122
|
+
::Naf::QueuedJob.stub(:check_weight_sum).
|
123
|
+
and_return([])
|
124
|
+
|
125
|
+
::Naf::QueuedJob.weight_available_on_machine(machine).
|
126
|
+
should == [queued_job]
|
127
|
+
end
|
128
|
+
|
129
|
+
it "return queued job when machine has cpus and memory left" do
|
130
|
+
machine.stub(:machine_affinity_slots).and_return([cpu_affinity_slot, memory_affinity_slot])
|
131
|
+
::Naf::QueuedJob.stub(:check_weight_sum).
|
132
|
+
and_return([])
|
133
|
+
|
134
|
+
::Naf::QueuedJob.weight_available_on_machine(machine).
|
135
|
+
should == [queued_job]
|
136
|
+
end
|
137
|
+
|
138
|
+
it "return queued job when machine does not have cpu/memory restriction" do
|
139
|
+
machine.stub(:machine_affinity_slots).and_return([])
|
140
|
+
|
141
|
+
::Naf::QueuedJob.weight_available_on_machine(machine).
|
142
|
+
should == [queued_job]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "#check_weight_sum" do
|
147
|
+
let!(:queued_job) { FactoryGirl.create(:queued_job) }
|
148
|
+
let!(:affinity) { FactoryGirl.create(:affinity, id: 4, affinity_name: 'cpus') }
|
149
|
+
let!(:affinity_tab) { FactoryGirl.create(:job_affinity_tab_base,
|
150
|
+
historical_job: queued_job.historical_job,
|
151
|
+
affinity_id: affinity.id,
|
152
|
+
affinity_parameter: 1)}
|
153
|
+
it "does not return queued job when machine has cpus left" do
|
154
|
+
::Naf::QueuedJob.check_weight_sum(4, 1, 3).
|
155
|
+
should == []
|
156
|
+
end
|
157
|
+
|
158
|
+
it "does not return queued job when job does not have cpu affinity" do
|
159
|
+
affinity_tab.delete
|
160
|
+
::Naf::QueuedJob.check_weight_sum(4, 1, 3).
|
161
|
+
should == []
|
162
|
+
end
|
163
|
+
|
164
|
+
it "return jobs when machine does not have cpus left" do
|
165
|
+
::Naf::QueuedJob.check_weight_sum(4, 3, 3).
|
166
|
+
should == [queued_job]
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Naf
|
4
|
+
describe RunningJob do
|
5
|
+
let!(:running_job) { FactoryGirl.create(:running_job_base) }
|
6
|
+
|
7
|
+
# Mass-assignment
|
8
|
+
[:application_id,
|
9
|
+
:application_type_id,
|
10
|
+
:command,
|
11
|
+
:application_run_group_restriction_id,
|
12
|
+
:application_run_group_name,
|
13
|
+
:application_run_group_limit,
|
14
|
+
:started_on_machine_id,
|
15
|
+
:pid,
|
16
|
+
:request_to_terminate,
|
17
|
+
:marked_dead_by_machine_id,
|
18
|
+
:log_level,
|
19
|
+
:started_at].each do |a|
|
20
|
+
it { should allow_mass_assignment_of(a) }
|
21
|
+
end
|
22
|
+
|
23
|
+
[:id,
|
24
|
+
:created_at,
|
25
|
+
:updated_at].each do |a|
|
26
|
+
it { should_not allow_mass_assignment_of(a) }
|
27
|
+
end
|
28
|
+
|
29
|
+
#---------------------
|
30
|
+
# *** Associations ***
|
31
|
+
#+++++++++++++++++++++
|
32
|
+
|
33
|
+
it { should belong_to(:historical_job) }
|
34
|
+
it { should belong_to(:application) }
|
35
|
+
it { should belong_to(:application_type) }
|
36
|
+
it { should belong_to(:application_run_group_restriction) }
|
37
|
+
it { should belong_to(:started_on_machine) }
|
38
|
+
it { should belong_to(:marked_dead_by_machine) }
|
39
|
+
|
40
|
+
#--------------------
|
41
|
+
# *** Validations ***
|
42
|
+
#++++++++++++++++++++
|
43
|
+
|
44
|
+
it { should validate_presence_of(:application_type_id) }
|
45
|
+
it { should validate_presence_of(:command) }
|
46
|
+
it { should validate_presence_of(:application_run_group_restriction_id) }
|
47
|
+
|
48
|
+
#----------------------
|
49
|
+
# *** Class Methods ***
|
50
|
+
#++++++++++++++++++++++
|
51
|
+
|
52
|
+
describe "#started_on" do
|
53
|
+
let(:machine) { mock_model(Machine) }
|
54
|
+
before do
|
55
|
+
running_job.started_on_machine = machine
|
56
|
+
end
|
57
|
+
|
58
|
+
it "return the correct job record" do
|
59
|
+
::Naf::RunningJob.should_receive(:where).and_return([running_job])
|
60
|
+
::Naf::RunningJob.started_on(machine).should == [running_job]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#in_run_group" do
|
65
|
+
it "return the correct job record" do
|
66
|
+
::Naf::RunningJob.should_receive(:where).and_return([running_job])
|
67
|
+
::Naf::RunningJob.in_run_group('test').should == [running_job]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#assigned_jobs" do
|
72
|
+
let(:machine) { mock_model(Machine) }
|
73
|
+
|
74
|
+
it "return the correct job record" do
|
75
|
+
::Naf::RunningJob.stub(:started_on).and_return([running_job])
|
76
|
+
::Naf::RunningJob.assigned_jobs(machine).should == [running_job]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#affinity_weights" do
|
81
|
+
let(:machine) { FactoryGirl.create(:machine) }
|
82
|
+
before do
|
83
|
+
cpu_affinity = FactoryGirl.create(:affinity, id: 4, affinity_name: 'cpus')
|
84
|
+
memory_affinity = FactoryGirl.create(:affinity, id: 5, affinity_name: 'memory')
|
85
|
+
FactoryGirl.create(:job_affinity_tab_base, historical_job: running_job.historical_job,
|
86
|
+
affinity: cpu_affinity,
|
87
|
+
affinity_parameter: 1.0)
|
88
|
+
FactoryGirl.create(:job_affinity_tab_base, historical_job: running_job.historical_job,
|
89
|
+
affinity: memory_affinity,
|
90
|
+
affinity_parameter: 1.0)
|
91
|
+
|
92
|
+
running_job.started_on_machine = machine
|
93
|
+
running_job.save!
|
94
|
+
end
|
95
|
+
|
96
|
+
it "return the correct sum of affinity parameters for each affinity" do
|
97
|
+
::Naf::RunningJob.affinity_weights(machine).should == { 1 => 0.0,
|
98
|
+
2 => 0.0,
|
99
|
+
3 => 0.0,
|
100
|
+
4 => 1.0,
|
101
|
+
5 => 1.0 }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] ||= "test"
|
3
|
+
|
4
|
+
# What will our dummy Rails app be?
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'rspec/autorun'
|
9
|
+
require 'factory_girl'
|
10
|
+
|
11
|
+
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
|
12
|
+
|
13
|
+
# Require supporting files in spec/support
|
14
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.use_transactional_fixtures = true
|
18
|
+
config.include Naf::Engine.routes.url_helpers
|
19
|
+
config.infer_base_class_for_anonymous_controllers = true
|
20
|
+
config.include EngineRouting, type: :controller
|
21
|
+
end
|
22
|
+
|
23
|
+
FactoryGirl.find_definitions
|
24
|
+
|
25
|
+
# Create the DB Seed Records via Factories
|
26
|
+
affinities = [:normal_affinity, :canary_affinity, :perennial_affinity]
|
27
|
+
classifications = [:location_affinity_classification, :purpose_affinity_classification, :application_affinity_classification]
|
28
|
+
restrictions = [:no_limit, :limited_per_machine, :limited_per_all_machines]
|
29
|
+
|
30
|
+
(affinities + classifications + restrictions).each do |seed|
|
31
|
+
FactoryGirl.create(seed)
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module EngineRouting
|
2
|
+
def get(action, parameters = nil, session = nil, flash = nil)
|
3
|
+
process_action(action, parameters, session, flash, "GET")
|
4
|
+
end
|
5
|
+
|
6
|
+
# Executes a request simulating POST HTTP method and set/volley the response
|
7
|
+
def post(action, parameters = nil, session = nil, flash = nil)
|
8
|
+
process_action(action, parameters, session, flash, "POST")
|
9
|
+
end
|
10
|
+
|
11
|
+
# Executes a request simulating PUT HTTP method and set/volley the response
|
12
|
+
def put(action, parameters = nil, session = nil, flash = nil)
|
13
|
+
process_action(action, parameters, session, flash, "PUT")
|
14
|
+
end
|
15
|
+
|
16
|
+
# Executes a request simulating DELETE HTTP method and set/volley the response
|
17
|
+
def delete(action, parameters = nil, session = nil, flash = nil)
|
18
|
+
process_action(action, parameters, session, flash, "DELETE")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def process_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
24
|
+
parameters ||= {}
|
25
|
+
process(action, parameters.merge!(use_route: :naf), session, flash, method)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ScriptSpecHelper
|
2
|
+
# Run the script defined in a spec's let(:script)
|
3
|
+
# It rescues from the SystemExit exception that all scripts raise
|
4
|
+
# once they are finished (this is how the runner is setup)
|
5
|
+
|
6
|
+
# Yield to the given block before the script is run
|
7
|
+
# This is useful for setup code
|
8
|
+
# or if script is an instance, you can write some expectations or stubs
|
9
|
+
# Example:
|
10
|
+
#
|
11
|
+
# require 'spec_helper'
|
12
|
+
# module Process
|
13
|
+
# describe MyCoolScript do
|
14
|
+
# let(:script) { Process::MyCoolScript.new }
|
15
|
+
# it "should should find five downloads" do
|
16
|
+
# run_script do
|
17
|
+
# script.should_receive(:downloads).and_return(5)
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
def run_script(*args)
|
23
|
+
exit_status = 0
|
24
|
+
# Lets not log anything when we run tests of the scripts,
|
25
|
+
# especially if we are using Papertrail
|
26
|
+
# If any args were passed, set them to ARGV for the script to use.
|
27
|
+
#log_level_args = ["--log-configuration-files", "config/logging/af.yml,config/logging/test.yml"]
|
28
|
+
log_level_args = ["--log-configuration-files", "config/logging/test.yml"]
|
29
|
+
|
30
|
+
if args.length > 0
|
31
|
+
old_args = ARGV[0..-1]
|
32
|
+
ARGV[0..-1] = args + log_level_args
|
33
|
+
else
|
34
|
+
ARGV[0..-1] = log_level_args
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
if block_given?
|
39
|
+
yield
|
40
|
+
elsif script.is_a?(Class)
|
41
|
+
# script is a class, use the normal run method
|
42
|
+
script.run
|
43
|
+
else
|
44
|
+
# script is an instance, run it the way Af runs it.
|
45
|
+
# https://github.com/fiksu/af/blob/master/lib/af/application.rb
|
46
|
+
script._run
|
47
|
+
script._work
|
48
|
+
end
|
49
|
+
rescue SystemExit => e
|
50
|
+
exit_status = e.status
|
51
|
+
ensure
|
52
|
+
# Reset ARGV if it was changed
|
53
|
+
ARGV[0..-1] = old_args if args.length > 0
|
54
|
+
end
|
55
|
+
|
56
|
+
exit_status
|
57
|
+
end
|
58
|
+
end
|