Workflow test runs can be configured to automate tests
Originally developed for testing purposes, the WorkflowTestRunner to run workflows automatically in a Stand Alone environment is now also used in “live” systems. This use has been proven to be performing well in practice and is now fully supported by Deltares. See also 03 Testing workflows with the WorkflowTestRunner in SA mode
This module allows you to automate test and to run workflows with or without starting-up the user interface. As such, it can also be used to automate tasks in stand-alone systems, for example in combination with the windows task scheduler (or cron in linux systems).
fig1: layout of the workflowtestrun configuration
The workflow test run configuration consists of two main parts: General configuration and Activities
Give an optional description of the workflow test run
Optional directory references which can be use to refer to directories using a short name.
- refName the name which will be used to refer to the directory
- dir the directory to refer to.
Optional time to use as system time while running the workflow test. If the system time is not given it is taken from the current computer time.
- date date as yyyy-MM-dd
- time the time of day as HH:mm:ss
The activities of the workflow test run configuration that will be carried out. You can use activities in any order you like, they will be executed as ordered in your configuration file.
This activity can be used to remove files or directories to e.g. create an initial situation or to clean up after running the test.
- description optional description of the purge activity
- filter name of a file, directory. wild cards can be used (e.g. *test.*)
- clearLocalDatastore Empty element that empties the database
Activity can be used to copy files or directories between two locations e.g. to copy files to import to the applications import directory
- description optional description of the copy activity
- src source that should be copied to the given destination, wild cards can be used to refine your source
- dest destination where the source should be copied to. wild cards can be used to refine your destination
Runs the workflow file with the given id. The id must be known in the application environment.
taskProperties: Use a taskProperties configuration block to define how to run the workflow
- workflowId: identifier of workflow to run
- systemTime: (optional) overruling system time for running workflow
Exports the given time series to PI formatted file.
- exportFile path that specifies the location and name of the export file
- timeSeriesSet time series set as specified here
Exports the log messages produced during the last workflow run.
- exportFile file to which the logs will be exported.
- logLevel Level from which to export the log messages (DEBUG, INFO, WARN or ERROR)http://public.wldelft.nl/display/FEWSDOC/02+Data+Handling+in+DELFT-FEWS#02DataHandlinginDELFT-FEWS-TimeSeriesSets
- moduleInstanceId: (optional) Only export logs created by configured moduleinstance run.
Changes the system time.
- systemTime New system time.
Compares an exported file with a given reference file. The comparison will be visible in the log output of the application environment.
- exportFile location of the file that is to be checked with the reference file
- compareFile location of the file to compare export file with
Refreshes datastore. Empty element.
Search for the presence of text in a file
- searchFile file to search through
- searchString array of strings to search for
- emptyFile check if file is empty
Let process sleep for configured amount of milli seconds
Workflow test runs can either be started from within a FEWS stand-alone application, or within a JUnit test.
Run workflow test runs from within a FEWS stand-alone
To start a workflow test in DELFT-FEWS open the debug menu (F12) and select 'run workflow test' (C). This will open an open file dialog in which you can select a workflow configuration file to run in the current environment.
Run workflow test runs from JUnit tests
Workflow test runs can be started in JUnit tests in order to build (nightly) regression tests. To do so, initialize the test environment and create a datastore to pass to the workflow constructor. Next code snipped demonstrates the use of WorkflowTestRun in JUnit:
Run workflow test runs from bin dir
Workflow test runs can be started from the command line. To do so one must configure a Region as they would for a Stand Alone system.
Before 2014.02, configure in the bin directory the 'Region.exe' and 'Region.jpif' files. For the JPIF file some adaptation must be made. Here is an example:
From 2014.02 to 2017.02, this was done via an ini file:
Check the attachment workflow_test_run for an example.
Since 2018.02, the required flags should be set when calling FEWS from the command line. This can be done conveniently with the simple DOS batch file below. Note that one should at minimum specify the root folder where the FEWS bin is stored, the regionHome directory, the patch, and the WorkflowTestRun file that is to be executed.
The normal startup script in linux systems is shown below: