Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xk6-disruptor: add a first-steps monopage #1414

Closed
wants to merge 2 commits into from
Closed

Conversation

roobre
Copy link
Contributor

@roobre roobre commented Nov 14, 2023

This PR continues the work started on #1356, creating a single-page aimed to onboard people into trying the disruptor with as little friction as possible.

The included examples borrow some explanation from other pages, introducing a bit of redundancy as the price to pay to avoid too many cross-references.

The examples use and reference QuickPizza as a demo application.

Copy link
Contributor

@pablochacin pablochacin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, my impression is that the first steps page tries to cover multiple objectives introducing some overlapping.

My suggestions have two goals:

  1. Separate the generic first steps (requirements, installation) from the example. In particular, move the installation of the demo application to the example part
  2. Streamline the example to show the key disruptor functionality, removing some text that serves more like an introduction to the project. For this, we have the main project page.

In general, I'm still not sure this page has any benefit over the existing pages except puting everything in one place.


In order to follow this guide, you will need

- A microservice-based application that communicates over HTTP or GRPC.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- A microservice-based application that communicates over HTTP or GRPC.
- A cloud-native application that communicates over HTTP or GRPC.


- A microservice-based application that communicates over HTTP or GRPC.
- The ability to reach at least one service exposed by the application from the machine where you will run the tests.
- Privileged access to the Kubernetes cluster where your application is running from the machine where you will run the tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which privileges are needed?

In order to follow this guide, you will need

- A microservice-based application that communicates over HTTP or GRPC.
- The ability to reach at least one service exposed by the application from the machine where you will run the tests.
Copy link
Contributor

@pablochacin pablochacin Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The ability to reach at least one service exposed by the application from the machine where you will run the tests.
- The ability to reach the service you want to test from the machine where you will run the tests.

I would also add a reference to "exposing your application".


xk6-disruptor is distributed as a statically-compiled, dependency-free binary for Linux, MacOS, and Windows. For Linux and MacOS, both x86 and arm64 architectures are supported.

You can download the latest release for your architecture and platfrom from https://github.com/grafana/xk6-disruptor/releases. Look for the files named `xk6-disruptor-v*`, not `xk6-disruptor-agent-v*`: The latter are for advanced users and developers only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can download the latest release for your architecture and platfrom from https://github.com/grafana/xk6-disruptor/releases. Look for the files named `xk6-disruptor-v*`, not `xk6-disruptor-agent-v*`: The latter are for advanced users and developers only.
You can download the latest release for your architecture and platfrom from https://github.com/grafana/xk6-disruptor/releases. Look for the files named `xk6-disruptor-v*`, not `xk6-disruptor-agent-v*`: The latter is the agent, explained in [how it works](/docs/k6/<K6_VERSION>/testing-guides/injecting-faults-with-xk6-disruptor/how--it-works)


# Creating a simple k6 test

k6 was born and is often referred to as a load testing tool. However, with the flexibility that testing as code provides, and the large amount of extensions (such as xk6-disruptor) it has, a better way to think about k6 is as a reliability testing tool. We will now write a k6 test that checks if an API is behaving correctly, without putting enough load on it to significantly alter its behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
k6 was born and is often referred to as a load testing tool. However, with the flexibility that testing as code provides, and the large amount of extensions (such as xk6-disruptor) it has, a better way to think about k6 is as a reliability testing tool. We will now write a k6 test that checks if an API is behaving correctly, without putting enough load on it to significantly alter its behavior.


A more interesting way of using xk6-disruptor is to check how faults propagate across a distributed application. For the QuickPizza example, we know the Recommendations service, which provides the `/api/pizza` endpoint we were hitting earlier, has to make several calls to another service named Catalog. We can keep our test as above, testing for failures in the Recommendation service, but inject faults in the Catalog service to see how Recommendations reacts to that:

![A very similar diagram as above, with the three components connected by right-facing arrows. This time, the xk6-disruptor logo is located between the Recommendations and the Catalog services, instead of between the user and the Recommendations service](https://grafana.com/media/docs/k6-oss/xk6-disruptor-get-started-real.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![A very similar diagram as above, with the three components connected by right-facing arrows. This time, the xk6-disruptor logo is located between the Recommendations and the Catalog services, instead of between the user and the Recommendations service](https://grafana.com/media/docs/k6-oss/xk6-disruptor-get-started-real.png)
![Diagram consisting of three horizontal elements connected by arrows that point from one to the one on their right. The first element is an image of a female-presenting drawing of a crocodile, Bertha, which represents the user performing the test. An arrow points to the right to a service labeled Recommendations. Finally, from the Recommendations service, another arrow points to the Right to a service labeled Catalog, but the arrow is interrupted by another cartoon crocodile snapping a cable, the xk6-disruptor project logo](https://grafana.com/media/docs/k6-oss/xk6-disruptor-get-started-real.png)


# Checking requirements

xk6-disruptor focuses on injecting faults on applications running in Kubernetes. If you already have your application deployed to a development Kubernetes cluster, you are all set! If you don't, we will guide you through deploying a demo application on a local `minikube` cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should focus on the example. If the reader already has an application, how does this guide help?

Suggested change
xk6-disruptor focuses on injecting faults on applications running in Kubernetes. If you already have your application deployed to a development Kubernetes cluster, you are all set! If you don't, we will guide you through deploying a demo application on a local `minikube` cluster.
xk6-disruptor focuses on injecting faults into applications running in Kubernetes. If you already have access to a development Kubernetes cluster, you are all set! If you don't, we will guide you through deploying a demo application on a local `minikube` cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the opposite, actually: I added the example so people can still follow if they don't have their application deployed and accessible right when they are reading the article, but my original intention was for the guide to be the point of reference for developers/sres who do have an application and want to start using the disruptor. I think this was the feedback we got and originated this page: "I have an application but the multi-paged structure is hard to follow end to end to get me from zero to something"

Copy link
Contributor

@pablochacin pablochacin Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the example so people can still follow if they don't have their application deployed and accessible right when they are reading the article
think this was the feedback we got and originated this page: "I have an application but the multi-paged structure is hard to follow end to end to get me from zero to something"

That is still the goal and I understand the intention, but my own experience reading the content was the opposite.
It was unclear what the general steps are and what is specific to the demo. And the example makes a very long chunk of text and code in the middle of the guide!

The main problem I see is that any example with the disruptor API would be application specific.

I still think it would be better to put all the steps together and then demo them in an example. In this way, if someone already has an application the demo won't be in the middle.

- The ability to reach at least one service exposed by the application from the machine where you will run the tests.
- Privileged access to the Kubernetes cluster where your application is running from the machine where you will run the tests.

## Use our demo application
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Use our demo application
## Deploy the demo application

- The ability to reach at least one service exposed by the application from the machine where you will run the tests.
- Privileged access to the Kubernetes cluster where your application is running from the machine where you will run the tests.

## Use our demo application
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this section should go in its own high-level section, before the "creating a simple test" section.

import { check, sleep } from "k6";
import {ServiceDisruptor} from "k6/x/disruptor";

const BASE_URL = 'http://localhost:3333'; // <- Your reachable endpoint goes here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const BASE_URL = 'http://localhost:3333'; // <- Your reachable endpoint goes here.
const BASE_URL = 'http://localhost:3333'; // this is endpoint where the recommendations service is exposed

@roobre
Copy link
Contributor Author

roobre commented Nov 16, 2023

Thanks for your thoughts @pablochacin!

I think it might be worth commenting on the general comments before jumping into the specific suggestions.

Separate the generic first steps (requirements, installation) from the example. In particular, move the installation of the demo application to the example part

I agree with this. My goal was to make the page easy to follow to people who both have an application already and people who do not, but I'm not extremely happy with the result either. I'm not sure I understand your position in this. Do you prefer to focus the guide on the demo application, or do you prefer a more clear separation, for example using collapsible elements or something along those lines?

Streamline the example to show the key disruptor functionality, removing some text that serves more like an introduction to the project. For this, we have the main project page.

My assumption was that duplicating this information was a good thing: People who have read the main page will skip those paragraphs, and people who jump directly to hands-on tutorials without reading the theory will get some useful context. That being said, I understand this is kind of an style choice so I can scrap those parts out if we don't like the tradeoff.

@pablochacin
Copy link
Contributor

Do you prefer to focus the guide on the demo application, or do you prefer a more clear separation, for example using collapsible elements or something along those lines?

As I explained in a previous comment, my main concern is that mixing the guide with the example makes the text too long and at times it is not clear what it's specific to the demo.

The idea of collapsible may work, but then I think we should define the general structure that is useful for anyone who already has an application and then add examples along the way. The way it is structured and written now doesn't make this clear to me.

@pablochacin
Copy link
Contributor

My assumption was that duplicating this information was a good thing: People who have read the main page will skip those paragraphs, and people who jump directly to hands-on tutorials without reading the theory will get some useful context.

I think this goes against some practices in documentation that we discussed time ago with the k6 documentation folks. In particular, that each piece of content should have a clear objective and audience in mind.

We should try to stick to one simple goal in this page: make it easier fo someone to start using the disruptor in their project.

@roobre roobre closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants