# NeoLoadWeb Operator

The **NeoLoadWeb** operator allows piloting performance tests on a target system by leveraging the Tricentis NeoLoad Web solution.

Once triggered, this operator will configure and start the execution of a NeoLoad test run on the remote endpoint. When the test is unable to run then the operator blocks the Akamas workflow issuing an error.

## Operator arguments

This operator requires five pieces of information to pilot successfully performance tests within Akamas:

1. The location of a .zip archive(project file) containing the definition of the performance test. This location can be a URL accessible via HTTP/HTTPS or a file path accessible via SFTP.\
   Otherwise, the unique identifier of a previously uploaded project must be provided.
2. The name of the scenario to be used for the test
3. The URL of the NeoLoad Web API (either on-premise or SaaS)
4. The URL of the NeoLoad Web API for uploading project files
5. The account token used to access the NeoLoad Web APIs

When a `projectFile` is specified the Operator uploads the provided project to NeoLoad and launches the specified scenario. After the execution of the scenario, the project is deleted from NeoLoad. When a `projectId` is specified the Operator expects the project to be already available on NeoLoad. Please refer to [NeoLoad official documentation](https://www.neotys.com/documents/doc/nlweb/latest/en/html/#25057.htm) on how to upload a project and obtain a project ID.

| Name                     | Type   | Value Restrictions                                                                                                                | Required                                                                                             | Default                                                                         | Description                                                                                                                                                                                |
| ------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `scenarioName`           | String | It should match an existing scenario in the project file. Can be retrieved from the "runtime" section of your neoload controller. | No, if the component whose name is defined in `component` has a property that maps to `scenarioName` |                                                                                 | The name of the scenario to be used for the performance piloted by Akamas                                                                                                                  |
| `projectId`              | String | It should be a valid UUID                                                                                                         | No, if a `projectFile` is already defined                                                            |                                                                                 | The identified of a previously uploaded project file. Has precedence over `projectFile`                                                                                                    |
| `projectFile`            | Object | It should have a structure like the one described here below                                                                      | No, if a `projectId` is already defined                                                              |                                                                                 | The specification of the strategy to be used to get the archive containing the specification of the performance test to be piloted by Akamas. When defined `projectId` has the precedence. |
| `neoloadProjectFilesApi` | String | It should be a valid URL or IP                                                                                                    | No                                                                                                   | [https://neoload-files.saas.neotys.com](https://neoload-files.saas.neotys.com/) | The address of the API to be used to upload project files to NeoLoad Web                                                                                                                   |
| `neoloadApi`             | String | It should be a valid URL or IP                                                                                                    | No                                                                                                   | [https://neoload-api.saas.neotys.com](https://neoload-api.saas.neotys.com/)     | The address of the Neotys' NeoLoad Web API                                                                                                                                                 |
| `lgZones`                | String | Comma-separated list of zones and number of LG                                                                                    | No                                                                                                   |                                                                                 | The list of LG zones id with the number of the LGs. Example: "ZoneId1:10,ZoneId2:5". If empty, the default zone will be used with one LG.                                                  |
| `controllerZoneId`       | String | A controller zone Id                                                                                                              | No                                                                                                   |                                                                                 | The controller zone Id. If empty, the default zone will be used.                                                                                                                           |
| `component`              | String | It should match the name of an existing component of the System under test                                                        | No                                                                                                   |                                                                                 | The name of the component whose properties can be used as arguments of the operator.                                                                                                       |
| `accountToken`           | String | It should match an existing access token registered with NeoLoad Web                                                              | No, if specified in the component. See example below                                                 |                                                                                 | The token to be used to authenticate requests against the NeoLoad Web APIs                                                                                                                 |

### `ProjectFile` structure and arguments <a href="#getting-the-project-file-via-http-https" id="getting-the-project-file-via-http-https"></a>

The `projectFile` argument needs to be specified differently depending on the protocol used to get the specification of the performance test:

* HTTP/HTTPS
* SSH (SFTP)

#### HTTP/HTTPS

Here follows the structure of the `projectFile` argument in the case in which HTTP/HTTPS is used to get the specification of the performance test:

```yaml
# ...
projectFile:
    http:
        url: http://url_of_project_file
```

with its arguments:

| Name        | Type    | Value Restrictions             | Required | Default | Descrption                                                                                                                  |
| ----------- | ------- | ------------------------------ | -------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| `url`       | String  | It should be a valid URL or IP | Yes      |         | The URL of the project file                                                                                                 |
| `verifySSL` | Boolean |                                | No       | true    | If the https connection should be verified using the certificates available on the machine in which the operator is running |

#### SSH (SFTP)

Here follows the structure of the `projectFile` argument in the case in which SFTP is used to get the specification of the performance test.

```yaml
projectFile:
  ssh:
    hostname: this_is_a_hostname
    username: this_is_a_username
    sshPort: 22
    key: this_is_a_key
    path: /path/to/project/file
```

with its arguments

|            | Type             | Value Restrictions                                | Required                                          | Default | Description                                                                                                                |
| ---------- | ---------------- | ------------------------------------------------- | ------------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `hostname` | String           | It should be a valid SSH host address             | Yes                                               |         | SSH host address                                                                                                           |
| `username` | String           |                                                   | Yes                                               |         | SSH login username                                                                                                         |
| `password` | String           |                                                   | No. Either `password` or `key` should be provided |         | SSH login password                                                                                                         |
| `sshPort`  | Number (integer) | 1≤`sshPort`≤65532                                 |                                                   | 22      | SSH port                                                                                                                   |
| `key`      | String           |                                                   | No, Either `password` or `key` should be provided |         | SSH login key, provided directly its value or the path of the file to import from. The operator supports RSA and DSA Keys. |
| `path`     | String           | It should be a valid path on the SSH host machine | Yes                                               |         | The path of the project file                                                                                               |

### `component` structure and arguments <a href="#get-operator-arguments-from-component" id="get-operator-arguments-from-component"></a>

The `component` argument can be used to refer to a component by name and use its properties as the arguments of the operator.

#### **Component property to Operator argument mapping** <a href="#component-property-to-operator-argument-mapping" id="component-property-to-operator-argument-mapping"></a>

| Component property       | Operator argument              |
| ------------------------ | ------------------------------ |
| `neoloadProjectFilesApi` | `neoloadProjectFilesApi`       |
| `neoloadApi`             | `neoloadApi`                   |
| `accountToken`           | `accountToken`                 |
| `scenarioName`           | `scenarioName`                 |
| `controllerZoneId`       | `controllerZoneId`             |
| `lgZones`                | `lgZones`                      |
| `deleteProjectAfterTest` | `deleteProjectAfterTest`       |
| `url`                    | `projectFile->http->url`       |
| `verifySSL`              | `projectFile->http->verifySSL` |
| `hostname`               | `projectFile->ssh->hostname`   |
| `username`               | `projectFile->ssh->username`   |
| `password`               | `projectFile->ssh->password`   |
| `key`                    | `projectFile->ssh->key`        |
| `sshPort`                | `projectFile->ssh->sshPort`    |
| `path`                   | `projectFile->ssh->path`       |

### Examples <a href="#examples" id="examples"></a>

#### Without component argument <a href="#without-component" id="without-component"></a>

```yaml
name: task1
operator: NeoLoadWeb
arguments:
  projectFile:
    ssh:
      hostname: akamas-machine-1
      username: akamas
      key: |-
        -----BEGIN RSA PRIVATE KEY-----
        RSA KEY HERE
        -----END RSA PRIVATE KEY-----
       path: projects/project1.zip
  scenarioName: scenario1
  accountToken: "ACCOUNT TOKEN HERE"
```

#### With component argument <a href="#with-component" id="with-component"></a>

```yaml
name: task1
operator: NeoLoadWeb
arguments:
  component: component1
  accountToken: "ACCOUNT TOKEN HERE"
```
