DEV Community

Cover image for Are you ready for a Goose Attack?
NaveenKumar Namachivayam ⚡
NaveenKumar Namachivayam ⚡

Posted on • Originally published at qainsights.com

Are you ready for a Goose Attack?

Recently I stumbled upon a new load testing tool called Goose. Immediately I took it up for a spin and this blog post helps you to get started with Goose in IntelliJ IDEA. Let us get started. Before you read further, please check out my latest video series about Locust which will be very helpful for you in case if you are going to pursue Goose.

What is Goose?

Goose is a load testing tool written in Rust. It is inspired from Locust. If you want to get started with Goose, I recommend you to understand how Locust works from my video series for free.

Goose Repo

<!-- /wp:button -->

Goose has been developed by Tag1 Consulting from past 10 months. The current version of Goose at this time of writing is 0.10.9. You can check out the latest release from here.

Getting Started with Goose

Before you start installing and scripting in Goose, I recommend two things to learn: Rust and Locust.

To get started with Rust, you can check out the documentation in here; also, there are a lot of tutorials available on the internet.

Prerequisites

Following are the prerequisites required to get started with Goose:

  1. Rust
  2. IntelliJ IDEA or your favorite IDE
  3. Rust plugin for IntelliJ IDEA
  4. Cargo - package manager for Rust
  5. Goose

To download and install Rust and Cargo, please click here to follow the instructions.

I am going to use IntelliJ IDE for Goose. There is a plugin available for Rust in IntelliJ IDEA, to install the Rust plugin, launch IntelliJ, go to File > Settings > Plugins, search for Rust to install and enable.

Getting Started with Goose - Install Rust in IntelliJ IDEA
Getting Started with Goose - Install Rust in IntelliJ IDEA

Hello World in Goose

Now, let us create our first Goose project in IntelliJ IDEA. Launch IntelliJ IDEA, click on New Project, select Rust as shown below. Select Binary as Project template. Click on Next button.

Create Rust Project in IntelliJ IDEA
Create Rust Project in IntelliJ IDEA

Enter a project name as hello-world as shown below. Click on Finish button. This will create a new Rust project, not Goose. After creating a project, wait for a minute. IntelliJ will download the Rust macros.

Hello World
Hello World

By default, IntelliJ IDEA will create a main.rs file with the below code. Rust file has the extension *.rs.

fn main() {
    println!("Hello, world!");
}

Now, it is time to install the Goose as a dependency. Open Cargo.toml file from the project folder and enter goose = "0.10.9" under dependencies as shown below. This will download the goose crates.

Cargo.toml
Cargo.toml

Let us write our first Hello World in Rust for Goose. Open main.rs and enter the below code. It is totally fine, if you are not getting the code. I will explain it in my next post.

use goose::prelude::*;

async fn hello_world(user: &GooseUser) -> GooseTaskResult {
    let _goose_metrics = user.get("/").await?;

    Ok(())
}

fn main() -> Result<(), GooseError> {
    GooseAttack::initialize()?
        .register_taskset(taskset!("T00_HomePage")
            .register_task(task!(hello_world))
        )
        .execute()?
        .print();

    Ok(())
}

It is time to smoke load test the main.rs. Press Alt + F12 to open the terminal pane. cd into src folder, because that is where our main.rs file resides. Enter the below command and hit enter. This will compile your rust code and attack the host https://example.com

cargo run -- --host https://example.com

Please do not run your test for more than few seconds.

Goose will display the below details in the terminal window. If you observe the last line, it will show All 4 users hatched ...

Why 4 users? We never mentioned the number of users in our command line nor in the code. By default, Goose spins the number of users based on number of CPU cores of your system. My laptop has 2 CPU cores with the 4 logical processors, hence it is hatched 4 users.

During the execution, it displays per task metrics and per request metrics. We do have only one task called T00_HomePage with one request.

cargo run
cargo run

Press Ctrl + C, to terminate the execution. Once it is terminated, you can see the final stats as shown below.

terminating the test

Useful Goose Commands

Below are some of the useful commands for Goose.

Goose help options:

cargo run -- -h

To validate the Goose version:

cargo run -- -V

To see the tasks and exit

cargo run -- -l

Runtime options to run with 1 user (-u) in 1 second (-r) for 5 seconds (-t)

cargo run -- --host https://example.com -u 1 -r 1 -t 5s

To generate HTML report:

cargo run -- --host https://example.com -u 1 -r 1 -t 5s -R Run1.html

Sample Goose HTML Report

To generate detailed log file:

cargo run -- --host https://example.com -u 1 -r 1 -t 5s -gg -L mylog.log

My experience with Goose

From past one week I have been learning Rust and Goose, as a performance engineer, you may be feeling overwhelming while working in Goose. Because of the steep learning curve. You need to learn one more language Rust and then it would be added advantage if you know Locust.

Goose is heavily inspired from Locust but it addresses the disadvantage of Locust. Mainly because of Python is slower than the other language. Goose developers claims that the Locust (Python) requires more resources for the high volume test than the Goose.

My take is Goose is a good candidate only if you have a team of Rust developers with the performance knowledge.

Goose also has a feature called Gaggle, distributed load testing in Goose. Excellent candidate for CI/CD due to its command line nature.

In GitHub, it has over 100+ stars and with 5+ contributors.

On the down side, Goose doesn't seen a major release yet. At this time, there are 20+ open issues. Most of them are enhancements. Also, there are no quite Goose examples available yet to explore.

Conclusion

Goose is a new tool in the performance town. If you love Rust, you will love Goose. As a performance engineer, I always look for a new tool to learn and try. Goose is one of the instrument in my swiss army knife. I will wait for the right opportunity to use this tool. Meanwhile I will be happy with the current set of instruments.

Top comments (0)