test/flowtestbase.rb in openwferu-0.9.10.653 vs test/flowtestbase.rb in openwferu-0.9.11

- old
+ new

@@ -18,22 +18,19 @@ require 'rutest_utils' include OpenWFE -#$SLEEP_TIME = 0.100 $WORKFLOW_ENGINE_CLASS = Engine persistence = ENV["__persistence__"] require "openwfe/engine/file_persisted_engine" if persistence if persistence == "pure-persistence" - #$SLEEP_TIME = 0.999 $WORKFLOW_ENGINE_CLASS = FilePersistedEngine elsif persistence == "cached-persistence" - #$SLEEP_TIME = 0.250 $WORKFLOW_ENGINE_CLASS = CachedFilePersistedEngine end puts @@ -45,11 +42,11 @@ attr_reader \ :engine, :tracer def setup - @engine = $WORKFLOW_ENGINE_CLASS.new() + @engine = $WORKFLOW_ENGINE_CLASS.new @engine.application_context[:ruby_eval_allowed] = true @tracer = Tracer.new @engine.application_context["__tracer"] = @tracer @@ -119,22 +116,10 @@ OpenWFE::LaunchItem.new(flowDef) end fei = @engine.launch(li) - #if join == true - # @engine.get_scheduler.join_until_no_more_jobs - #elsif join.is_a?(Numeric) - # sleep join - #end - #if join.is_a?(Numeric) - # sleep join - #elsif join == true - # @engine.wait_for_engine - #else - # sleep $SLEEP_TIME - #end if join.is_a?(Numeric) sleep join else @engine.wait_for fei end @@ -177,11 +162,11 @@ if allowRemainingExpressions engine.get_expression_storages.each do |storage| storage.purge end - return + return fei end exp_storage = engine.get_expression_storage if exp_storage.length != 1 @@ -198,7 +183,31 @@ "(#{exp_storage.length})" return fei end +end + +# +# A bunch of methods for testing the journal component +# +module JournalTestBase + + def get_journal + @engine.get_journal + end + + def get_error_count (wfid) + + fn = get_journal.workdir + "/" + wfid + ".journal" + + get_journal.flush_buckets + + events = get_journal.load_events(fn) + + error_count = 0 + events.each { |evt| error_count += 1 if evt[0] == :error } + + error_count + end end