tengine_job 0.6.13 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -20
- data/Gemfile.lock +70 -72
- data/README.rdoc +2 -2
- data/bin/create_indexes_for_tengine_job +18 -0
- data/lib/tengine/job/connectable.rb +4 -4
- data/lib/tengine/job/drivers/job_execution_driver.rb +2 -2
- data/lib/tengine/job/drivers/jobnet_control_driver.rb +3 -3
- data/lib/tengine/job/drivers/schedule_driver.rb +12 -12
- data/lib/tengine/job/edge.rb +2 -2
- data/lib/tengine/job/expansion.rb +1 -1
- data/lib/tengine/job/jobnet.rb +12 -2
- data/lib/tengine/job/jobnet_actual.rb +29 -0
- data/lib/tengine/job/root_jobnet_actual.rb +20 -1
- data/lib/tengine/job/root_jobnet_template.rb +4 -4
- data/lib/tengine/job/signal.rb +1 -1
- data/lib/tengine/job/vertex.rb +10 -1
- metadata +130 -126
- data/.document +0 -5
- data/.rspec +0 -1
- data/Rakefile +0 -42
- data/VERSION +0 -1
- data/spec/fixtures/rjn_0001_simple_jobnet_builder.rb +0 -42
- data/spec/fixtures/rjn_0002_simple_parallel_jobnet_builder.rb +0 -42
- data/spec/fixtures/rjn_0003_fork_join_jobnet_builder.rb +0 -61
- data/spec/fixtures/rjn_0004_parallel_jobnet_with_finally_fixture.rb +0 -62
- data/spec/fixtures/rjn_0005_retry_two_layer_fixture.rb +0 -153
- data/spec/fixtures/rjn_0008_expansion_fixture.rb +0 -32
- data/spec/fixtures/rjn_0009_tree_sequential_jobnet_builder.rb +0 -174
- data/spec/fixtures/rjn_0010_2jobs_and_1job_parallel_jobnet_builder.rb +0 -39
- data/spec/fixtures/rjn_0011_nested_fork_jobnet_builder.rb +0 -96
- data/spec/fixtures/rjn_0012_nested_and_finally_builder.rb +0 -157
- data/spec/fixtures/rjn_1004_hadoop_job_in_jobnet_fixture.rb +0 -105
- data/spec/fixtures/rjn_means_root_jobnet +0 -0
- data/spec/fixtures/test_credential_fixture.rb +0 -12
- data/spec/fixtures/test_server_fixture.rb +0 -28
- data/spec/mongoid.yml +0 -35
- data/spec/spec_helper.rb +0 -58
- data/spec/sshd/.gitignore +0 -1
- data/spec/sshd/id_rsa +0 -51
- data/spec/sshd/id_rsa.pub +0 -1
- data/spec/sshd/ssh_host_rsa_key +0 -51
- data/spec/sshd/ssh_host_rsa_key.pub +0 -1
- data/spec/sshd/sshd_config +0 -10
- data/spec/sshd/sshd_config.erb +0 -11
- data/spec/sshd/tengine_job_test.sh +0 -6
- data/spec/support/jobnet_fixture_builder.rb +0 -145
- data/spec/support/mongo_index_key_log.rb +0 -91
- data/spec/tengine/job/category_spec.rb +0 -193
- data/spec/tengine/job/connectable_spec.rb +0 -94
- data/spec/tengine/job/drivers/job_controll_driver/connection_error_spec.rb +0 -236
- data/spec/tengine/job/drivers/job_controll_driver/duplicated_job_start_spec.rb +0 -302
- data/spec/tengine/job/drivers/job_controll_driver/expansion_spec.rb +0 -120
- data/spec/tengine/job/drivers/job_controll_driver/stop_spec.rb +0 -159
- data/spec/tengine/job/drivers/job_controll_driver_spec.rb +0 -740
- data/spec/tengine/job/drivers/job_execution_driver_spec.rb +0 -138
- data/spec/tengine/job/drivers/jobnet_control_driver/nested_and_finally_spec.rb +0 -472
- data/spec/tengine/job/drivers/jobnet_control_driver/nested_jobnet_spec.rb +0 -231
- data/spec/tengine/job/drivers/jobnet_control_driver/stop_jobnet_spec.rb +0 -202
- data/spec/tengine/job/drivers/jobnet_control_driver_spec.rb +0 -608
- data/spec/tengine/job/drivers/schedule_driver_spec.rb +0 -241
- data/spec/tengine/job/dsl_binder_spec.rb +0 -36
- data/spec/tengine/job/dsl_loader_spec.rb +0 -437
- data/spec/tengine/job/dsls/0013_hadoop_job_run.rb +0 -29
- data/spec/tengine/job/dsls/0014_join_and_join.rb +0 -19
- data/spec/tengine/job/dsls/0015_fork_and_fork.rb +0 -18
- data/spec/tengine/job/dsls/0016_complex_fork_and_join.rb +0 -20
- data/spec/tengine/job/dsls/0017_finally.rb +0 -15
- data/spec/tengine/job/dsls/0018_expansion.rb +0 -23
- data/spec/tengine/job/dsls/0019_execute_job_on_event.rb +0 -16
- data/spec/tengine/job/dsls/0020_duplicated_jobnet_name.rb +0 -16
- data/spec/tengine/job/dsls/0021_caption.rb +0 -13
- data/spec/tengine/job/dsls/1060_test_dir1/1060_test_dir2/0013_hadoop_job_run.rb +0 -29
- data/spec/tengine/job/dsls/2003_expansion/expansion_5.rb +0 -11
- data/spec/tengine/job/dsls/VERSION +0 -1
- data/spec/tengine/job/dynamic_env_spec.rb +0 -95
- data/spec/tengine/job/edge_spec.rb +0 -241
- data/spec/tengine/job/element_selector_notation_spec.rb +0 -354
- data/spec/tengine/job/examples_spec.rb +0 -62
- data/spec/tengine/job/execution_spec.rb +0 -100
- data/spec/tengine/job/expansion_spec.rb +0 -116
- data/spec/tengine/job/hadoop_job_run_spec.rb +0 -65
- data/spec/tengine/job/job_spec.rb +0 -4
- data/spec/tengine/job/jobnet/1015_complecated_jobnet_spec.rb +0 -72
- data/spec/tengine/job/jobnet_actual_spec.rb +0 -175
- data/spec/tengine/job/jobnet_spec.rb +0 -399
- data/spec/tengine/job/jobnet_template_spec.rb +0 -240
- data/spec/tengine/job/killing_spec.rb +0 -91
- data/spec/tengine/job/reset_spec.rb +0 -958
- data/spec/tengine/job/reset_spec/4056_1_dump.txt +0 -1
- data/spec/tengine/job/root_jobnet_actual_spec.rb +0 -89
- data/spec/tengine/job/root_jobnet_template_spec.rb +0 -248
- data/spec/tengine/job/script_executable_spec.rb +0 -132
- data/spec/tengine/job/stoppable_spec.rb +0 -176
- data/spec/tengine/job/vertex_spec.rb +0 -25
- data/spec/tengine_job_spec.rb +0 -4
- data/tengine_job.gemspec +0 -198
- data/tmp/log/.gitignore +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000004'), "created_at"=>'2011-12-13 14:19:16 UTC', "updated_at"=>'2011-12-13 14:19:20 UTC', "server_name"=>"test_server1", "credential_name"=>"test_credential1", "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn0006", "script"=>nil, "description"=>"jn0006", "jobnet_type_cd"=>1, "category_id"=>BSON::ObjectId('4edf213100bb830f1000008d'), "version"=>29, "dsl_filepath"=>"0006_retry_three_layer.rb", "dsl_lineno"=>23, "dsl_version"=>"123", "_type"=>"Tengine::Job::RootJobnetActual", "phase_cd"=>80, "template_id"=>BSON::ObjectId('4ee75ee400bb83194c000157'), "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000005'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn1", "script"=>nil, "description"=>"jn1", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000006'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>80, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000007'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn11", "script"=>nil, "description"=>"jn11", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000008'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>80, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000009'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j111", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j111", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000a'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>80, "started_at"=>'2011-12-13 17:37:46 UTC', "executing_pid"=>"31490", "exit_status"=>"1", "finished_at"=>'2011-12-13 17:37:49 UTC', "error_messages"=>["Job process failed. STDOUT and STDERR were redirected to files. You can see them at /home/goku/stdout-31490.log and /home/goku/stderr-31490.log on the server "]}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j112", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j112", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000b'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"finally", "script"=>nil, "description"=>"finally", "jobnet_type_cd"=>2, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000c'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000d'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn11_f", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"jn11_f", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000e'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "started_at"=>'2011-12-13 17:37:49 UTC', "executing_pid"=>"31597", "exit_status"=>"0", "finished_at"=>'2011-12-13 17:37:52 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300000f'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000010'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300000d'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300000e')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000011'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300000e'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300000f')}], "started_at"=>'2011-12-13 17:37:49 UTC', "finished_at"=>'2011-12-13 17:37:52 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000012'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000013'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000009'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300000a')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000014'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300000a'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300000b')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000015'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300000b'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000012')}], "started_at"=>'2011-12-13 17:37:46 UTC', "finished_at"=>'2011-12-13 17:37:52 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j12", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j12", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000016'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"finally", "script"=>nil, "description"=>"finally", "jobnet_type_cd"=>2, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000017'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000018'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn1_f", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"jn1_f", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000019'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "started_at"=>'2011-12-13 17:37:52 UTC', "executing_pid"=>"31710", "exit_status"=>"0", "finished_at"=>'2011-12-13 17:37:55 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300001a'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c300001b'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000018'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000019')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c300001c'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000019'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300001a')}], "started_at"=>'2011-12-13 17:37:52 UTC', "finished_at"=>'2011-12-13 17:37:55 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300001d'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c300001e'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000007'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000008')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c300001f'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000008'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000016')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000020'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000016'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300001d')}], "started_at"=>'2011-12-13 17:37:46 UTC', "finished_at"=>'2011-12-13 17:37:55 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn2", "script"=>nil, "description"=>"jn2", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000021'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000022'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j21", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j21", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000023'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn22", "script"=>nil, "description"=>"jn22", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000024'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000025'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j221", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j221", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000026'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"j222", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"j222", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000027'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"finally", "script"=>nil, "description"=>"finally", "jobnet_type_cd"=>2, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000028'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000029'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn22_f", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"jn22_f", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300002a'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300002b'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c300002c'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000029'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300002a')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c300002d'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300002a'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300002b')}]}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300002e'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c300002f'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000025'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000026')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000030'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000026'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000027')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000031'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000027'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300002e')}]}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"finally", "script"=>nil, "description"=>"finally", "jobnet_type_cd"=>2, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000032'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000033'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn2_f", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"jn2_f", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000034'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>20}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000035'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000036'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000033'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000034')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000037'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000034'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000035')}]}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000038'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000039'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000022'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000023')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c300003a'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000023'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000024')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c300003b'), "phase_cd"=>0, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000024'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000038')}]}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"finally", "script"=>nil, "description"=>"finally", "jobnet_type_cd"=>2, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300003c'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "children"=>[{"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300003d'), "_type"=>"Tengine::Job::Start"}, {"created_at"=>nil, "updated_at"=>nil, "server_name"=>nil, "credential_name"=>nil, "killing_signals"=>nil, "killing_signal_interval"=>nil, "name"=>"jn_f", "script"=>"$HOME/0006_retry_three_layer.sh", "description"=>"jn_f", "jobnet_type_cd"=>1, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300003e'), "_type"=>"Tengine::Job::JobnetActual", "phase_cd"=>40, "started_at"=>'2011-12-13 17:37:55 UTC', "executing_pid"=>"31824", "exit_status"=>"0", "finished_at"=>'2011-12-13 17:37:58 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c300003f'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000040'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300003d'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300003e')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000041'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c300003e'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c300003f')}], "started_at"=>'2011-12-13 17:37:55 UTC', "finished_at"=>'2011-12-13 17:37:58 UTC'}, {"created_at"=>nil, "updated_at"=>nil, "_id"=>BSON::ObjectId('4ee78d6900bb8379c3000042'), "_type"=>"Tengine::Job::End"}], "edges"=>[{"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000043'), "phase_cd"=>20, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000005'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000006')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000044'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000006'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000021')}, {"_id"=>BSON::ObjectId('4ee78d6900bb8379c3000045'), "phase_cd"=>50, "origin_id"=>BSON::ObjectId('4ee78d6900bb8379c3000021'), "destination_id"=>BSON::ObjectId('4ee78d6900bb8379c3000042')}], "started_at"=>'2011-12-13 17:37:46 UTC', "finished_at"=>'2011-12-13 17:37:59 UTC'}
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Tengine::Job::RootJobnetActual do
|
5
|
-
|
6
|
-
context :update_with_lock do
|
7
|
-
before do
|
8
|
-
Tengine::Job::Vertex.delete_all
|
9
|
-
builder = Rjn0001SimpleJobnetBuilder.new
|
10
|
-
builder.create_actual
|
11
|
-
@ctx = builder.context
|
12
|
-
end
|
13
|
-
|
14
|
-
it "updateで更新できる" do
|
15
|
-
root = @ctx[:root]
|
16
|
-
j11 = root.find_descendant(@ctx[:j11].id)
|
17
|
-
j11.executing_pid = "1111"
|
18
|
-
root.save!
|
19
|
-
#
|
20
|
-
loaded = Tengine::Job::RootJobnetActual.find(root.id)
|
21
|
-
loaded.find_descendant(@ctx[:j11].id).executing_pid.should == "1111"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "update_with_lockで更新できる" do
|
25
|
-
count = 0
|
26
|
-
root = @ctx[:root]
|
27
|
-
root.update_with_lock do
|
28
|
-
count += 1
|
29
|
-
j11 = root.find_descendant(@ctx[:j11].id)
|
30
|
-
j11.executing_pid = "1111"
|
31
|
-
end
|
32
|
-
count.should == 1
|
33
|
-
#
|
34
|
-
loaded = Tengine::Job::RootJobnetActual.find(root.id)
|
35
|
-
loaded.find_descendant(@ctx[:j11].id).executing_pid.should == "1111"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
describe :rerun do
|
41
|
-
before do
|
42
|
-
Tengine::Job::Execution.delete_all
|
43
|
-
Tengine::Job::Vertex.delete_all
|
44
|
-
builder = Rjn0001SimpleJobnetBuilder.new
|
45
|
-
@root = builder.create_actual
|
46
|
-
@ctx = builder.context
|
47
|
-
@execution = Tengine::Job::Execution.create!({
|
48
|
-
:root_jobnet_id => @root.id,
|
49
|
-
})
|
50
|
-
@root.phase_key = :error
|
51
|
-
@ctx[:e1].phase_key = :transmitted
|
52
|
-
@ctx[:j11].phase_key = :success
|
53
|
-
@ctx[:e2].phase_key = :transmitted
|
54
|
-
@ctx[:j12].phase_key = :error
|
55
|
-
@ctx[:e3].phase_key = :active
|
56
|
-
@root.save!
|
57
|
-
@execution.phase_key = :error
|
58
|
-
@execution.save!
|
59
|
-
end
|
60
|
-
|
61
|
-
context "rerunするとExecutionが別に作られて、それを実行するイベントが発火される" do
|
62
|
-
[true, false].each do |spot|
|
63
|
-
|
64
|
-
it "スポット実行 #{spot.inspect}" do
|
65
|
-
execution1 = Tengine::Job::Execution.new(:retry => true, :spot => spot,
|
66
|
-
:root_jobnet_id => @root.id,
|
67
|
-
:target_actual_ids => [@ctx[:j12].id])
|
68
|
-
Tengine::Job::Execution.should_receive(:new).with({
|
69
|
-
:retry => true, :spot => spot,
|
70
|
-
:root_jobnet_id => @root.id
|
71
|
-
}).and_return(execution1)
|
72
|
-
sender = mock(:sender)
|
73
|
-
sender.should_receive(:wait_for_connection).and_yield
|
74
|
-
sender.should_receive(:fire).with(:'start.execution.job.tengine',
|
75
|
-
:properties => {
|
76
|
-
:execution_id => execution1.id.to_s,
|
77
|
-
})
|
78
|
-
expect{
|
79
|
-
execution = @root.rerun(@ctx[:j12].id, :spot => spot, :sender => sender)
|
80
|
-
execution.id.should_not == @execution.id # rerunの戻り値のexecutionは元々のexecutionとは別物です
|
81
|
-
}.to change(Tengine::Job::Execution, :count).by(1)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
@@ -1,248 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Tengine::Job::RootJobnetTemplate do
|
5
|
-
|
6
|
-
describe :generate do
|
7
|
-
context "rjn0001" do
|
8
|
-
before do
|
9
|
-
Tengine::Job::Vertex.delete_all
|
10
|
-
builder = Rjn0001SimpleJobnetBuilder.new
|
11
|
-
@jobnet = builder.create_template
|
12
|
-
@ctx = builder.context
|
13
|
-
end
|
14
|
-
|
15
|
-
it "実行用ジョブネットを生成する" do
|
16
|
-
root = @jobnet.generate
|
17
|
-
root.should be_a(Tengine::Job::RootJobnetActual)
|
18
|
-
root.children.length.should == 4
|
19
|
-
root.children[0].should be_a(Tengine::Job::Start)
|
20
|
-
root.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j11"}
|
21
|
-
root.children[2].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j12"}
|
22
|
-
root.children[3].should be_a(Tengine::Job::End)
|
23
|
-
root.edges.length.should == 3
|
24
|
-
root.edges[0].tap{|edge| edge.origin.should == root.children[0]; edge.destination.should == root.children[1]}
|
25
|
-
root.edges[1].tap{|edge| edge.origin.should == root.children[1]; edge.destination.should == root.children[2]}
|
26
|
-
root.edges[2].tap{|edge| edge.origin.should == root.children[2]; edge.destination.should == root.children[3]}
|
27
|
-
root.template.id.should == @jobnet.id
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "rjn0002" do
|
32
|
-
before do
|
33
|
-
Tengine::Job::Vertex.delete_all
|
34
|
-
builder = Rjn0002SimpleParallelJobnetBuilder.new
|
35
|
-
@jobnet = builder.create_template
|
36
|
-
@ctx = builder.context
|
37
|
-
end
|
38
|
-
|
39
|
-
it "実行用ジョブネットを生成する" do
|
40
|
-
root = @jobnet.generate
|
41
|
-
root.should be_a(Tengine::Job::RootJobnetActual)
|
42
|
-
root.children.length.should == 6
|
43
|
-
root.children[0].should be_a(Tengine::Job::Start)
|
44
|
-
root.children[1].should be_a(Tengine::Job::Fork)
|
45
|
-
root.children[2].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j11"}
|
46
|
-
root.children[3].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j12"}
|
47
|
-
root.children[4].should be_a(Tengine::Job::Join)
|
48
|
-
root.children[5].should be_a(Tengine::Job::End)
|
49
|
-
root.edges.length.should == 6
|
50
|
-
root.edges[0].tap{|edge| edge.origin.should == root.children[0]; edge.destination.should == root.children[1]}
|
51
|
-
root.edges[1].tap{|edge| edge.origin.should == root.children[1]; edge.destination.should == root.children[2]}
|
52
|
-
root.edges[2].tap{|edge| edge.origin.should == root.children[1]; edge.destination.should == root.children[3]}
|
53
|
-
root.edges[3].tap{|edge| edge.origin.should == root.children[2]; edge.destination.should == root.children[4]}
|
54
|
-
root.edges[4].tap{|edge| edge.origin.should == root.children[3]; edge.destination.should == root.children[4]}
|
55
|
-
root.edges[5].tap{|edge| edge.origin.should == root.children[4]; edge.destination.should == root.children[5]}
|
56
|
-
root.template.id.should == @jobnet.id
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "rjn0012" do
|
61
|
-
before do
|
62
|
-
Tengine::Job::Vertex.delete_all
|
63
|
-
builder = Rjn0012NestedAndFinallyBuilder.new
|
64
|
-
@jobnet = builder.create_template
|
65
|
-
@ctx = builder.context
|
66
|
-
end
|
67
|
-
|
68
|
-
it "実行用ジョブネットを生成する" do
|
69
|
-
root = @jobnet.generate
|
70
|
-
root.should be_a(Tengine::Job::RootJobnetActual)
|
71
|
-
root.children.length.should == 5
|
72
|
-
root.children[0].should be_a(Tengine::Job::Start)
|
73
|
-
root.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1000"}
|
74
|
-
root.children[2].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j2000"}
|
75
|
-
root.children[3].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.jobnet_type_key.should == :finally}
|
76
|
-
root.children[4].should be_a(Tengine::Job::End)
|
77
|
-
root.edges.length.should == 3
|
78
|
-
root.edges[0].tap{|edge| edge.origin.should == root.children[0]; edge.destination.should == root.children[1]}
|
79
|
-
root.edges[1].tap{|edge| edge.origin.should == root.children[1]; edge.destination.should == root.children[2]}
|
80
|
-
root.edges[2].tap{|edge| edge.origin.should == root.children[2]; edge.destination.should == root.children[4]}
|
81
|
-
root.children[1].tap do |j1000|
|
82
|
-
j1000.children.length.should == 5
|
83
|
-
j1000.children[0].should be_a(Tengine::Job::Start)
|
84
|
-
j1000.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1100"}
|
85
|
-
j1000.children[2].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1200"}
|
86
|
-
j1000.children[3].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.jobnet_type_key.should == :finally}
|
87
|
-
j1000.children[4].should be_a(Tengine::Job::End)
|
88
|
-
j1000.edges.length.should == 3
|
89
|
-
j1000.edges[0].tap{|edge| edge.origin.should == j1000.children[0]; edge.destination.should == j1000.children[1]}
|
90
|
-
j1000.edges[1].tap{|edge| edge.origin.should == j1000.children[1]; edge.destination.should == j1000.children[2]}
|
91
|
-
j1000.edges[2].tap{|edge| edge.origin.should == j1000.children[2]; edge.destination.should == j1000.children[4]}
|
92
|
-
j1000.children[1].tap do |j1100|
|
93
|
-
j1100.children.length.should == 3
|
94
|
-
j1100.children[0].should be_a(Tengine::Job::Start)
|
95
|
-
j1100.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1110"}
|
96
|
-
j1100.children[2].should be_a(Tengine::Job::End)
|
97
|
-
j1100.edges.length.should == 2
|
98
|
-
j1100.edges[0].tap{|edge| edge.origin.should == j1100.children[0]; edge.destination.should == j1100.children[1]}
|
99
|
-
j1100.edges[1].tap{|edge| edge.origin.should == j1100.children[1]; edge.destination.should == j1100.children[2]}
|
100
|
-
end
|
101
|
-
j1000.children[2].tap do |j1200|
|
102
|
-
j1200.children.length.should == 3
|
103
|
-
j1200.children[0].should be_a(Tengine::Job::Start)
|
104
|
-
j1200.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1210"}
|
105
|
-
j1200.children[2].should be_a(Tengine::Job::End)
|
106
|
-
j1200.edges.length.should == 2
|
107
|
-
j1200.edges[0].tap{|edge| edge.origin.should == j1200.children[0]; edge.destination.should == j1200.children[1]}
|
108
|
-
j1200.edges[1].tap{|edge| edge.origin.should == j1200.children[1]; edge.destination.should == j1200.children[2]}
|
109
|
-
end
|
110
|
-
j1000.children[3].tap do |j1f00|
|
111
|
-
j1f00.children.length.should == 4
|
112
|
-
j1f00.children[0].should be_a(Tengine::Job::Start)
|
113
|
-
j1f00.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1f10"}
|
114
|
-
j1f00.children[2].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.jobnet_type_key.should == :finally}
|
115
|
-
j1f00.children[3].should be_a(Tengine::Job::End)
|
116
|
-
j1f00.edges.length.should == 2
|
117
|
-
j1f00.edges[0].tap{|edge| edge.origin.should == j1f00.children[0]; edge.destination.should == j1f00.children[1]}
|
118
|
-
j1f00.edges[1].tap{|edge| edge.origin.should == j1f00.children[1]; edge.destination.should == j1f00.children[3]}
|
119
|
-
j1f00.children[1].tap do |j1f10|
|
120
|
-
j1f10.children.length.should == 3
|
121
|
-
j1f10.children[0].should be_a(Tengine::Job::Start)
|
122
|
-
j1f10.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1f11"}
|
123
|
-
j1f10.children[2].should be_a(Tengine::Job::End)
|
124
|
-
j1f10.edges.length.should == 2
|
125
|
-
j1f10.edges[0].tap{|edge| edge.origin.should == j1f10.children[0]; edge.destination.should == j1f10.children[1]}
|
126
|
-
j1f10.edges[1].tap{|edge| edge.origin.should == j1f10.children[1]; edge.destination.should == j1f10.children[2]}
|
127
|
-
end
|
128
|
-
j1f00.children[2].tap do |j1ff0|
|
129
|
-
j1ff0.children.length.should == 3
|
130
|
-
j1ff0.children[0].should be_a(Tengine::Job::Start)
|
131
|
-
j1ff0.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j1ff1"}
|
132
|
-
j1ff0.children[2].should be_a(Tengine::Job::End)
|
133
|
-
j1ff0.edges.length.should == 2
|
134
|
-
j1ff0.edges[0].tap{|edge| edge.origin.should == j1ff0.children[0]; edge.destination.should == j1ff0.children[1]}
|
135
|
-
j1ff0.edges[1].tap{|edge| edge.origin.should == j1ff0.children[1]; edge.destination.should == j1ff0.children[2]}
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
root.children[2].tap do |j2000|
|
140
|
-
j2000.children.length.should == 3
|
141
|
-
j2000.children[0].should be_a(Tengine::Job::Start)
|
142
|
-
j2000.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "j2100"}
|
143
|
-
j2000.children[2].should be_a(Tengine::Job::End)
|
144
|
-
j2000.edges.length.should == 2
|
145
|
-
j2000.edges[0].tap{|edge| edge.origin.should == j2000.children[0]; edge.destination.should == j2000.children[1]}
|
146
|
-
j2000.edges[1].tap{|edge| edge.origin.should == j2000.children[1]; edge.destination.should == j2000.children[2]}
|
147
|
-
end
|
148
|
-
root.children[3].tap do |jf000|
|
149
|
-
jf000.children.length.should == 3
|
150
|
-
jf000.children[0].should be_a(Tengine::Job::Start)
|
151
|
-
jf000.children[1].tap{|j| j.should be_a(Tengine::Job::JobnetActual); j.name.should == "jf100"}
|
152
|
-
jf000.children[2].should be_a(Tengine::Job::End)
|
153
|
-
jf000.edges.length.should == 2
|
154
|
-
jf000.edges[0].tap{|edge| edge.origin.should == jf000.children[0]; edge.destination.should == jf000.children[1]}
|
155
|
-
jf000.edges[1].tap{|edge| edge.origin.should == jf000.children[1]; edge.destination.should == jf000.children[2]}
|
156
|
-
end
|
157
|
-
root.template.id.should == @jobnet.id
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
161
|
-
|
162
|
-
end
|
163
|
-
|
164
|
-
describe :execute do
|
165
|
-
|
166
|
-
before do
|
167
|
-
Tengine::Job::Vertex.delete_all
|
168
|
-
builder = Rjn0001SimpleJobnetBuilder.new
|
169
|
-
@jobnet = builder.create_template
|
170
|
-
@ctx = builder.context
|
171
|
-
@execution = Tengine::Job::Execution.create!({
|
172
|
-
:root_jobnet_id => @jobnet.id,
|
173
|
-
})
|
174
|
-
end
|
175
|
-
|
176
|
-
it "create Execution" do
|
177
|
-
mock_sender = mock(:sender)
|
178
|
-
mock_sender.should_receive(:fire)
|
179
|
-
execution = @jobnet.execute(:sender => mock_sender)
|
180
|
-
execution.should be_a(Tengine::Job::Execution)
|
181
|
-
root_jobnet_actual = execution.root_jobnet
|
182
|
-
root_jobnet_actual.should be_a(Tengine::Job::RootJobnetActual)
|
183
|
-
root_jobnet_actual.template.id.should == @jobnet.id
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
describe "名前で検索" do
|
190
|
-
before do
|
191
|
-
Tengine::Core::Setting.delete_all
|
192
|
-
Tengine::Core::Setting.create!(:name => "dsl_version", :value => "2")
|
193
|
-
Tengine::Job::RootJobnetTemplate.delete_all
|
194
|
-
Rjn0001SimpleJobnetBuilder.new.create_template(:dsl_version => "1")
|
195
|
-
Rjn0002SimpleParallelJobnetBuilder.new.create_template(:dsl_version => "2")
|
196
|
-
end
|
197
|
-
|
198
|
-
[:find_by_name, :find_by_name!].each do |method_name|
|
199
|
-
context "#{method_name}は見つかった場合はそれを返す" do
|
200
|
-
it "バージョン指定なし" do
|
201
|
-
template = Tengine::Job::RootJobnetTemplate.send(method_name, "rjn0002")
|
202
|
-
template.should be_a(Tengine::Job::RootJobnetTemplate)
|
203
|
-
template.name.should == "rjn0002"
|
204
|
-
template.dsl_version.should == "2"
|
205
|
-
end
|
206
|
-
|
207
|
-
it "バージョン指定あり" do
|
208
|
-
template = Tengine::Job::RootJobnetTemplate.send(method_name, "rjn0001", :version => "1")
|
209
|
-
template.should be_a(Tengine::Job::RootJobnetTemplate)
|
210
|
-
template.name.should == "rjn0001"
|
211
|
-
template.dsl_version.should == "1"
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context ":find_by_nameは見つからなかった場合はnilを返す" do
|
217
|
-
it "バージョン指定なし" do
|
218
|
-
Tengine::Job::RootJobnetTemplate.find_by_name("rjn0001").should == nil
|
219
|
-
end
|
220
|
-
|
221
|
-
it "バージョン指定あり" do
|
222
|
-
Tengine::Job::RootJobnetTemplate.find_by_name("rjn0002", :version => "1").should == nil
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
context ":find_by_name!は見つからなかった場合はTengine::Errors::NotFoundをraiseする" do
|
227
|
-
it "バージョン指定なし" do
|
228
|
-
begin
|
229
|
-
Tengine::Job::RootJobnetTemplate.find_by_name!("rjn0001")
|
230
|
-
fail
|
231
|
-
rescue Tengine::Errors::NotFound => e
|
232
|
-
e.message.should == "Tengine::Job::RootJobnetTemplate named \"rjn0001\" not found"
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
it "バージョン指定あり" do
|
237
|
-
begin
|
238
|
-
Tengine::Job::RootJobnetTemplate.find_by_name!("rjn0002", :version => "1")
|
239
|
-
fail
|
240
|
-
rescue Tengine::Errors::NotFound => e
|
241
|
-
e.message.should == "Tengine::Job::RootJobnetTemplate named \"rjn0002\" with {:version=>\"1\"} not found"
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'erb'
|
4
|
-
require 'etc'
|
5
|
-
require 'tempfile'
|
6
|
-
|
7
|
-
describe Tengine::Job::ScriptExecutable do
|
8
|
-
describe :execute do
|
9
|
-
let :ssh_dir do
|
10
|
-
File.expand_path("../../../sshd", __FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
before :all do
|
14
|
-
# 1. sshdをさがす
|
15
|
-
sshd = nil
|
16
|
-
ENV["PATH"].split(/:/).find do |dir|
|
17
|
-
Dir.glob("#{dir}/sshd") do |path|
|
18
|
-
if File.executable?(path)
|
19
|
-
sshd = path
|
20
|
-
break
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
raise "sshd not found" unless sshd
|
26
|
-
|
27
|
-
# 2. sshd_configの生成
|
28
|
-
template = File.expand_path("sshd_config.erb", ssh_dir)
|
29
|
-
hostkey = File.expand_path("ssh_host_rsa_key", ssh_dir)
|
30
|
-
clientkey = File.expand_path("id_rsa", ssh_dir)
|
31
|
-
File.chmod(0400, hostkey, clientkey)
|
32
|
-
File.chmod(0700, ssh_dir)
|
33
|
-
@port = nil
|
34
|
-
|
35
|
-
# 指定したポートはもう使われているかもしれないので、その際は
|
36
|
-
# sshdが起動に失敗するので、何回かポートを変えて試す。
|
37
|
-
n = 0
|
38
|
-
begin
|
39
|
-
@port = rand(32768)
|
40
|
-
Tempfile.open("sshd_config", ssh_dir) do |conf|
|
41
|
-
File.open(template, "rb") do |tmpl|
|
42
|
-
conf.write ERB.new(tmpl.read).result(binding)
|
43
|
-
end
|
44
|
-
conf.flush
|
45
|
-
conf.close(false) # no unlink
|
46
|
-
argv = [sshd, "-Def", conf.path, "-h", hostkey]
|
47
|
-
@pid = Process.spawn(*argv)
|
48
|
-
sleep 1 # まあこんくらい待てばいいでしょ
|
49
|
-
Process.waitpid2(@pid, Process::WNOHANG)
|
50
|
-
end
|
51
|
-
rescue Errno::ECHILD
|
52
|
-
raise "10 attempt to invoke sshd failed." if (n += 1) > 10
|
53
|
-
retry
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
after :all do
|
58
|
-
if @pid
|
59
|
-
begin
|
60
|
-
Process.kill "INT", @pid
|
61
|
-
Process.waitpid @pid
|
62
|
-
rescue Errno::ECHILD
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
before do
|
68
|
-
uid = Etc.getlogin
|
69
|
-
case uid
|
70
|
-
when "root"
|
71
|
-
pending "rootは危険なのでこのテストを実行できません"
|
72
|
-
when NilClass
|
73
|
-
raise "who am i?"
|
74
|
-
end
|
75
|
-
@credential = Tengine::Resource::Credential.find_or_create_by_name!(
|
76
|
-
:name => uid,
|
77
|
-
:description => "myself",
|
78
|
-
:auth_type_cd => :ssh_public_key,
|
79
|
-
:auth_values => {
|
80
|
-
:username => uid,
|
81
|
-
:private_keys => [
|
82
|
-
File.binread(Dir[File.expand_path("id_rsa", ssh_dir)].first),
|
83
|
-
],
|
84
|
-
:passphrase => "",
|
85
|
-
}
|
86
|
-
)
|
87
|
-
puts @port.inspect
|
88
|
-
@server = Tengine::Resource::Server.find_or_create_by_name!(
|
89
|
-
:name => "localhost",
|
90
|
-
:description => "localhost",
|
91
|
-
:provided_id => "localhost",
|
92
|
-
:properties => {
|
93
|
-
:ssh_port => @port,
|
94
|
-
},
|
95
|
-
:addressed => {
|
96
|
-
:dns_name => "localhost",
|
97
|
-
:ip_address => "localhost",
|
98
|
-
:private_dns_name => "localhost",
|
99
|
-
:private_ip_address => "localhost",
|
100
|
-
},
|
101
|
-
)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "終了コードを取得できる" do
|
105
|
-
j = Tengine::Job::JobnetActual.new(
|
106
|
-
:server_name => @server.name,
|
107
|
-
:credential_name => @credential.name,
|
108
|
-
:script => File.expand_path("tengine_job_test.sh", ssh_dir)
|
109
|
-
)
|
110
|
-
j.execute(j.script)
|
111
|
-
end
|
112
|
-
|
113
|
-
# it "終了コードを取得できる" do
|
114
|
-
# Tengine::Job::ScriptActual.new(:name => "echo_foo",
|
115
|
-
# :script => "/Users/goku/tengine/echo_foo.sh"
|
116
|
-
# )
|
117
|
-
# end
|
118
|
-
|
119
|
-
it "https://www.pivotaltracker.com/story/show/22269461" do
|
120
|
-
j = Tengine::Job::JobnetActual.new(
|
121
|
-
:server_name => @server.name,
|
122
|
-
:credential_name => @credential.name,
|
123
|
-
:script => "echo \u{65e5}\u{672c}\u{8a9e}"
|
124
|
-
)
|
125
|
-
str = ''
|
126
|
-
j.execute(j.script) do |ch, data|
|
127
|
-
str << data
|
128
|
-
end
|
129
|
-
str.force_encoding('UTF-8').should be_valid_encoding
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|