Skip to content

Commit

Permalink
Reorganize disruptor get-started
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin committed Oct 3, 2023
1 parent 70262a5 commit 1fa6c35
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_modules/
docs/sources/get-started/run-cloud-tests-from-the-CLI.md
docs/sources/get-started/run-your-first-tests.md
CONTRIBUTING_FILE_FORMAT.md
src/data/markdown/docs/40 xk6-disruptor/01 Get started/01 Welcome.md
src/data/markdown/docs/40 xk6-disruptor/01 Get started/01 First steps.md
src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md
src/data/markdown/docs/40 xk6-disruptor/04 Examples/01 Inject Grpc faults into Service.md
src/data/markdown/docs/40 xk6-disruptor/04 Examples/02 Inject HTTP faults into Pod.md
Expand Down
8 changes: 4 additions & 4 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ function getDocPagesProps({
// add prefix to xk6-disruptor pages slugs and sidebar links
if (slug.startsWith('xk6-disruptor/')) {
slug = `javascript-api/${slug}`;
if (slug.includes('xk6-disruptor/get-started/welcome')) {
if (slug.includes('xk6-disruptor/get-started/first-steps')) {
// make the section root out of the welcome page
slug = `/javascript-api/xk6-disruptor/`;
}
Expand All @@ -684,7 +684,7 @@ function getDocPagesProps({
);
replacePathsInSidebarTree(
sidebarTree,
'/javascript-api/xk6-disruptor/get-started/welcome',
'/javascript-api/xk6-disruptor/get-started/first-steps',
'/javascript-api/xk6-disruptor',
);

Expand Down Expand Up @@ -1191,7 +1191,7 @@ const createRedirects = ({ actions }) => {
const { createRedirect } = actions;

createRedirect({
fromPath: '/get-started/welcome/',
fromPath: '/get-started/first-steps/',
toPath: '/',
redirectInBrowser: true,
isPermanent: true,
Expand Down Expand Up @@ -1860,7 +1860,7 @@ const createRedirects = ({ actions }) => {
'/using-k6-browser/selecting-elements/',
'/javascript-api/k6-browser/get-started/selecting-elements/':
'/using-k6-browser/selecting-elements/',
'/javascript-api/xk6-disruptor/get-started/welcome/':
'/javascript-api/xk6-disruptor/get-started/first-steps/':
'/javascript-api/xk6-disruptor/',
...newJavascriptURLsRedirects,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'Welcome'
title: 'About'
heading: 'xk6-disruptor Documentation'
head_title: 'xk6-disruptor Documentation'
excerpt: 'xk6-disruptor is a k6 extension providing fault injection capabilities to test system reliability under turbulent conditions.'
Expand All @@ -21,24 +21,6 @@ It provides a Javascript API to inject different [faults](/javascript-api/xk6-di

Other types of faults and disruptors will be introduced in the future. The [Roadmap](https://github.com/grafana/xk6-disruptor/blob/main/ROADMAP.md) presents the project's goals for the coming months regarding new functionalities and enhancements.

```javascript
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.kubernetes.io/name": "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")
}
```

## Use cases

Expand All @@ -59,11 +41,15 @@ Common use cases are:

## Learn more

Check the [requirements](/javascript-api/xk6-disruptor/get-started/requirements/), [installation](/javascript-api/xk6-disruptor/get-started/installation/), and [how to expose your application](/javascript-api/xk6-disruptor/get-started/expose-your-application/) to get started with the disruptor.
Lear more about [Fault injection](https://k6.io/blog/democratize-chaos-testing/) and [Building Resilience early in the development cycle](https://k6.io/blog/building-resilience-early-in-the-development-cycle/).

This documentation presents a few [examples of injecting faults in different scenarios](/javascript-api/xk6-disruptor/examples/).
Check the [first steps](/javascript-api/xk6-disruptor/get-started/first-steps) to get started with the disruptor.

Also, an [interactive demo environment in Killercoda](https://killercoda.com/grafana-xk6-disruptor/scenario/killercoda) is available to use the k6 disruptor right away. You can fail the services of a demo application without having to install Kubernetes on your local machine.
Follow the [examples of injecting faults in different scenarios](/javascript-api/xk6-disruptor/examples/).

Visit the [interactive demo environment in Killercoda](https://killercoda.com/grafana-xk6-disruptor/scenario/killercoda) and try the disruptor in a demo application without having to do any setup.

## Contributing

For any unexpected behavior, please search the [GitHub issues](https://github.com/grafana/xk6-disruptor/issues) first.

Expand Down
2 changes: 0 additions & 2 deletions src/data/markdown/docs/40 xk6-disruptor/01 Get started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ excerpt: 'xk6-disruptor is an extension that adds fault injection capabilities t

Inject faults into kubernetes-based applications with `xk6-disruptor`. Start here to learn the basics to use the disruptor:

- [About `xk6-disruptor`](/javascript-api/xk6-disruptor/)

- [Requirements](/javascript-api/xk6-disruptor/get-started/requirements)

- [Installation](/javascript-api/xk6-disruptor/get-started/installation)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: 'First steps'
heading: 'xk6-disruptor first steps'
head_title: 'xk6-disruptor First steps'
excerpt: 'xk6-disruptor is a k6 extension providing fault injection capabilities to k6.'
---

[xk6-disruptor](https://github.com/grafana/xk6-disruptor) is an extension that adds fault injection capabilities to k6.

It provides a Javascript [API]((/javascript-api/xk6-disruptor/api)) to inject [faults](/javascript-api/xk6-disruptor/api/faults/) such as errors and delays into HTTP and gRPC requests served by selected Kubernetes [Pods](/javascript-api/xk6-disruptor/api/poddisruptor) or [Services](/javascript-api/xk6-disruptor/api/servicedisruptor).


```javascript
export default function () {
// Create a new disruptor that targets a service
const disruptor = new ServiceDisruptor("app-service","app-namespace");

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

## Next steps

Learn more about xk6-disruptor and fault injection in [About](/javascript-api/xk6-disruptor/about).

Explore the fault injection [API](/javascript-api/xk6-disruptor/api)

See [step-by-step examples](/javascript-api/xk6-disruptor/examples).

Visit the [interactive demo environment](https://killercoda.com/grafana-xk6-disruptor/scenario/killercoda).

Learn the basics of using the disruptor in your test project:

- [Requirements](/javascript-api/xk6-disruptor/get-started/requirements)

- [Installation](/javascript-api/xk6-disruptor/get-started/installation)

0 comments on commit 1fa6c35

Please sign in to comment.