Skip to content

wwonigkeit/memlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memlab 1.0

Run memlab in Direktiv on buster



About memlab

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.

Example(s)

Function Configuration

functions:
- id: memlab
  image: gcr.io/direktiv/functions/memlab:1.0
  type: knative-workflow

Basic

- 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

Change node version

- id: memlab 
  type: action
  action:
    function: memlab
    input:
      node: "16"
      commands:
      - command: node -v

Using a context

- 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  

Using Direktiv variable as script

- id: memlab 
  type: action
  action:
    function: memlab
    files:
    - key: scenario.js
      scope: workflow
    input:
      commands:
      - command: memlab run --scenario scenario.js      

Secrets

No secrets required

Request

Request Attributes

PostParamsBody

Response

List of executed commands.

Reponse Types

PostOKBody

Example Reponses

[
  {
    "result": "Hello World",
    "success": true
  }
]

Errors

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

Types

postOKBody

Properties

Name Type Go type Required Default Description Example
memlab []PostOKBodyMemlabItems []*PostOKBodyMemlabItems

postOKBodyMemlabItems

Properties

Name Type Go type Required Default Description Example
result interface{} interface{}
success boolean bool

postParamsBody

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

postParamsBodyCommandsItems

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
print 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published