Skip to content

A load testing tool for Minecraft servers based on Mineflayer and YAML scenarios.

License

Notifications You must be signed in to change notification settings

GaetanOff/StressTest-MC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Stress-Test-MC ๐Ÿš€

๐Ÿ› ๏ธ A load testing tool for Minecraft servers based on Mineflayer and YAML scenarios.

๐Ÿ“Œ Features

โœ… Simulates Minecraft bots (joining, movement, chat, interactions...)
โœ… Easy configuration using YAML scenarios
โœ… Multi-threading support (configurable number of threads for better performance)
โœ… Supports SOCKS5 proxies (optional activation)
โœ… Advanced logging system (logs/bot.log)
โœ… Automatic reconnection (to be implemented if needed)
โœ… Ability to load custom scenarios


๐Ÿ“ฆ Installation

1๏ธโƒฃ Clone the project

git clone https://github.com/GaetanOff/StressTest-MC.git
cd Stress-Test-MC

2๏ธโƒฃ Install dependencies

If you're using pnpm:

pnpm install

Otherwise, with npm:

npm install

โš™๏ธ Configuration

The config/config.json file allows you to adjust project settings.

Configuration options:

  • botJoinDelay (number): Delay in milliseconds between bot connections (default: 500ms)
  • threads (number): Number of worker threads to use for bot management (default: 1)
    • Use 1 for single-threaded execution (original behavior)
    • Use > 1 to enable multi-threading and improve performance with many bots
  • proxy: Proxy configuration for SOCKS5 proxies
  • logging: Logging configuration (enable/disable and log level)

Example configuration:

{
  "botJoinDelay": 500,
  "threads": 3,
  "proxy": {
    "enabled": false,
    "list": [
      { "host": "proxy1.com", "port": 1080 },
      { "host": "proxy2.com", "port": 1080 }
    ],
    "maxRetries": 3
  },
  "logging": {
    "enabled": true,
    "level": "info"
  }
}

๐Ÿ“Œ Note: The server configuration (host, port, version) is defined in each scenario YAML file, not in config.json.


๐Ÿ“œ Creating a scenario

Scenarios are defined in config/scenarios/ using YAML.

Example scenario (scenario-1.yml)

name: "Stress Test - Exploration and Chat"
numberOfBots: 60  # Total number of bots to spawn

server:
  host: "play.example.com"
  port: 25565

event:
  onJoin:
    execute: "/help"  # Command executed as soon as the bot joins
    wait: 2s          # Wait 2 seconds before executing the next actions

actions:
  move-group:
    type: move
    position:
      x: 100
      y: 65
      z: 200
    speed: normal  # slow, normal, fast
    waitAfter: 5s  # Waiting time after reaching the destination

  send-messages:
    type: chat
    messages:
      - "Hello everyone!"
      - "Anyone up for a game?"
      - "I'm a bot, but a friendly one ๐Ÿค–"
    interval: 10s  # Time between each message

  interact-block:
    type: interact
    target:
      x: 105
      y: 65
      z: 205
    action: "right_click"  # Can be "left_click" or "right_click"
    delay: 3s  # Time before interaction

๐Ÿš€ Usage

1๏ธโƒฃ Launch a scenario

node src/index.js scenario-1.yml

๐Ÿ“Œ If no scenario is specified, scenario-1.yml will be used by default.

2๏ธโƒฃ Configure multi-threading

To improve performance when launching many bots, you can configure multiple threads in config.json:

{
  "threads": 4  // Launch bots across 4 threads
}

The bots will be automatically distributed across the specified number of threads. Each bot will be named Bot-ThreadNumber-LocalNumber (e.g., Bot-1-1, Bot-1-2, Bot-2-1, etc.).

3๏ธโƒฃ Enable proxies

In config.json, set "enabled": true under "proxy":

"proxy": {
  "enabled": true,
  "list": [
    { "host": "proxy1.com", "port": 1080 },
    { "host": "proxy2.com", "port": 1080 }
  ],
  "maxRetries": 3
}

๐Ÿš€ Running the Project with Docker

This project includes a Docker setup to easily run Minecraft bot stress tests without installing dependencies manually.

1๏ธโƒฃ Build the Docker Image

docker build -t stress-test-mc .

2๏ธโƒฃ Run the Container

To start the project inside a Docker container:

docker run --rm -it stress-test-mc

This will launch the bots as defined in the default scenario.

3๏ธโƒฃ Run a Custom Scenario

To run a specific scenario:

docker run --rm -it stress-test-mc node src/index.js scenario-2.yml

4๏ธโƒฃ Mount Local Files (For Development)

If you want to modify files without rebuilding the image, mount the current directory:

docker run --rm -it -v $(pwd):/app stress-test-mc

This allows you to edit code locally, and it will reflect inside the container.


๐Ÿ“‚ Project structure

mc-load-tester/
โ”‚โ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ scenarios/              # ๐Ÿ“‚ YAML scenarios
โ”‚   โ”‚   โ”œโ”€โ”€ scenario-1.yml
โ”‚   โ”‚   โ”œโ”€โ”€ scenario-2.yml
โ”‚   โ”œโ”€โ”€ config.json             # โš™๏ธ Main configuration
โ”‚
โ”‚โ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ bots/
โ”‚   โ”‚   โ”œโ”€โ”€ botManager.js       # ๐ŸŽฎ Bot management & multi-threading
โ”‚   โ”‚   โ”œโ”€โ”€ botFactory.js       # ๐Ÿ—๏ธ Bot creation
โ”‚   โ”‚   โ”œโ”€โ”€ botActions.js       # ๐Ÿ”ง Bot actions
โ”‚   โ”‚   โ”œโ”€โ”€ botLifecycle.js     # ๐Ÿ”„ Shared bot lifecycle functions
โ”‚   โ”‚   โ”œโ”€โ”€ worker.js           # ๐Ÿงต Worker thread handler
โ”‚   โ”œโ”€โ”€ scenario/
โ”‚   โ”‚   โ”œโ”€โ”€ scenarioManager.js  # ๐Ÿ“œ Scenario execution
โ”‚   โ”‚   โ”œโ”€โ”€ scenarioParser.js   # ๐Ÿ“ YAML parsing
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ logger.js           # ๐Ÿ–Š๏ธ Logging system
โ”‚   โ”‚   โ”œโ”€โ”€ helpers.js          # โšก Utility functions
โ”‚
โ”‚โ”€โ”€ logs/                       # ๐Ÿ“‚ Log files (auto-created)
โ”‚โ”€โ”€ index.js                    # ๐Ÿš€ Main entry point
โ”‚โ”€โ”€ package.json                 # ๐Ÿ“ฆ Dependencies and scripts
โ”‚โ”€โ”€ README.md                    # ๐Ÿ“– Documentation

๐Ÿ“„ Logs

Logs are recorded in logs/bot.log.

Example (single-threaded):

[2025-01-30T07:57:39.999Z] [INFO] ๐Ÿš€ Launching 60 bots...
[2025-01-30T07:57:40.000Z] [INFO] ๐Ÿค– Creating bot: Bot_1
[2025-01-30T07:57:40.001Z] [INFO] โœ… Bot_1 has connected!
[2025-01-30T07:57:42.005Z] [INFO] ๐Ÿ’ฌ Bot_1 says: "Hello everyone!"

Example (multi-threaded):

[2025-01-30T07:57:39.999Z] [INFO] ๐Ÿš€ Launching 60 bots...
[2025-01-30T07:57:39.999Z] [INFO] ๐Ÿงต Starting 60 bots across 3 threads (โ‰ˆ20 bots per thread)
[2025-01-30T07:57:40.000Z] [INFO] [Thread 1] ๐Ÿค– Creating bot: Bot-1-1
[2025-01-30T07:57:40.000Z] [INFO] [Thread 2] ๐Ÿค– Creating bot: Bot-2-1
[2025-01-30T07:57:40.000Z] [INFO] [Thread 3] ๐Ÿค– Creating bot: Bot-3-1
[2025-01-30T07:57:40.001Z] [INFO] [Thread 1] โœ… Bot-1-1 has connected!

๐Ÿ“ License

All the code is licensed under GPL v3.
Feel free to modify and improve it! ๐Ÿ˜ƒ


๐Ÿ™Œ Contributing

๐Ÿ’ก Ideas, suggestions, or bugs?
Open an issue or submit a pull request!


๐Ÿ“ฌ Contact

๐Ÿ“ง contact@gaetandev.fr
๐ŸŒ Website
๐Ÿ’ฌ Discord: GaetanDev


๐ŸŽ‰ Thank you for using Stress-Test-MC!

If you have any questions or suggestions, let me know! ๐Ÿš€๐Ÿ˜ƒ

About

A load testing tool for Minecraft servers based on Mineflayer and YAML scenarios.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published