k6build

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: AGPL-3.0 Imports: 5 Imported by: 2

README

k6build

k6build builds custom k6 binaries with extensions

Examples

The following sections describe different usage scenarios.

kubernetes

examples/kubernetes describes how to run k6build in a kubernetes cluster and execute k6 tests in a pod using k6exec.

k6-operator

TODO: use k6-operator for running the tests using a custom image.

k6build

Build k6 with various builders.

Build k6 using one of the supported builders.

Commands


k6build cache

k6build cache server

Synopsis

Starts a k6build cache server.

The cache server offers a REST API for storing and downloading objects.

Objects can be retrieved by a download url returned when the object is stored.

The --download-url specifies the base URL for downloading objects. This is necessary to allow downloading the objects from different machines.

k6build cache [flags]

Examples


# start the cache server serving an external url
k6build cache --download0url http://external.url

# store object from same host
curl -x POST http://localhost:9000/cache/objectID -d "object content" | jq .
{
	"Error": "",
	"Object": {
	  "ID": "objectID",
	  "Checksum": "17d3eb873fe4b1aac4f9d2505aefbb5b53b9a7f34a6aadd561be104c0e9d678b",
	  "URL": "http://external.url:9000/cache/objectID/download"
	}
      }

# download object from another machine using the external url
curl http://external.url:9000/cache/objectID/download

Flags

  -c, --cache-dir string      cache directory (default "/tmp/cache/objectstore")
  -d, --download-url string   base url used for downloading objects. If not specified http://localhost:<port> is used
  -h, --help                  help for cache
  -l, --log-level string      log level (default "INFO")
  -p, --port int              port server will listen (default 9000)

SEE ALSO

  • k6build - Build k6 with various builders.

k6build local

build custom k6 binary locally

Synopsis

k6build local builder creates a custom k6 binary artifacts that satisfies certain dependencies. Requires the golang toolchain and git.

k6build local [flags]

Examples


# build k6 v0.51.0 with latest version of k6/x/kubernetes
k6build local -k v0.51.0 -d k6/x/kubernetes

platform: linux/amd64
k6: v0.51.0
k6/x/kubernetes: v0.9.0
checksum: 7f06720503c80153816b4ef9f58571c2fce620e0447fba1bb092188ff87e322d

# build k6 v0.51.0 with k6/x/kubernetes v0.8.0 and k6/x/output-kafka v0.7.0
k6build local -k v0.51.0 \
    -d k6/x/kubernetes:v0.8.0 \
    -d k6/x/output-kafka:v0.7.0

platform: linux/amd64
k6: v0.51.0
k6/x/kubernetes: v0.8.0
k6/x/output-kafka": v0.7.0
checksum: f4af178bb2e29862c0fc7d481076c9ba4468572903480fe9d6c999fea75f3793


# build k6 v0.50.0 with latest version of k6/x/kubernetes using a custom catalog
k6build local -k v0.50.0 -d k6/x/kubernetes \
    -c /path/to/catalog.json -q

# build k6 v0.50.0 using a custom GOPROXY
k6build local -k v0.50.0 -e GOPROXY=http://localhost:80 -q

Flags

  -f, --cache-dir string         cache dir (default "/tmp/buildservice")
  -c, --catalog string           dependencies catalog (default "catalog.json")
  -g, --copy-go-env              copy go environment (default true)
  -d, --dependency stringArray   list of dependencies in form package:constrains
  -e, --env stringToString       build environment variables (default [])
  -h, --help                     help for local
  -k, --k6 string                k6 version constrains (default "*")
  -o, --output string            path to put the binary as an executable. (default "k6")
  -p, --platform string          target platform (default GOOS/GOARCH)
  -q, --quiet                    don't print artifact's details
  -v, --verbose                  print build process output

SEE ALSO

  • k6build - Build k6 with various builders.

k6build remote

build a custom k6 using a remote build server

Synopsis

Builds custom k6 binaries using a k6build server returning the details of the binary artifact and optionally download it.

k6build remote [flags]

Examples


# build k6 v0.51.0 with k6/x/kubernetes v0.8.0 and k6/x/output-kafka v0.7.0
k6build remote -s http://localhost:8000 \
    -k v0.51.0 \
    -p linux/amd64 \
    -d k6/x/kubernetes:v0.8.0 \
    -d k6/x/output-kafka:v0.7.0

id: 62d08b13fdef171435e2c6874eaad0bb35f2f9c7
platform: linux/amd64
k6: v0.51.0
k6/x/kubernetes: v0.9.0
k6/x/output-kafka": v0.7.0
checksum: f4af178bb2e29862c0fc7d481076c9ba4468572903480fe9d6c999fea75f3793
url: http://localhost:8000/cache/62d08b13fdef171435e2c6874eaad0bb35f2f9c7/download


# build k6 v0.51 with k6/x/output-kafka v0.7.0 and download as 'build/k6'
k6build remote -s http://localhost:8000 \
    -p linux/amd64  \
    -k v0.51.0 -d k6/x/output-kafka:v0.7.0 \
    -o build/k6 -q

# check downloaded binary
build/k6 version
k6 v0.51.0 (go1.22.2, linux/amd64)
Extensions:
  github.com/grafana/xk6-output-kafka v0.7.0, xk6-kafka [output]

Flags

  -d, --dependency stringArray   list of dependencies in form package:constrains
  -h, --help                     help for remote
  -k, --k6 string                k6 version constrains (default "*")
  -o, --output string            path to download the custom binary as an executable. If not specified, the artifact is not downloaded.
  -p, --platform string          target platform (default GOOS/GOARCH)
  -q, --quiet                    don't print artifact's details
  -s, --server string            url for build server (default "http://localhost:8000")

SEE ALSO

  • k6build - Build k6 with various builders.

k6build server

k6 build service

Synopsis

starts a k6build server

k6build server [flags]

Examples


# start the build server using a custom catalog
k6build server -c /path/to/catalog.json

# start the server the build server using a custom GOPROXY
k6build server -e GOPROXY=http://localhost:80

Flags

      --cache-url string     cache server url (default "http://localhost:9000")
  -c, --catalog string       dependencies catalog (default "catalog.json")
  -g, --copy-go-env          copy go environment (default true)
  -e, --env stringToString   build environment variables (default [])
  -h, --help                 help for server
  -l, --log-level string     log level (default "INFO")
  -p, --port int             port server will listen (default 8000)
  -v, --verbose              print build process output

SEE ALSO

  • k6build - Build k6 with various builders.

Documentation

Overview

Package k6build defines a service for building k8 binaries

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildFailed = errors.New("build failed") //nolint:revive

Functions

func ParseLogLevel added in v0.2.3

func ParseLogLevel(levelString string) (slog.Level, error)

ParseLogLevel parses the level from a string

Types

type Artifact

type Artifact struct {
	ID string `json:"id,omitempty"`
	// URL to fetch the artifact's binary
	URL string `json:"url,omitempty"`
	// list of dependencies
	Dependencies map[string]string `json:"dependencies,omitempty"`
	// platform
	Platform string `json:"platform,omitempty"`
	// binary checksum (sha256)
	Checksum string `json:"checksum,omitempty"`
}

Artifact defines a binary that can be downloaded TODO: add metadata (e.g. list of dependencies, checksum, date compiled)

func (Artifact) Print added in v0.3.1

func (a Artifact) Print() string

Print returns a string with a pretty print of the artifact

func (Artifact) PrintSummary added in v0.3.1

func (a Artifact) PrintSummary() string

PrintSummary returns a string with a pretty print of the artifact

func (Artifact) String added in v0.2.0

func (a Artifact) String() string

String returns a text serialization of the Artifact

type BuildService

type BuildService interface {
	// Build returns a k6 Artifact given its dependencies and version constrain
	Build(ctx context.Context, platform string, k6Constrains string, deps []Dependency) (Artifact, error)
}

BuildService defines the interface of a build service

type Dependency

type Dependency struct {
	// Name is the name of the dependency.
	Name string `json:"name,omitempty"`
	// Constraints contains the version constraints of the dependency.
	Constraints string `json:"constraints,omitempty"`
}

Dependency contains the properties of a k6 dependency.

type Module

type Module struct {
	Path    string `json:"path,omitempty"`
	Version string `json:"vesion,omitempty"`
}

Module defines an artifact dependency

Directories

Path Synopsis
cmd
Package cmd contains build cobra command factory function.
Package cmd contains build cobra command factory function.
cache
Package cache implements the cache command
Package cache implements the cache command
k6build
package main implements the CLI root command for the k6build tool
package main implements the CLI root command for the k6build tool
local
Package local implements the local build command
Package local implements the local build command
remote
Package remote implements the client command
Package remote implements the client command
server
Package server implements the build server command
Package server implements the build server command
pkg
api
Package api defines the interface to a build service
Package api defines the interface to a build service
cache
Package cache defines the interface of a cache service
Package cache defines the interface of a cache service
cache/api
Package api defines the interface to a cache server
Package api defines the interface to a cache server
cache/client
Package client implements a cache client
Package client implements a cache client
cache/file
Package file implements a file-backed cache
Package file implements a file-backed cache
cache/server
Package server implements a cache server
Package server implements a cache server
client
Package client implements a client for a build service
Package client implements a client for a build service
local
Package local implements a local build service
Package local implements a local build service
server
Package server implements a build server
Package server implements a build server
tools
gendoc
Package main contains CLI documentation generator tool.
Package main contains CLI documentation generator tool.

Jump to

Keyboard shortcuts

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