disruptor

package module
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

README

xk6-disruptor



xk6-disruptor
"Like Unit Testing, but for Reliability"

xk6-disruptor is an extension adds fault injection capabilities to Grafana k6. It implements the ideas of the Chaos Engineering discipline and enables Grafana k6 users to test their system's reliability under turbulent conditions.

⚠️ Important xk6-disruptor is in the alpha stage, undergoing active development. We do not guarantee API compatibility between releases - your k6 scripts may need to be updated on each release until this extension reaches v1.0 release.

Why xk6-disruptor?

xk6-disruptor is purposely designed and built to provide the best experience for developers trying to make their systems more reliable:

  • Everything as code.

    • No need to learn a new DSL.
    • Developers can use their usual development IDE
    • Facilitate test reuse and sharing
  • Fast to adopt with no day-two surprises.

    • No need to deploy and maintain a fleet of agents or operators.
  • Easy to extend and integrate with other types of tests.

    • No need to try to glue multiple tools together to get the job done.

Also, this project has been built to be a good citizen in the Grafana k6 ecosystem by:

  • Working well with other extensions.
  • Working well with k6's core concepts and features.

You can check this out in the following example:

export default function () {
    // Create a new pod disruptor with a selector 
    // that matches pods from the "default" namespace with the label "app=my-app"
    const disruptor = new PodDisruptor({
        namespace: "default",
        select: { labels: { app: "my-app" } },
    });

    // Disrupt the targets by injecting HTTP faults into them for 30 seconds
    const fault = {
        averageDelay: 500,
        errorRate: 0.1,
        errorCode: 500
    }
    disruptor.injectHTTPFaults(fault, "30s")
}

Features

The project, at this time, is intended to test systems running in Kubernetes. Other platforms are not supported at this time.

It offers an API for creating disruptors that target one specific type of the component (e.g., Pods) and is capable of injecting different kinds of faults, such as errors in HTTP requests served by that component. Currently, disruptors exist for Pods and Services, but others will be introduced in the future as well as additional types of faults for the existing disruptors.

Use cases

The main use case for xk6-disruptor is to test the resiliency of an application of diverse types of disruptions by reproducing their effects without reproducing their root causes. For example, inject delays in the HTTP requests an application makes to a service without having to stress or interfere with the infrastructure (network, nodes) on which the service runs or affect other workloads in unexpected ways.

In this way, xk6-disruptor make reliability tests repeatable and predictable while limiting their blast radius. These are essential characteristics to incorporate these tests in the test suits of applications deployed on shared infrastructures such as staging environments.

Learn more

Check the get started guide for instructions on how to install and use xk6-disruptor.

The examples section in the documentation presents examples of using xk6-disruptor for injecting faults in different scenarios.

If you encounter any bugs or unexpected behavior, please search the currently open GitHub issues first, and create a new one if it doesn't exist yet.

The Roadmap presents the project's goals for the coming months regarding new functionalities and enhancements.

If you are interested in contributing with the development of this project, check the contributing guide

Documentation

Overview

Package disruptor implement the k6 extension interface for calling disruptors from js scripts running in the goya runtime

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ModuleInstance

type ModuleInstance struct {
	// contains filtered or unexported fields
}

ModuleInstance represents an instance of the JS module.

func (*ModuleInstance) Exports

func (m *ModuleInstance) Exports() modules.Exports

Exports implements the modules.Instance interface and returns the exports of the JS module.

type RootModule

type RootModule struct{}

RootModule is the global module object type. It is instantiated once per test run and will be used to create `k6/x/disruptor` module instances for each VU.

func (*RootModule) NewModuleInstance

func (*RootModule) NewModuleInstance(vu modules.VU) modules.Instance

NewModuleInstance returns a new instance of the disruptor module for each VU.

Directories

Path Synopsis
cmd
agent
Package vli implements the root level command for the disruptor agent CLI
Package vli implements the root level command for the disruptor agent CLI
agent/commands
Package commands implements the CLI interface for the disruptor agent
Package commands implements the CLI interface for the disruptor agent
e2e-cluster
Package main implements the main function for the e2e environment setup tool
Package main implements the main function for the e2e environment setup tool
e2e-cluster/commands
Package commands implements the CLI interface for the e2e env CLI tool
Package commands implements the CLI interface for the e2e env CLI tool
hack
depsync
main is the main package for depsync, a script that checks and provides commands to synchronize common dependencies with k6 core.
main is the main package for depsync, a script that checks and provides commands to synchronize common dependencies with k6 core.
pkg
agent
Package agent implements functions for injecting faults in a target
Package agent implements functions for injecting faults in a target
agent/protocol
Package protocol implements the agent that injects disruptors in protocols.
Package protocol implements the agent that injects disruptors in protocols.
agent/protocol/grpc
Package grpc implements a proxy that applies disruptions to gRPC requests This package is inspired by and extensively copies code from https://github.com/mwitkow/grpc-proxy
Package grpc implements a proxy that applies disruptions to gRPC requests This package is inspired by and extensively copies code from https://github.com/mwitkow/grpc-proxy
agent/protocol/http
Package http implements a proxy that applies disruptions to HTTP requests
Package http implements a proxy that applies disruptions to HTTP requests
agent/stressors
Package stressors implements resource stressors for CPU, Memory, I/O and network
Package stressors implements resource stressors for CPU, Memory, I/O and network
agent/tcpconn
Package tcpconn contains a TCP connection disruptor.
Package tcpconn contains a TCP connection disruptor.
api
Package api implements a layer between javascript code (via goja)) and the disruptors allowing for validations and type conversions when needed
Package api implements a layer between javascript code (via goja)) and the disruptors allowing for validations and type conversions when needed
disruptors
Package disruptors implements an API for disrupting targets
Package disruptors implements an API for disrupting targets
internal/version
Package version provide information about the build version
Package version provide information about the build version
iptables
Package iptables implements objects that manipulate netfilter rules by calling the iptables binary.
Package iptables implements objects that manipulate netfilter rules by calling the iptables binary.
kubernetes
Package kubernetes implements helper functions for manipulating resources in a Kubernetes cluster.
Package kubernetes implements helper functions for manipulating resources in a Kubernetes cluster.
kubernetes/helpers
Package helpers implement helper functions for managing Kubernetes resources such as services and pods
Package helpers implement helper functions for managing Kubernetes resources such as services and pods
runtime
Package runtime implements functions to interact with the execution runtime
Package runtime implements functions to interact with the execution runtime
runtime/profiler
Package profiler offers functions to profile the execution of a process using go's built-in profiling tools
Package profiler offers functions to profile the execution of a process using go's built-in profiling tools
testutils/assertions
Package assertions implements functions that help assess conditions in tests
Package assertions implements functions that help assess conditions in tests
testutils/cluster
Package cluster implements helpers for creating test clusters using [kind] as a library.
Package cluster implements helpers for creating test clusters using [kind] as a library.
testutils/command
Package command offers utility functions for testing commands
Package command offers utility functions for testing commands
testutils/e2e/checks
Package checks implements functions that verify conditions in a cluster
Package checks implements functions that verify conditions in a cluster
testutils/e2e/cluster
Package cluster offers helpers for setting a cluster for e2e testing
Package cluster offers helpers for setting a cluster for e2e testing
testutils/e2e/deploy
Package deploy offers helpers for deploying applications in a cluster
Package deploy offers helpers for deploying applications in a cluster
testutils/e2e/fetch
Package fetch implements utility functions for getting files from diverse sources
Package fetch implements utility functions for getting files from diverse sources
testutils/e2e/fixtures
Package fixtures implements helpers for setting e2e tests
Package fixtures implements helpers for setting e2e tests
testutils/e2e/kubectl
Package kubectl implements helper functions for managing kubernetes resources in e2e tests
Package kubectl implements helper functions for managing kubernetes resources in e2e tests
testutils/e2e/kubernetes
Package kubernetes implements helper functions for handling k8s resources in e2e tests
Package kubernetes implements helper functions for handling k8s resources in e2e tests
testutils/e2e/kubernetes/namespace
Package namespace implements helper functions for manipulating kubernetes namespaces
Package namespace implements helper functions for manipulating kubernetes namespaces
testutils/grpc
Package grpc offers utils for testing gppc services
Package grpc offers utils for testing gppc services
testutils/grpc/dynamic
Package dynamic implements a dynamic grpc client It requires the server to be registered to the grpc reflection Service
Package dynamic implements a dynamic grpc client It requires the server to be registered to the grpc reflection Service
testutils/grpc/ping
Package ping provides a grpc service for testing The service allows controlling the response returned by the server including the generation of specific errors.
Package ping provides a grpc service for testing The service allows controlling the response returned by the server including the generation of specific errors.
testutils/kubernetes/builders
Package builders offers functions for building test objects
Package builders offers functions for building test objects
testutils/testcontainers
Package testcontainers implements utility functions for running tests with TestContainers
Package testcontainers implements utility functions for running tests with TestContainers
types/intstr
Package intstr implements a custom type for handling values that can be either a string or an int32
Package intstr implements a custom type for handling values that can be either a string or an int32
utils
Package utils offers functions of general utility in other parts of the system
Package utils offers functions of general utility in other parts of the system
testcontainers
echoserver
Package main contains a simple TCP echoserver, that repeats back to the client every line it receives.
Package main contains a simple TCP echoserver, that repeats back to the client every line it receives.

Jump to

Keyboard shortcuts

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