Skip to main content

Batch command and Recipe

Introduction

The batch's recipe allows you to define and execute complex testing scenarios through YAML files. These recipes consist of steps, each containing specific actions, options, and arguments.

Keywords

  • version: Reserved for future updates to the recipe format.
  • targets: A target functions similarly to a tag, specifying a port or host. Each target is unique within the recipe.
    • name: Target's name. This can be utilized within a recipe.
    • filter: A filter expression(Regualar expression) to selectively match specific targets.
    • tags: Existing tags will be enumerated under this keyword.
  • steps: A step represents a unit of command execution. Each step triggers the associated coordinator's command.
    • description: Briefly describes the purpose of the step.
    • action: Specifies the current command to be executed.
      • args: Arguments required for the command.
      • options: Additional options for the command.
    • allowFailure: Allow the step to continue execution even if it encounters errors.

Getting Started

Example 1: Simple Test Run

The following is a basic example of a recipe file for a simple test run:

---
version: 1
steps:
- description: test run for simple test
action: test.run
options:
t: fl
w: 5
args:
target: qa
script: simple/test_1.js
- description:
action: log.read
args:
target: qa
dirName: task-fl
fileName: default.log
options:
n: 6

Example 2: Working with Targets

The following example demonstrates how to work with targets:

---
version: 1
targets:
- name: tester_port_0
filter: tester-0[0-9]-p.[0]
tags:
- tester-01
- tester-02
- name: tester_port_2
filter: tester-0[0-9]-p.[2]
tags:
- tester-01
- tester-02
steps:
- description: show default.log's last line in port 0
action: log.read
args:
target: tester_port_0
dirName: task-a
fileName: default.log
options:
n: 1
- description: show default.log's last line in port 2
action: log.read
options:
n: 1
args:
target: tester_port_2
dirName: task-a
fileName: default.log
allowFailure: true

In this example, the allowFailure keyword is added to the second step. This indicates that the batch should proceed to the next step even if this step encounters errors.

User-specific Arguments and Environment Variables

The batch's recipe supports user-specific arguments and environment variables. Here's an example:

Environment variables:

HOST=192.1.1.1
USER=maestro
PASSWD=SECRET

Recipe:

version: 1
steps:
- description: Setting username to ${USERNAME}
action: config.username
options:
username: ${USERNAME}
- description: Adding host ${HOST}
action: host.add
options:
t: tester
u: ${USER}
p: ${PASSWD}
skipFrameworkUpdate: true
allowFailure: true
args:
host: ${HOST}
- description: Confirm added host ${HOST}
action: host.list
- description: Confirm added port list ${HOST}
action: port.list
options:
i: true

Batch Submit Command:

The batch submit command is used to submit a batch job with user-specific arguments and environment variables:

coordinator # batch submit -a USERNAME="MAESTRO Q" -e HOST -e USER -e PASSWD

Replacing YAML files

Before executing the recipe, replace the YAML file with user-specific arguments and environment variables.

version: 1
steps:
- description: Setting username to MAESTRO Q
action: config.username
options:
username: MAESTRO Q
- description: Adding host 192.1.1.1
action: host.add
options:
t: tester
u: maestro
p: SECRET
skipFrameworkUpdate: true
allowFailure: true
args:
host: 192.1.1.1
- description: Confirm added host 192.1.1.1
action: host.list
- description: Confirm added port list 192.1.1.1
action: port.list
options:
i: true