Skip to content
Phillip Markert edited this page Jan 3, 2017 · 10 revisions

What is normalization?

Hyperpotamus runs all scripts through a process called normalization. The normalization process expands any shortcuts in the script and wraps singular elements into arrays where appropriate. The goal of normalization is to conform scripts that are entered with shortcut syntax into a common format.

During the normalization process, the hyperpotamus engine handles normalizing the script structure and any common elements/properties, however, individual action elements may also be subject to normalization. It is the responsibility of the installed plugins to perform this normalization on any action elements. Each plugin has the opportunity to analyze each action in a script and to normalize/update the structure. As an example, some types of scalar values can be converted into actions. In other cases, normalization may fill in default values or rewrite actions to a different form.

As an example, here are some mappings between basic/scalar types and action elements.

  • integer -> status action
  • string -> text action
  • regex -> regex action
  • true -> noop action
  • false -> fail action
  • array -> and action

NOTE: To see what the normalized version of your script looks like, run the hyperpotamus [command-line](command line interface) tool against your script with the --normalize flag. This will print out both the normalized YAML and JSON representations of your script. NOTE: Some data-types, such as functions, cannot be serialized to JSON.

Normalization Example

request: http://nodejs.org
response:
  - 200
  - /for easily building fast, scalable network applications/i

This script requests the homepage for http://nodejs.org and validates that the HTTP response code is 200 and that the given text appears on the page (case insensitive). After normalization, the script looks like:

normalized: true
steps:
  - request:
      url: "http://nodejs.org"
      headers: {}
    response:
      actions:
        - status: 200
        - regex:
            pattern: "for easily building fast, scalable network applications"
            options: i

Or the JSON equivalent:

{
  "normalized": true,
  "steps": [
    {
      "request": {
        "url": "http://nodejs.org",
        "headers": {}
      },
      "response": {
        "actions": [
          {
            "status": 200
          },
          {
            "regex": {
              "pattern": "for easily building fast, scalable network applications",
              "options": "i"
            }
          }
        ]
      }
    }
  ]
}

Clone this wiki locally