Etherpad Socket.IO Load Test Client

1.0.3 · active · verified Sun Apr 19

`etherpad-load-test-socket-io` is a client library providing the core logic for programmatically load testing an Etherpad instance via its Socket.IO API. It simulates various user activities, such as "lurkers" (viewers) and "active authors" (editors), to gauge the performance and scalability of an Etherpad server. While this package provides the underlying client functionality, it is typically consumed by higher-level command-line tools, such as `etherpad-load-test`, which offer a more user-friendly interface for executing load tests. The current stable version is 1.0.3, with a Node.js engine requirement of `>=18.0.0`. Its release cadence aligns with the development of the `etherpad-load-test` CLI and the broader Etherpad project, focusing on stability and compatibility with Etherpad Lite. Its key differentiator is its direct, low-level interaction with Etherpad's Socket.IO protocol, enabling deep customization of load testing scenarios.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to programmatically initialize and connect a single `etherpad-load-test-socket-io` client to a specific Etherpad pad, simulating a user for a set duration, and handling basic connection events.

import Client from 'etherpad-load-test-socket-io';

// Configuration for your Etherpad instance and the load test
const etherpadUrl = 'http://127.0.0.1:9001'; // Ensure your Etherpad instance is running here
const padId = 'myLoadTestPad';
const userId = 'testUser123';
const userName = 'Load Tester';
const readOnly = false; // true for lurkers, false for active authors

async function runSingleClientTest() {
  console.log(`Starting client for pad: ${padId}`);

  try {
    // Instantiate the client with Etherpad details
    const client = new Client(etherpadUrl, padId, userId, userName, readOnly);

    // Event listeners for client lifecycle and messages
    client.on('connect', () => {
      console.log(`Client ${userId} connected to ${etherpadUrl}/p/${padId}`);
      // Additional actions can be performed here, e.g., typing or sending messages
      // For a basic connection test, just connecting and waiting is sufficient.
    });

    client.on('disconnect', (reason: string) => {
      console.log(`Client ${userId} disconnected: ${reason}`);
    });

    client.on('error', (err: Error) => {
      console.error(`Client ${userId} error: ${err.message}`);
    });

    client.on('message', (msg: any) => {
      // console.log(`Client ${userId} received message:`, msg); // Can be very verbose for active pads
    });

    // Establish the connection to the Etherpad instance
    client.connect();

    // Keep the client connected for a duration (e.g., 30 seconds)
    console.log(`Keeping client ${userId} connected for 30 seconds...`);
    await new Promise(resolve => setTimeout(resolve, 30000));

    // Disconnect after the test duration
    client.disconnect();
    console.log(`Client ${userId} test finished.`);

  } catch (error) {
    console.error('Failed to initialize or run client:', error);
  }
}

runSingleClientTest();

view raw JSON →