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,138 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
- require 'tengine/rspec'
4
-
5
- describe 'job_execution_driver' do
6
- include Tengine::RSpec::Extension
7
-
8
- target_dsl File.expand_path("../../../../lib/tengine/job/drivers/job_execution_driver.rb", File.dirname(__FILE__))
9
- driver :job_execution_driver
10
-
11
- # in [rjn0001]
12
- # (S1) --e1-->(j11)--e2-->(j12)--e3-->(E1)
13
- context "rjn0001" do
14
- before do
15
- Tengine::Job::Vertex.delete_all
16
- builder = Rjn0001SimpleJobnetBuilder.new
17
- @root = builder.create_actual
18
- @ctx = builder.context
19
- @execution = Tengine::Job::Execution.create!({
20
- :root_jobnet_id => @root.id,
21
- })
22
- end
23
-
24
- it "ジョブの起動イベントを受け取ったら" do
25
- @execution.phase_key = :initialized
26
- @execution.save!
27
- @root.phase_key = :initialized
28
- @root.save!
29
- tengine.should_fire(:"start.jobnet.job.tengine",
30
- :source_name => @root.name_as_resource,
31
- :properties => {
32
- :execution_id => @execution.id.to_s,
33
- :root_jobnet_id => @root.id.to_s,
34
- :root_jobnet_name_path => @root.name_path,
35
- :target_jobnet_id => @root.id.to_s,
36
- :target_jobnet_name_path => @root.name_path,
37
- })
38
- tengine.receive("start.execution.job.tengine", :properties => {
39
- :execution_id => @execution.id.to_s,
40
- :root_jobnet_id => @root.id.to_s,
41
- :root_jobnet_name_path => @root.name_path,
42
- :target_jobnet_id => @root.id.to_s,
43
- :target_jobnet_name_path => @root.name_path,
44
- })
45
- @execution.reload
46
- @execution.phase_key.should == :starting
47
- @root.reload
48
- @root.phase_key.should == :ready
49
- end
50
-
51
- it "start.execution.job.tengine.failed.tengined, double save" do
52
- @execution.phase_key = :initialized
53
- @execution.save!
54
- @root.phase_key = :initialized
55
- @root.save!
56
- tengine.receive("start.execution.job.tengine.failed.tengined", :properties => {
57
- :original_event => {
58
- :event_type_name => "start.execution.job.tengine",
59
- :properties => {
60
- :execution_id => @execution.id.to_s,
61
- :root_jobnet_id => @root.id.to_s,
62
- :root_jobnet_name_path => @root.name_path,
63
- :target_jobnet_id => @root.id.to_s,
64
- :target_jobnet_name_path => @root.name_path,
65
- }}})
66
- @execution.reload
67
- @execution.phase_key.should == :stuck
68
- end
69
-
70
- it "start.execution.job.tengine.failed.tengined, broken event" do
71
- @execution.phase_key = :initialized
72
- @execution.save!
73
- @root.phase_key = :initialized
74
- @root.save!
75
- tengine.receive("start.execution.job.tengine.failed.tengined", :properties => {
76
- :original_event => {
77
- :event_type_name => "start.execution.job.tengine",
78
- :properties => {}}})
79
- @execution.reload
80
- @execution.phase_key.should_not == :stuck
81
- end
82
-
83
- %w[user_stop timeout].each do |stop_reason|
84
- context stop_reason do
85
- it "強制停止イベントを受け取ったら" do
86
- @execution.phase_key = :running
87
- @execution.save!
88
- @root.phase_key = :running
89
- @root.save!
90
- tengine.should_fire(:"stop.jobnet.job.tengine",
91
- :source_name => @root.name_as_resource,
92
- :properties => {
93
- :execution_id => @execution.id.to_s,
94
- :root_jobnet_id => @root.id.to_s,
95
- :root_jobnet_name_path => @root.name_path,
96
- :target_jobnet_id => @root.id.to_s,
97
- :target_jobnet_name_path => @root.name_path,
98
- :stop_reason => stop_reason
99
- })
100
- tengine.receive("stop.execution.job.tengine",
101
- :source_name => @execution.name_as_resource,
102
- :properties => {
103
- :execution_id => @execution.id.to_s,
104
- :root_jobnet_id => @root.id.to_s,
105
- :root_jobnet_name_path => @root.name_path,
106
- :target_jobnet_id => @root.id.to_s,
107
- :target_jobnet_name_path => @root.name_path,
108
- :stop_reason => stop_reason
109
- })
110
- @execution.reload
111
- @execution.phase_key.should == :dying
112
- @root.reload
113
- @root.phase_key.should == :running
114
- end
115
- end
116
- end
117
- # jobnet_control_driverでexecution起動後の処理を行っています
118
-
119
- it "stop.execution.job.tengine.failed.tengined" do
120
- @execution.phase_key = :running
121
- @execution.save!
122
- @root.phase_key = :running
123
- @root.save!
124
- tengine.receive("stop.execution.job.tengine.failed.tengined", :properties => {
125
- :original_event => {
126
- :event_type_name => "STOP.execution.job.tengine",
127
- :properties => {
128
- :execution_id => @execution.id.to_s,
129
- :root_jobnet_id => @root.id.to_s,
130
- :root_jobnet_name_path => @root.name_path,
131
- :target_jobnet_id => @root.id.to_s,
132
- :target_jobnet_name_path => @root.name_path,
133
- }}})
134
- @execution.reload
135
- @execution.phase_key.should == :stuck
136
- end
137
- end
138
- end
@@ -1,472 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
- require 'tengine/rspec'
4
-
5
- describe 'jobnet_control_driver' do
6
- include Tengine::RSpec::Extension
7
-
8
- target_dsl File.expand_path("../../../../../lib/tengine/job/drivers/jobnet_control_driver.rb", File.dirname(__FILE__))
9
- driver :jobnet_control_driver
10
-
11
- # in [rjn0012]
12
- # (S1)--e1-->[j1000]--e2-->[j2000]--e3-->(E1)
13
- #
14
- # in [j1000]
15
- # (S2)--e4-->[j1100]--e5-->[j1200]--e6-->(E2)
16
- #
17
- # in [j1100]
18
- # (S3)--e7-->(j1110)--e8-->(E3)
19
- #
20
- # in [j1200]
21
- # (S4)--e9-->(j1210)--e10-->(E4)
22
- #
23
- # in [j1000:finally (=j1f00)]
24
- # (S5)--e11-->[j1f10]--e12-->(E5)
25
- #
26
- # in [j1f10]
27
- # (S6)--e13-->(j1f11)--e14-->(E6)
28
- #
29
- # in [j1000:finally:finally (=j1ff0)]
30
- # (S7)--e15-->(j1ff1)--e16-->(E7)
31
- #
32
- # in [j2000]
33
- # (S8)--e17-->(j2100)--e18-->(E8)
34
- #
35
- # in [jf000:finally (=jf000)]
36
- # (S9)--e19-->(jf100)--e20-->(E9)
37
- #
38
- context "rjn0012" do
39
- before do
40
- Tengine::Job::Vertex.delete_all
41
- builder = Rjn0012NestedAndFinallyBuilder.new
42
- @root = builder.create_actual
43
- @ctx = builder.context
44
- @execution = Tengine::Job::Execution.create!({
45
- :root_jobnet_id => @root.id,
46
- })
47
- @base_props = {
48
- :execution_id => @execution.id.to_s,
49
- :root_jobnet_id => @root.id.to_s,
50
- :root_jobnet_name_path => @root.name_path,
51
- :target_jobnet_id => @root.id.to_s,
52
- :target_jobnet_name_path => @root.name_path,
53
- }
54
- end
55
-
56
- context "j1100が終了して" do
57
- it "j1100が成功した場合、j1200を実行するイベントが発火される" do
58
- @root.phase_key = :running
59
- @ctx.vertex(:j1000).phase_key = :running
60
- @ctx.vertex(:j1100).phase_key = :success
61
- @ctx.vertex(:j1110).phase_key = :success
62
- @ctx.vertex(:j1200).phase_key = :initialized
63
- @ctx.vertex(:j1000).finally_vertex.phase_key = :initialized
64
- [:e1, :e4, :e7, :e8].each{|name| @ctx.edge(name).phase_key = :transmitted}
65
- @root.save!
66
- tengine.should_fire(:"start.jobnet.job.tengine",
67
- :source_name => @ctx[:j1200].name_as_resource,
68
- :properties => @base_props.merge({
69
- :target_jobnet_id => @ctx[:j1200].id.to_s,
70
- :target_jobnet_name_path => @ctx[:j1200].name_path,
71
- }))
72
- tengine.receive(:"success.jobnet.job.tengine",
73
- :properties => @base_props.merge({
74
- :target_jobnet_id => @ctx[:j1100].id.to_s,
75
- :target_jobnet_name_path => @ctx[:j1100].name_path,
76
- }))
77
- @root.reload
78
- [:e1, :e4, :e5, :e7, :e8].each{|name| @ctx.edge(name).phase_key = :transmitted}
79
- [:e2, :e3, :e6 ].each{|name| @ctx.edge(name).phase_key = :active }
80
- @ctx.vertex(:j1100).phase_key.should == :success
81
- @ctx.vertex(:j1200).phase_key.should == :ready
82
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :initialized
83
- end
84
-
85
- it "j1100が失敗した場合、j1200ではなく、j1f00が実行するイベントが発火される" do
86
- @root.phase_key = :running
87
- @ctx.vertex(:j1000).phase_key = :running
88
- @ctx.vertex(:j1100).phase_key = :error
89
- @ctx.vertex(:j1110).phase_key = :error
90
- @ctx.vertex(:j1200).phase_key = :initialized
91
- @ctx.vertex(:j1000).finally_vertex.phase_key = :initialized
92
- [:e1, :e4, :e7].each{ |name| @ctx.edge(name).phase_key = :transmitted}
93
- [:e8 ].each{ |name| @ctx.edge(name).phase_key = :closed }
94
- [:e5, :e6 ].each{ |name| @ctx.edge(name).phase_key = :active }
95
- @root.save!
96
- tengine.should_fire(:"start.jobnet.job.tengine",
97
- :source_name => @ctx[:j1000].finally_vertex.name_as_resource,
98
- :properties => @base_props.merge({
99
- :target_jobnet_id => @ctx[:j1000].finally_vertex.id.to_s,
100
- :target_jobnet_name_path => @ctx[:j1000].finally_vertex.name_path,
101
- }))
102
- tengine.receive(:"error.jobnet.job.tengine",
103
- :properties => @base_props.merge({
104
- :target_jobnet_id => @ctx[:j1100].id.to_s,
105
- :target_jobnet_name_path => @ctx[:j1100].name_path,
106
- }))
107
- @root.reload
108
- [:e1, :e4, :e7].each{ |name| [name, @ctx.edge(name).phase_key].should == [name, :transmitted]}
109
- [:e5, :e6, :e8].each{ |name| [name, @ctx.edge(name).phase_key].should == [name, :closed ]}
110
- [:e2, :e3 ].each{ |name| [name, @ctx.edge(name).phase_key].should == [name, :closing ]}
111
- @ctx.vertex(:j1100).phase_key.should == :error
112
- @ctx.vertex(:j1200).phase_key.should == :initialized
113
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :ready
114
- end
115
- end
116
-
117
- context "j1200が終了して、j1f00が実行される" do
118
- it "j1200が成功した場合、j1f00が実行するイベントが発火される" do
119
- @root.phase_key = :running
120
- @ctx.vertex(:j1000).phase_key = :running
121
- @ctx.vertex(:j1100).phase_key = :success
122
- @ctx.vertex(:j1110).phase_key = :success
123
- @ctx.vertex(:j1200).phase_key = :success
124
- @ctx.vertex(:j1210).phase_key = :success
125
- @ctx.vertex(:j1000).finally_vertex.phase_key = :initialized
126
- [:e1, :e4, :e5, :e7, :e8, :e9, :e10].each{|name| @ctx.edge(name).phase_key = :transmitted}
127
- [:e2, :e3, :e6, ].each{|name| @ctx.edge(name).phase_key = :active }
128
- @root.save!
129
- tengine.should_fire(:"start.jobnet.job.tengine",
130
- :source_name => @ctx[:j1000].finally_vertex.name_as_resource,
131
- :properties => @base_props.merge({
132
- :target_jobnet_id => @ctx[:j1000].finally_vertex.id.to_s,
133
- :target_jobnet_name_path => @ctx[:j1000].finally_vertex.name_path,
134
- }))
135
- tengine.receive(:"success.jobnet.job.tengine", :properties => @base_props.merge({
136
- :target_jobnet_id => @ctx[:j1200].id.to_s,
137
- :target_jobnet_name_path => @ctx[:j1200].name_path,
138
- }))
139
- @root.reload
140
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10].each{|name| @ctx.edge(name).phase_key = :transmitted}
141
- [:e2, :e3 ].each{|name| @ctx.edge(name).phase_key = :active }
142
- @ctx.vertex(:j1100).phase_key.should == :success
143
- @ctx.vertex(:j1110).phase_key.should == :success
144
- @ctx.vertex(:j1200).phase_key.should == :success
145
- @ctx.vertex(:j1210).phase_key.should == :success
146
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :ready
147
- end
148
-
149
- it "j1200が失敗した場合、j1f00が実行するイベントが発火される" do
150
- @root.phase_key = :running
151
- @ctx.vertex(:j1000).phase_key = :running
152
- @ctx.vertex(:j1100).phase_key = :success
153
- @ctx.vertex(:j1110).phase_key = :success
154
- @ctx.vertex(:j1200).phase_key = :error
155
- @ctx.vertex(:j1210).phase_key = :error
156
- @ctx.vertex(:j1000).finally_vertex.phase_key = :initialized
157
- [:e1, :e4, :e5, :e7, :e8, :e9].each{|name| @ctx.edge(name).phase_key = :transmitted}
158
- [:e10 ].each{|name| @ctx.edge(name).phase_key = :closed }
159
- @root.save!
160
- tengine.should_fire(:"start.jobnet.job.tengine",
161
- :source_name => @ctx[:j1000].finally_vertex.name_as_resource,
162
- :properties => @base_props.merge({
163
- :target_jobnet_id => @ctx[:j1000].finally_vertex.id.to_s,
164
- :target_jobnet_name_path => @ctx[:j1000].finally_vertex.name_path,
165
- }))
166
- tengine.receive(:"error.jobnet.job.tengine",
167
- :properties => @base_props.merge({
168
- :target_jobnet_id => @ctx[:j1200].id.to_s,
169
- :target_jobnet_name_path => @ctx[:j1200].name_path,
170
- }))
171
- @root.reload
172
- [:e1, :e4, :e5, :e7, :e8].each{|name| @ctx.edge(name).phase_key = :transmitted}
173
- [:e6, :e10 ].each{|name| @ctx.edge(name).phase_key = :closed }
174
- [:e2, :e3 ].each{|name| @ctx.edge(name).phase_key = :active }
175
- @ctx.vertex(:j1100).phase_key.should == :success
176
- @ctx.vertex(:j1110).phase_key.should == :success
177
- @ctx.vertex(:j1200).phase_key.should == :error
178
- @ctx.vertex(:j1210).phase_key.should == :error
179
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :ready
180
- end
181
- end
182
-
183
- context "j1f00が終了" do
184
- it "j1f00が成功した場合" do
185
- @root.phase_key = :running
186
- @ctx.vertex(:j1000).phase_key = :running
187
- @ctx.vertex(:j1100).phase_key = :success
188
- @ctx.vertex(:j1110).phase_key = :success
189
- @ctx.vertex(:j1200).phase_key = :success
190
- @ctx.vertex(:j1210).phase_key = :success
191
- @ctx.vertex(:j1000).finally_vertex.phase_key = :success
192
- @ctx.vertex(:j1000).finally_vertex.finally_vertex.phase_key = :success
193
- @ctx.vertex(:j1ff1).phase_key = :success
194
- [:e2, :e3, :e17, :e18, :e19, :e20].each{|name| @ctx.edge(name).phase_key = :active }
195
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e12, :e13, :e14, :e15, :e16].
196
- each{|name| @ctx.edge(name).phase_key = :transmitted}
197
- @root.save!
198
- tengine.should_fire(:"success.jobnet.job.tengine",
199
- :source_name => @ctx[:j1000].name_as_resource,
200
- :properties => @base_props.merge({
201
- :target_jobnet_id => @ctx[:j1000].id.to_s,
202
- :target_jobnet_name_path => @ctx[:j1000].name_path,
203
- }))
204
- tengine.receive(:"success.jobnet.job.tengine",
205
- :properties => @base_props.merge({
206
- :target_jobnet_id => @ctx.vertex(:j1000).finally_vertex.id.to_s,
207
- :target_jobnet_name_path => @ctx.vertex(:j1000).finally_vertex.name_path,
208
- }))
209
- @root.reload
210
- [:e2, :e3, :e17, :e18, :e19, :e20].each{|name| @ctx.edge(name).phase_key.should == :active }
211
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e12, :e13, :e14, :e15, :e16].
212
- each{|name| @ctx.edge(name).phase_key.should == :transmitted}
213
- @ctx.vertex(:j1100).phase_key.should == :success
214
- @ctx.vertex(:j1110).phase_key.should == :success
215
- @ctx.vertex(:j1200).phase_key.should == :success
216
- @ctx.vertex(:j1210).phase_key.should == :success
217
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :success
218
- @ctx.vertex(:j2000).phase_key.should == :initialized
219
- end
220
-
221
- it "j1000が成功した場合" do
222
- @root.phase_key = :running
223
- @ctx[:j1000].phase_key = :success
224
- @ctx[:j1100].phase_key = :success
225
- @ctx[:j1110].phase_key = :success
226
- @ctx[:j1200].phase_key = :success
227
- @ctx[:j1210].phase_key = :success
228
- @ctx[:j1000].finally_vertex.phase_key = :success
229
- @ctx[:j1000].finally_vertex.finally_vertex.phase_key = :success
230
- @ctx[:j1ff1].phase_key = :success
231
- [:e2, :e3, :e17, :e18, :e19, :e20].each{|name| @ctx[name].phase_key = :active }
232
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e12, :e13, :e14, :e15, :e16].
233
- each{|name| @ctx[name].phase_key = :transmitted}
234
- @root.save!
235
- tengine.should_fire(:"start.jobnet.job.tengine",
236
- :source_name => @ctx[:j2000].name_as_resource,
237
- :properties => @base_props.merge({
238
- :target_jobnet_id => @ctx.vertex(:j2000).id.to_s,
239
- :target_jobnet_name_path => @ctx.vertex(:j2000).name_path,
240
- }))
241
- tengine.receive(:"success.jobnet.job.tengine",
242
- :properties => @base_props.merge({
243
- :target_jobnet_id => @ctx.vertex(:j1000).id.to_s,
244
- :target_jobnet_name_path => @ctx.vertex(:j1000).name_path,
245
- }))
246
- @root.reload
247
- [:e3, :e17, :e18, :e19, :e20].each{|name| @ctx.edge(name).phase_key.should == :active }
248
- [:e2 ].each{|name| @ctx.edge(name).phase_key.should == :transmitting }
249
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e12, :e13, :e14, :e15, :e16].
250
- each{|name| @ctx.edge(name).phase_key.should == :transmitted}
251
- @ctx.vertex(:j1100).phase_key.should == :success
252
- @ctx.vertex(:j1110).phase_key.should == :success
253
- @ctx.vertex(:j1200).phase_key.should == :success
254
- @ctx.vertex(:j1210).phase_key.should == :success
255
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :success
256
- @ctx.vertex(:j2000).phase_key.should == :ready
257
- end
258
-
259
- it "j1f00が失敗した場合" do
260
- @root.phase_key = :running
261
- @ctx.vertex(:j1000).phase_key = :running
262
- @ctx.vertex(:j1100).phase_key = :success
263
- @ctx.vertex(:j1110).phase_key = :success
264
- @ctx.vertex(:j1200).phase_key = :success
265
- @ctx.vertex(:j1210).phase_key = :success
266
- @ctx.vertex(:j1000).finally_vertex.phase_key = :error
267
- @ctx.vertex(:j1000).finally_vertex.finally_vertex.phase_key = :error
268
- @ctx.vertex(:j1ff1).phase_key = :error
269
- [:e2, :e3, :e17, :e18, :e19, :e20].each{|name| @ctx.edge(name).phase_key = :active }
270
- [:e12, :e16].each{|name| @ctx.edge(name).phase_key = :closed}
271
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e13, :e14, :e15].
272
- each{|name| @ctx.edge(name).phase_key = :transmitted}
273
- @root.save!
274
- tengine.should_fire(:"error.jobnet.job.tengine",
275
- :source_name => @ctx[:j1000].name_as_resource,
276
- :properties => @base_props.merge({
277
- :target_jobnet_id => @ctx[:j1000].id.to_s,
278
- :target_jobnet_name_path => @ctx[:j1000].name_path,
279
- }))
280
- tengine.receive(:"error.jobnet.job.tengine",
281
- :properties => @base_props.merge({
282
- :target_jobnet_id => @ctx.vertex(:j1000).finally_vertex.id.to_s,
283
- :target_jobnet_name_path => @ctx.vertex(:j1000).finally_vertex.name_path,
284
- }))
285
- @root.reload
286
- [:e2, :e3, :e17, :e18, :e19, :e20].each{|name| @ctx.edge(name).phase_key.should == :active }
287
- [:e12, :e16].each{|name| @ctx.edge(name).phase_key.should == :closed}
288
- [:e1, :e4, :e5, :e6, :e7, :e8, :e9, :e10, :e11, :e13, :e14, :e15].
289
- each{|name| @ctx.edge(name).phase_key.should == :transmitted}
290
- @ctx.vertex(:j1100).phase_key.should == :success
291
- @ctx.vertex(:j1110).phase_key.should == :success
292
- @ctx.vertex(:j1200).phase_key.should == :success
293
- @ctx.vertex(:j1210).phase_key.should == :success
294
- @ctx.vertex(:j1000).finally_vertex.phase_key.should == :error
295
- @ctx.vertex(:j1000).finally_vertex.finally_vertex.phase_key.should == :error
296
- @ctx.vertex(:j1ff1).phase_key.should == :error
297
- @root.finally_vertex.phase_key.should == :initialized
298
- end
299
- end
300
-
301
- end
302
-
303
-
304
- context "rjn0005" do
305
- before do
306
- Tengine::Job::Vertex.delete_all
307
- builder = Rjn0005RetryTwoLayerFixture.new
308
- @root = builder.create_actual
309
- @ctx = builder.context
310
- @execution = Tengine::Job::Execution.create!({
311
- :root_jobnet_id => @root.id,
312
- })
313
- @base_props = {
314
- :execution_id => @execution.id.to_s,
315
- :root_jobnet_id => @root.id.to_s,
316
- :root_jobnet_name_path => @root.name_path,
317
- :target_jobnet_id => @root.id.to_s,
318
- :target_jobnet_name_path => @root.name_path,
319
- }
320
- end
321
-
322
- all_edge_names = (1..26).map{|idx| :"e#{idx}"}
323
-
324
- context "j41がエラーになったことをjn4で受けた場合" do
325
- it "以降のvertexがclosedになる" do
326
- @root.phase_key = :running
327
- @ctx[:j1].phase_key = :success
328
- @ctx[:j2].phase_key = :success
329
- @ctx[:j4].phase_key = :initialized
330
- @ctx[:jn4].phase_key = :running
331
- @ctx[:j41].phase_key = :error
332
- [
333
- :j42, :j43, :j44,
334
- :jn4f, :jn4_f,
335
- :finally, :jn0005_fjn, :jn0005_f, :jn0005_fjn,
336
- :jn0005_f1, :jn0005_f2, :jn0005_fjn_f, :jn0005_fif
337
- ].each do |key|
338
- @ctx[key].phase_key = :initialized
339
- end
340
- transmitted_edges = [:e1, :e2, :e3, :e4, :e9]
341
- transmitted_edges.each{|name| @ctx[name].phase_key = :transmitted}
342
- (all_edge_names - transmitted_edges).each{|name| @ctx[name].phase_key = :active}
343
- @root.save!
344
- tengine.should_fire(:"start.jobnet.job.tengine",
345
- :source_name => @ctx[:jn4f].name_as_resource,
346
- :properties => @base_props.merge({
347
- :target_jobnet_id => @ctx[:jn4f].id.to_s,
348
- :target_jobnet_name_path => @ctx[:jn4f].name_path,
349
- }))
350
- tengine.receive(:"error.job.job.tengine",
351
- :properties => @base_props.merge({
352
- :target_jobnet_id => @ctx[:jn4].id.to_s,
353
- :target_jobnet_name_path => @ctx[:jn4].name_path,
354
- :target_job_id => @ctx[:j41].id.to_s,
355
- :target_job_name_path => @ctx[:j41].name_path,
356
- }))
357
-
358
- @root.reload
359
- [
360
- :j42, :j43, :j44,
361
- :jn4_f,
362
- :finally, :jn0005_fjn, :jn0005_f, :jn0005_fjn,
363
- :jn0005_f1, :jn0005_f2, :jn0005_fjn_f, :jn0005_fif
364
- ].each do |key|
365
- @ctx[key].phase_key.should == :initialized
366
- end
367
- transmitted_edges = [:e1, :e2, :e3, :e4, :e9]
368
- transmitted_edges.each{|name| @ctx.edge(name).phase_key.should == :transmitted}
369
- closed_edges = [
370
- :e10, :e11, :e12, :e13, :e14, :e15, :e16, # jn4のedge
371
- ]
372
- closing_edges = [
373
- :e6, :e7, :e8, # rootのedge
374
- ]
375
- closed_edges.each{|name| [name, @ctx.edge(name).phase_key].should == [name, :closed]}
376
- (all_edge_names - transmitted_edges - closed_edges - closing_edges).
377
- each{|name| [name, @ctx.edge(name).phase_key].should == [name, :active]}
378
- @root.phase_key.should == :running
379
-
380
- expected_job_phases = {
381
- :j1 => :success,
382
- :j2 => :success,
383
- :j4 => :initialized,
384
- :jn4 => :running,
385
- :j41 => :error,
386
- :jn4f => :initialized,
387
- }
388
-
389
- actual_job_phases = expected_job_phases.keys.inject({}) do |d, key|
390
- d[key] = @ctx[key].phase_key
391
- d
392
- end
393
-
394
- actual_job_phases.should == expected_job_phases
395
- end
396
- end
397
-
398
- context "j41がエラーになって、jn4_fを実行中に、j2が失敗した場合" do
399
- it "jn4の終了を待ってからfinallyが実行される" do
400
- @root.phase_key = :running
401
- @ctx[:j1].phase_key = :success
402
- @ctx[:j2].phase_key = :error
403
- @ctx[:j4].phase_key = :initialized
404
- @ctx[:jn4].phase_key = :running
405
- @ctx[:jn4f].phase_key = :running
406
- @ctx[:jn4_f].phase_key = :running
407
- @ctx[:j41].phase_key = :error
408
- [
409
- :j42, :j43, :j44,
410
- :finally, :jn0005_fjn, :jn0005_f, :jn0005_fjn,
411
- :jn0005_f1, :jn0005_f2, :jn0005_fjn_f, :jn0005_fif
412
- ].each do |key|
413
- @ctx[key].phase_key = :initialized
414
- end
415
- transmitted_edges = [:e1, :e2, :e3, :e4, :e9, :e17]
416
- transmitted_edges.each{|name| @ctx[name].phase_key = :transmitted}
417
- closed_edges = [:e10, :e11, :e12, :e13, :e14, :e15, :e16] # jn4のedge
418
- closed_edges.each{|name| @ctx.edge(name).phase_key = :closed}
419
- closing_edges = [:e6, :e7, :e8] # rootのedge
420
- closing_edges.each{|name| @ctx.edge(name).phase_key = :closing}
421
- (all_edge_names - transmitted_edges - closed_edges - closing_edges).
422
- each{|name| @ctx[name].phase_key = :active}
423
- @root.save!
424
- tengine.should_not_fire
425
- tengine.receive(:"error.job.job.tengine",
426
- :properties => @base_props.merge({
427
- :target_jobnet_id => @root.id.to_s,
428
- :target_jobnet_name_path => @root.name_path,
429
- :target_job_id => @ctx[:j2].id.to_s,
430
- :target_job_name_path => @ctx[:j2].name_path,
431
- }))
432
-
433
- @root.reload
434
- [
435
- :j42, :j43, :j44,
436
- :finally, :jn0005_fjn, :jn0005_f, :jn0005_fjn,
437
- :jn0005_f1, :jn0005_f2, :jn0005_fjn_f, :jn0005_fif
438
- ].each do |key|
439
- @ctx[key].phase_key.should == :initialized
440
- end
441
- transmitted_edges = [:e1, :e2, :e3, :e4, :e9, :e17]
442
- transmitted_edges.each{|name| @ctx.edge(name).phase_key.should == :transmitted}
443
- closed_edges = [:e10, :e11, :e12, :e13, :e14, :e15, :e16, :e5, ] # jn4のedge + j2の後
444
- closed_edges.each{|name| [name, @ctx.edge(name).phase_key].should == [name, :closed]}
445
- closing_edges = [:e6, :e7, :e8] # rootのedge
446
- closing_edges.each{|name| [name, @ctx.edge(name).phase_key].should == [name, :closing]}
447
- (all_edge_names - transmitted_edges - closed_edges - closing_edges).
448
- each{|name| [name, @ctx.edge(name).phase_key].should == [name, :active]}
449
- @root.phase_key.should == :running
450
-
451
- expected_job_phases = {
452
- :j1 => :success,
453
- :j2 => :error,
454
- :j4 => :initialized,
455
- :jn4 => :running,
456
- :jn4f => :running,
457
- :jn4_f => :running,
458
- :j41 => :error,
459
- }
460
-
461
- actual_job_phases = expected_job_phases.keys.inject({}) do |d, key|
462
- d[key] = @ctx[key].phase_key
463
- d
464
- end
465
-
466
- actual_job_phases.should == expected_job_phases
467
- end
468
-
469
- end
470
- end
471
-
472
- end