xk6_dns

package module
v0.0.0-...-d7e29d8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

xk6-dns

This is a k6 extension using the xk6 system.

Build

To build a k6 binary with this plugin, first ensure you have the prerequisites:

  • Go toolchain
  • If you're using SQLite, a build toolchain for your system that includes gcc or another C compiler. On Debian and derivatives install the build-essential package. On Windows you can use tdm-gcc. Make sure that gcc is in your PATH.
  • Git

Then:

  1. Install xk6:
go install github.com/k6io/xk6/cmd/xk6@latest
  1. Build the binary:
xk6 build v0.33.0 --with github.com/vanstinator/xk6-dns

Example

// example.js
import dns from 'k6/x/dns';

export let options = {
    discardResponseBodies: true,
    scenarios: {
        my_awesome_dns_test: {
            executor: 'constant-vus',
            vus: 1,
            duration: '5s',
        },
    },
};

export default function () {
    dns.setReadTimeout('1s');
    dns.resolve('127.0.0.1:53', 'example.com.', 'A');
}

Result output:

$ ./k6 run example.js

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

  execution: local
     script: example.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 35s max duration (incl. graceful stop):
           * my_awesome_dns_test: 1 looping VUs for 5s (gracefulStop: 30s)


running (05.0s), 0/1 VUs, 1938 complete and 0 interrupted iterations
my_awesome_api_test ↓ [======================================] 1 VUs  5s

     data_received........: 87 kB 17 kB/s
     data_sent............: 56 kB 11 kB/s
     dns.dial.count.......: 1938  387.409151/s
     dns.request.count....: 1938  387.409151/s
     dns.response.rtt.....: avg=2.04ms min=0s       med=1ms   max=356ms    p(90)=1ms    p(95)=1ms
     iteration_duration...: avg=2.56ms min=794.36μs med=1.5ms max=357.11ms p(90)=1.64ms p(95)=1.68ms
     iterations...........: 1938  387.409151/s
     vus..................: 1     min=1        max=1
     vus_max..............: 1     min=1        max=1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DialCount = stats.New("dns.dial.count", stats.Counter)
	DialError = stats.New("dns.dial.error", stats.Counter)

	RequestCount = stats.New("dns.request.count", stats.Counter)
	RequestError = stats.New("dns.request.error", stats.Counter)

	ResponseTime = stats.New("dns.response.time", stats.Trend, stats.Time)
)

Functions

func NewK6TCPConn

func NewK6TCPConn(addr string) (*k6TCPConn, error)

func NewK6UDPConn

func NewK6UDPConn(addr string) (*k6UDPConn, error)

Types

type K6DNS

type K6DNS struct {
	Version string
	// contains filtered or unexported fields
}

func NewK6DNS

func NewK6DNS(version string) *K6DNS

func (*K6DNS) ResolveTCP

func (k *K6DNS) ResolveTCP(ctx context.Context, addr, query, qtypeStr string) (string, error)

func (*K6DNS) ResolveUDP

func (k *K6DNS) ResolveUDP(ctx context.Context, addr, query, qtypeStr string) (string, error)

func (*K6DNS) SetDialTimeout

func (k *K6DNS) SetDialTimeout(s string) error

func (*K6DNS) SetReadTimeout

func (k *K6DNS) SetReadTimeout(s string) error

func (*K6DNS) SetWriteTimeout

func (k *K6DNS) SetWriteTimeout(s string) error

Jump to

Keyboard shortcuts

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