xk6-sftp
An extension for the k6 load testing tool that adds support for SFTP (Secure File Transfer Protocol) operations. This extension allows you to perform SFTP actions such as uploading, downloading, and managing files on an SFTP server as part of your load testing scripts. It is useful for testing the performance and reliability of systems that rely on SFTP for file transfers.
Install
To build a k6 binary with this extension, first ensure you have the prerequisites:
Then:
- Download xk6:
go install go.k6.io/xk6/cmd/xk6@latest
- Build the k6 binary:
xk6 build --with github.com/InditexTech/xk6-sftp@latest
Development
For building a k6 binary with the extension from the local code, you can run:
make build
For testing and running the extension locally, an SFTP server is required. The default target in the Makefile will:
- Run an SFTP server with Docker Compose (make sure you have Docker & Docker Compose installed in your system).
- Download the dependencies.
- Format your code.
- Run the integration tests.
- Run the example script.
git clone git@github.com:InditexTech/xk6-sftp.git
cd xk6-sftp
make
Usage
This extension provides the following JS methods for interacting with the SFTP server:
import xk6sftp from "k6/x/sftp";
// Create a new SFTP client
const client = xk6sftp.newClient("username", "password", "host", 3322);
export default function () {
// Upload a file, creating target directories if necessary
let result = client.uploadFile("localPath", "remotePath");
// Download a file
result = client.downloadFile("remotePath", "localPath");
// Delete a file
result = client.deleteFile("remotePath")
// All the ...File methods return a JS object such as:
// {"success":true,"message":"file uploaded successfully"}
}
export function teardown() {
if (client !== null) {
// Close the SFTP connection
client.close();
}
}
See the examples folder for a more detailed usage example.
Contributing
Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines on how to contribute to this project.
License
This project is licensed under the terms of the AGPL-3.0-only license.
© 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)