npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express2gatling

v1.0.0

Published

A Node / Express tool to record http requests and convert them to Gatling scripts

Downloads

2

Readme

express2gatling · GitHub license

express2gatling is a library written in Typescript that records incoming HTTP calls within Express and exports them into Gatling scripts.

Gatling is a major stress-testing tool written in Scala that can ramp up millions of users and generate high-resolution metrics.

Gatling's website : https://gatling.io

/!\ Please note that this library is at its early stages and shall be considered as highly limited and unstable. Lots of features are to be added. Feel free to contribute!

Introduction

While Gatling is one of the best tools there is to perform stress-tests on a server, it also comes with its difficulties and can be tedious to handle. This library aims at providing a very simple tool to auto-generate Gatling scripts. It works the following way :

  • You add the library's recorder as a middleware in your express stack
  • An end user manipulates the client-side of the application (Postman, website, mobile app etc.)
  • The recorder analyses every incoming HTTP request
  • When the end user is done, the recorder generates scala files that that are directly compatible with Gatling.

###Limitations

This library only works with Node / Express, and for the time being it is most suited to the JSON format regarding the request / responses bodies.

Installation

To install the library simply do :

npm i --save-dev express2gatling

Usage

The simplest snippet to use the library is the following (in your app.js) :

import { Recorder } from 'express2gatling';

[...]

const app = express();

// Mandatory for the recorder to watch req/res bodies !!! (see https://github.com/expressjs/body-parser)
app.use(BodyParser.json());

// Initialize the recorder and inject it into express
const options = {}; // Recording options
const recorder = new Recorder(options);
app.use((req, res, next) => recorder.rec(req, res, next));

// You can call recorder.write() anytime : here we'll invoke it on user manual shutdown
process.on('SIGINT', () => recorder.write());

Output

Once you call recorder.write(), the library will generate a folder (defaults to /gatling) containing two files :

  • Requests.scala : contains all the HTTP requests, scripted in the scala / Gatling fashion
  • Simulation1.scala : contains the main entry point for Gatling, with scenario definitions

Whatever the features and limitations of the library, feel free to modify those scripts manually.

Running an actual stress test

For the scripts to be run you shall install Gatling : https://gatling.io/open-source

Follow the procedures & documentation provided on Gatling's website. Normally you should download a zip file containing the sources to run Gatling in standalone mode. You might have to install a JDK to have it run.

Once Gatling is operationnl, point it to your scripts by modifying the galting.conf file :

[...]
directory {
    simulations = "/path/to/your/generated/folder/simulations"
}
[...]

Follow the instructions prompted in the console that shall eventually lead the stress test being ran and HTML reports being generated.

For more info about Gatling please refer to their website.

Documentation

TODO