Send your request Join Sii

Performance testing tools provide invaluable support for developers, allowing them to assess the performance and scalability of applications under increasing loads. However, it’s worth noting that not all functionalities are available in every tool, especially in open-source solutions.

Custom solutions are often required when working with new or less popular tools. In such situations, extensions play a crucial role by enabling developers to add custom features to performance testing tools. They empower developers to enhance the potential of the tools and tailor them to specific project requirements, whether it involves simulating real-world loads, integrating with other tools, or monitoring additional metrics.

Extensions thus serve as a key element that bridges the available functionalities of tools with the unique needs of projects.


In k6, a powerful performance testing tool, there’s an opportunity to create custom extensions through a tool called xk6. It allows developers to develop extensions and plugins that can significantly expand the capabilities of k6. This flexibility enables the developer community to easily create custom tools that meet the specific testing project requirements. Some of the available extensions can be found in the k6 documentation.

Installing the tool is straightforward and looks like this:

xk6 installation
Fig. 1 xk6 installation

After successful installation, we are ready to use xk6. However, before we proceed with that, let’s start by writing our first extension.

Implementing the first extension

To begin, let’s choose the functionality we want to cover. We’ll focus on covering the SMTP protocol. SMTP (Simple Mail Transfer Protocol) is a communication protocol for sending email messages between mail servers. It’s a standard protocol used to send emails from one mail server to another over the internet.

The next step is to write a simple template that we will then expand with additional parts.

Writing a simple template
Fig. 2 Writing a simple template

The script registers a module named “k6/x/smtp” using the modules.Register function. This registration allows the module to be used later in test scripts written in JavaScript. The next step is to initialize the GO module. We’ll use the following command for that.

Initializing the GO module
Fig. 3 Initializing the GO module

Let’s assume we want to define a single function in the test responsible for both authentication and sending an email. Based on the available smtp documentation, let’s implement the functionality to use it as an extension.

Implementation of the functionality
Fig. 4 Implementation of the functionality

In the implemented logic, the following elements are included:

  • The options structure – a structure named options are defined, containing fields: Subject, Message, and UDW. These are optional parameters that can be passed when sending an email.
  • The plainAuth function – a helper function that creates an smtp.Auth object using PlainAuth authentication. This authentication requires specifying the host, password, and sender.
  • The SendMail function – the primary function that performs email sending. It takes parameters such as host, port, sender, password, recipient, and options (options structure). Based on these parameters, an email message is created and sent using smtp.SendMail.

“Go mod tidy” is a command that synchronizes the go.mod file with the dependencies used in our code. Let’s apply it to synchronize our project.

Synchronization of the project
Fig. 5 Synchronization of the project

Building the scenario

We can build k6 binary packages using xk6 on the local system or within Docker. The latter approach is more stable as it mitigates the possibility of errors stemming from the specific system or distribution. However, building an image is necessary for this. You can find an example of it in my repository.

Let’s proceed with building the image locally.

Building the image
Fig. 6 Building the image

This will create a binary file named k6. The example script that we can run using the extension looks as follows.

The example script
Fig. 7 The example script

In this way, we can utilize the library within test scenarios by running k6 using the binary file instead of a system command


In today’s eighth part of the series, we delved into the topic of extensions in k6 and understood their significant role in enhancing this tool’s functionality. We learned the definition of extensions as custom add-ons that allow developers to tailor k6 to the specific needs of a project.

Throughout the article, we constructed our own k6 extension from scratch, which helped us understand how to implement custom features step by step within this tool. Through practical examples, we had the opportunity to witness the flexibility and adaptability of k6 through the capabilities of extensions.

This also marks the final article in the “Performance Under Control with k6” series, where we conclude our journey of exploring k6 from the ground up. I want to express sincere gratitude to all those who persevered and followed our series from the first article. I hope you gained insights into the possibilities and potential that k6 offers and acquired valuable skills necessary for effective performance testing of applications.


If you haven’t had a chance to read the articles in the series yet, you can find them here:

In addition, I encourage you to check out the project’s repository and repository for previous parts.

5/5 ( vote: 1)
5/5 ( vote: 1)
Grzegorz Piechnik

Performance Test Engineer z udokumentowanym doświadczeniem w branży bankowej, giełdowej i streamingowej. Jego praca skupiona jest głównie na pełnej automatyzacji procesów wydajnościowych oraz zarządzaniu obserwowalnością w systemach. Poza pracą prowadzi bloga dotyczącego CyberSecurity, Devops i wydajności aplikacji oraz zajmuje się rozwojem narzędzi open source. Ponadto edukuje, szkoli i wprowadza nowe osoby do branży IT

Leave a comment

Your email address will not be published. Required fields are marked *

You might also like

More articles

Don't miss out

Subscribe to our blog and receive information about the latest posts.

Get an offer

If you have any questions or would like to learn more about our offer, feel free to contact us.

Send your request Send your request

Natalia Competency Center Director

Get an offer

Join Sii

Find the job that's right for you. Check out open positions and apply.

Apply Apply

Paweł Process Owner

Join Sii


Ta treść jest dostępna tylko w jednej wersji językowej.
Nastąpi przekierowanie do strony głównej.

Czy chcesz opuścić tę stronę?