xk6sftp

package module
v0.0.0-...-dacc7c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

README

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();
  }
}

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct{}

func (*Client) NewClient

func (*Client) NewClient(user, password, host string, port int) *SFTPClient

type OperationResult

type OperationResult struct {
	Success bool
	Message string
}

type SFTPClient

type SFTPClient struct {
	// contains filtered or unexported fields
}

func (*SFTPClient) Close

func (s *SFTPClient) Close() *OperationResult

func (*SFTPClient) DeleteFile

func (s *SFTPClient) DeleteFile(remotePath string) *OperationResult

func (*SFTPClient) DownloadFile

func (s *SFTPClient) DownloadFile(remotePath, localPath string) *OperationResult

func (*SFTPClient) UploadFile

func (s *SFTPClient) UploadFile(localPath, remotePath string) *OperationResult

type SFTPClientInterface

type SFTPClientInterface interface {
	UploadFile(localPath, remotePath string) *OperationResult
	DownloadFile(remotePath, localPath string) *OperationResult
	DeleteFile(remotePath string) *OperationResult
	Close() *OperationResult
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL