Run memlab in Direktiv on buster
-
License: Apache-2.0
-
Issue Tracking: https://github.com/direktiv-apps/memlab/issues
-
Maintainer: direktiv.io
This function provides a memlab install on Node.js as a Direktiv function. memlab is a memory leak detector for front-end JS.
Node Version Manager is installed to support LTS versions. The following versions are installed in this function:
-
18.10.0
-
16.17.1
NVM (Node Version Manager) can be used as well to install different versions but it is function wide which means changes are visible to all function calls during the function / container lifetime. If the application is returning plain JSON on standard out it will be used as JSON result in Direktiv. If the application prints other strings to standard out the response will be a plain string. If JSON output is required the application can create and write to a file called output.json. If this file exists, this function uses its contents as return value. Functions can have a context to persist the node_modules directory across different execution cycles. Unlike Direktiv's regular behaviour to have a new working directory for each execution, the context ensures that it runs in the same directory each time.
functions:
- id: memlab
image: gcr.io/direktiv/functions/memlab:1.0
type: knative-workflow
- id: memlab
type: action
action:
function: memlab
input:
files:
- name: scenario.js
data: |
// initial page load's url
function url() {
return "https://www.youtube.com";
}
// action where you suspect the memory leak might be happening
async function action(page) {
await page.click('[id="video-title-link"]');
}
// how to go back to the state before action
async function back(page) {
await page.click('[id="logo-icon"]');
}
module.exports = { action, back, url };
commands:
- command: memlab run --scenario scenario.js
- id: memlab
type: action
action:
function: memlab
input:
node: "16"
commands:
- command: node -v
- id: memlab
type: action
action:
function: memlab
input:
context: memlab-app
files:
- name: scenario.js
data: |
// initial page load's url
function url() {
return "https://www.youtube.com";
}
// action where you suspect the memory leak might be happening
async function action(page) {
await page.click('[id="video-title-link"]');
}
// how to go back to the state before action
async function back(page) {
await page.click('[id="logo-icon"]');
}
module.exports = { action, back, url };
commands:
- command: npm install uuid
- command: memlab run --scenario scenario.js
- id: memlab
type: action
action:
function: memlab
files:
- key: scenario.js
scope: workflow
input:
commands:
- command: memlab run --scenario scenario.js
No secrets required
List of executed commands.
[
{
"result": "Hello World",
"success": true
}
]
Type | Description |
---|---|
io.direktiv.command.error | Command execution failed |
io.direktiv.output.error | Template error for output generation of the service |
io.direktiv.ri.error | Can not create information object from request |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
memlab | []PostOKBodyMemlabItems | []*PostOKBodyMemlabItems |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
result | interface{} | interface{} |
✓ | |||
success | boolean | bool |
✓ |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
commands | []PostParamsBodyCommandsItems | []*PostParamsBodyCommandsItems |
[{"command":"memlab run --scenario scenario.js"}] |
Array of commands. | ||
context | string | string |
Direktiv will delete the working directory after each execution. With the context the application can run in a different | |||
directory and commands like npm install will be persistent. If context is not set the "node_module" directory will be deleted | ||||||
and each execution of the flow uses an empty modules folder. Multiple apps can not share a context. | ||||||
files | []DirektivFile | []apps.DirektivFile |
File to create before running commands. | |||
node | string | string |
"18.10.0" |
Default node version for the script |
Properties
Name | Type | Go type | Required | Default | Description | Example |
---|---|---|---|---|---|---|
command | string | string |
Command to run | |||
continue | boolean | bool |
Stops excecution if command fails, otherwise proceeds with next command | |||
boolean | bool |
true |
If set to false the command will not print the full command with arguments to logs. | |||
silent | boolean | bool |
If set to false the command will not print output to logs. |