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,34 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe LoggerLevel do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:level].each do |a|
|
|
7
|
+
it { should allow_mass_assignment_of(a) }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
[:id,
|
|
11
|
+
:created_at,
|
|
12
|
+
:updated_at].each do |a|
|
|
13
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
#---------------------
|
|
17
|
+
# *** Associations ***
|
|
18
|
+
#+++++++++++++++++++++
|
|
19
|
+
|
|
20
|
+
it { should have_many(:logger_style_names) }
|
|
21
|
+
|
|
22
|
+
#--------------------
|
|
23
|
+
# *** Validations ***
|
|
24
|
+
#++++++++++++++++++++
|
|
25
|
+
|
|
26
|
+
it { should validate_presence_of(:level) }
|
|
27
|
+
|
|
28
|
+
describe "uniqueness"do
|
|
29
|
+
subject { FactoryGirl.create(:logger_level) }
|
|
30
|
+
it { should validate_uniqueness_of(:level) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe LoggerName do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:name].each do |a|
|
|
7
|
+
it { should allow_mass_assignment_of(a) }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
[:id,
|
|
11
|
+
:created_at,
|
|
12
|
+
:updated_at].each do |a|
|
|
13
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
#---------------------
|
|
17
|
+
# *** Associations ***
|
|
18
|
+
#+++++++++++++++++++++
|
|
19
|
+
|
|
20
|
+
it { should have_many(:logger_style_names) }
|
|
21
|
+
it { should have_many(:logger_styles) }
|
|
22
|
+
|
|
23
|
+
#--------------------
|
|
24
|
+
# *** Validations ***
|
|
25
|
+
#++++++++++++++++++++
|
|
26
|
+
|
|
27
|
+
it { should validate_presence_of(:name) }
|
|
28
|
+
|
|
29
|
+
describe "uniqueness"do
|
|
30
|
+
subject { FactoryGirl.create(:logger_name) }
|
|
31
|
+
it { should validate_uniqueness_of(:name) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe LoggerStyleName do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:logger_style_id,
|
|
7
|
+
:logger_name_id,
|
|
8
|
+
:logger_level_id].each do |a|
|
|
9
|
+
it { should allow_mass_assignment_of(a) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
[:id,
|
|
13
|
+
:created_at,
|
|
14
|
+
:updated_at].each do |a|
|
|
15
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#---------------------
|
|
19
|
+
# *** Associations ***
|
|
20
|
+
#+++++++++++++++++++++
|
|
21
|
+
|
|
22
|
+
it { should belong_to(:logger_name) }
|
|
23
|
+
it { should belong_to(:logger_style) }
|
|
24
|
+
it { should belong_to(:logger_level) }
|
|
25
|
+
|
|
26
|
+
#--------------------
|
|
27
|
+
# *** Validations ***
|
|
28
|
+
#++++++++++++++++++++
|
|
29
|
+
|
|
30
|
+
it { should validate_presence_of(:logger_name_id) }
|
|
31
|
+
it { should validate_presence_of(:logger_style_id) }
|
|
32
|
+
|
|
33
|
+
describe "uniqueness"do
|
|
34
|
+
subject { FactoryGirl.create(:logger_style_name) }
|
|
35
|
+
it { should validate_uniqueness_of(:logger_style_id).scoped_to(:logger_name_id) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe LoggerStyle do
|
|
5
|
+
let!(:logger_style) { FactoryGirl.create(:logger_style) }
|
|
6
|
+
let!(:logger_style_name1) {
|
|
7
|
+
FactoryGirl.create(:logger_style_name, logger_name: FactoryGirl.create(:logger_name, name: 'Name1'),
|
|
8
|
+
logger_level: FactoryGirl.create(:logger_level, level: 'Level1'),
|
|
9
|
+
logger_style_id: logger_style.id)
|
|
10
|
+
}
|
|
11
|
+
let!(:logger_style_name2) {
|
|
12
|
+
FactoryGirl.create(:logger_style_name, logger_name: FactoryGirl.create(:logger_name, name: 'Name2'),
|
|
13
|
+
logger_level: FactoryGirl.create(:logger_level, level: 'Level2'),
|
|
14
|
+
logger_style_id: logger_style.id)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Mass-assignment
|
|
18
|
+
[:name,
|
|
19
|
+
:note,
|
|
20
|
+
:logger_style_names_attributes].each do |a|
|
|
21
|
+
it { should allow_mass_assignment_of(a) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
[:id,
|
|
25
|
+
:created_at,
|
|
26
|
+
:updated_at].each do |a|
|
|
27
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#---------------------
|
|
31
|
+
# *** Associations ***
|
|
32
|
+
#+++++++++++++++++++++
|
|
33
|
+
|
|
34
|
+
it { should have_many(:logger_style_names) }
|
|
35
|
+
it { should have_many(:logger_names) }
|
|
36
|
+
|
|
37
|
+
#--------------------
|
|
38
|
+
# *** Validations ***
|
|
39
|
+
#++++++++++++++++++++
|
|
40
|
+
|
|
41
|
+
it { should validate_presence_of(:name) }
|
|
42
|
+
it { should validate_uniqueness_of(:name) }
|
|
43
|
+
|
|
44
|
+
describe "#check_logger_style_names_attributes" do
|
|
45
|
+
let(:error_message) { {
|
|
46
|
+
logger_name_id: ['should be an uniqueness']
|
|
47
|
+
} }
|
|
48
|
+
|
|
49
|
+
before do
|
|
50
|
+
logger_style_name2.logger_name_id = logger_style_name1.logger_name_id
|
|
51
|
+
logger_style.logger_style_names << logger_style_name1
|
|
52
|
+
logger_style.logger_style_names << logger_style_name2
|
|
53
|
+
logger_style.check_logger_style_names_attributes
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "add errors to logger style" do
|
|
57
|
+
logger_style.errors.messages.should == error_message
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#-------------------------
|
|
62
|
+
# *** Instance Methods ***
|
|
63
|
+
#+++++++++++++++++++++++++
|
|
64
|
+
|
|
65
|
+
describe "#_logger_names" do
|
|
66
|
+
before do
|
|
67
|
+
logger_style.logger_style_names << logger_style_name1
|
|
68
|
+
logger_style.logger_style_names << logger_style_name2
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "return comma separated logger names" do
|
|
72
|
+
logger_style._logger_names.should == 'Name1, Name2'
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
describe "#logger_levels" do
|
|
77
|
+
before do
|
|
78
|
+
logger_style.logger_style_names << logger_style_name1
|
|
79
|
+
logger_style.logger_style_names << logger_style_name2
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "return comma separated logger levels" do
|
|
83
|
+
logger_style.logger_levels.should == 'Level1, Level2'
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe MachineAffinitySlot do
|
|
5
|
+
let(:machine) { mock_model(Machine, server_address: '0.0.0.1', server_name: 'Machine1') }
|
|
6
|
+
let!(:slot) { FactoryGirl.create(:normal_machine_affinity_slot) }
|
|
7
|
+
|
|
8
|
+
# Mass-assignment
|
|
9
|
+
[:machine_id,
|
|
10
|
+
:affinity_id,
|
|
11
|
+
:required,
|
|
12
|
+
:affinity_parameter].each do |a|
|
|
13
|
+
it { should allow_mass_assignment_of(a) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
[:id,
|
|
17
|
+
:created_at].each do |a|
|
|
18
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#---------------------
|
|
22
|
+
# *** Associations ***
|
|
23
|
+
#+++++++++++++++++++++
|
|
24
|
+
|
|
25
|
+
it { should belong_to(:machine) }
|
|
26
|
+
it { should belong_to(:affinity) }
|
|
27
|
+
|
|
28
|
+
#--------------------
|
|
29
|
+
# *** Validations ***
|
|
30
|
+
#++++++++++++++++++++
|
|
31
|
+
|
|
32
|
+
it { should validate_presence_of(:machine_id) }
|
|
33
|
+
it { should validate_presence_of(:affinity_id) }
|
|
34
|
+
|
|
35
|
+
#--------------------
|
|
36
|
+
# *** Delegations ***
|
|
37
|
+
#++++++++++++++++++++
|
|
38
|
+
|
|
39
|
+
context "with regard to delegation" do
|
|
40
|
+
it "deleage to affinity_name method" do
|
|
41
|
+
slot.affinity.should_receive(:affinity_name)
|
|
42
|
+
slot.affinity_name
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "delegate to affinity_classification_name method" do
|
|
46
|
+
slot.affinity.should_receive(:affinity_classification_name)
|
|
47
|
+
slot.affinity_classification_name
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "delegate to affinity_short_name method" do
|
|
51
|
+
slot.affinity.should_receive(:affinity_short_name)
|
|
52
|
+
slot.affinity_short_name
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#-------------------------
|
|
57
|
+
# *** Instance Methods ***
|
|
58
|
+
#+++++++++++++++++++++++++
|
|
59
|
+
|
|
60
|
+
before do
|
|
61
|
+
slot.machine = machine
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "#machine_server_address" do
|
|
65
|
+
it "return the correct address" do
|
|
66
|
+
slot.machine_server_address.should == '0.0.0.1'
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#machine_server_name" do
|
|
71
|
+
it "return the correct name" do
|
|
72
|
+
slot.machine_server_name.should == 'Machine1'
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe MachineRunnerInvocation do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:machine_runner_id,
|
|
7
|
+
:pid,
|
|
8
|
+
:dead_at,
|
|
9
|
+
:wind_down_at,
|
|
10
|
+
:commit_information,
|
|
11
|
+
:branch_name,
|
|
12
|
+
:repository_name,
|
|
13
|
+
:deployment_tag].each do |a|
|
|
14
|
+
it { should allow_mass_assignment_of(a) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
[:id,
|
|
18
|
+
:created_at,
|
|
19
|
+
:updated_at].each do |a|
|
|
20
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#---------------------
|
|
24
|
+
# *** Associations ***
|
|
25
|
+
#+++++++++++++++++++++
|
|
26
|
+
|
|
27
|
+
it { should belong_to(:machine_runner) }
|
|
28
|
+
it { should have_many(:historical_jobs) }
|
|
29
|
+
|
|
30
|
+
#--------------------
|
|
31
|
+
# *** Validations ***
|
|
32
|
+
#++++++++++++++++++++
|
|
33
|
+
|
|
34
|
+
it { should validate_presence_of(:machine_runner_id) }
|
|
35
|
+
it { should validate_presence_of(:pid) }
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe MachineRunner do
|
|
5
|
+
# Mass-assignment
|
|
6
|
+
[:machine_id,
|
|
7
|
+
:runner_cwd].each do |a|
|
|
8
|
+
it { should allow_mass_assignment_of(a) }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
[:id,
|
|
12
|
+
:created_at,
|
|
13
|
+
:updated_at].each do |a|
|
|
14
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#---------------------
|
|
18
|
+
# *** Associations ***
|
|
19
|
+
#+++++++++++++++++++++
|
|
20
|
+
|
|
21
|
+
it { should belong_to(:machine) }
|
|
22
|
+
it { should have_many(:machine_runner_invocations) }
|
|
23
|
+
|
|
24
|
+
#--------------------
|
|
25
|
+
# *** Validations ***
|
|
26
|
+
#++++++++++++++++++++
|
|
27
|
+
|
|
28
|
+
it { should validate_presence_of(:machine_id) }
|
|
29
|
+
it { should validate_presence_of(:runner_cwd) }
|
|
30
|
+
|
|
31
|
+
describe "uniqueness"do
|
|
32
|
+
subject { FactoryGirl.create(:machine_runner) }
|
|
33
|
+
it { should validate_uniqueness_of(:machine_id).scoped_to(:runner_cwd) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Naf
|
|
4
|
+
describe Machine do
|
|
5
|
+
let!(:machine) { FactoryGirl.create(:machine) }
|
|
6
|
+
|
|
7
|
+
# Mass-assignment
|
|
8
|
+
[:server_address,
|
|
9
|
+
:server_name,
|
|
10
|
+
:server_note,
|
|
11
|
+
:enabled,
|
|
12
|
+
:thread_pool_size,
|
|
13
|
+
:log_level,
|
|
14
|
+
:marked_down,
|
|
15
|
+
:short_name,
|
|
16
|
+
:deleted].each do |a|
|
|
17
|
+
it { should allow_mass_assignment_of(a) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
[:id,
|
|
21
|
+
:created_at,
|
|
22
|
+
:updated_at].each do |a|
|
|
23
|
+
it { should_not allow_mass_assignment_of(a) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#---------------------
|
|
27
|
+
# *** Associations ***
|
|
28
|
+
#+++++++++++++++++++++
|
|
29
|
+
|
|
30
|
+
it { should have_many(:machine_affinity_slots) }
|
|
31
|
+
it { should have_many(:affinities) }
|
|
32
|
+
it { should have_many(:machine_runners) }
|
|
33
|
+
|
|
34
|
+
#--------------------
|
|
35
|
+
# *** Validations ***
|
|
36
|
+
#++++++++++++++++++++
|
|
37
|
+
|
|
38
|
+
it { should validate_presence_of(:server_address) }
|
|
39
|
+
it { should validate_uniqueness_of(:short_name) }
|
|
40
|
+
|
|
41
|
+
['', 'aa', 'aA', 'Aa', 'AA', '_a', 'a1', 'A1', '_9'].each do |v|
|
|
42
|
+
it { should allow_value(v).for(:short_name) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
['1_', '3A', '9a'].each do |v|
|
|
46
|
+
it { should_not allow_value(v).for(:short_name) }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
[-2147483647, 2147483646, 0, 1].each do |v|
|
|
50
|
+
it { should allow_value(v).for(:thread_pool_size) }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
[-2147483648, 2147483647, 1.0].each do |v|
|
|
54
|
+
it { should_not allow_value(v).for(:thread_pool_size) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "with regard to checking the schedules" do
|
|
58
|
+
before do
|
|
59
|
+
machine.mark_checked_schedule
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should be time to check the schedules if it's been longer than the check period" do
|
|
63
|
+
check_period = Time.now - Machine.last_time_schedules_were_checked
|
|
64
|
+
Machine.is_it_time_to_check_schedules?(check_period).should be_true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should not be time to check the schedules if it's been shorter than the check period" do
|
|
68
|
+
Machine.is_it_time_to_check_schedules?(1.minute).should be_false
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "when created" do
|
|
73
|
+
it "should not save with a bad address" do
|
|
74
|
+
bad_machine = FactoryGirl.build(:machine, server_address: "21312")
|
|
75
|
+
bad_machine.save.should_not be_true
|
|
76
|
+
bad_machine.should have(1).error_on(:server_address)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should be found by the enabled scope" do
|
|
80
|
+
Machine.enabled.should include(machine)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should be not be stale" do
|
|
84
|
+
machine.is_stale?(1).should be_false
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
context "when updating its status" do
|
|
89
|
+
let!(:time_before_update) { Time.zone.now }
|
|
90
|
+
|
|
91
|
+
it "should mark schedules as checked" do
|
|
92
|
+
machine.mark_checked_schedule
|
|
93
|
+
machine.last_checked_schedules_at.should be > time_before_update
|
|
94
|
+
machine.last_checked_schedules_at.should be < Time.zone.now
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should mark itself as alive" do
|
|
98
|
+
machine.mark_alive
|
|
99
|
+
machine.last_seen_alive_at.should be > time_before_update
|
|
100
|
+
machine.last_seen_alive_at.should be < Time.zone.now
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "should become stale" do
|
|
104
|
+
machine.mark_alive
|
|
105
|
+
sleep(2.0)
|
|
106
|
+
machine.is_stale?(1).should be_true
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
context "when marking itself as dead" do
|
|
111
|
+
it "should un-enable itself, and mark child proceses as dead" do
|
|
112
|
+
mock_machine_logger = double('machine_logger')
|
|
113
|
+
mock_machine_logger.should_receive(:alarm).and_return(nil)
|
|
114
|
+
dying_machine = machine
|
|
115
|
+
dying_machine.should_receive(:machine_logger).and_return(mock_machine_logger)
|
|
116
|
+
dying_machine.should_receive(:mark_processes_as_dead).and_return(nil)
|
|
117
|
+
dying_machine.mark_machine_down(dying_machine)
|
|
118
|
+
dying_machine.marked_down.should be_true
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#----------------------
|
|
123
|
+
# *** Class Methods ***
|
|
124
|
+
#++++++++++++++++++++++
|
|
125
|
+
|
|
126
|
+
describe "#enabled" do
|
|
127
|
+
before do
|
|
128
|
+
machine.update_attributes!(enabled: true)
|
|
129
|
+
FactoryGirl.create(:machine_two, enabled: false)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "return the correct machine" do
|
|
133
|
+
::Naf::Machine.enabled.all.should == [machine]
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
describe "#up" do
|
|
138
|
+
it "return the correct status" do
|
|
139
|
+
FactoryGirl.create(:machine, marked_down: true)
|
|
140
|
+
::Naf::Machine.down.all.should == [machine]
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe "#down" do
|
|
145
|
+
it "return the correct status" do
|
|
146
|
+
machine2 = FactoryGirl.create(:machine, marked_down: true)
|
|
147
|
+
::Naf::Machine.down.all.should == [machine2]
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe "#machine_ip_address" do
|
|
152
|
+
it "return the correct ip address" do
|
|
153
|
+
::Naf::Machine.stub(:hostname).and_raise(StandardError)
|
|
154
|
+
::Naf::Machine.machine_ip_address.should == '127.0.0.1'
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "return the correct ip address" do
|
|
158
|
+
::Naf::Machine.stub(:hostname).and_return('1.1.1.1')
|
|
159
|
+
::Naf::Machine.machine_ip_address.should == '1.1.1.1'
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe "#hostname" do
|
|
164
|
+
it "return the correct ip address" do
|
|
165
|
+
Socket.stub(:gethostname).and_raise(StandardError)
|
|
166
|
+
::Naf::Machine.hostname.should == 'local'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "return the correct ip address" do
|
|
170
|
+
Socket.stub(:gethostname).and_return('test.local')
|
|
171
|
+
::Naf::Machine.hostname.should == 'test.local'
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
describe "#local_machine" do
|
|
176
|
+
before do
|
|
177
|
+
::Naf::Machine.stub(:machine_ip_address).and_return('1.1.1.1')
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "return the correct machine" do
|
|
181
|
+
machine.update_attributes!(server_address: '1.1.1.1')
|
|
182
|
+
::Naf::Machine.local_machine.should == machine
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "return no machines" do
|
|
186
|
+
::Naf::Machine.local_machine.should == nil
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
describe "#current" do
|
|
191
|
+
before do
|
|
192
|
+
::Naf::Machine.stub(:local_machine).and_return(machine)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "return the correct machine" do
|
|
196
|
+
::Naf::Machine.current.should == machine
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
describe "#last_time_schedules_were_checked" do
|
|
201
|
+
before do
|
|
202
|
+
machine.last_checked_schedules_at = Time.zone.now
|
|
203
|
+
machine.save!
|
|
204
|
+
FactoryGirl.create(:machine_two, last_checked_schedules_at: Time.zone.now - 5.minutes)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "return the correct machine" do
|
|
208
|
+
::Naf::Machine.last_time_schedules_were_checked.to_i.should == machine.last_checked_schedules_at.to_i
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe "#is_it_time_to_check_schedules?" do
|
|
213
|
+
let!(:time) { Time.zone.now }
|
|
214
|
+
|
|
215
|
+
it "return the correct ip address" do
|
|
216
|
+
::Naf::Machine.stub(:last_time_schedules_were_checked).and_return(time)
|
|
217
|
+
::Naf::Machine.is_it_time_to_check_schedules?(1.minute).should == false
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it "return true when last checked is nil" do
|
|
221
|
+
::Naf::Machine.stub(:last_time_schedules_were_checked).and_return(nil)
|
|
222
|
+
::Naf::Machine.is_it_time_to_check_schedules?(time).should == true
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
#-------------------------
|
|
227
|
+
# *** Instance Methods ***
|
|
228
|
+
#+++++++++++++++++++++++++
|
|
229
|
+
|
|
230
|
+
describe "#to_s" do
|
|
231
|
+
it "parse the machine correctly" do
|
|
232
|
+
machine.to_s.should == "::Naf::Machine<ENABLED, id: #{machine.id}, address: 0.0.0.1, " +
|
|
233
|
+
"pool size: 5, last checked schedules: , last seen: >"
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
describe "#correct_server_address?" do
|
|
238
|
+
it "return 0 for valid ip address" do
|
|
239
|
+
machine.correct_server_address?.should == 0
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it "return nil for invalid ip address" do
|
|
243
|
+
machine.server_address = '1.1'
|
|
244
|
+
machine.correct_server_address?.should == nil
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
describe "#mark_checked_schedule" do
|
|
249
|
+
before do
|
|
250
|
+
Timecop.freeze(Time.zone.now)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
after do
|
|
254
|
+
Timecop.return
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "change last_checked_schedules_at" do
|
|
258
|
+
lambda {
|
|
259
|
+
machine.mark_checked_schedule
|
|
260
|
+
}.should change(machine, :last_checked_schedules_at).
|
|
261
|
+
from(nil).to(Time.zone.now)
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
describe "#mark_alive" do
|
|
266
|
+
before do
|
|
267
|
+
Timecop.freeze(Time.zone.now)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
after do
|
|
271
|
+
Timecop.return
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it "change last_seen_alive_at" do
|
|
275
|
+
lambda {
|
|
276
|
+
machine.mark_alive
|
|
277
|
+
}.should change(machine, :last_seen_alive_at).
|
|
278
|
+
from(nil).to(Time.zone.now)
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
describe "#mark_up" do
|
|
283
|
+
before do
|
|
284
|
+
machine.update_attributes!(marked_down: true)
|
|
285
|
+
Timecop.freeze(Time.zone.now)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
after do
|
|
289
|
+
Timecop.return
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
it "change marked_down" do
|
|
293
|
+
lambda {
|
|
294
|
+
machine.mark_up
|
|
295
|
+
}.should change(machine, :marked_down).
|
|
296
|
+
from(true).to(false)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
describe "#mark_down" do
|
|
301
|
+
let!(:machine2) { FactoryGirl.create(:machine) }
|
|
302
|
+
before do
|
|
303
|
+
machine.mark_down(machine2)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it "set marked_down to true" do
|
|
307
|
+
machine.marked_down.should == true
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
it "set marked_down_by_machine_id" do
|
|
311
|
+
machine.marked_down_by_machine_id.should == machine2.id
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
it "change marked_down_at to timestamp" do
|
|
315
|
+
machine.marked_down_at.should be_within(3.seconds).of(Time.zone.now)
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
describe "#is_stale?" do
|
|
320
|
+
it "return true when machine is stale" do
|
|
321
|
+
machine.last_seen_alive_at = Time.zone.now - 1.minute
|
|
322
|
+
machine.is_stale?(1.second).should == true
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "return false when machine is not stale" do
|
|
326
|
+
machine.last_seen_alive_at = Time.zone.now
|
|
327
|
+
machine.is_stale?(1.minute).should == false
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
it "return false when the runner hasn't been started" do
|
|
331
|
+
machine.last_seen_alive_at = nil
|
|
332
|
+
machine.is_stale?(1.second).should == false
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
describe "#mark_processes_as_dead" do
|
|
337
|
+
before(:all) do
|
|
338
|
+
Timecop.freeze(Time.zone.now)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
after(:all) do
|
|
342
|
+
Timecop.return
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
let!(:running_job) {
|
|
346
|
+
FactoryGirl.create(:running_job_base, created_at: Time.zone.now - 1.minute, started_on_machine_id: machine.id)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
before do
|
|
350
|
+
machine.mark_processes_as_dead(machine)
|
|
351
|
+
running_job.reload
|
|
352
|
+
running_job.historical_job.reload
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
it "set request_to_terminate to true" do
|
|
356
|
+
running_job.request_to_terminate.should == true
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
it "set marked_dead_by_machine_id to the machine's id" do
|
|
360
|
+
running_job.marked_dead_by_machine_id.should == machine.id
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
it "set marked_dead_at to the current time" do
|
|
364
|
+
running_job.marked_dead_at.should be_within(3.seconds).of(Time.zone.now)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
it "mark the job as finished" do
|
|
368
|
+
running_job.historical_job.finished_at.should be_within(3.seconds).of(Time.zone.now)
|
|
369
|
+
end
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
describe "#mark_machine_down" do
|
|
373
|
+
before(:all) do
|
|
374
|
+
Timecop.freeze(Time.zone.now)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
after(:all) do
|
|
378
|
+
Timecop.return
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
before do
|
|
382
|
+
machine.mark_machine_down(machine)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
it "set marked_down to true" do
|
|
386
|
+
machine.marked_down.should == true
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
it "set marked_down_by_machine_id to the machine's id" do
|
|
390
|
+
machine.marked_down_by_machine_id.should == machine.id
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
it "set marked_down_at to the current time" do
|
|
394
|
+
machine.marked_down_at.should be_within(3.seconds).of(Time.zone.now)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
describe "#affinity" do
|
|
399
|
+
it "return affinity associated with machine's id" do
|
|
400
|
+
affinity = FactoryGirl.create(:affinity, id: 4,
|
|
401
|
+
affinity_classification_id: 1,
|
|
402
|
+
affinity_name: machine.id.to_s)
|
|
403
|
+
machine.affinity.should == affinity
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
it "nil when there's no affinity associated with machine's id" do
|
|
407
|
+
machine.affinity.should == nil
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
describe "#short_name_if_it_exist" do
|
|
412
|
+
it "return short name" do
|
|
413
|
+
machine.short_name = 'Machine1'
|
|
414
|
+
machine.short_name_if_it_exist.should == 'Machine1'
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "return server name" do
|
|
418
|
+
machine.short_name = nil
|
|
419
|
+
machine.server_name = 'machine.example.com'
|
|
420
|
+
machine.short_name_if_it_exist.should == 'machine.example.com'
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
end
|
|
425
|
+
end
|