Define a test-suite from a Workflow

This first example shows how to configure a wft4galaxy workflow test for Galaxy.

Main steps:

  1. prepare the Galaxy workflow to test: check workflow consistency and export it from Galaxy as a .ga file;
  2. choose its input datasets and generate its expected output files;
  3. write a workflow test configuration file;
  4. launch wft4galaxy to execute the test.

As an example, we consider the workflow change_case whose files are in the folder examples/change_case:

In [1]:
SUITE_FOLDER="../examples/change_case"
cd ${SUITE_FOLDER}
ls
expected_output         workflow-test.yml
input                   workflow.ga

1. Workflow preparation

Consider the following simple workflow ‘’ChangeCase’‘ which simply changes (to upper) the case of an input text by using only one Galaxy text transformation tool: the ChangeCase tool.

wf-changecase-workflow

Figure 1. Workflow “ChangeCase”

As Fig. 1 shows, the workflow has one input and one output. To test it, both the input and the output must be uniquely identified. Typically, Galaxy identifies them using Names and Labels, respectively. For our sample workflow, the identifiers are:

  • Name “InputText” for the input (Fig. 2);
  • Label “OutputText” for the output (Fig. 3).

wf-changecase-inputdataset

Figure 2. Workflow input: “Input Dataset”

wf-changecase-outputdataset

Figure 3. Workflow output: “output1”

Satisfied that both input and outputs are uniquely identified, we can download the Galaxy workflow definition, i.e., the .ga file. To obtain the .ga file you have to select your workflow from the Workflows menu of the Galaxy web interface, click Share or Download and finally click the button Download.

2. Choose inputs and expected outputs

As input for this workflow, we can use any text file (e.g., examples/change_case/input.txt) and, as expected output, a file containing the same text but in upper case (e.g., examples/change_case/expected_output.txt).

3. Define the workflow test

The code below defines a simple test for our sample workflow. It’s in the file workflows-test.yml:

workflows:
  # workflow test "change case"
  change_case:
    file: "workflow.ga"
    inputs:
      InputText: "input"
    expected:
      OutputText: "expected_output"

See the Section “Test Definition File” of the documentation for more details about the legal test definition syntax.

4. Execute the defined test

The only mandatory argument to run the test is the definition file, which can be specified using the option -f | --file:

In [2]:
wft4galaxy -f "workflow-test.yml" --enable-logger \
           --server http://192.168.64.8:30700 --api-key 4b86f51252b5f220012b3e259d0877f9
[]
2016-11-11 15:48:55,150 INFO: Configuration: {'galaxy_url': 'http://192.168.64.8:30700', 'enable_logger': True, 'galaxy_api_key': '4b86f51252b5f220012b3e259d0877f9', 'enable_debug': False, 'disable_cleanup': False, 'output_folder': 'results', 'workflows': {'change_case': WorkflowTestConfig: name=change_case, file=workflow.ga, inputs=[InputText], expected_outputs=[OutputText]}, 'disable_assertions': False, 'logger_level': 20}
Workflow Test: 'change_case' ... 2016-11-11 15:48:55,806 INFO: Create a history '_WorkflowTestHistory_f84791bd-a81d-11e6-abed-a45e60c4fc6b' (id: u'9fc1c2078b8ee907')
2016-11-11 15:48:57,601 INFO: Workflow '_WorkflowTest_Change Case (imported from API)' (id: 52d6bdfafedbb5e5) running ...
2016-11-11 15:49:05,914 INFO: Workflow '_WorkflowTest_Change Case (imported from API)' (id: 52d6bdfafedbb5e5) executed
2016-11-11 15:49:05,916 INFO: Checking test output: ...
2016-11-11 15:49:05,964 INFO: Checking test output: DONE
ok

----------------------------------------------------------------------
Ran 1 test in 11.152s

OK