Skip to content
InditexTechPublic

About

xk6 sftp protocol

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

16 stars

Watchers

2 watching

Forks

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:

  1. Download xk6:
go install go.k6.io/xk6/cmd/xk6@latest
  1. 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();
  }
}

SSH host keys are verified against ~/.ssh/known_hosts. Set XK6_SFTP_KNOWN_HOSTS to use a different known hosts file. Add and verify the server's host key before connecting; connections to unknown or changed keys are rejected.

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.)

About

xk6 sftp protocol

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

16 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages