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.
Files changed (97) hide show
  1. data/Gemfile +1 -20
  2. data/Gemfile.lock +70 -72
  3. data/README.rdoc +2 -2
  4. data/bin/create_indexes_for_tengine_job +18 -0
  5. data/lib/tengine/job/connectable.rb +4 -4
  6. data/lib/tengine/job/drivers/job_execution_driver.rb +2 -2
  7. data/lib/tengine/job/drivers/jobnet_control_driver.rb +3 -3
  8. data/lib/tengine/job/drivers/schedule_driver.rb +12 -12
  9. data/lib/tengine/job/edge.rb +2 -2
  10. data/lib/tengine/job/expansion.rb +1 -1
  11. data/lib/tengine/job/jobnet.rb +12 -2
  12. data/lib/tengine/job/jobnet_actual.rb +29 -0
  13. data/lib/tengine/job/root_jobnet_actual.rb +20 -1
  14. data/lib/tengine/job/root_jobnet_template.rb +4 -4
  15. data/lib/tengine/job/signal.rb +1 -1
  16. data/lib/tengine/job/vertex.rb +10 -1
  17. metadata +130 -126
  18. data/.document +0 -5
  19. data/.rspec +0 -1
  20. data/Rakefile +0 -42
  21. data/VERSION +0 -1
  22. data/spec/fixtures/rjn_0001_simple_jobnet_builder.rb +0 -42
  23. data/spec/fixtures/rjn_0002_simple_parallel_jobnet_builder.rb +0 -42
  24. data/spec/fixtures/rjn_0003_fork_join_jobnet_builder.rb +0 -61
  25. data/spec/fixtures/rjn_0004_parallel_jobnet_with_finally_fixture.rb +0 -62
  26. data/spec/fixtures/rjn_0005_retry_two_layer_fixture.rb +0 -153
  27. data/spec/fixtures/rjn_0008_expansion_fixture.rb +0 -32
  28. data/spec/fixtures/rjn_0009_tree_sequential_jobnet_builder.rb +0 -174
  29. data/spec/fixtures/rjn_0010_2jobs_and_1job_parallel_jobnet_builder.rb +0 -39
  30. data/spec/fixtures/rjn_0011_nested_fork_jobnet_builder.rb +0 -96
  31. data/spec/fixtures/rjn_0012_nested_and_finally_builder.rb +0 -157
  32. data/spec/fixtures/rjn_1004_hadoop_job_in_jobnet_fixture.rb +0 -105
  33. data/spec/fixtures/rjn_means_root_jobnet +0 -0
  34. data/spec/fixtures/test_credential_fixture.rb +0 -12
  35. data/spec/fixtures/test_server_fixture.rb +0 -28
  36. data/spec/mongoid.yml +0 -35
  37. data/spec/spec_helper.rb +0 -58
  38. data/spec/sshd/.gitignore +0 -1
  39. data/spec/sshd/id_rsa +0 -51
  40. data/spec/sshd/id_rsa.pub +0 -1
  41. data/spec/sshd/ssh_host_rsa_key +0 -51
  42. data/spec/sshd/ssh_host_rsa_key.pub +0 -1
  43. data/spec/sshd/sshd_config +0 -10
  44. data/spec/sshd/sshd_config.erb +0 -11
  45. data/spec/sshd/tengine_job_test.sh +0 -6
  46. data/spec/support/jobnet_fixture_builder.rb +0 -145
  47. data/spec/support/mongo_index_key_log.rb +0 -91
  48. data/spec/tengine/job/category_spec.rb +0 -193
  49. data/spec/tengine/job/connectable_spec.rb +0 -94
  50. data/spec/tengine/job/drivers/job_controll_driver/connection_error_spec.rb +0 -236
  51. data/spec/tengine/job/drivers/job_controll_driver/duplicated_job_start_spec.rb +0 -302
  52. data/spec/tengine/job/drivers/job_controll_driver/expansion_spec.rb +0 -120
  53. data/spec/tengine/job/drivers/job_controll_driver/stop_spec.rb +0 -159
  54. data/spec/tengine/job/drivers/job_controll_driver_spec.rb +0 -740
  55. data/spec/tengine/job/drivers/job_execution_driver_spec.rb +0 -138
  56. data/spec/tengine/job/drivers/jobnet_control_driver/nested_and_finally_spec.rb +0 -472
  57. data/spec/tengine/job/drivers/jobnet_control_driver/nested_jobnet_spec.rb +0 -231
  58. data/spec/tengine/job/drivers/jobnet_control_driver/stop_jobnet_spec.rb +0 -202
  59. data/spec/tengine/job/drivers/jobnet_control_driver_spec.rb +0 -608
  60. data/spec/tengine/job/drivers/schedule_driver_spec.rb +0 -241
  61. data/spec/tengine/job/dsl_binder_spec.rb +0 -36
  62. data/spec/tengine/job/dsl_loader_spec.rb +0 -437
  63. data/spec/tengine/job/dsls/0013_hadoop_job_run.rb +0 -29
  64. data/spec/tengine/job/dsls/0014_join_and_join.rb +0 -19
  65. data/spec/tengine/job/dsls/0015_fork_and_fork.rb +0 -18
  66. data/spec/tengine/job/dsls/0016_complex_fork_and_join.rb +0 -20
  67. data/spec/tengine/job/dsls/0017_finally.rb +0 -15
  68. data/spec/tengine/job/dsls/0018_expansion.rb +0 -23
  69. data/spec/tengine/job/dsls/0019_execute_job_on_event.rb +0 -16
  70. data/spec/tengine/job/dsls/0020_duplicated_jobnet_name.rb +0 -16
  71. data/spec/tengine/job/dsls/0021_caption.rb +0 -13
  72. data/spec/tengine/job/dsls/1060_test_dir1/1060_test_dir2/0013_hadoop_job_run.rb +0 -29
  73. data/spec/tengine/job/dsls/2003_expansion/expansion_5.rb +0 -11
  74. data/spec/tengine/job/dsls/VERSION +0 -1
  75. data/spec/tengine/job/dynamic_env_spec.rb +0 -95
  76. data/spec/tengine/job/edge_spec.rb +0 -241
  77. data/spec/tengine/job/element_selector_notation_spec.rb +0 -354
  78. data/spec/tengine/job/examples_spec.rb +0 -62
  79. data/spec/tengine/job/execution_spec.rb +0 -100
  80. data/spec/tengine/job/expansion_spec.rb +0 -116
  81. data/spec/tengine/job/hadoop_job_run_spec.rb +0 -65
  82. data/spec/tengine/job/job_spec.rb +0 -4
  83. data/spec/tengine/job/jobnet/1015_complecated_jobnet_spec.rb +0 -72
  84. data/spec/tengine/job/jobnet_actual_spec.rb +0 -175
  85. data/spec/tengine/job/jobnet_spec.rb +0 -399
  86. data/spec/tengine/job/jobnet_template_spec.rb +0 -240
  87. data/spec/tengine/job/killing_spec.rb +0 -91
  88. data/spec/tengine/job/reset_spec.rb +0 -958
  89. data/spec/tengine/job/reset_spec/4056_1_dump.txt +0 -1
  90. data/spec/tengine/job/root_jobnet_actual_spec.rb +0 -89
  91. data/spec/tengine/job/root_jobnet_template_spec.rb +0 -248
  92. data/spec/tengine/job/script_executable_spec.rb +0 -132
  93. data/spec/tengine/job/stoppable_spec.rb +0 -176
  94. data/spec/tengine/job/vertex_spec.rb +0 -25
  95. data/spec/tengine_job_spec.rb +0 -4
  96. data/tengine_job.gemspec +0 -198
  97. data/tmp/log/.gitignore +0 -1
@@ -1,29 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # [jobnet0013]
6
- # start --- job1 --- [hadoop_job_run1] --- job2 --- end
7
- #
8
- # [hadoop_job_run1]
9
- # start --- [hadoop_job1] --- [hadoop_job2] --- end
10
- #
11
- # [hadoop_job1]
12
- # |--- map ------|
13
- # start ---F J--- end
14
- # |--- reduce ---|
15
- #
16
- # [hadoop_job2]
17
- # |--- map ------|
18
- # start ---F J--- end
19
- # |--- reduce ---|
20
- #
21
- jobnet("jobnet0013", "ジョブネット0013", :vm_instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
22
- auto_sequence
23
- job("job1", "ジョブ1", "import_hdfs.sh")
24
- hadoop_job_run("hadoop_job_run1", "Hadoopジョブ1", "hadoop_job_run.sh") do
25
- hadoop_job("hadoop_job1")
26
- hadoop_job("hadoop_job2")
27
- end
28
- job("job2", "ジョブ2", "export_hdfs.sh")
29
- end
@@ -1,19 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # [jobnet0014]
6
- # |--- job1 ---|
7
- # | J--- job4 ---|
8
- # start ---F--- job2 ---| |
9
- # | J--- job5 --- end
10
- # |--- job3 ----------------|
11
- #
12
- jobnet("jobnet0014", :instance_name => "i-11111111", :user_group_credential_name => "goku-ssh-pk1") do
13
- boot_jobs("job1", "job2", "job3")
14
- job("job1", "echo 'job1'", :to => "job4")
15
- job("job2", "echo 'job2'", :to => "job4")
16
- job("job3", "echo 'job3'", :to => "job5")
17
- job("job4", "echo 'job4'", :to => "job5")
18
- job("job5", "echo 'job5'")
19
- end
@@ -1,18 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # [jobnet0015]
6
- # |--- job2--------------------|
7
- # | |
8
- # start --- job1 ---F |--- job4 --- J--- end
9
- # |--- job3 ---- F |
10
- # |--- job5 ----|
11
- jobnet("jobnet0015", :instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
12
- boot_jobs("job1")
13
- job("job1", "echo 'job1'", :to => ["job2", "job3"])
14
- job("job2", "echo 'job2'")
15
- job("job3", "echo 'job3'", :to => ["job4", "job5"])
16
- job("job4", "echo 'job4'")
17
- job("job5", "echo 'job5'")
18
- end
@@ -1,20 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # [jobnet0016]
6
- # |--- job4 --- job5 ---|
7
- # |--- job1 --- job3 ---F |
8
- # start ---F |=== J --- job6 ----- J--- end
9
- # |--- job2 ------------F |
10
- # |--------- job7 ------|
11
- jobnet("jobnet0016", :instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
12
- boot_jobs("job1", "job2")
13
- job("job1", "echo 'job1'", :to => ["job3"])
14
- job("job2", "echo 'job2'", :to => ["job6", "job7"])
15
- job("job3", "echo 'job3'", :to => ["job4", "job6"])
16
- job("job4", "echo 'job4'", :to => "job5")
17
- job("job5", "echo 'job5'")
18
- job("job6", "echo 'job6'")
19
- job("job7", "echo 'job7'")
20
- end
@@ -1,15 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- jobnet("jobnet0017", "ジョブネット0017", :instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
6
- auto_sequence
7
- job("job1", "ジョブ1", "job1.sh")
8
- job("job2", "ジョブ2", "job2.sh")
9
- job("job3", "ジョブ3", "job3.sh")
10
- finally do
11
- auto_sequence
12
- job("finally_job1", "finallyジョブ1", "finally_job1.sh")
13
- job("finally_job2", "finallyジョブ2", "finally_job2.sh")
14
- end
15
- end
@@ -1,23 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- jobnet("jobnet0018_01") do
6
- boot_jobs("job101", "job102", "job103")
7
- job("job101", "echo 'success101'")
8
- job("job102", "echo 'success102'")
9
- job("job103", "echo 'success103'")
10
- end
11
-
12
- jobnet("jobnet0018_02") do
13
- auto_sequence
14
- job("job101", "echo 'success101'")
15
- job("job102", "echo 'success102'")
16
- job("job103", "echo 'success103'")
17
- end
18
-
19
- jobnet("jobnet0018") do
20
- auto_sequence
21
- expansion("jobnet0018_01")
22
- expansion("jobnet0018_02")
23
- end
@@ -1,16 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- jobnet("jobnet0019") do
6
- auto_sequence
7
- job("j11", "tengine_job_test 5 j11'")
8
- job("j12", "tengine_job_test 5 j12'")
9
- job("j13", "tengine_job_test 5 j13'")
10
- end
11
-
12
- driver :driver_for_jobnet_0019 do
13
- on :foo do
14
- jobnet("jobnet0019").execute(:sender => self)
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # 同じジョブネット名を2回指定しています
6
- jobnet("jobnet0020", :instance_name => "test_server1", :credential_name => "test_credential1") do
7
- auto_sequence
8
- job("job1", "$HOME/tengine_job_test.sh 0 job1")
9
- job("job2", "$HOME/tengine_job_test.sh 0 job2")
10
- end
11
-
12
- jobnet("jobnet0020", :instance_name => "test_server1", :credential_name => "test_credential1") do
13
- auto_sequence
14
- job("job3", "$HOME/tengine_job_test.sh 0 job3")
15
- job("job4", "$HOME/tengine_job_test.sh 0 job4")
16
- end
@@ -1,13 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- jobnet("jobnet0021", :caption => "ジョブネット0021", :instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
6
- auto_sequence
7
- job("job1", "ジョブ1", "job1.sh")
8
- job("job2", "job2.sh", :description => "ジョブ2")
9
- job("job3", "job3.sh", :caption => "ジョブ3")
10
- hadoop_job_run("hadoop_job_run4", "hadoop_job_run4.sh", :caption => "Hadoopジョブ4") do
11
- hadoop_job("hadoop_job")
12
- end
13
- end
@@ -1,29 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- # [jobnet0013]
6
- # start --- job1 --- [hadoop_job_run1] --- job2 --- end
7
- #
8
- # [hadoop_job_run1]
9
- # start --- [hadoop_job1] --- [hadoop_job2] --- end
10
- #
11
- # [hadoop_job1]
12
- # |--- map ------|
13
- # start ---F J--- end
14
- # |--- reduce ---|
15
- #
16
- # [hadoop_job2]
17
- # |--- map ------|
18
- # start ---F J--- end
19
- # |--- reduce ---|
20
- #
21
- jobnet("jobnet0013", "ジョブネット0013", :vm_instance_name => "i-11111111", :credential_name => "goku-ssh-pk1") do
22
- auto_sequence
23
- job("job1", "ジョブ1", "import_hdfs.sh")
24
- hadoop_job_run("hadoop_job_run1", "Hadoopジョブ1", "hadoop_job_run.sh") do
25
- hadoop_job("hadoop_job1")
26
- hadoop_job("hadoop_job2")
27
- end
28
- job("job2", "ジョブ2", "export_hdfs.sh")
29
- end
@@ -1,11 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'tengine_job'
4
-
5
- jobnet('job_reference_test_6_2', '機能テスト6-2', :vm_instance_name => "test_server1", :credential_name => "test_credential1") do
6
- boot_jobs('job6-2-1')
7
- job('job6-2-1', '~/mm_server/spec/models/job/mm_job.sh 30 job_function_test_6-2-1', :to => ['job6-2-2', 'job6-2-3'])
8
- job('job6-2-2', '~/mm_server/spec/models/job/mm_job.sh 30 job_function_test_6-2-2', :to => 'job6-2-4')
9
- job('job6-2-3', '~/mm_server/spec/models/job/mm_job.sh 30 job_function_test_6-2-3', :to => 'job6-2-4')
10
- job('job6-2-4', '~/mm_server/spec/models/job/mm_job.sh 30 job_function_test_6-2-4', :to => 'job6-2-3')
11
- end
@@ -1 +0,0 @@
1
- 20111003160000
@@ -1,95 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe 'hadoop_job_run' do
5
- before(:all) do
6
- Tengine.plugins.add(Tengine::Job::DslLoader)
7
- end
8
-
9
- def load_dsl(filename)
10
- config = {
11
- :action => "load",
12
- :tengined => { :load_path => File.expand_path("../../../examples/#{filename}", File.dirname(__FILE__)) },
13
- }
14
- @version = File.read(File.expand_path("../../../examples/VERSION", File.dirname(__FILE__))).strip
15
- @bootstrap = Tengine::Core::Bootstrap.new(config)
16
- @bootstrap.boot
17
- Tengine::Core::Setting.stub(:dsl_version).and_return(@version)
18
- end
19
-
20
- describe "基本的なジョブDSL" do
21
- context "0021_dynamic_env.rb" do
22
- before do
23
- Tengine::Job::JobnetTemplate.delete_all
24
- Tengine::Resource::PhysicalServer.delete_all
25
- TestServerFixture.test_server1
26
- TestCredentialFixture.test_credential1
27
- load_dsl("0021_dynamic_env.rb")
28
- end
29
-
30
- shared_examples_for "実行時に環境変数を設定できる" do
31
- it "j1" do
32
- mock_event = mock(:event)
33
- signal = Tengine::Job::Signal.new(mock_event)
34
- mock_ssh = mock(:ssh)
35
- Net::SSH.should_receive(:start).and_yield(mock_ssh)
36
- mock_channel = mock(:channel)
37
- mock_ssh.should_receive(:open_channel).and_yield(mock_channel)
38
- mock_channel.should_receive(:exec).with(an_instance_of(String)) do |cmd|
39
- cmd.should =~ /export FOO=BAR/
40
- end
41
- @root.element("j1").run(@execution)
42
- end
43
-
44
- it "j2" do
45
- mock_event = mock(:event)
46
- signal = Tengine::Job::Signal.new(mock_event)
47
- mock_ssh = mock(:ssh)
48
- Net::SSH.should_receive(:start).and_yield(mock_ssh)
49
- mock_channel = mock(:channel)
50
- mock_ssh.should_receive(:open_channel).and_yield(mock_channel)
51
- mock_channel.should_receive(:exec).with(an_instance_of(String)) do |cmd|
52
- cmd.should =~ /export SERVER_NAME=test_server1 && export DNS_NAME=localhost/
53
- end
54
- @root.element("j2").run(@execution)
55
- end
56
- end
57
-
58
- context "rjn0021_1" do
59
- before do
60
- @template = Tengine::Job::RootJobnetTemplate.find_by_name!("rjn0021_1")
61
- mock_sender = mock(:sender)
62
- mock_sender.should_receive(:fire).with(any_args)
63
- @execution = @template.execute(:sender => mock_sender)
64
- @root = @execution.root_jobnet
65
- end
66
- it_should_behave_like "実行時に環境変数を設定できる"
67
- end
68
-
69
- context "/rjn0021/rjn0021_1" do
70
- before do
71
- @template = Tengine::Job::RootJobnetTemplate.find_by_name!("rjn0021")
72
- mock_sender = mock(:sender)
73
- mock_sender.should_receive(:fire).with(any_args)
74
- @execution = @template.execute(:sender => mock_sender)
75
- @root = @execution.root_jobnet.vertex_by_name_path("/rjn0021/rjn0021_1")
76
- end
77
- it_should_behave_like "実行時に環境変数を設定できる"
78
- end
79
-
80
- context "/rjn0021/rjn0021_2" do
81
- before do
82
- @template = Tengine::Job::RootJobnetTemplate.find_by_name!("rjn0021")
83
- mock_sender = mock(:sender)
84
- mock_sender.should_receive(:fire).with(any_args)
85
- @execution = @template.execute(:sender => mock_sender)
86
- @root = @execution.root_jobnet.vertex_by_name_path("/rjn0021/rjn0021_2")
87
- end
88
- it_should_behave_like "実行時に環境変数を設定できる"
89
- end
90
-
91
- end
92
-
93
- end
94
-
95
- end
@@ -1,241 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Tengine::Job::Edge do
5
- before do
6
- @now = Time.now.utc
7
- @event = mock(:event, :occurred_at => @now)
8
- @execution = mock(:execution,
9
- :id => "execution_id",
10
- :estimated_time => 600,
11
- :actual_estimated_end => Time.utc(2011,10,27,19,8),
12
- :preparation_command => nil)
13
- @execution.stub!(:retry).and_return(false) # 再実行ではないという設定
14
- @execution.stub!(:in_scope?).with(any_args).and_return(true)
15
- @signal = Tengine::Job::Signal.new(@event)
16
- @signal.stub!(:execution).and_return(@execution)
17
- end
18
-
19
- describe :transmit do
20
- context "シンプルなケース" do
21
- # in [rjn0001]
22
- # (S1) --e1-->(j11)--e2-->(j12)--e3-->(E1)
23
- before do
24
- builder = Rjn0001SimpleJobnetBuilder.new
25
- builder.create_actual
26
- @ctx = builder.context
27
- end
28
-
29
- it "e1をtransmitするとtransmitting、j11はactivateされてreadyになり、イベントが通知されるのを待つ" do
30
- @ctx[:e1].phase_key = :active
31
- @ctx[:j11].phase_key = :initialized
32
- @ctx[:root].save!
33
- @ctx[:e1].transmit(@signal)
34
- @ctx[:e1].phase_key.should == :transmitting
35
- @ctx[:j11].phase_key.should == :ready
36
- @signal.reservations.length.should == 1
37
- reservation = @signal.reservations.first
38
- reservation.event_type_name.should == :"start.job.job.tengine"
39
- reservation.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
40
- reservation.options[:properties][:target_job_id].should == @ctx[:j11].id.to_s
41
- reservation.options[:source_name].should =~ %r<^job:.+/\d+/#{@ctx[:root].id.to_s}/#{@ctx[:j11].id.to_s}$>
42
- end
43
-
44
- it "j11がactivateされると、e1はcompleteされてtransmittedになり、j11はstartingになる" do
45
- @ctx[:root].phase_key = :starting
46
- @ctx[:e1].phase_key = :transmitting
47
- @ctx[:j11].phase_key = :ready
48
- @ctx[:root].save!
49
- @ctx[:j11].should_receive(:execute)
50
- @execution.should_receive(:signal=).with(@signal)
51
- @execution.stub(:retry).and_return(false)
52
- @ctx[:j11].activate(@signal)
53
- @signal.callback.should_not be_nil
54
- @signal.callback.call # 2回に分けてphaseを更新するのでcallbackすることを期待しています
55
- @ctx[:e1].phase_key.should == :transmitted
56
- @ctx[:j11].phase_key.should == :starting
57
- @signal.reservations.length.should == 0
58
- end
59
- end
60
-
61
- context "分岐するケース" do
62
- # in [rjn0002]
63
- # |--e2-->(j11)--e4-->|
64
- # (S1)--e1-->[F1] [J1]--e6-->(E1)
65
- # |--e3-->(j12)--e5-->|
66
- before do
67
- builder = Rjn0002SimpleParallelJobnetBuilder.new
68
- builder.create_actual
69
- @ctx = builder.context
70
- end
71
-
72
- it "e1をtransmitするとe1はtransmitted,e2とe3はtransmittingでj11とj12はreadyになる" do
73
- [:e1, :e2, :e3].each{|name| @ctx[name].phase_key = :active}
74
- @ctx[:j11].phase_key = :initialized
75
- @ctx[:j12].phase_key = :initialized
76
- @ctx[:root].save!
77
- @ctx[:e1].transmit(@signal)
78
- @ctx[:root].save!
79
- @ctx[:root].reload
80
- @ctx.edge(:e1).phase_key.should == :transmitted
81
- @ctx.edge(:e2).phase_key.should == :transmitting
82
- @ctx.edge(:e3).phase_key.should == :transmitting
83
- @ctx.vertex(:j11).phase_key.should == :ready
84
- @ctx.vertex(:j12).phase_key.should == :ready
85
- @signal.reservations.length.should == 2
86
- @signal.reservations.first.tap do |r|
87
- r.event_type_name.should == :"start.job.job.tengine"
88
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
89
- r.options[:properties][:target_job_id].should == @ctx[:j11].id.to_s
90
- r.options[:source_name].should =~ %r<^job:.+/\d+/#{@ctx[:root].id.to_s}/#{@ctx[:j11].id.to_s}$>
91
- end
92
- @signal.reservations.last.tap do |r|
93
- r.event_type_name.should == :"start.job.job.tengine"
94
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
95
- r.options[:properties][:target_job_id].should == @ctx[:j12].id.to_s
96
- r.options[:source_name].should =~ %r<^job:.+/\d+/#{@ctx[:root].id.to_s}/#{@ctx[:j12].id.to_s}$>
97
- end
98
- end
99
-
100
- it "e4をtransmitするとtransmittedになるけどe6は変わらず" do
101
- [:e4, :e5, :e6].each{|name| @ctx[name].phase_key = :active}
102
- @ctx[:root].save!
103
- @ctx[:e4].transmit(@signal)
104
- @ctx[:root].save!
105
- @ctx[:root].reload
106
- @ctx[:e4].phase_key.should == :transmitted
107
- @ctx[:e5].phase_key.should == :active
108
- @ctx[:e6].phase_key.should == :active
109
- @signal.reservations.should be_empty
110
- end
111
-
112
- it "e4をtransmitした後、e5をtransmitするとe6もtransmittedになる" do
113
- @ctx[:root].phase_key = :running
114
- @ctx[:e4].phase_key = :transmitted
115
- @ctx[:e5].phase_key = :active
116
- @ctx[:e6].phase_key = :active
117
- @ctx[:root].save!
118
- @ctx[:e5].transmit(@signal)
119
- @ctx[:root].save!
120
- @ctx[:root].reload
121
- @ctx.edge(:e4).phase_key.should == :transmitted
122
- @ctx.edge(:e5).phase_key.should == :transmitted
123
- @ctx.edge(:e6).phase_key.should == :transmitted
124
- @ctx.vertex(:J1).activatable?.should == true
125
- @signal.reservations.first.tap do |r|
126
- r.event_type_name.should == :"success.jobnet.job.tengine"
127
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
128
- end
129
- end
130
- end
131
-
132
- context "forkとjoinが直接組み合わされるケース" do
133
- # in [rjn0003]
134
- # |--e7-->(j14)--e11-->(j16)--e14--->|
135
- # |--e2-->(j11)--e4-->(j13)--e6-->[F2] |
136
- # (S1)--e1-->[F1] |--e8-->[J1]--e12-->(j17)--e15-->[J2]--e16-->(E2)
137
- # | |--e9-->[J1] |
138
- # |--e3-->(j12)------e5---------->[F3] |
139
- # |--e10---->(j15)---e13------------>|
140
- before do
141
- builder = Rjn0003ForkJoinJobnetBuilder.new
142
- builder.create_actual
143
- @ctx = builder.context
144
- end
145
-
146
- it "e6.transmitしてもe12には伝搬しない" do
147
- [:e5, :e6, :e7, :e8, :e9, :e10, :e12].each{|name| @ctx[name].phase_key = :active}
148
- [:j14, :j15, :j17].each{|name| @ctx[name].phase_key = :initialized}
149
- @ctx[:root].save!
150
- @ctx[:e6].transmit(@signal)
151
- @ctx[:e6].phase_key.should == :transmitted
152
- @ctx[:e7].phase_key.should == :transmitting
153
- @ctx[:e8].phase_key.should == :transmitted
154
- @ctx[:e12].phase_key.should == :active
155
- @ctx[:j14].phase_key.should == :ready
156
- @signal.reservations.length.should == 1
157
- @signal.reservations.first.tap do |r|
158
- r.event_type_name.should == :"start.job.job.tengine"
159
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
160
- r.options[:properties][:target_job_id].should == @ctx[:j14].id.to_s
161
- r.options[:source_name].should =~ %r<^job:.+/\d+/#{@ctx[:root].id.to_s}/#{@ctx[:j14].id.to_s}$>
162
- end
163
- end
164
-
165
- it "e5とe6の両方をtransmitするとe12に伝搬する" do
166
- [:e5, :e9, :e10, :e12].each{|name| @ctx[name].phase_key = :active}
167
- @ctx[:e6].phase_key = :transmitted
168
- @ctx[:e7].phase_key = :transmitting
169
- @ctx[:e8].phase_key = :transmitted
170
- [:j14].each{|name| @ctx[name].phase_key = :ready}
171
- [:j15, :j17].each{|name| @ctx[name].phase_key = :initialized}
172
- @ctx[:root].save!
173
- @signal.reservations.clear
174
- @ctx[:e5].transmit(@signal)
175
- @ctx[:e6].phase_key.should == :transmitted
176
- @ctx[:e7].phase_key.should == :transmitting
177
- @ctx[:e8].phase_key.should == :transmitted
178
- @ctx[:e9].phase_key.should == :transmitted
179
- @ctx[:e10].phase_key.should == :transmitting
180
- @ctx[:e12].phase_key.should == :transmitting
181
- @signal.reservations.length.should == 2
182
- @signal.reservations.first.tap do |r|
183
- r.event_type_name.should == :"start.job.job.tengine"
184
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
185
- r.options[:properties][:target_job_id].should == @ctx[:j17].id.to_s
186
- end
187
- @signal.reservations.last.tap do |r|
188
- r.event_type_name.should == :"start.job.job.tengine"
189
- r.options[:properties][:target_jobnet_id].should == @ctx[:root].id.to_s
190
- r.options[:properties][:target_job_id].should == @ctx[:j15].id.to_s
191
- end
192
- end
193
-
194
- end
195
-
196
- end
197
-
198
- context "<BUG>再実行したジョブが準備中のままになってしまう" do
199
- # in [jn0004]
200
- # |--e3-->(j2)--e5-->|
201
- # (S1)--e1-->(j1)--e2-->[F1] [J1]--e7-->(j4)--e8-->(E1)
202
- # |--e4-->(j3)--e6-->|
203
- #
204
- # in [jn0004/finally]
205
- # (S2) --e9-->(jn0004_f)-e10-->(E2)
206
- before do
207
- builder = Rjn0004ParallelJobnetWithFinally.new
208
- builder.create_actual
209
- @ctx = builder.context
210
- end
211
-
212
- context "j1が失敗するとe2以降のedgeはclosedになる。" do
213
- before do
214
- [:e1].each{|name| @ctx[name].phase_key = :transmitted}
215
- [:e2, :e3, :e4, :e5, :e6, :e7, :e8].each{|name| @ctx[name].phase_key = :closed}
216
- [:root, :j1].each{|name| @ctx[name].phase_key = :error}
217
- [:j2].each{|name| @ctx[name].phase_key = :ready}
218
- [:j3, :j4].each{|name| @ctx[name].phase_key = :initialized}
219
- @ctx[:root].save!
220
- end
221
-
222
- it "j2以降を再実行しようとしてclosedのe3に対してcompleteしても問題なく動けばOK" do
223
- @now = Time.now.utc
224
- @event = mock(:event, :occurred_at => @now)
225
- @execution = mock(:execution,
226
- :id => "execution_id",
227
- :estimated_time => 600,
228
- :retry => true,
229
- :spot => true,
230
- :target_actual_ids => [@ctx[:j2].id.to_s],
231
- :actual_estimated_end => Time.utc(2011,10,27,19,8),
232
- :preparation_command => "export J2_FAIL=true")
233
- @execution.should_receive(:ack).with(an_instance_of(Tengine::Job::Signal))
234
- @signal = Tengine::Job::Signal.new(@event)
235
- @signal.stub!(:execution).and_return(@execution)
236
- @ctx.vertex(:j2).activate(@signal)
237
- end
238
- end
239
- end
240
-
241
- end