Test Data Management

How to manage your test data automatically.

Please note

The content on this page pertains only to the new Platform StormForge Performance Testing environment at https://app.stormforge.io/perftest.

Test data management can also be done with the forge CLI tool in the Standalone Performance Testing environment.

In this guide you will learn how to automatically keep your test data up to date so that your performance tests are ready to run any time.

To follow along you need our command line tool stormforge to be installed. We offer our CLI for multiple platforms, please check our installation guide.

As always, if you have any questions, feel free to get in contact any time!

Test Data Management with our CLI

Keeping your test data up to date can a bit challenging. But on the other hand it is a crucial part to be ready to run performance tests anytime and also to be able to run test on a regular basis.

Let’s say you have a performance test defined for your web shop where you need product information to navigate to product detail pages. We will need the internal ID, one stock keeping unit identifier (SKU) and the matching product SEO-slug which is used in product page URLs. Here is an example of this data in CSV format:

id,sku,slug
346556,616da072-38a1-4002-ab57-d06a4930e627,acme-earthquake-pills
537925,a6588a43-5e6e-4cad-b408-809745af0e27,acme-disintegrating-pistol
892976,de154984-6e4b-4c44-9481-db2204d11694,bird-seed

Here is a quick example snippet on how to work with the data (for more details check our documentation on data sources. We will load the product detail page and then add the product to the basket:

var products = session.ds.loadStructured("shop/blackfriday.csv");
var product = session.ds.pickFrom(products);

// visit product page at /p/2342-product-slug
session.get("/p/:id-:slug", {
  params: {
    id: product.get("id"),
    slug: product.get("slug"),
  }
});

// add product to basket
session.post("/cart/add", {
  payload: JSON.stringify({
    id: product.get("id"),
    sku: product.get("sku"),
    amount: 1,
  })
});

Your QA environment is a living system and changes all the time (new products get created etc). In order to perform daily performance tests against this environment you also have to keep shop/blackfriday.csv up to date. Otherwise your test might be producing more HTTP 404 Not Found then you indent to!

One way would to do that manually by uploading new test data. Or, you could automate it!

Putting Things Together

Let’s say you have a script in place called script/export-product-data.sh which prints out test data for products from the QA system in the format we require. You can combine this with the stormforge create datasource command like this to upload it to StormForge:

$ script/export-product-data.sh > tmp/products.csv
$ stormforge create data-source --from-file tmp/products.csv \
  --name shop/blackfriday.csv \
  --fields id,sku,slug

List of Data Sources

If you now add a job to your build system like Jenkins to run regularly (e.g. daily or every hour), you can automatically push a fresh version of test data to StormForge to be always ready to run tests.

The stormforge CLI can do a lot more with datasources. Check out more features and options using stormforge help.

Last modified August 3, 2022