Git Product home page Git Product logo

node-locust's Introduction

node-locust

Links

  • Locust Website: locust.io
  • Locust Documentation: docs.locust.io

Description

node-locust is a load generator for locust written in JavaScript

Usage:

# Start locust master
locust --master \
       --master-bind-port 5557 \
       --host <test-server> \
       --locustfile ./locust-node/dummy.py

# Start node client
node-locust --locustfile ./examples/basic.js \
            --master-host 127.0.0.1
            --master-port 5557

Locust file:

const { Locust, TaskSet, HTTPClient } = require('node-locust');

class UserTasks extends TaskSet {
  constructor() {
    super();

    this.http = new HTTPClient({
      baseURL: <test-server>,
      timeout: 2000
    },  this.recordSuccess.bind(this),
        this.recordFailure.bind(this));

    this.tasks = [{
      task: () => this.getUserInfo(),
      weight: 2
    }, {
      task: () => this.updateUserInfo(),
      weight: 1
    }];
  }

  async getUserInfo() {
    await this.http.request({
      method: 'GET',
      url: '/users/1'
    });
  }

  async updateUserInfo() {
    await this.http.request({
      method: 'PUT',
      url: '/users/1',
      body: {
        name: 'user-name'
      }
    });
  }
}

class MyLocust extends Locust {
  constructor() {
    super();

    this.taskSet = new UserTasks();
  }
}

module.exports = { MyLocust };

License

Open source licensed under the MIT license (see LICENSE file for details).

node-locust's People

Contributors

jspdown avatar matthewadams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-locust's Issues

Where do the node-locust and locust executables live?

Hi

So attempting to try and use this but can't seem to locate where the node-locust and locust executables are found as per the usage instructions.

The npm install didn't render any binaries, and attempting to use the index.js file here as the binary throws ๐Ÿ‘

./node_modules/locust-node/index.js: line 1: syntax error near unexpected token `('
./node_modules/locust-node/index.js: line 1: `const path = require('path');'

Are there some steps missing in the readme?

Cheers

Just found this...

This is not an issue I am just curious if this is a working solution and what version of LocustIo it was tested with?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.