xpulsar

package module
v0.0.0-...-6528d99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

Test pulsar using k6

Build k6 with extension


# install xk6 using go or download(https://github.com/grafana/xk6/releases)
❯ go install go.k6.io/xk6/cmd/xk6@latest

# build k6
❯ xk6 build --with github.com/koolay/xk6-pulsar=.

Run tests

# --vus virtual users 
# --duration  how lang continue testing

❯ PULSAR_TOPIC=localtest PULSAR_ADDR=localhost:6650 ./k6 run test_producer.js --duration 10s --vus 2

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: test_producer.js
     output: -

  scenarios: (100.00%) 1 scenario, 2 max VUs, 40s max duration (incl. graceful stop):
           * default: 2 looping VUs for 10s (gracefulStop: 30s)

INFO[0010] teardown!!                                    source=console

running (10.1s), 0/2 VUs, 2142 complete and 0 interrupted iterations
default ✓ [======================================] 2 VUs  10s

     ✓ is send

     █ teardown

     checks.........................: 100.00% ✓ 2142       ✗ 0
     data_received..................: 0 B     0 B/s
     data_sent......................: 0 B     0 B/s
     iteration_duration.............: avg=9.31ms min=102.58µs med=9.19ms max=18.47ms p(90)=10.67ms p(95)=11.69ms
     iterations.....................: 2142    212.791617/s
     pulsar.publish.error.count.....: 0       0/s
     pulsar.publish.message.bytes...: 70 MB   7.0 MB/s
     pulsar.publish.message.count...: 2142    212.791617/s
     vus............................: 2       min=2        max=2
     vus_max........................: 2       min=2        max=2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PublishMessages = stats.New("pulsar.publish.message.count", stats.Counter)
	PublishBytes    = stats.New("pulsar.publish.message.bytes", stats.Counter, stats.Data)
	PublishErrors   = stats.New("pulsar.publish.error.count", stats.Counter)
)

Functions

func ReportPubishMetrics

func ReportPubishMetrics(ctx context.Context, currentStats PublisherStats) error

Types

type ProducerConfig

type ProducerConfig struct {
	Topic string
}

type PubSub

type PubSub struct{}

func (*PubSub) CloseClient

func (p *PubSub) CloseClient(client pulsar.Client)

func (*PubSub) CloseProducer

func (p *PubSub) CloseProducer(producer pulsar.Producer)

func (*PubSub) CreateClient

func (p *PubSub) CreateClient(clientConfig PulsarClientConfig) (pulsar.Client, error)

func (*PubSub) CreateProducer

func (p *PubSub) CreateProducer(client pulsar.Client, config ProducerConfig) pulsar.Producer

func (*PubSub) Publish

func (p *PubSub) Publish(
	ctx context.Context,
	producer pulsar.Producer,
	body []byte,
	properties map[string]string,
	async bool,
) error

type PublisherStats

type PublisherStats struct {
	Topic        string
	ProducerName string
	Messages     int
	Errors       int
	Bytes        int64
}

type PulsarClientConfig

type PulsarClientConfig struct {
	URL string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL