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,231 +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 [rjn0011]
12
- # (S1)--e1-->[j1100]--e2-->(j1200)--e3-->[j1300]--e4-->(E1)
13
- #
14
- # in [j1100]
15
- # (S2)--e5-->(j1110)--e6-->[j1120]--e7-->[j1130]--e8-->(j1140)--e9-->(E2)
16
- #
17
- # in [j1120]
18
- # (S3)--e10-->(j1121)--e11-->(E3)
19
- #
20
- # in [j1130]
21
- # (S4)--e12-->(j1131)--e13-->(E4)
22
- #
23
- # in [j1300]
24
- # (S5)--e14-->(j1310)--e15-->(E5)
25
- #
26
- context "rjn0011" do
27
- before do
28
- Tengine::Job::Vertex.delete_all
29
- builder = Rjn0011NestedForkJobnetBuilder.new
30
- @root = builder.create_actual
31
- @ctx = builder.context
32
- @execution = Tengine::Job::Execution.create!({
33
- :root_jobnet_id => @root.id,
34
- })
35
- @base_props = {
36
- :execution_id => @execution.id.to_s,
37
- :root_jobnet_id => @root.id.to_s,
38
- :root_jobnet_name_path => @root.name_path,
39
- :target_jobnet_id => @root.id.to_s,
40
- :target_jobnet_name_path => @root.name_path,
41
- }
42
- end
43
-
44
- it "S1から起動" do
45
- @root.phase_key = :ready
46
- @root.save!
47
- tengine.should_fire(:"start.jobnet.job.tengine",
48
- :source_name => @ctx[:j1100].name_as_resource,
49
- :properties => @base_props.merge({
50
- :target_jobnet_id => @ctx[:j1100].id.to_s,
51
- :target_jobnet_name_path => @ctx[:j1100].name_path,
52
- }))
53
- tengine.receive("start.jobnet.job.tengine", :properties => @base_props)
54
- @root.reload
55
- @ctx.edge(:e1).phase_key.should == :transmitting
56
- (2..15).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
57
- @root.phase_key.should == :starting
58
- @ctx.vertex(:j1100).phase_key.should == :ready
59
- end
60
-
61
- context "j1100を起動" do
62
- it do
63
- @root.phase_key = :starting
64
- @ctx.vertex(:j1100).phase_key = :ready
65
- @ctx[:e1].phase_key = :transmitting
66
- (2..15).each{|idx| @ctx[:"e#{idx}"].phase_key = :active }
67
- @root.save!
68
- tengine.should_fire(:"start.job.job.tengine",
69
- :source_name => @ctx[:j1110].name_as_resource,
70
- :properties => @base_props.merge({
71
- :target_jobnet_id => @ctx[:j1100].id.to_s,
72
- :target_jobnet_name_path => @ctx[:j1100].name_path,
73
- :target_job_id => @ctx[:j1110].id.to_s,
74
- :target_job_name_path => @ctx[:j1110].name_path,
75
- }))
76
- tengine.receive(:"start.jobnet.job.tengine", :properties => @base_props.merge({
77
- :target_jobnet_id => @ctx[:j1100].id.to_s,
78
- :target_jobnet_name_path => @ctx[:j1100].name_path,
79
- }))
80
- @root.reload
81
- @root.phase_key = :running
82
- @ctx.edge(:e1).phase_key.should == :transmitted
83
- @ctx.edge(:e5).phase_key.should == :transmitting
84
- (2..4).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
85
- (6..15).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
86
- @ctx.vertex(:j1100).phase_key.should == :starting
87
- end
88
- end
89
-
90
- context 'j1110を実行' do
91
- it "成功した場合" do
92
- @root.phase_key = :starting
93
- @ctx.vertex(:j1100).phase_key = :running
94
- @ctx.vertex(:j1110).phase_key = :success
95
- @ctx[:e1].phase_key = :transmitted
96
- @ctx[:e5].phase_key = :transmitted
97
- @root.save!
98
- tengine.should_not_fire(:"start.job.job.tengine",
99
- :source_name => @ctx[:j1110].name_as_resource,
100
- :properties => @base_props.merge({
101
- :target_jobnet_id => @ctx[:j1100].id.to_s,
102
- :target_jobnet_name_path => @ctx[:j1100].name_path,
103
- :target_job_id => @ctx[:j1110].id.to_s,
104
- :target_job_name_path => @ctx[:j1110].name_path,
105
- }))
106
- tengine.should_fire(:"start.jobnet.job.tengine",
107
- :source_name => @ctx[:j1120].name_as_resource,
108
- :properties => @base_props.merge({
109
- :target_jobnet_id => @ctx[:j1120].id.to_s,
110
- :target_jobnet_name_path => @ctx[:j1120].name_path,
111
- }))
112
- tengine.receive("success.job.job.tengine", :properties => @base_props.merge({
113
- :target_jobnet_id => @ctx[:j1100].id.to_s,
114
- :target_jobnet_name_path => @ctx[:j1100].name_path,
115
- :target_job_id => @ctx[:j1110].id.to_s,
116
- :target_job_name_path => @ctx[:j1110].name_path,
117
- }))
118
- @root.reload
119
- @root.phase_key = :running
120
- @ctx.edge(:e1).phase_key.should == :transmitted
121
- @ctx.edge(:e5).phase_key.should == :transmitted
122
- @ctx.edge(:e6).phase_key.should == :transmitting
123
- ((2..15).to_a - [5, 6]).each do |idx|
124
- [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active]
125
- end
126
- @ctx.vertex(:j1100).phase_key.should == :running
127
- @ctx.vertex(:j1110).phase_key.should == :success
128
- @ctx.vertex(:j1120).phase_key.should == :ready
129
- end
130
-
131
- it "失敗した場合" do
132
- @root.phase_key = :running
133
- @ctx.vertex(:j1100).phase_key = :running
134
- @ctx.vertex(:j1110).phase_key = :error
135
- @ctx[:e1].phase_key = :transmitted
136
- @ctx[:e5].phase_key = :transmitted
137
- @root.save!
138
- tengine.should_fire(:"error.jobnet.job.tengine",
139
- :source_name => @ctx[:j1100].name_as_resource,
140
- :properties => @base_props.merge({
141
- :target_jobnet_id => @ctx[:j1100].id.to_s,
142
- :target_jobnet_name_path => @ctx[:j1100].name_path,
143
- }))
144
- tengine.receive("error.job.job.tengine", :properties => @base_props.merge({
145
- :target_jobnet_id => @ctx[:j1100].id.to_s,
146
- :target_jobnet_name_path => @ctx[:j1100].name_path,
147
- :target_job_id => @ctx[:j1110].id.to_s,
148
- :target_job_name_path => @ctx[:j1110].name_path,
149
- }))
150
- @root.reload
151
- @ctx.edge(:e1).phase_key.should == :transmitted
152
- @ctx.edge(:e5).phase_key.should == :transmitted
153
- (2..4).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :closing }
154
- (6..9).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :closed }
155
- (10..15).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
156
- @ctx.vertex(:j1100).phase_key.should == :error
157
- @ctx.vertex(:j1110).phase_key.should == :error
158
- end
159
- end
160
-
161
-
162
- context 'j1100' do
163
- it "成功した場合" do
164
- @root.phase_key = :running
165
- [:j1100, :j1110, :j1120, :j1130, :j1140].each do |jobnet_name|
166
- @root.vertex(@ctx[jobnet_name].id).phase_key = :success
167
- end
168
- @ctx[:e1].phase_key = :transmitted
169
- (5..9).each{|idx|@ctx[:"e#{idx}"].phase_key = :transmitted}
170
- @root.save!
171
- tengine.should_fire(:"start.job.job.tengine",
172
- :source_name => @ctx[:j1200].name_as_resource,
173
- :properties => @base_props.merge({
174
- :target_jobnet_id => @root.id.to_s,
175
- :target_jobnet_name_path => @root.name_path,
176
- :target_job_id => @ctx[:j1200].id.to_s,
177
- :target_job_name_path => @ctx[:j1200].name_path,
178
- }))
179
- tengine.receive("success.jobnet.job.tengine", :properties => @base_props.merge({
180
- :target_jobnet_id => @ctx[:j1100].id.to_s,
181
- }))
182
- @root.reload
183
- @root.edge(@ctx[:e1].id).phase_key.should == :transmitted
184
- @root.edge(@ctx[:e2].id).phase_key.should == :transmitting
185
- (3..4).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
186
- (5..9).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :transmitted }
187
- (10..15).each{|idx| @ctx.edge(:"e#{idx}").phase_key.should == :active }
188
- @root.vertex(@ctx[:j1100].id).phase_key.should == :success
189
- @root.vertex(@ctx[:j1110].id).phase_key.should == :success
190
- end
191
-
192
- it "失敗した場合" do
193
- @root.phase_key = :running
194
- [:j1100, :j1110].each do |jobnet_name|
195
- @root.vertex(@ctx[jobnet_name].id).phase_key = :error
196
- end
197
- [:j1120, :j1130, :j1140].each do |jobnet_name|
198
- @root.vertex(@ctx[jobnet_name].id).phase_key = :ready
199
- end
200
- @ctx[:e1].phase_key = :transmitted
201
- @ctx[:e5].phase_key = :transmitted
202
- (6..9).each{|idx|@ctx[:"e#{idx}"].phase_key = :closed}
203
- @root.save!
204
-
205
- tengine.should_fire(:"error.jobnet.job.tengine",
206
- :source_name => @root.name_as_resource,
207
- :properties => @base_props.merge({
208
- :target_jobnet_id => @root.id.to_s,
209
- :target_jobnet_name_path => @root.name_path,
210
- }))
211
- tengine.receive("error.jobnet.job.tengine", :properties => @base_props.merge({
212
- :target_jobnet_id => @ctx[:j1100].id.to_s,
213
- :target_jobnet_name_path => @ctx[:j1100].name_path,
214
- }))
215
- @root.reload
216
- @root.edge(@ctx[:e1].id).phase_key.should == :transmitted
217
- (2..4).each do |idx|
218
- [:"e#{idx}", @root.edge(@ctx[:"e#{idx}"].id).phase_key].should == [:"e#{idx}", :closed]
219
- end
220
- @root.edge(@ctx[:e5].id).phase_key.should == :transmitted
221
- (6..9).each do |idx|
222
- [:"e#{idx}", @root.edge(@ctx[:"e#{idx}"].id).phase_key].should == [:"e#{idx}", :closed]
223
- end
224
- @root.vertex(@ctx[:j1100].id).phase_key.should == :error
225
- @root.vertex(@ctx[:j1110].id).phase_key.should == :error
226
- end
227
- end
228
-
229
- end
230
-
231
- end
@@ -1,202 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
- require 'tengine/rspec'
4
-
5
- describe 'stop.jobnet.job.tengine' 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
- context "rjn0011" do
12
- before do
13
- Tengine::Job::Vertex.delete_all
14
- builder = Rjn0011NestedForkJobnetBuilder.new
15
- @root = builder.create_actual
16
- @ctx = builder.context
17
- @execution = Tengine::Job::Execution.create!({
18
- :root_jobnet_id => @root.id,
19
- })
20
- end
21
-
22
- context "j1120" do
23
- before do
24
- @ctx[:root].tap{|j| j.phase_key = :running}
25
- @ctx[:j1100].tap{|j| j.phase_key = :running}
26
- @ctx[:j1110].tap{|j| j.phase_key = :success; j.executing_pid = "1110"}
27
- [:e1, :e5, :e6].each{|name| @ctx[name].phase_key = :transmitted}
28
- @base_props = {
29
- :execution_id => @execution.id.to_s,
30
- :root_jobnet_id => @root.id.to_s,
31
- :root_jobnet_name_path => @root.name_path.to_s,
32
- :target_jobnet_id => @ctx[:j1120].id.to_s,
33
- :target_jobnet_name_path => @ctx[:j1120].name_path,
34
- }
35
- end
36
-
37
- context "runningの場合" do
38
- before do
39
- @ctx[:j1120].tap{|j| j.phase_key = :running}
40
- end
41
-
42
- context "j1121がinitialized" do
43
- before do
44
- @ctx[:j1121].tap{|j| j.phase_key = :initialized}
45
- [:e10].each{|name| @ctx[name].phase_key = :active}
46
- @root.save!
47
- end
48
-
49
- it "j1120をstopすると自身をdyingにして、エッジをcloseして、j1121については何もしません" do
50
- tengine.should_not_fire
51
- tengine.receive(:"stop.jobnet.job.tengine",
52
- :source_name => @ctx[:j1120].name_as_resource,
53
- :properties => @base_props)
54
- @root.reload
55
- @root.phase_key.should == :running
56
- @ctx.vertex(:j1100).tap{|j| j.phase_key.should == :running}
57
- @ctx.vertex(:j1110).tap{|j| j.phase_key.should == :success}
58
- @ctx.vertex(:j1120).tap{|j| j.phase_key.should == :dying}
59
- @ctx.vertex(:j1121).tap{|j| j.phase_key.should == :initialized}
60
- [:e1, :e5, :e6].each{|name| @ctx.edge(name).phase_key.should == :transmitted }
61
- (2..4).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
62
- (7..9).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
63
- (10..11).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :closing] }
64
- (12..15).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
65
- end
66
- end
67
-
68
- [
69
- [:ready , :transmitting, :closing],
70
- [:starting, :transmitted , :transmitted],
71
- [:running , :transmitted , :transmitted],
72
- ].each do |(j1121_phase_key, e10_phase_key, e10_new_phase_key)|
73
-
74
- context "j1121が#{j1121_phase_key}" do
75
- before do
76
- @ctx[:j1121].tap{|j| j.phase_key = j1121_phase_key}
77
- [:e10].each{|name| @ctx[name].phase_key = e10_phase_key}
78
- @root.save!
79
- end
80
-
81
- [nil, 'user_stop', 'timeout'].each do |stop_reason|
82
- context "stop_reason: #{stop_reason.inspect}" do
83
- it "j1120をstopすると自身をdyingにして、エッジをcloseして、j1121についてはstop.job.job.tengineを発火します" do
84
- tengine.should_fire(:"stop.job.job.tengine",
85
- :source_name => @ctx[:j1121].name_as_resource,
86
- :properties => @base_props.merge({
87
- :stop_reason => stop_reason,
88
- :target_job_id => @ctx[:j1121].id.to_s,
89
- :target_job_name_path => @ctx[:j1121].name_path,
90
- }))
91
- tengine.receive(:"stop.jobnet.job.tengine",
92
- :source_name => @ctx[:j1120].name_as_resource,
93
- :properties => @base_props.merge({
94
- :target_jobnet_id => @ctx[:j1120].id.to_s,
95
- :target_jobnet_name_path => @ctx[:j1120].name_path,
96
- :stop_reason=>stop_reason,
97
- }))
98
- @root.reload
99
- @root.phase_key.should == :running
100
- @ctx.vertex(:j1100).tap{|j| j.phase_key.should == :running}
101
- @ctx.vertex(:j1110).tap{|j| j.phase_key.should == :success}
102
- @ctx.vertex(:j1120).tap{|j| j.phase_key.should == :dying}
103
- @ctx.vertex(:j1121).tap{|j| j.phase_key.should == j1121_phase_key}
104
- [:e1, :e5, :e6].each{|name| @ctx.edge(name).phase_key.should == :transmitted }
105
- [:e10].each{|name| @ctx.edge(name).phase_key.should == e10_new_phase_key }
106
- [:e11].each{|name| @ctx.edge(name).phase_key.should == :closing }
107
- (2..4).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
108
- (7..9).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
109
- (12..15).each{|idx| [:"e#{idx}", @ctx.edge(:"e#{idx}").phase_key].should == [:"e#{idx}", :active] }
110
- end
111
- end
112
- end
113
-
114
- end
115
- end
116
-
117
- end
118
- end
119
-
120
- end
121
-
122
-
123
- # in [jn0004]
124
- # |--e3-->(j2)--e5-->|
125
- # (S1)--e1-->(j1)--e2-->[F1] [J1]--e7-->(j4)--e8-->(E1)
126
- # |--e4-->(j3)--e6-->|
127
- #
128
- # in [jn0004/finally]
129
- # (S2) --e9-->(jn0004_f)-e10-->(E2)
130
- #
131
- context "jn0004" do
132
- before do
133
- Tengine::Job::Vertex.delete_all
134
- builder = Rjn0004ParallelJobnetWithFinally.new
135
- @root = builder.create_actual
136
- @ctx = builder.context
137
- @execution = Tengine::Job::Execution.create!({
138
- :root_jobnet_id => @root.id,
139
- })
140
- end
141
-
142
- context "ジョブネットが強制停止された場合" do
143
- before do
144
- @ctx[:root].tap{|j| j.phase_key = :dying}
145
- @ctx[:j1].tap{|j| j.phase_key = :error}
146
- [:e1, ].each{|name| @ctx[name].phase_key = :transmitted}
147
- @base_props = {
148
- :execution_id => @execution.id.to_s,
149
- :root_jobnet_id => @root.id.to_s,
150
- :root_jobnet_name_path => @root.name_path.to_s,
151
- :target_jobnet_id => @root.id.to_s,
152
- :target_jobnet_name_path => @root.name_path,
153
- }
154
- @root.save!
155
- end
156
-
157
- it "finallyの親のジョブネットは強制停止中であるため、finallyは動かない" do
158
- tengine.should_fire(:"error.jobnet.job.tengine",
159
- :source_name => @ctx[:root].name_as_resource,
160
- :properties => @base_props)
161
- tengine.receive(:"error.job.job.tengine",
162
- :source_name => @ctx[:j1].name_as_resource,
163
- :properties => @base_props.merge({
164
- :target_job_id => @ctx[:j1].id.to_s,
165
- :target_job_name_path => @ctx[:j1].name_path,
166
- }))
167
- end
168
- end
169
-
170
- context "ジョブネットではなくジョブj1が強制停止された場合" do
171
- before do
172
- @ctx[:root].tap{|j| j.phase_key = :running} # ジョブネットは強制停止されていません
173
- @ctx[:j1].tap{|j| j.phase_key = :error}
174
- [:e1, ].each{|name| @ctx[name].phase_key = :transmitted}
175
- @base_props = {
176
- :execution_id => @execution.id.to_s,
177
- :root_jobnet_id => @root.id.to_s,
178
- :root_jobnet_name_path => @root.name_path.to_s,
179
- :target_jobnet_id => @root.id.to_s,
180
- :target_jobnet_name_path => @root.name_path,
181
- }
182
- end
183
-
184
- it "finallyの親のジョブネットは実行中であるため、finallyは実行される" do
185
- @root.save!
186
- tengine.should_fire(:"start.jobnet.job.tengine",
187
- :source_name => @root.finally_vertex.name_as_resource,
188
- :properties => @base_props.merge({
189
- :target_jobnet_id => @root.finally_vertex.id.to_s,
190
- :target_jobnet_name_path => @root.finally_vertex.name_path,
191
- }))
192
- tengine.receive(:"error.job.job.tengine",
193
- :source_name => @ctx[:j1].name_as_resource,
194
- :properties => @base_props.merge({
195
- :target_job_id => @ctx[:j1].id.to_s,
196
- :target_job_name_path => @ctx[:j1].name_path,
197
- }))
198
- end
199
- end
200
- end
201
-
202
- end
@@ -1,608 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
- require 'tengine/rspec'
4
-
5
- describe 'job_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
- before do
12
- @now = Time.now
13
- Time.stub!(:now).and_return(@now)
14
- end
15
-
16
- # in [rjn0001]
17
- # (S1) --e1-->(j11)--e2-->(j12)--e3-->(E1)
18
- context "rjn0001" do
19
- before do
20
- Tengine::Job::Vertex.delete_all
21
- builder = Rjn0001SimpleJobnetBuilder.new
22
- @root = builder.create_actual
23
- @ctx = builder.context
24
- @execution = Tengine::Job::Execution.create!({
25
- :root_jobnet_id => @root.id,
26
- })
27
- @base_props = {
28
- :execution_id => @execution.id.to_s,
29
- :root_jobnet_id => @root.id.to_s,
30
- :root_jobnet_name_path => @root.name_path,
31
- :target_jobnet_id => @root.id.to_s,
32
- :target_jobnet_name_path => @root.name_path,
33
- }
34
- end
35
-
36
- it "ジョブネット起動イベントを受信したら" do
37
- @execution.phase_key = :starting
38
- @execution.save!
39
- @root.phase_key = :ready
40
- @root.save!
41
- tengine.should_fire(:"start.job.job.tengine",
42
- :source_name => @ctx[:j11].name_as_resource,
43
- :properties => {
44
- :target_job_id => @ctx[:j11].id.to_s,
45
- :target_job_name_path => @ctx[:j11].name_path,
46
- }.update(@base_props))
47
- tengine.receive("start.jobnet.job.tengine", :properties => @base_props)
48
- @execution.reload
49
- @execution.phase_key.should == :running
50
- @root.reload
51
- @root.phase_key.should == :starting
52
- @root.started_at.utc.iso8601.should == @now.utc.iso8601
53
- @ctx.edge(:e1).phase_key.should == :transmitting
54
- @ctx.vertex(:j11).phase_key.should == :ready
55
- end
56
-
57
-
58
- context 'j11を実行' do
59
- it "成功した場合" do
60
- @root.phase_key = :running
61
- @ctx[:e1].phase_key = :transmitted
62
- @ctx[:j11].phase_key = :success
63
- @root.save!
64
- tengine.should_fire(:"start.job.job.tengine",
65
- :source_name => @ctx[:j12].name_as_resource,
66
- :properties => {
67
- :target_job_id => @ctx[:j12].id.to_s,
68
- :target_job_name_path => @ctx[:j12].name_path,
69
- }.update(@base_props))
70
- tengine.receive("success.job.job.tengine",
71
- :source_name => @ctx[:j11].name_as_resource,
72
- :properties => {
73
- :target_job_id => @ctx[:j11].id.to_s,
74
- :target_job_name_path => @ctx[:j11].name_path,
75
- }.update(@base_props))
76
- @root.reload
77
- @root.phase_key.should == :running
78
- @ctx.vertex(:j12).phase_key.should == :ready
79
- @ctx.edge(:e2).phase_key.should == :transmitting
80
- @ctx.edge(:e3).phase_key.should == :active
81
- end
82
-
83
- it "ルートジョブネットの成功を受けてそのexecutionが成功する" do
84
- @execution.phase_key = :running
85
- @execution.save!
86
- @root.phase_key = :success
87
- @ctx[:e1].phase_key = :transmitted
88
- @ctx[:e2].phase_key = :transmitted
89
- @ctx[:e3].phase_key = :transmitted
90
- @ctx[:j11].phase_key = :success
91
- @ctx[:j12].phase_key = :success
92
- @root.save!
93
- tengine.should_fire(:"success.execution.job.tengine",
94
- :source_name => @execution.name_as_resource,
95
- :properties => @base_props)
96
- tengine.receive("success.jobnet.job.tengine", :properties => @base_props)
97
- @execution.reload
98
- @execution.phase_key.should == :success
99
- end
100
-
101
-
102
- it "失敗した場合" do
103
- @root.phase_key = :running
104
- @ctx[:e1].phase_key = :transmitted
105
- @ctx[:j11].phase_key = :error
106
- @root.save!
107
- tengine.should_fire(:"error.jobnet.job.tengine",
108
- :source_name => @root.name_as_resource,
109
- :properties => @base_props)
110
- tengine.receive("error.job.job.tengine", :properties => {
111
- :target_job_id => @ctx[:j11].id.to_s
112
- }.update(@base_props))
113
- @root.reload
114
- @ctx.vertex(:j11).phase_key.should == :error
115
- @ctx.vertex(:j12).phase_key.should == :initialized
116
- @ctx.edge(:e2).phase_key.should == :closed
117
- @ctx.edge(:e3).phase_key.should == :closed
118
- @root.phase_key.should == :error
119
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
120
- end
121
-
122
- it "ルートジョブネットの失敗を受けてそのexecutionが失敗する" do
123
- @execution.phase_key = :running
124
- @execution.save!
125
- @root.phase_key = :error
126
- @ctx[:e1].phase_key = :transmitted
127
- @ctx[:e2].phase_key = :closed
128
- @ctx[:e3].phase_key = :closed
129
- @ctx[:j11].phase_key = :error
130
- @ctx[:j12].phase_key = :initialized
131
- @root.save!
132
- tengine.should_fire(:"error.execution.job.tengine",
133
- :source_name => @execution.name_as_resource,
134
- :properties => @base_props)
135
- tengine.receive("error.jobnet.job.tengine", :properties => @base_props)
136
- @execution.reload
137
- @execution.phase_key.should == :error
138
- end
139
-
140
- end
141
-
142
- context 'j12を実行' do
143
- it "成功した場合" do
144
- @root.phase_key = :running
145
- @ctx[:e1].phase_key = :transmitted
146
- @ctx[:e2].phase_key = :transmitted
147
- @ctx[:j11].phase_key = :success
148
- @ctx[:j12].phase_key = :success
149
- @root.save!
150
- tengine.should_fire(:"success.jobnet.job.tengine",
151
- :source_name => @root.name_as_resource,
152
- :properties => @base_props)
153
- tengine.receive("success.job.job.tengine", :properties => {
154
- :target_job_id => @ctx[:j12].id.to_s
155
- }.update(@base_props))
156
- @root.reload
157
- @ctx.edge(:e3).phase_key.should == :transmitted
158
- @root.phase_key.should == :success
159
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
160
- end
161
-
162
- it "失敗した場合" do
163
- @root.phase_key = :running
164
- @ctx[:e1].phase_key = :transmitted
165
- @ctx[:e2].phase_key = :transmitted
166
- @ctx[:j11].phase_key = :success
167
- @ctx[:j12].phase_key = :error
168
- @root.save!
169
- tengine.should_fire(:"error.jobnet.job.tengine",
170
- :source_name => @root.name_as_resource,
171
- :properties => @base_props)
172
- tengine.receive("error.job.job.tengine", :properties => {
173
- :target_job_id => @ctx[:j12].id.to_s
174
- }.update(@base_props))
175
- @root.reload
176
- @ctx.edge(:e3).phase_key.should == :closed
177
- @root.phase_key.should == :error
178
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
179
- end
180
-
181
- it "上位のジョブネットがstuckしていた場合" do
182
- @root.phase_key = :stuck
183
- @root.save!
184
- tengine.receive("success.job.job.tengine", :properties => {
185
- :target_job_id => @ctx[:j12].id.to_s
186
- }.update(@base_props))
187
- @root.reload
188
- @root.phase_key.should == :stuck
189
- end
190
- end
191
-
192
- end
193
-
194
- # in [rjn0002]
195
- # |--e2-->(j11)--e4-->|
196
- # (S1)--e1-->[F1] [J1]--e6-->(E1)
197
- # |--e3-->(j12)--e5-->|
198
- context "rjn0002" do
199
- before do
200
- Tengine::Job::Vertex.delete_all
201
- builder = Rjn0002SimpleParallelJobnetBuilder.new
202
- @root = builder.create_actual
203
- @ctx = builder.context
204
- @execution = Tengine::Job::Execution.create!({
205
- :root_jobnet_id => @root.id,
206
- })
207
- @base_props = {
208
- :execution_id => @execution.id.to_s,
209
- :root_jobnet_id => @root.id.to_s,
210
- :root_jobnet_name_path => @root.name_path,
211
- :target_jobnet_id => @root.id.to_s,
212
- :target_jobnet_name_path => @root.name_path,
213
- }
214
- end
215
-
216
- it "最初のリクエスト" do
217
- [:e1, :e2, :e3, :e4, :e5, :e6].each{|name| @ctx[name].phase_key = :active}
218
- @root.phase_key = :ready
219
- @root.save!
220
- tengine.should_fire(:"start.job.job.tengine",
221
- :source_name => @ctx.vertex(:j11).name_as_resource,
222
- :properties => {
223
- :target_job_id => @ctx[:j11].id.to_s,
224
- :target_job_name_path => @ctx[:j11].name_path,
225
- }.update(@base_props))
226
- tengine.should_fire(:"start.job.job.tengine",
227
- :source_name => @ctx.vertex(:j12).name_as_resource,
228
- :properties => {
229
- :target_job_id => @ctx[:j12].id.to_s,
230
- :target_job_name_path => @ctx[:j12].name_path,
231
- }.update(@base_props))
232
- tengine.receive("start.jobnet.job.tengine", :properties => @base_props)
233
- @root.reload
234
- @root.phase_key.should == :starting
235
- @root.started_at.utc.iso8601.should == @now.utc.iso8601
236
- @ctx.vertex(:j11).phase_key.should == :ready
237
- @ctx.vertex(:j12).phase_key.should == :ready
238
- @ctx.edge(:e1).phase_key.should == :transmitted
239
- @ctx.edge(:e2).phase_key.should == :transmitting
240
- @ctx.edge(:e3).phase_key.should == :transmitting
241
- @ctx.edge(:e4).phase_key.should == :active
242
- @ctx.edge(:e5).phase_key.should == :active
243
- @ctx.edge(:e6).phase_key.should == :active
244
- end
245
-
246
- context 'j11を実行' do
247
- before do
248
- @root.phase_key = :running
249
- # j12は実行中
250
- @ctx[:e1].phase_key = :transmitted
251
- @ctx[:e2].phase_key = :transmitted
252
- @ctx[:e3].phase_key = :transmitted
253
- @ctx[:j11].phase_key = :running
254
- @ctx[:j12].phase_key = :running
255
- @root.save!
256
- end
257
-
258
- it "成功した場合" do
259
- @ctx[:j11].phase_key = :success
260
- @root.save!
261
- tengine.should_not_fire
262
- tengine.receive("success.job.job.tengine", :properties => {
263
- :target_job_id => @ctx[:j11].id.to_s,
264
- :target_job_name_path => @ctx[:j11].name_path,
265
- }.update(@base_props))
266
- @root.reload
267
- @ctx.vertex(:j12).phase_key.should == :running
268
- @ctx.edge(:e4).phase_key.should == :transmitted
269
- @ctx.edge(:e5).phase_key.should == :active
270
- @ctx.edge(:e6).phase_key.should == :active
271
- end
272
-
273
- it "失敗した場合" do
274
- @ctx[:j11].phase_key = :error
275
- @root.save!
276
- tengine.should_not_fire
277
- tengine.receive("error.job.job.tengine", :properties => {
278
- :target_job_id => @ctx[:j11].id.to_s,
279
- :target_job_name_path => @ctx[:j11].name_path,
280
- }.update(@base_props))
281
- @root.reload
282
- @ctx.vertex(:j12).phase_key.should == :running
283
- @ctx.edge(:e4).phase_key.should == :closed
284
- @ctx.edge(:e5).phase_key.should == :active
285
- @ctx.edge(:e6).phase_key.should == :closing
286
- end
287
- end
288
-
289
- context 'j12を実行' do
290
- context "j11は成功した場合" do
291
- before do
292
- @root.phase_key = :running
293
- @ctx[:e1].phase_key = :transmitted
294
- @ctx[:e2].phase_key = :transmitted
295
- @ctx[:e3].phase_key = :transmitted
296
- @ctx[:e4].phase_key = :transmitted
297
- @ctx[:j11].phase_key = :success
298
- @ctx[:j12].phase_key = :running
299
- @root.save!
300
- end
301
-
302
- it "成功した場合" do
303
- @ctx[:j12].phase_key = :success
304
- @root.save!
305
- tengine.should_fire(:"success.jobnet.job.tengine",
306
- :source_name => @root.name_as_resource,
307
- :properties => @base_props)
308
- tengine.receive("success.job.job.tengine", :properties => {
309
- :target_job_id => @ctx[:j12].id.to_s,
310
- }.update(@base_props))
311
- @root.reload
312
- @root.phase_key.should == :success
313
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
314
- @ctx.edge(:e5).phase_key.should == :transmitted
315
- @ctx.edge(:e6).phase_key.should == :transmitted
316
- end
317
-
318
- it "失敗した場合" do
319
- @ctx[:j12].phase_key = :error
320
- @root.save!
321
- tengine.should_fire(:"error.jobnet.job.tengine",
322
- :source_name => @root.name_as_resource,
323
- :properties => @base_props)
324
- tengine.receive("error.job.job.tengine", :properties => {
325
- :target_job_id => @ctx[:j12].id.to_s
326
- }.update(@base_props))
327
- @root.reload
328
- @root.phase_key.should == :error
329
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
330
- @ctx.edge(:e5).phase_key.should == :closed
331
- @ctx.edge(:e6).phase_key.should == :closed
332
- end
333
- end
334
-
335
- context "j11は失敗した場合" do
336
- before do
337
- @root.phase_key = :running
338
- @ctx[:e1].phase_key = :transmitted
339
- @ctx[:e2].phase_key = :transmitted
340
- @ctx[:e3].phase_key = :transmitted
341
- @ctx[:e4].phase_key = :closed
342
- @ctx[:e5].phase_key = :active
343
- @ctx[:e6].phase_key = :closing
344
- @ctx[:j11].phase_key = :error
345
- @ctx[:j12].phase_key = :running
346
- @root.save!
347
- end
348
-
349
- it "成功した場合" do
350
- @ctx[:j12].phase_key = :success
351
- @root.save!
352
- tengine.should_fire(:"error.jobnet.job.tengine",
353
- :source_name => @root.name_as_resource,
354
- :properties => @base_props)
355
- tengine.receive("success.job.job.tengine", :properties => {
356
- :target_job_id => @ctx[:j12].id.to_s,
357
- }.update(@base_props))
358
- @root.reload
359
- @root.phase_key.should == :error
360
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
361
- @ctx.edge(:e5).phase_key.should == :transmitted
362
- @ctx.edge(:e6).phase_key.should == :closed
363
- end
364
-
365
-
366
- it "失敗した場合" do
367
- @ctx[:j12].phase_key = :error
368
- @root.save!
369
- tengine.should_fire(:"error.jobnet.job.tengine",
370
- :source_name => @root.name_as_resource,
371
- :properties => @base_props)
372
- tengine.receive("error.job.job.tengine", :properties => {
373
- :target_job_id => @ctx[:j12].id.to_s,
374
- :target_job_name_path => @ctx[:j12].name_path,
375
- }.update(@base_props))
376
- @root.reload
377
- @root.phase_key.should == :error
378
- @root.finished_at.utc.iso8601.should == @now.utc.iso8601
379
- @ctx.edge(:e5).phase_key.should == :closed
380
- @ctx.edge(:e6).phase_key.should == :closed
381
- end
382
- end
383
- end
384
-
385
- end
386
-
387
- # in [rjn0010]
388
- # |-----e2----->(j11)-----e4----->|
389
- # [S1]--e1-->[F1] [J1]--e7-->[E1]
390
- # |--e3-->(j12)--e5-->(j13)--e6-->|
391
- context "rjn0010" do
392
- before do
393
- Tengine::Job::Vertex.delete_all
394
- builder = Rjn00102jobsAnd1jobParallelJobnetBuilder.new
395
- @root = builder.create_actual
396
- @ctx = builder.context
397
- @execution = Tengine::Job::Execution.create!({
398
- :root_jobnet_id => @root.id,
399
- })
400
- @base_props = {
401
- :execution_id => @execution.id.to_s,
402
- :root_jobnet_id => @root.id.to_s,
403
- :target_jobnet_id => @root.id.to_s,
404
- }
405
- end
406
-
407
- # j11, j12の実行は Rjn0002SimpleParallelJobnetBuilder と同じなので省略。
408
-
409
- # j11が失敗した際に、タイミングが悪くj12からj13へ処理が遷移する瞬間で、
410
- # j10にはactiveなvertexがない状態になった場合でも、j13が実行されてから
411
- # j10のfinished.jobnet.job.tengineイベントが発火されなければならない。
412
-
413
- # 動作としては j11が失敗すると、j11からE1までの間のe4とe7をclosedにする。
414
- # その後j12が終了すると、e5はclosedされていないので、transmitされてj13が動く。
415
- # その後j13が実行された後、e6をtransmitした際に、j10の全てのedgeがactiveで
416
- # なくなるので、j10は終了したと見なされる。
417
-
418
- context 'j11が失敗' do
419
- context "j12が同時に成功" do
420
- before do
421
- @root.phase_key = :running
422
- @ctx[:e1].phase_key = :transmitted
423
- @ctx[:e2].phase_key = :transmitted
424
- @ctx[:e3].phase_key = :transmitted
425
- @ctx[:j11].phase_key = :running
426
- @ctx[:j12].phase_key = :running
427
- @ctx[:j13].phase_key = :ready
428
- @root.save!
429
- end
430
-
431
- it do
432
- # j12が成功したという、finished.job.job.tengineイベントが投げられて、j13のstart.job.job.tengineが受信されるまでの間に、
433
- @ctx[:j12].phase_key = :success
434
- @ctx[:e5].phase_key = :active
435
- # j11が失敗したという finished.job.job.tengineイベントが受信された場合
436
- @ctx[:j11].phase_key = :error
437
- @root.save!
438
- tengine.should_not_fire # j13が動いていないので、e5,e6はactiveなので、ジョブネットは終了しません。
439
- tengine.receive("error.job.job.tengine", :properties => {
440
- :target_job_id => @ctx[:j11].id.to_s,
441
- }.update(@base_props))
442
- @root.reload
443
- @root.phase_key.should == :running
444
- @root.finished_at.should == nil
445
- @ctx.edge(:e4).phase_key.should == :closed
446
- @ctx.edge(:e5).phase_key.should == :active
447
- @ctx.edge(:e6).phase_key.should == :active
448
- @ctx.edge(:e7).phase_key.should == :closing
449
- end
450
- end
451
-
452
- end
453
-
454
- end
455
-
456
- context "start.jobnet.job.tengine.failed.tengined" do
457
- it "stuckにする" do
458
- Tengine::Core::Schedule.delete_all
459
- Tengine::Job::Vertex.delete_all
460
- builder = Rjn0001SimpleJobnetBuilder.new
461
- @root = builder.create_actual
462
- @ctx = builder.context
463
- @execution = Tengine::Job::Execution.create!({
464
- :root_jobnet_id => @root.id,
465
- })
466
- @root.phase_key = :initialized
467
- @root.save!
468
- EM.run_block do
469
- tengine.receive("start.jobnet.job.tengine.failed.tengined", :properties => {
470
- :original_event => {
471
- :event_type_name => "start.jobnet.job.tengine",
472
- :properties => {
473
- :execution_id => @execution.id.to_s,
474
- :root_jobnet_id => @root.id.to_s,
475
- :root_jobnet_name_path => @root.name_path,
476
- :target_jobnet_id => @root.id.to_s,
477
- :target_jobnet_name_path => @root.name_path,
478
- }}})
479
- end
480
- @root.reload
481
- @root.phase_key.should == :stuck
482
- end
483
-
484
- it "broken event" do
485
- Tengine::Core::Schedule.delete_all
486
- Tengine::Job::Vertex.delete_all
487
- builder = Rjn0001SimpleJobnetBuilder.new
488
- @root = builder.create_actual
489
- @ctx = builder.context
490
- @execution = Tengine::Job::Execution.create!({
491
- :root_jobnet_id => @root.id,
492
- })
493
- @root.phase_key = :initialized
494
- @root.save!
495
- EM.run_block do
496
- tengine.receive("start.jobnet.job.tengine.failed.tengined", :properties => {
497
- :original_event => {
498
- :event_type_name => "start.jobnet.job.tengine",
499
- :properties => {
500
- :execution_id => @execution.id.to_s,
501
- :root_jobnet_id => @root.id.to_s,
502
- :root_jobnet_name_path => @root.name_path,
503
- :target_job_id => @root.id.to_s,
504
- :target_jobnet_name_path => @root.name_path,
505
- }}})
506
- end
507
- @root.reload
508
- @root.children[1].phase_key.should == :initialized
509
- @root.phase_key.should_not == :stuck # initialized
510
- end
511
- end
512
-
513
- context "success.job.job.tengine.failed.tengined" do
514
- it "stuckにする(ただし上位のジョブネットを)" do
515
- Tengine::Core::Schedule.delete_all
516
- Tengine::Job::Vertex.delete_all
517
- builder = Rjn0001SimpleJobnetBuilder.new
518
- @root = builder.create_actual
519
- @ctx = builder.context
520
- @execution = Tengine::Job::Execution.create!({
521
- :root_jobnet_id => @root.id,
522
- })
523
- @root.phase_key = :initialized
524
- @root.save!
525
- EM.run_block do
526
- tengine.receive("success.job.job.tengine.failed.tengined", :properties => {
527
- :original_event => {
528
- :event_type_name => "success.job.job.tengine",
529
- :properties => {
530
- :execution_id => @execution.id.to_s,
531
- :root_jobnet_id => @root.id.to_s,
532
- :root_jobnet_name_path => @root.name_path,
533
- :target_jobnet_id => @root.id.to_s,
534
- :target_jobnet_name_path => @root.name_path,
535
- :target_job_id => @root.children[1].id.to_s,
536
- }}})
537
- end
538
- @root.reload
539
- @root.phase_key.should == :stuck
540
- end
541
- end
542
-
543
- context "error.job.job.tengine.failed.tengined" do
544
- it "stuckにする(ただし上位のジョブネットを)" do
545
- Tengine::Core::Schedule.delete_all
546
- Tengine::Job::Vertex.delete_all
547
- builder = Rjn0001SimpleJobnetBuilder.new
548
- @root = builder.create_actual
549
- @ctx = builder.context
550
- @execution = Tengine::Job::Execution.create!({
551
- :root_jobnet_id => @root.id,
552
- })
553
- @root.phase_key = :initialized
554
- @root.save!
555
- EM.run_block do
556
- tengine.receive("error.job.job.tengine.failed.tengined", :properties => {
557
- :original_event => {
558
- :event_type_name => "error.job.job.tengine",
559
- :properties => {
560
- :execution_id => @execution.id.to_s,
561
- :root_jobnet_id => @root.id.to_s,
562
- :root_jobnet_name_path => @root.name_path,
563
- :target_jobnet_id => @root.id.to_s,
564
- :target_jobnet_name_path => @root.name_path,
565
- :target_job_id => @root.children[1].id.to_s,
566
- }}})
567
- end
568
- @root.reload
569
- @root.phase_key.should == :stuck
570
- end
571
- end
572
-
573
-
574
- %w[
575
- success.jobnet.job.tengine.failed.tengined
576
- error.jobnet.job.tengine.failed.tengined
577
- stop.jobnet.job.tengine.failed.tengined
578
- ].each do |i|
579
- describe i do
580
- it "stuckにする" do
581
- Tengine::Core::Schedule.delete_all
582
- Tengine::Job::Vertex.delete_all
583
- builder = Rjn0001SimpleJobnetBuilder.new
584
- @root = builder.create_actual
585
- @ctx = builder.context
586
- @execution = Tengine::Job::Execution.create!({
587
- :root_jobnet_id => @root.id,
588
- })
589
- @root.phase_key = :initialized
590
- @root.save!
591
- EM.run_block do
592
- tengine.receive(i, :properties => {
593
- :original_event => {
594
- :event_type_name => "start.jobnet.job.tengine",
595
- :properties => {
596
- :execution_id => @execution.id.to_s,
597
- :root_jobnet_id => @root.id.to_s,
598
- :root_jobnet_name_path => @root.name_path,
599
- :target_jobnet_id => @root.id.to_s,
600
- :target_jobnet_name_path => @root.name_path,
601
- }}})
602
- end
603
- @root.reload
604
- @root.phase_key.should == :stuck
605
- end
606
- end
607
- end
608
- end