Skip to content

redis-developer/go-redis-test-app

Repository files navigation

Hitless Tool - YAML Configuration

This tool has been modified to read configuration exclusively from YAML files, similar to the Node.js Redis test app format.

Usage

./hitless-tool workloads/example-workload.yaml

The tool now accepts a single argument: the path to the YAML configuration file.

YAML Configuration Format

The YAML configuration follows this structure:

runner:
  redis:
    host: "127.0.0.1"
    port: 6379
    username: ""
    password: ""
    database: 0
    timeout: "5s"
  
  test:
    mode: "standalone"        # standalone or cluster
    clients: 10               # Number of concurrent clients
    workload:
      type: "exec"            # exec, multi, or pub_sub
      maxDuration: "60s"      # Duration or "endless"
      options:
        batchSize: 50
        getSetRatio: 0.5
        valueSize: 100
        iterationCount: null  # null for unlimited
        delayAfterIteration: "10ms"
        transactionSize: 10

global:
  rps: 0                      # Max requests per second (0 = no limit)
  betweenClientsDelay: "0ms"  # Delay between client creation
  metrics:
    enabled: true
    appName: "go-hitless"
    version: "1.0.0"
    runId: ""            # Auto-generated if empty
  output:
    jsonFile: ""         # Path for JSON results export (optional)

Configuration Sections

runner.redis

Redis connection configuration including host, port, authentication, and timeouts.

runner.test

Test execution configuration including mode, number of clients, and workload definition.

runner.test.workload

Workload-specific settings including type, duration, and various options.

global

Global application settings including rate limiting, client delays, and metrics configuration.

Workload Types

exec

Executes individual Redis commands (GET, SET, HGET, HSET)

multi

Executes commands in MULTI/EXEC transactions

pub_sub

Publishes and subscribes to Redis channels

Key Generation

The tool supports two key generation strategies:

  • random: Generate random keys within the specified range
  • sequential: Generate sequential keys (currently implemented as random)

The keyPattern field supports %d placeholder for the generated number.

Example Workloads

Several example workloads are provided in the workloads/ directory:

  • example-workload.yaml: Basic exec workload
  • multi-workload.yaml: Multi/exec transaction workload with rate limiting
  • pubsub-workload.yaml: Pub/sub workload that runs endlessly

Running Examples

# Basic exec workload
./hitless-tool workloads/example-workload.yaml

# Multi/exec workload with rate limiting
./hitless-tool workloads/multi-workload.yaml

# Pub/sub workload (runs forever)
./hitless-tool workloads/pubsub-workload.yaml

Metrics Configuration

Metrics can be enabled/disabled and configured through the YAML file:

global:
  metrics:
    enabled: true           # Enable/disable metrics
    appName: "my-app"      # Application name for metrics
    version: "1.0.0"       # Version for metrics
    runId: "custom"   # Custom run ID (auto-generated if empty)

JSON Output Results

Instead of sending metrics to an OTLP endpoint, you can disable metrics and export test results to a JSON file:

global:
  metrics:
    enabled: false          # Disable metrics export
    appName: "my-test-app" 
    version: "1.0.0"
  output:
    jsonFile: "test-results.json"  # Export results to JSON file

When metrics are disabled and a JSON output file is configured, the tool will export final test results containing:

  • Test Duration: Total test execution time with start/end timestamps
  • App Name: Application name from configuration
  • Workload Name: Type of workload executed (exec, multi, pubsub)
  • Total Commands Count: Total number of commands attempted
  • Successful Commands: Number of commands that succeeded
  • Failed Commands: Number of commands that failed
  • Success Rate: Percentage of successful commands
  • Overall Throughput: Average commands per second

Example JSON output:

{
  "test_duration": "5.04s",
  "start_timestamp": "2025-07-22T10:50:02+03:00",
  "end_timestamp": "2025-07-22T10:50:07+03:00",
  "app_name": "redis-test-app",
  "workload_name": "exec",
  "total_commands_count": 604,
  "successful_commands": 604,
  "failed_commands": 0,
  "success_rate": 100,
  "overall_throughput": 119.78
}

The results are exported both to the specified JSON file and printed to stdout for easy viewing.

Duration and Delay Values

All duration and delay values use Go's duration format:

  • "1s" - 1 second
  • "500ms" - 500 milliseconds
  • "1m" - 1 minute
  • "1h" - 1 hour
  • "endless" - Run forever (only for maxDuration)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages