PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/test/functional/ft_1_process_status.rb

http://github.com/jmettraux/ruote
Ruby | 838 lines | 574 code | 238 blank | 26 comment | 4 complexity | fe9316f0ce70eeb39ca39fdd38690a51 MD5 | raw file
  1. #
  2. # testing ruote
  3. #
  4. # Fri May 15 09:51:28 JST 2009
  5. #
  6. require File.expand_path('../base', __FILE__)
  7. require 'ruote/participant'
  8. class FtProcessStatusTest < Test::Unit::TestCase
  9. include FunctionalBase
  10. def test_process
  11. pdef = Ruote.process_definition :name => 'my process' do
  12. participant :ref => 'alpha'
  13. end
  14. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  15. wfid = @dashboard.launch(pdef, :workitem => { 'kilroy' => 'was here' })
  16. wait_for(:alpha)
  17. ps = @dashboard.process(wfid)
  18. assert_equal 'my process', ps.definition_name
  19. assert_equal nil, ps.definition_revision
  20. assert_not_nil ps.launched_time
  21. assert_equal(
  22. {"my process"=>["0", ["define", {"name"=>"my process"}, [["participant", {"ref"=>"alpha"}, []]]]]},
  23. ps.variables)
  24. end
  25. def test_variables
  26. pdef = Ruote.process_definition 'my process' do
  27. sequence do
  28. set :var => 'toto', :val => 'nada'
  29. participant :ref => 'alpha'
  30. end
  31. end
  32. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  33. wfid = @dashboard.launch(pdef, :workitem => { 'kilroy' => 'was here' })
  34. wait_for(:alpha)
  35. ps = @dashboard.process(wfid)
  36. assert_equal 'my process', ps.definition_name
  37. assert_equal(
  38. {"my process"=>["0", ["define", {"my process"=>nil}, [["sequence", {}, [["set", {"var"=>"toto", "val"=>"nada"}, []], ["participant", {"ref"=>"alpha"}, []]]]]]], "toto"=>"nada"},
  39. ps.variables)
  40. end
  41. def test_errors
  42. pdef = Ruote.process_definition 'my process' do
  43. nada
  44. end
  45. wfid = @dashboard.launch(pdef)
  46. wait_for(wfid)
  47. errs = @dashboard.errors
  48. assert_equal 1, errs.size
  49. assert_equal wfid, errs.first.wfid
  50. err = @dashboard.errors(wfid)
  51. assert_equal 1, err.size
  52. assert_equal wfid, err.first.wfid
  53. assert_equal 1, @dashboard.errors(:count => true)
  54. end
  55. def test_current_tree
  56. pdef = Ruote.process_definition 'my process' do
  57. sequence do
  58. echo 'ok'
  59. participant :ref => :alpha
  60. end
  61. end
  62. alpha = @dashboard.register :alpha, Ruote::NullParticipant
  63. wfid = @dashboard.launch(pdef)
  64. wait_for('dispatched')
  65. ps = @dashboard.process(wfid)
  66. assert_equal(
  67. ["define", {"my process"=>nil}, [
  68. ["sequence", {}, [
  69. ["echo", {"ok"=>nil}, []],
  70. ["participant", {"ref"=>"alpha"}, []]]]]],
  71. ps.current_tree)
  72. assert_equal(
  73. ["define", {"my process"=>nil}, [
  74. ["sequence", {}, [
  75. ["echo", {"ok"=>nil}, []],
  76. ["participant", {"ref"=>"alpha"}, []]]]]],
  77. ps.original_tree)
  78. #
  79. # tinkering with trees ...
  80. e = ps.expressions.find { |e| e.fei.expid == '0_0_1' }
  81. e.update_tree([ 'participant', { 'ref' => 'bravo' }, [] ])
  82. assert_equal(
  83. ["define", {"my process"=>nil}, [
  84. ["sequence", {}, [
  85. ["echo", {"ok"=>nil}, []],
  86. ["participant", {"ref"=>"alpha"}, []]]]]],
  87. ps.original_tree)
  88. assert_equal(
  89. ["define", {"my process"=>nil}, [
  90. ["sequence", {}, [
  91. ["echo", {"ok"=>nil}, []],
  92. ["participant", {"ref"=>"bravo"}, []]]]]],
  93. ps.current_tree)
  94. end
  95. def test_current_tree_and_re_apply
  96. pdef = Ruote.process_definition 'my process' do
  97. sequence do
  98. echo 'ok'
  99. participant :ref => :alpha
  100. end
  101. end
  102. alpha = @dashboard.register :alpha, Ruote::NullParticipant
  103. wfid = @dashboard.launch(pdef)
  104. wait_for('dispatched')
  105. ps = @dashboard.process(wfid)
  106. exp = ps.expressions.find { |fexp| fexp.fei.expid == '0_0_1' }
  107. @dashboard.re_apply(
  108. exp,
  109. :tree =>
  110. [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'alpha', {}, [] ] ] ])
  111. wait_for('dispatched')
  112. ps = @dashboard.process(wfid)
  113. assert_equal(
  114. ["define", {"my process"=>nil}, [
  115. ["sequence", {}, [
  116. ["echo", {"ok"=>nil}, []],
  117. ["sequence", {"_triggered"=>"on_re_apply"}, [
  118. ["participant", {"ref"=>"alpha"}, []],
  119. ["alpha", {}, []]]]]]]],
  120. ps.current_tree)
  121. end
  122. def test_tree_when_define_rewrites_it
  123. pdef = Ruote.process_definition 'my process' do
  124. participant :ref => :alpha
  125. define 'sub0' do
  126. echo 'meh'
  127. end
  128. end
  129. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  130. wfid = @dashboard.launch(pdef)
  131. wait_for(:alpha)
  132. ps = @dashboard.process(wfid)
  133. assert_equal(
  134. {"my process"=>["0", ["define", {"my process"=>nil}, [["define", {"sub0"=>nil}, [["echo", {"meh"=>nil}, []]]], ["participant", {"ref"=>"alpha"}, []]]]], "sub0"=>["0_0", ["define", {"sub0"=>nil}, [["echo", {"meh"=>nil}, []]]]]},
  135. ps.variables)
  136. assert_equal(
  137. ["define", {"my process"=>nil}, [
  138. ["define", {"sub0"=>nil}, [
  139. ["echo", {"meh"=>nil}, []]]],
  140. ["participant", {"ref"=>"alpha"}, []]]],
  141. ps.current_tree)
  142. assert_equal(
  143. ["define", {"my process"=>nil}, [
  144. ["define", {"sub0"=>nil}, [
  145. ["echo", {"meh"=>nil}, []]]],
  146. ["participant", {"ref"=>"alpha"}, []]]],
  147. ps.original_tree)
  148. end
  149. def test_all_variables
  150. pdef = Ruote.process_definition do
  151. define 'sub0' do
  152. sequence do
  153. set :var => 'v1', :val => 1
  154. alpha
  155. end
  156. end
  157. sequence do
  158. set :var => 'v0', :val => 0
  159. sub0
  160. end
  161. end
  162. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  163. wfid = @dashboard.launch(pdef)
  164. wait_for(:alpha)
  165. ps = @dashboard.process(wfid)
  166. assert_equal(0, ps.variables['v0'])
  167. assert_equal(nil, ps.variables['v1'])
  168. #p ps.all_variables
  169. assert_equal(2, ps.all_variables.size)
  170. h = ps.all_variables.values.inject({}) { |h, vh| h.merge!(vh) }
  171. assert_equal(0, h['v0'])
  172. assert_equal(1, h['v1'])
  173. end
  174. def test_tags
  175. pdef = Ruote.process_definition do
  176. sequence :tag => 'main' do
  177. alpha :tag => 'part'
  178. end
  179. end
  180. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  181. wfid = @dashboard.launch(pdef)
  182. wait_for(:alpha)
  183. ps = @dashboard.process(wfid)
  184. assert_equal %w[ main main/part part ], ps.tags.keys.sort
  185. assert_equal %w[ main main/part part ], ps.all_tags.keys.sort
  186. assert_equal 3, ps.all_tags.size
  187. assert_kind_of Array, ps.all_tags['main']
  188. assert_equal 1, ps.all_tags['main'].size
  189. end
  190. def test_all_tags
  191. pdef = Ruote.process_definition do
  192. define 'sub0' do
  193. sequence :tag => 'tag0' do
  194. alpha
  195. end
  196. end
  197. sequence :tag => 'tag0' do
  198. sub0
  199. end
  200. end
  201. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  202. wfid = @dashboard.launch(pdef)
  203. wait_for(:alpha)
  204. ps = @dashboard.process(wfid)
  205. assert_equal 2, ps.tags.size
  206. assert_equal 2, ps.all_tags['tag0'].size
  207. end
  208. def test_processes
  209. pdef = Ruote.process_definition :name => 'my process' do
  210. participant :ref => 'alpha'
  211. end
  212. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  213. wfid0 = @dashboard.launch(pdef)
  214. wfid1 = @dashboard.launch(pdef)
  215. wait_for(:alpha)
  216. wait_for(:alpha)
  217. ps = @dashboard.processes
  218. assert_equal 2, ps.size
  219. assert_equal [ wfid0, wfid1 ].sort, ps.collect { |e| e.wfid }.sort
  220. assert_equal 2, alpha.size
  221. end
  222. def test_processes_and_leftovers
  223. n = 3
  224. @dashboard.register_participant :alpha, Ruote::StorageParticipant
  225. n.times.collect { @dashboard.launch(Ruote.define { alpha }) }
  226. while @dashboard.storage_participant.size < n; sleep 0.100; end
  227. sleep 0.100
  228. @dashboard.ps(@dashboard.storage_participant.first.wfid).expressions.each do |exp|
  229. @dashboard.storage.delete(exp.h)
  230. end
  231. # nuking all the expressions of a process instance
  232. assert_equal n - 1, @dashboard.processes.size
  233. assert_equal n, @dashboard.storage_participant.size
  234. # orphan workitem left in storage
  235. assert_equal 1, @dashboard.leftovers.size
  236. end
  237. def test_left_overs
  238. [
  239. { '_id' => '0!f!x', 'type' => 'workitems', 'fei' => { 'wfid' => 'x' } },
  240. { '_id' => '0!f!y', 'type' => 'errors', 'fei' => { 'wfid' => 'y' } },
  241. { '_id' => '0!f!a', 'type' => 'workitems', 'fei' => { 'wfid' => 'a' } },
  242. { '_id' => '0!f!a', 'type' => 'expressions', 'fei' => { 'wfid' => 'a' } },
  243. { '_id' => '0!f!z', 'type' => 'schedules', 'fei' => { 'wfid' => 'z' },
  244. 'at' => Ruote.time_to_utc_s(Time.now + 24 * 3600) }
  245. ].each do |doc|
  246. @dashboard.storage.put(doc)
  247. end
  248. assert_equal(
  249. 3,
  250. @dashboard.leftovers.size)
  251. assert_equal(
  252. %w[ workitems errors schedules ],
  253. @dashboard.leftovers.collect { |lo| lo['type'] })
  254. end
  255. def test_tree_rewrite
  256. pdef = Ruote.process_definition :name => 'test' do
  257. sequence do
  258. alpha
  259. bravo
  260. charly
  261. end
  262. delta
  263. end
  264. @dashboard.register_participant :alpha do |wi, fexp|
  265. tracer << "a\n"
  266. parent = fexp.parent
  267. parent.update_tree
  268. parent.updated_tree[2][1] = [ 'charly', {}, [] ]
  269. parent.persist
  270. end
  271. @dashboard.register_participant :bravo do |wi, fexp|
  272. tracer << "b\n"
  273. end
  274. @dashboard.register_participant :charly do |wi, fexp|
  275. tracer << "c\n"
  276. stash[:tree0] = fexp.context.engine.process(fexp.fei.wfid).current_tree
  277. end
  278. @dashboard.register_participant :delta do |wi, fexp|
  279. tracer << "d\n"
  280. stash[:tree1] = fexp.context.engine.process(fexp.fei.wfid).current_tree
  281. end
  282. assert_trace %w[ a c c d ], pdef
  283. assert_equal(
  284. ["define", {"name"=>"test"}, [
  285. ["sequence", {}, [
  286. ["alpha", {}, []],
  287. ["charly", {}, []],
  288. ["participant", {"ref"=>"charly"}, []]]],
  289. ["delta", {}, []]]],
  290. @dashboard.context.stash[:tree0])
  291. assert_equal(
  292. ["define", {"name"=>"test"}, [
  293. ["sequence", {}, [
  294. ["alpha", {}, []],
  295. ["charly", {}, []],
  296. ["charly", {}, []]]],
  297. ["participant", {"ref"=>"delta"}, []]]],
  298. @dashboard.context.stash[:tree1])
  299. end
  300. def test_when_on_cancel_subprocess
  301. pdef = Ruote.process_definition :name => 'test' do
  302. sequence :on_cancel => 'sub0' do
  303. alpha
  304. end
  305. define 'sub0' do
  306. alpha
  307. end
  308. end
  309. alpha = @dashboard.register :alpha, Ruote::StorageParticipant
  310. wfid = @dashboard.launch(pdef)
  311. wait_for(:alpha)
  312. @dashboard.cancel_process(wfid)
  313. wait_for(:alpha)
  314. wait_for(1)
  315. assert_match wfid, alpha.first.fei.wfid
  316. assert_not_nil alpha.first.fei.subid
  317. assert_equal 0, @dashboard.process(wfid).errors.size
  318. assert_equal 4, @dashboard.process(wfid).expressions.size
  319. assert_equal(
  320. ["define", {"name"=>"test"}, [
  321. ["define", {"sub0"=>nil}, [["alpha", {}, []]]],
  322. ["sequence", {"on_cancel"=>"sub0"}, [["alpha", {}, []]]]]],
  323. @dashboard.process(wfid).original_tree)
  324. assert_equal(
  325. ["define", {"name"=>"test"}, [
  326. ["define", {"sub0"=>nil}, [
  327. ["alpha", {}, []]]],
  328. ["subprocess", {"_triggered"=>"on_cancel", "ref"=>"sub0"}, [
  329. ["define", {"sub0"=>nil}, [
  330. ["participant", {"ref"=>"alpha"}, []]]]]]]],
  331. @dashboard.process(wfid).current_tree)
  332. end
  333. def test_fexp_to_h
  334. pdef = Ruote.process_definition :name => 'my process' do
  335. participant :ref => 'alpha'
  336. end
  337. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  338. wfid = @dashboard.launch(pdef)
  339. wait_for(:alpha)
  340. ps = @dashboard.process(wfid)
  341. h = ps.expressions.find { |hf|
  342. hf.is_a?(Ruote::Exp::ParticipantExpression)
  343. }.to_h
  344. assert_equal 'participant', h['name']
  345. assert_equal 'alpha', h['participant_name']
  346. assert_equal ["participant", {"ref"=>"alpha"}, []], h['original_tree']
  347. end
  348. def test_to_dot
  349. pdef = Ruote.process_definition :name => 'my process' do
  350. concurrence do
  351. participant :ref => 'alpha'
  352. participant :ref => 'bravo'
  353. end
  354. end
  355. alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant
  356. wfid = @dashboard.launch(pdef)
  357. wait_for(:alpha)
  358. ps = @dashboard.process(wfid)
  359. #puts
  360. #puts ps.to_dot
  361. dot = ps.to_dot
  362. dot = dot.gsub(wfid, 'wfid')
  363. dot = dot.gsub(/![^!]+!/, '!!')
  364. dot = dot.gsub(/wfid [^ ]+ /, 'wfid ')
  365. dot = dot.strip
  366. assert_equal(
  367. %{
  368. digraph "process wfid {
  369. "0!!wfid" [ label="wfid 0 define" ];
  370. "0!!wfid" -> "0_0!!wfid";
  371. "0_0!!wfid" [ label="wfid 0_0 concurrence" ];
  372. "0_0!!wfid" -> "0!!wfid";
  373. "0_0!!wfid" -> "0_0_0!!wfid";
  374. "0_0!!wfid" -> "0_0_1!!wfid";
  375. "0_0_0!!wfid" [ label="wfid 0_0_0 participant" ];
  376. "0_0_0!!wfid" -> "0_0!!wfid";
  377. "0_0_1!!wfid" [ label="wfid 0_0_1 participant" ];
  378. "0_0_1!!wfid" -> "0_0!!wfid";
  379. "err_0_0_1!!wfid" [ label = "error : #<ArgumentError: no participant named 'bravo'>" ];
  380. "err_0_0_1!!wfid" -> "0_0_1!!wfid" [ style = "dotted" ];
  381. }
  382. }.strip,
  383. dot)
  384. end
  385. def test_last_active
  386. pdef = Ruote.define do
  387. alpha
  388. bravo
  389. end
  390. @dashboard.register_participant '.+', Ruote::StorageParticipant
  391. wfid = @dashboard.launch(pdef)
  392. @dashboard.wait_for(:alpha)
  393. t0 = Time.parse(@dashboard.process(wfid).last_active)
  394. sp = @dashboard.storage_participant
  395. sp.proceed(sp.first)
  396. @dashboard.wait_for(:bravo)
  397. t1 = Time.parse(@dashboard.process(wfid).last_active)
  398. assert t1 > t0
  399. end
  400. def test_position
  401. pdef = Ruote.define do
  402. alpha :task => 'clean car'
  403. end
  404. @dashboard.register_participant '.+', Ruote::StorageParticipant
  405. wfid = @dashboard.launch(pdef)
  406. @dashboard.wait_for(:alpha)
  407. assert_equal(
  408. [ [ 'alpha', { 'task' => 'clean car' } ] ],
  409. @dashboard.process(wfid).position.collect { |pos| pos[1..-1] })
  410. # #position leverages #workitems
  411. assert_equal(
  412. [ [ wfid, 'alpha' ] ],
  413. @dashboard.process(wfid).workitems.collect { |wi|
  414. [ wi.fei.wfid, wi.participant_name ]
  415. })
  416. end
  417. def test_position_when_error
  418. pdef = Ruote.define do
  419. participant
  420. end
  421. wfid = @dashboard.launch(pdef)
  422. @dashboard.wait_for(wfid)
  423. assert_equal 1, @dashboard.process(wfid).errors.size
  424. assert_equal(
  425. [ [ nil,
  426. { 'error' => '#<ArgumentError: no participant name specified>' } ] ],
  427. @dashboard.process(wfid).position.collect { |pos| pos[1..-1] })
  428. end
  429. def test_ps_with_stored_workitems
  430. @dashboard.register_participant '.+', Ruote::StorageParticipant
  431. wfid = @dashboard.launch(Ruote.define { alpha })
  432. @dashboard.wait_for(:alpha)
  433. ps = @dashboard.process(wfid)
  434. assert_equal 1, ps.stored_workitems.size
  435. assert_equal Ruote::Workitem, ps.stored_workitems.first.class
  436. end
  437. def test_ps_without_stored_workitems
  438. @dashboard.register_participant '.+', Ruote::NullParticipant
  439. wfid = @dashboard.launch(Ruote.define { alpha })
  440. @dashboard.wait_for(:alpha)
  441. ps = @dashboard.process(wfid)
  442. assert_equal 0, ps.stored_workitems.size
  443. end
  444. def test_schedules
  445. @dashboard.register_participant '.+', Ruote::NullParticipant
  446. wfid = @dashboard.launch(Ruote.define { alpha :timeout => '2d' })
  447. @dashboard.wait_for(:alpha)
  448. assert_equal 1, @dashboard.schedules.size
  449. assert_equal 1, @dashboard.schedules(:count => true)
  450. end
  451. def test_processes_and_schedules
  452. @dashboard.register_participant '.+', Ruote::NullParticipant
  453. wfid = @dashboard.launch(Ruote.define { alpha :timeout => '2d' })
  454. @dashboard.wait_for(:alpha)
  455. ps = @dashboard.process(wfid)
  456. assert_equal 1, ps.schedules.size
  457. assert_match /^0_0![a-f0-9]+!#{wfid}$/, ps.schedules.first['target'].sid
  458. end
  459. def test_ps_pagination
  460. n = 7
  461. @dashboard.register_participant '.+', Ruote::StorageParticipant
  462. wfids = (1..n).collect { |i|
  463. @dashboard.launch(Ruote.define { alpha })
  464. }.sort
  465. while @dashboard.storage_participant.size < n; sleep 0.140; end
  466. assert_equal wfids, @dashboard.process_wfids
  467. assert_equal(
  468. wfids,
  469. @dashboard.processes.collect { |ps| ps.wfid })
  470. assert_equal(
  471. wfids,
  472. @dashboard.processes(:test => :garbage).collect { |ps| ps.wfid })
  473. # prompted by
  474. # http://groups.google.com/group/openwferu-users/browse_thread/thread/ee493bdf8d8cdb37
  475. assert_equal(
  476. wfids[0, 3],
  477. @dashboard.processes(:limit => 3).collect { |ps| ps.wfid })
  478. assert_equal(
  479. wfids[3, 3],
  480. @dashboard.processes(:skip => 3, :limit => 3).collect { |ps| ps.wfid })
  481. #puts "==="
  482. #wfids.each { |wfid| puts wfid }
  483. #puts "---"
  484. #@dashboard.processes(:limit => 3, :descending => false).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
  485. #puts "---"
  486. #@dashboard.processes(:limit => 3, :descending => true).collect { |ps| ps.wfid }.each { |wfid| puts wfid }
  487. assert_equal(
  488. wfids.reverse[0, 3],
  489. @dashboard.processes(
  490. :limit => 3, :descending => true
  491. ).collect { |ps| ps.wfid })
  492. assert_equal(
  493. n,
  494. @dashboard.processes(:count => true))
  495. end
  496. # Issue identified by David Goodlad :
  497. #
  498. # http://gist.github.com/600451
  499. #
  500. def test_ps_and_schedules
  501. pdef = Ruote.define do
  502. concurrence do
  503. wait '4h'
  504. wait '2h'
  505. end
  506. end
  507. wfid = @dashboard.launch(pdef)
  508. @dashboard.wait_for(4)
  509. #assert_equal 1, @dashboard.processes.size
  510. assert_equal [ wfid ], @dashboard.processes.collect { |ps| ps.wfid }
  511. end
  512. def test_ps
  513. @dashboard.register 'alpha', Ruote::NullParticipant
  514. wfid = nil
  515. 2.times { wfid = @dashboard.launch(Ruote.define { alpha }) }
  516. @dashboard.wait_for(4)
  517. assert_equal 2, @dashboard.ps.size
  518. assert_equal wfid, @dashboard.ps(wfid).wfid
  519. end
  520. def test_definition_name
  521. pdef = Ruote.process_definition :name => 'invictus' do
  522. alpha
  523. end
  524. alpha = @dashboard.register_participant :alpha, Ruote::NullParticipant
  525. wfid = @dashboard.launch(pdef)
  526. wait_for(:alpha)
  527. assert_equal 'invictus', @dashboard.process(wfid).definition_name
  528. exp = @dashboard.process(wfid).expressions.first
  529. @dashboard.storage.delete(exp.h)
  530. assert_nil @dashboard.process(wfid).definition_name
  531. assert_nil @dashboard.process(wfid).definition_revision
  532. end
  533. def test_leaves
  534. pdef = Ruote.define do
  535. concurrence do
  536. alpha
  537. wait '1w'
  538. end
  539. end
  540. @dashboard.register_participant :alpha, Ruote::NullParticipant
  541. wfid = @dashboard.launch(pdef)
  542. wait_for(:alpha)
  543. wait_for(1)
  544. leaves = @dashboard.process(wfid).leaves
  545. assert_equal(
  546. [ "0_0_0:Ruote::Exp::ParticipantExpression:",
  547. "0_0_1:Ruote::Exp::WaitExpression:" ],
  548. leaves.collect { |fexp|
  549. [ fexp.fei.expid,
  550. fexp.class.to_s,
  551. fexp.error ? fexp.error.message : '' ].join(':')
  552. })
  553. end
  554. def test_leaves_when_errors
  555. pdef = Ruote.define do
  556. concurrence do
  557. wait '1w'
  558. participant
  559. alpha
  560. end
  561. end
  562. @dashboard.register_participant :alpha, Ruote::NullParticipant
  563. wfid = @dashboard.launch(pdef)
  564. wait_for(:alpha)
  565. wait_for(1)
  566. leaves = @dashboard.process(wfid).leaves
  567. assert_equal(
  568. [ "0_0_0:Ruote::Exp::WaitExpression:",
  569. "0_0_1:Ruote::Exp::ParticipantExpression:#<ArgumentError: no participant name specified>",
  570. "0_0_2:Ruote::Exp::ParticipantExpression:" ],
  571. leaves.collect { |fexp|
  572. [ fexp.fei.expid,
  573. fexp.class.to_s,
  574. fexp.error ? fexp.error.message : '' ].join(':')
  575. })
  576. end
  577. def test_root_workitem
  578. pdef = Ruote.define do
  579. alpha
  580. end
  581. @dashboard.register_participant :alpha, Ruote::NullParticipant
  582. wfid = @dashboard.launch(pdef, 'small' => 'town')
  583. wait_for(:alpha)
  584. wi = @dashboard.process(wfid).root_workitem
  585. assert_equal 'town', wi.fields['small']
  586. end
  587. def test_to_h
  588. @dashboard.register_participant :alpha, Ruote::StorageParticipant
  589. pdef = Ruote.define do
  590. concurrence do
  591. alpha
  592. wait '1d'
  593. nada
  594. end
  595. end
  596. wfid = @dashboard.launch(pdef)
  597. @dashboard.wait_for(7)
  598. assert_equal Hash, @dashboard.ps(wfid).to_h.class
  599. end
  600. end