k6

command module
v0.0.0-...-29e7bc9 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

README

k6

Like unit testing, for performance

Modern load testing for developers and testers in the DevOps era.

Github release Build status Go Report Card Codecov branch
Slack channel

Download · Documentation · Community Forum


---

k6 is a modern load-testing tool, built on our years of experience in the performance and testing industries. It's built to be powerful, extensible, and full-featured. The key design goal is to provide the best developer experience.

Its core features are:

  • Configurable load generation. Even lower-end machines can simulate lots of traffic.
  • Tests as code. Reuse scripts, modularize logic, version control, and integrate tests with your CI.
  • A full-featured API. The scripting API is packed with features that help you simulate real application traffic.
  • An embedded JavaScript engine. The performance of Go, the scripting familiarity of JavaScript.
  • Multiple Protocol support. HTTP, WebSockets, gRPC, and more.
  • Large extension ecosystem. You can extend k6 to support your needs. And many people have already shared their extensions with the community!
  • Flexible metrics storage and visualization. Summary statistics or granular metrics, exported to the service of your choice.

This is what load testing looks like in the 21st century.

Example script

import http from "k6/http";
import { check, sleep } from "k6";

// Test configuration
export const options = {
  thresholds: {
    // Assert that 99% of requests finish within 3000ms.
    http_req_duration: ["p(99) < 3000"],
  },
  // Ramp the number of virtual users up and down
  stages: [
    { duration: "30s", target: 15 },
    { duration: "1m", target: 15 },
    { duration: "20s", target: 0 },
  ],
};

// Simulated user behavior
export default function () {
  let res = http.get("https://test-api.k6.io/public/crocodiles/1/");
  // Validate response status
  check(res, { "status was 200": (r) => r.status == 200 });
  sleep(1);
}

You can run scripts like this on the CLI, or in your CI, or across a Kubernetes cluster.

Documentation

The docs cover all aspects of using k6. Some highlights include:

  • Get Started. Install, run a test, inspect results.
  • HTTP requests. Have your virtual users use HTTP methods. Or, check the other Protocols.
  • Thresholds. Set goals for your test, and codify your SLOs.
  • Options. Configure your load, duration, TLS certificates, and much, much more.
  • Scenarios. Choose how to model your workload: open models, closed models, constant RPS, fixed iterations, and more.
  • Results output. Study, filter, and export your test results.
  • JavaScript API. Reference and examples of all k6 modules.
  • Extensions. Extend k6 for new protocols and use cases.

These links barely scratch the surface! If you're looking for conceptual information, you can read about Test types, Test strategies, or one of the many informative Blog posts.

Contribute

If you want to contribute or help with the development of k6, start by reading CONTRIBUTING.md. Before you start coding, it might be a good idea to first discuss your plans and implementation details with the k6 maintainers—especially when it comes to big changes and features. You can do this in the GitHub issue for the problem you're solving (create one if it doesn't exist).

Note: To disclose security issues, refer to SECURITY.md.

Support

To get help, report bugs, suggest features, and discuss k6 with others, refer to SUPPORT.md.

License

k6 is distributed under the AGPL-3.0 license.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1
Package v1 implements the v1 of the k6's REST API
Package v1 implements the v1 of the k6's REST API
Package cloudapi contains several things related to the k6 cloud - various data and config structures, a REST API client, log streaming logic, etc.
Package cloudapi contains several things related to the k6 cloud - various data and config structures, a REST API client, log streaming logic, etc.
cmd
Package cmd implements the command-line interface of k6.
Package cmd implements the command-line interface of k6.
state
Package state contains the types and functionality used for keeping track of cmd-related values that are used globally throughout k6.
Package state contains the types and functionality used for keeping track of cmd-related values that are used globally throughout k6.
tests
Package tests contains integration tests that run k6 commands, and interact with standard I/O streams.
Package tests contains integration tests that run k6 commands, and interact with standard I/O streams.
converter
har
Package errext contains extensions for normal Go errors that are used in k6.
Package errext contains extensions for normal Go errors that are used in k6.
exitcodes
Package exitcodes contains the constants representing possible k6 exit error codes.
Package exitcodes contains the constants representing possible k6 exit error codes.
Package execution contains most of the components that schedule, execute and control individual k6 tests.
Package execution contains most of the components that schedule, execute and control individual k6 tests.
Package ext contains the extension registry and all generic functionality for k6 extensions.
Package ext contains the extension registry and all generic functionality for k6 extensions.
js
Package js is the JavaScript implementation of the lib.Runner and relative concepts for executing concurrent-safe JavaScript code.
Package js is the JavaScript implementation of the lib.Runner and relative concepts for executing concurrent-safe JavaScript code.
common
Package common contains helpers for interacting with the JavaScript runtime.
Package common contains helpers for interacting with the JavaScript runtime.
eventloop
Package eventloop implements an event loop to be used thought js and it's subpackages
Package eventloop implements an event loop to be used thought js and it's subpackages
modules
Package modules defines interfaces used for developing k6's JavaScript modules.
Package modules defines interfaces used for developing k6's JavaScript modules.
modules/k6
Package k6 implements the module imported as 'k6' from inside k6.
Package k6 implements the module imported as 'k6' from inside k6.
modules/k6/data
Package data implements `k6/data` js module for k6.
Package data implements `k6/data` js module for k6.
modules/k6/experimental
Package experimental includes experimental module features
Package experimental includes experimental module features
modules/k6/experimental/browser
Package browser contains a RootModule wrapper that wraps around the experimental browser RootModule.
Package browser contains a RootModule wrapper that wraps around the experimental browser RootModule.
modules/k6/experimental/tracing
Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
Package tracing implements a k6 JS module for instrumenting k6 scripts with tracing context information.
modules/k6/html
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT
generated by js/modules/k6/html/gen/gen_elements.go; DO NOT EDIT
modules/k6/http
Package http implements the k6/http js module for k6.
Package http implements the k6/http js module for k6.
modules/k6/ws
Package ws implements a k6/ws for k6.
Package ws implements a k6/ws for k6.
modulestest
Package modulestest contains helpers to test js modules
Package modulestest contains helpers to test js modules
lib
Package lib is a kitchen sink of...
Package lib is a kitchen sink of...
fsext
Package fsext provides extended file system functions
Package fsext provides extended file system functions
netext/grpcext
Package grpcext allows gRPC requests collecting stats info.
Package grpcext allows gRPC requests collecting stats info.
testutils/httpmultibin
Package httpmultibin is indended only for use in tests, do not import in production code!
Package httpmultibin is indended only for use in tests, do not import in production code!
types
Package types contains types used in the codebase Most of the types have a Null prefix like gopkg.in/guregu/null.v3 and UnmarshalJSON and MarshalJSON methods.
Package types contains types used in the codebase Most of the types have a Null prefix like gopkg.in/guregu/null.v3 and UnmarshalJSON and MarshalJSON methods.
Package loader is about loading files from either the filesystem or through https requests.
Package loader is about loading files from either the filesystem or through https requests.
Package log implements various logrus hooks.
Package log implements various logrus hooks.
Package metrics contains various k6 components that deal with metrics and thresholds.
Package metrics contains various k6 components that deal with metrics and thresholds.
engine
Package engine contains the internal metrics engine responsible for aggregating metrics during the test and evaluating thresholds against them.
Package engine contains the internal metrics engine responsible for aggregating metrics during the test and evaluating thresholds against them.
Package output contains the interfaces that k6 outputs (and output extensions) have to implement, as well as some helpers to make their implementation and management easier.
Package output contains the interfaces that k6 outputs (and output extensions) have to implement, as well as some helpers to make their implementation and management easier.
cloud
Package cloud implements an Output that flushes to the k6 Cloud platform.
Package cloud implements an Output that flushes to the k6 Cloud platform.
cloud/expv2
Package expv2 contains a Cloud output using a Protobuf binary format for encoding payloads.
Package expv2 contains a Cloud output using a Protobuf binary format for encoding payloads.
cloud/expv2/pbcloud
Package pbcloud contains the Protobuf definitions used for the metrics flush RPCs.
Package pbcloud contains the Protobuf definitions used for the metrics flush RPCs.
cloud/v1
Package cloud implements an Output that flushes to the k6 Cloud platform using the version1 of the protocol flushing a json-based payload.
Package cloud implements an Output that flushes to the k6 Cloud platform using the version1 of the protocol flushing a json-based payload.
csv
Package csv implements an output writing metrics in csv format
Package csv implements an output writing metrics in csv format
ui
Package ui contains some generic UI k6 components.
Package ui contains some generic UI k6 components.
console
Package console implements the command-line UI for k6.
Package console implements the command-line UI for k6.
pb
Package pb implements a progressbar component for CLI user interfaces
Package pb implements a progressbar component for CLI user interfaces

Jump to

Keyboard shortcuts

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