Skip to content

Load Testing Blog

REST API using Node.js

I want to setup a simple REST server that allows to Create, Read, Update and Delete data (Users in this case) using Node.js, Express, and TypeScript:

  • I could do it using Java/Spring in a couple of minutes, but I want to learn more about Node.js.
  • Express seems to be a good choice to create REST APIs.
  • And as I think that TypeScript may be the good compromise between Java and Javascript I will keep on giving it a try.

Also, I would like to feel as comfortable as using Java. First I need a debugger. No need to spam console.log() using node-inspector. Then unit tests are mandatory and cannot go without a code coverage tool. Finally, I make use of various tools to build, test, debug and run the TypeScript code. Grunt is convenient simplify these processes (plus it's a gain for productivity).
The only thing I bypassed is a code quality tool. We use SonarQube on a daily basis for OctoPerf, and I might do the same for this sample someday.

Before reading this article further, you may check the result on GitHub Rest-Crud.

AngularJs domain name filter

Until now, we used default names such as 'Untitled VU' for virtual users created in octoperf, our load testing tool. That's not very relevant. So we changed it to the domain name of the tested website.

The load tester selects a URL to test, and we need to extract the domain name from it.

A nice trick is to create an hyperlink element <a href="..."/>. Then we can retrieve the hostname, parsed by the browser. So instead of relying on a regex we use the browser built-in URI parsing capabilities. It's easier and safer.

TypeScript using WebStorm

We use AngularJs at OctoPerf.com, for the frontend of our load testing tool. As AngularJs V2 quick start guide uses TypeScript, I think it's a good motivation to give it a try.

Prerequisite

Node.js and npm must be installed to run this sample. WebStorm is used to automatically transpile our .ts files (compile them to .js ones).

We can also use the command line transpiler:

  • npm install -g typescript to install it.
  • tsc --watch -m commonjs greeter.ts to transpile it.

Base tools for bloggers

To follow up on my article about creating blog based on Jekyll, Bootstrap4, Grunt, Bower and hosted on GitHub pages, I'm adding ways of measuring and increasing the number of visitors.

This article is a quick tutorial to do the same, starting from the blog template:

  • Get to know how many visitors are caught in your blog using Google Analytics,
  • Generate a Sitemap.xml using Jekyll and feed it to Google,
  • Embed Twitter buttons,
  • And use Disqus to handle your articles comments.

Load Testing Reports Exporting

This short post describes the modifications made to OctoPerf for its last update, and how they can help you save time while load testing.

Our goal is, and has always been, to ease the work of load testers. Creating test reports using Word / Excel can take a lot of time.

Exporting the report

That's why we automated this process in OctoPerf, our load testing solution. Even as your performance bench is running, you can edit the generated report:

  • List errors to check that your virtual users are properly configured,
  • Add various charts to identify performance bottleneck,
  • Insert text to explain what could be donne to improve response times,
  • Give your conclusions to the stakeholders.

You can have a complete test report, ready to be delivered, as soon as the bench ends. And now, you can directly export it from OctoPerf into a PDF file.