Running Mode

Currently, boomer has two running mode, standalone and distributed.

Distributed

When running in distributed mode, boomer will connect to a locust master and running as a slave. It’s the default running mode of boomer.

Standalone

When running in standalone mode, boomer doesn’t need to connect to a locust master and start testing immediately.

You can write you own output and add more by calling boomer.AddOutput().

Here is an example for writting to stdout.

AddOutput(new boomer.NewConsoleOutput())

Here is an example for pushing output to Prometheus Pushgateway.

var globalBoomer *boomer.Boomer

func main() {
   task1 := &boomer.Task{
      Name:   "foo",
      Weight: 10,
      Fn:     foo,
   }

   numClients := 10
   spawnRate := float64(10)
   globalBoomer = boomer.NewStandaloneBoomer(numClients, spawnRate)
   globalBoomer.AddOutput(boomer.NewPrometheusPusherOutput("http://localhost:9091", "hrp"))
   globalBoomer.Run(task1)
}
 1package main
 2
 3import (
 4	"log"
 5	"time"
 6
 7	"github.com/myzhan/boomer"
 8)
 9
10func foo() {
11	start := time.Now()
12	time.Sleep(100 * time.Millisecond)
13	elapsed := time.Since(start)
14
15	// Report your test result as a success, if you write it in python, it will looks like this
16	// events.request_success.fire(request_type="http", name="foo", response_time=100, response_length=10)
17	globalBoomer.RecordSuccess("http", "foo", elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))
18}
19
20var globalBoomer *boomer.Boomer
21
22func main() {
23	log.SetFlags(log.LstdFlags | log.Lshortfile)
24
25	task1 := &boomer.Task{
26		Name:   "foo",
27		Weight: 10,
28		Fn:     foo,
29	}
30
31	numClients := 10
32	spawnRate := float64(10)
33	globalBoomer = boomer.NewStandaloneBoomer(numClients, spawnRate)
34	globalBoomer.AddOutput(boomer.NewConsoleOutput())
35	globalBoomer.Run(task1)
36}