Skip to content

WoSai/ultron

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ultron

Go Report Card codecov GoDoc Ultron CI CodeQL

a http load testing tool in go

Usage

Requirements

Go 1.16+

Install

go get github.com/wosai/ultron/v2

Example

LocalRunner

package main

import (
	"net/http"
	"time"

	"github.com/wosai/ultron/v2"
)

func main() {
	task := ultron.NewTask()
	attacker := ultron.NewHTTPAttacker("google")
	attacker.Apply(
		ultron.WithPrepareFunc(func() (*http.Request, error) { // 压测事务逻辑实现
			return http.NewRequest(http.MethodGet, "https://www.google.com/ncr", nil)
		}),
		ultron.WithCheckFuncs(ultron.CheckHTTPStatusCode),
	)
	task.Add(attacker, 1)

	plan := ultron.NewPlan("google homepage")
	plan.AddStages(
		&ultron.V1StageConfig{
			Duration:        10 * time.Minute,
			ConcurrentUsers: 200,
			RampUpPeriod:    10,
		}
	)

	runner := ultron.NewLocalRunner()
	runner.Assign(task)   

	if err := runner.Launch(); err != nil {
		panic(err)
	}

	if err := runner.StartPlan(plan); err != nil {
		panic(err)
	}

	block := make(chan struct{}, 1)
	<-block
}

SlaveRunner

package main

import (
	"net/http"

	"github.com/wosai/ultron/v2"
	"google.golang.org/grpc"
)

func main() {
	task := ultron.NewTask()
	attacker := ultron.NewHTTPAttacker("google")
	attacker.Apply(
		ultron.WithPrepareFunc(func() (*http.Request, error) { // 压测事务逻辑实现
			return http.NewRequest(http.MethodGet, "https://www.google.com/ncr", nil)
		}),
		ultron.WithCheckFuncs(ultron.CheckHTTPStatusCode),
	)
	task.Add(attacker, 1)

	// 启动runner
	runner := ultron.NewSlaveRunner()
	runner.Assign(task)
	runner.SubscribeResult(nil)                                          // 订阅单次压测结果
	if err := runner.Connect(":2021", grpc.WithInsecure()); err != nil { // 连接master的grpc服务
		panic(err)
	}

	// 阻塞当前goroutine,避免程序推出
	block := make(chan struct{}, 1)
	<-block
}

MasterRunner

ultron

master

Web Portal

plan

stats

Report

Terminal Table

stats report

JSON Format

{
    "first_attack": "2021-11-02T03:09:08.419359417Z",
    "last_attack": "2021-11-02T03:09:21.209236204Z",
    "total_requests": 139450,
    "total_tps": 10903.15429322517,
    "full_history": true,
    "reports": {
        "benchmark": {
            "name": "benchmark",
            "requests": 139450,
            "min": 10000253,
            "max": 40510983,
            "median": 10000000,
            "average": 11869156,
            "tps": 10903.15429322517,
            "distributions": {
                "0.50": 10000000,
                "0.60": 10000000,
                "0.70": 10000000,
                "0.80": 10000000,
                "0.90": 20000000,
                "0.95": 21000000,
                "0.97": 26000000,
                "0.98": 29000000,
                "0.99": 30000000,
                "1.00": 40510983
            },
            "full_history": true,
            "first_attack": "2021-11-02T03:09:08.419359417Z",
            "last_attack": "2021-11-02T03:09:21.209236204Z"
        }
    },
    "extras": {
        "plan": "benchmark test"
    }
}

Grafana Dashboard

scripts/grafana/dashboard.json

Enhancements

Module Description
github.com/wosai/ultron/attacker/fastattacker/v2 Another http attacker implemented by fasthttp
github.com/wosai/ultron/attacker/jsonrpc/v2 A attacker used for jsonrpc protocol
github.com/wosai/ultron/handler/influxdbv1/v2 A handler that save attack result and report in InfluxDB v1
github.com/wosai/ultron/attacker/mqtt/v2 A attacker used for MQTT protocol v3.3

Contributors

Made with contrib.rocks.

Packages

No packages published

Languages

  • Go 84.1%
  • JavaScript 13.8%
  • Makefile 0.9%
  • TypeScript 0.6%
  • HTML 0.3%
  • CSS 0.2%
  • Less 0.1%