Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The suite definition describes the static structure, its it's not until the definition is loaded in the server, that we see its dynamic behaviour.

With ecflow python apiAPI, the dynamic behaviour of the suite can be simulated, ( i.e. in the same manner as the server).

...

  • Exercise the suite definition. There is no need for '.ecf' files
  • Allows for very easy experimentation.
  • Can be done on the client-side, no need for server
  • Can help in detecting deadlock's
  • Will simulate with both 'real' and 'hybrid' clocks
  • A year's simulation can be done in a few seconds
  • Can be added as a unit test, to prevent regressions

The simulation relies on you adding simple verification attributes. (This is similar to c/c++/python asserts). These can be added on to a task, family, and suite nodes. (see below for an example)

There are however restrictions. If the definition has large loops due to, crons or  Repeat attributes, which run indefinitely, then in this case the simulation will never complete, and will timeout after a years year's worth of run time.

This can be compensated for by adding start and end clock. If no start/end clock is specified, the simulator makes the following assumption about the simulation period.

  • No time dependencies - simulate for 24 hours.
  • day attributes              attributes                - simulate for 1 week
  • date attributes             attributes              - simulate for 1 month
  • cron attributes             attributes              - simulate for 1 year
  • repeat attributes             - simulate for 1 year

Additionally if time base attributes like, time, today,cron have has no minutes, then the simulator will use 1-hour resolution.

Here is an example of a text-based suite definition that use uses a verify attribute, for which we want to check our assumption about the dynamic behaviour.

...

This python segment shows how to load a text-based suite definition(cron.def) and simulate it in python.

...

  • defs.depth: This file shows a depth-first view, of why simulation did not complete.
  • defs.flat: This shows a simple flat view, of why simulation did not complete

...

This simulation is expected to fail , since we have a deadlock/ race condition


Code Block
suite dead_lock
  family family
    task t1
      trigger t2 == complete
    task t2
      trigger t1 == complete
  endfamily
endsuite



Code Block
languagepy
titlesimulate a deadlock. Create definition in python
fron
from ecflow import Defs,Suite,Family,Task,Trigger
defs = Defs(
        Suite("dead_lock",
            Family('family',
                Task('t1', 
Trigger("t2 == complete")),
                Task('t2', 
Trigger("t1 == complete")))))

theResult = defs.simulate(); # simulate the definition
assert len(theResult) != 0, "Expected simulation to return errors" 
print theResult