...
What | nameofinstance.xml |
---|---|
Description | Workflow test runs can be configured to automate tests |
schema location |
Table of Contents |
---|
Warning |
---|
This component is only intended for test purposes, not for production use. |
Introduction
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).
Configuration
fig1: layout of the workflowtestrun configuration
The workflow test run configuration consists of two main parts: General configuration and Activities
General
description
Give an optional description of the workflow test run
dirDefinition
Optional directory references which can be use to refer to directories using a short name.
attributes:
- refName the name which will be used to refer to the directory
- dir the directory to refer to.
systemTime
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.
attributes:
- date date as yyyy-MM-dd
- time the time of day as HH:mm:ss
Activities
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.
PurgeActivity
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.
attributes:
- description optional description of the purge activity
- filter name of a file, directory. wild cards can be used (e.g. *test.*)
CopyActivity
Activity can be used to copy files or directories between two locations e.g. to copy files to import to the applications import directory
attributes:
- 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
WorkflowActivity
Runs the workflow file with the given id. The id must be known in the application environment.
ExportTimeSeriesActivity
Exports the given time series to PI formatted file.
attributes:
- exportFile path that specifies the location and name of the export file
- timeSeriesSet time series set as specified here
CompareActivity
Compares an exported file with a given reference file. The comparison will be visible in the log output of the application environment.
attributes:
- exportFile location of the file that is to be checked with the reference file
- compareFile location of the file to compare export file with
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' (U). 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:
No Format |
---|
] || {toc} {warn} This component is only intended for test purposes, not for production use. {warn} h2. Introduction 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). h2. Configuration !workflowtestrun.png! fig1: layout of the workflowtestrun configuration The workflow test run configuration consists of two main parts: General configuration and Activities h2. General h3. description Give an optional description of the workflow test run h3. dirDefinition Optional directory references which can be use to refer to directories using a short name. attributes: * *refName* the name which will be used to refer to the directory * *dir* the directory to refer to. h3. systemTime 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. attributes: * *date* date as yyyy-MM-dd * *time* the time of day as HH:mm:ss h2. Activities 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. h3. PurgeActivity 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. attributes: * *description* optional description of the purge activity * *filter* name of a file, directory. wild cards can be used (e.g. \*test.*) h3. CopyActivity Activity can be used to copy files or directories between two locations e.g. to copy files to import to the applications import directory attributes: * *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 h3. WorkflowActivity Runs the workflow file with the given id. The id must be known in the application environment. h3. ExportTimeSeriesActivity Exports the given time series to PI formatted file. attributes: * *exportFile* path that specifies the location and name of the export file * *timeSeriesSet* time series set as specified [here|http://public.wldelft.nl/display/FEWSDOC/02+Data+Handling+in+DELFT-FEWS#02DataHandlinginDELFT-FEWS-TimeSeriesSets] h3. CompareActivity Compares an exported file with a given reference file. The comparison will be visible in the log output of the application environment. attributes: * *exportFile* location of the file that is to be checked with the reference file * *compareFile* location of the file to compare export file with Workflow test runs can either be started from within a FEWS stand-alone application, or within a JUnit test. h2. 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' (U). This will open an open file dialog in which you can select a workflow configuration file to run in the current environment. h2. 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: {noformat} .... // init test application App.init(WorkflowTestRunTest.class); FewsInstance.init(TestSupport.getInputFile()); TestSupport.setUp(); configDir = TestSupport.getInputFile("config"); relativeViewPeriod = new RelativePeriod(-100 * TimeUnit.DAY_MILLIS, TimeUnit.DAY_MILLIS); connection = TestSupport.createTestDatabase("test"); // create datastore dataStore = new TestDataStore(connection, configDir, coldStatesDir, cacheDir, time0); // select the workflowtest configuration file File configFile = TestSupport.getInputFile("testfiles/WFT_Test1.xml"); SystemActivityDescriptor descriptor = dataStore.getRuns().getSystemActivityDescriptors().add(SystemActivityType.OC); // the WorkflowTestRun is created here WorkflowTestRun testRun = new WorkflowTestRun(dataStore, descriptor); // run it testRun.run(configFile); .... {noformat} h2. Run workflow test runs from bin dir h3. Windows 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. In the bin directory configure the |
Run workflow test runs from bin dir
Windows
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. In the bin directory configure the 'Region.exe'
...
and
...
'Region.jpif'
...
files.
...
For
...
the
...
JPIF
...
file
...
some
...
adaptation
...
must
...
be
...
made.
...
Here
...
is
...
an
...
example:
No Format |
---|
} ..\jre -mx256m -cp $JARS_PATH$ nl.wldelft.fews.system.workflowtestrun.WorkflowTestRun Region_Name ..\path_to_your_config_test_file.xml {noformat} |
The
...
procedure
...
above
...
works
...
(in
...
case
...
of
...
a
...
1.5
...
jre)
...
only
...
when
...
double
...
clicking
...
on
...
the
...
exe
...
or
...
when
...
executing
...
it
...
from
...
the
...
windows
...
scheduler.
...
It
...
does
...
not
...
running
...
when
...
calling
...
the
...
exe
...
from
...
a
...
batch
...
file
...
or
...
when
...
calling
...
it
...
directly
...
from
...
the
...
command
...
line.
...
If
...
you
...
need
...
this
...
use
...
a
...
1.6
...
jre
...
version
...
and
...
create
...
a
...
batch
...
file
...
similar
...
to
...
the
...
example
...
below:
No Format |
---|
} ..\jre\bin\java.exe -mx512m -cp "*" nl.wldelft.fews.system.workflowtestrun.WorkflowTestRun MYREGION ..\path_to_test_file.xml {noformat} |
Check
...
the
...
attachment
...
...
...
for
...
an
...
example.
Linux
The normal startup script in linux systems is shown below:
No Format |
---|
h3. Linux The normal startup script in linux systems is shown below: {noformat} #!/bin/sh # # Script to start Delft-FEWS # # One argument required: the name of the region directory # export JAVA_HOME=$(pwd)/jre/bin if [ "$1" = "" ]; then echo "Usage: $0 <region name>" exit fi if [ ! -d "bin" -o ! -d "$1" ]; then echo "Start the script in the directory holding the region directory" exit fi # # Assemble the list of jar files in the bin directory # cd bin base=`pwd` # Assemble the classes # classes="" for f in $base/*.jar ;do if [ "$classes" = "" ]; then classes="$f" else classes="${classes}:$f" fi done echo "Java runtime: ${JAVA_HOME:-/opt/java/bin}/java - should at least be 1.5" echo "Starting application ..." ${JAVA_HOME:-/opt/java/bin}/java -Xmx256M -Djava.library.path=$base \ -classpath "$classes" \ nl.wldelft.fews.gui.explorer.Application $1 # # Remote debugging: add the following lines to the above: # -Xdebug \ # -Xrunjdwp:transport=dt_socket,address=8000,suspend=y,server=y \ exit {noformat} |