You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 44 Next »

What

nameofinstance.xml

Description

Workflow test runs can be configured to automate tests

schema location

http://fews.wldelft.nl/schemas/version1.0/workflowTestRun.xsd

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

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.*)
  • clearLocalDatastore Empty element that empties the database

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.

choice:

taskProperties: Use a taskProperties configuration block to define how to run the workflow

WftrWorkflowGroup:

  • workflowId: identifier of workflow to run
  • systemTime: (optional) overruling system time for running workflow

 

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

ExportLogsActivity

Exports the log messages produced during the last workflow run.

SetSystemTimeActivity

Changes the system time.

  • systemTime New system time.

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

RefreshActivity

Refreshes datastore. Empty element.

ContainsActivity

Search for the presence of text in a file

attributes:

  • searchFile file to search through
  • searchString array of strings to search for
  • emptyFile check if file is empty

SleepActivity

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' (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:

....
// 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);
....

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.

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:

..\jre
-mx256m
-cp
$JARS_PATH$
nl.wldelft.fews.system.workflowtestrun.WorkflowTestRun
Region_Name
..\path_to_your_config_test_file.xml

Since 2014.02 this is done via an ini file:

#Delft-FEWS ini file
main.class=nl.wldelft.fews.system.workflowtestrun.WorkflowTestRun
classpath.1=*.jar

#Java Runtime jvm.dll location
## for 32 bits use ../jre/bin/client/jvm.dll
vm.location=../jre/bin/client/jvm.dll
## 64 bits use ../jre/bin/server/jvm.dll
##vm.location=../jre/bin/server/jvm.dll

vmarg.1=-Xms512m
vmarg.2=-Xmx1024m

#location of the bin dir has changed in 2017.01 (was .)
working.directory=../bin

#region_home directory - <region_home> to be replaced with actual region home directory
arg.1=../<region_home>
arg.2=..\path_to_your_config_test_file.xml

 

Check the attachment workflow_test_run for an example. 

Linux

The normal startup script in linux systems is shown below:

#!/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

  • No labels