tag1consulting / goose

Load testing framework, inspired by Locust
https://tag1.com/goose
Apache License 2.0
759 stars 69 forks source link

Unable to generate report with transactions without http requests #545

Closed AlexXi19 closed 1 year ago

AlexXi19 commented 1 year ago

I'm trying to create some loadtests without using the goose user's http client but instead use my own client. However, when I try this, I'm able to see the metrics in the CLI, but the application panics on exit, which I'm guessing is from generating the report. I was able to generate a report correctly when I use the user to send http requests.

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/alexxi/.cargo/registry/src/github.com-1ecc6299db9ec823/goose-0.17.0/src/graph.rs:425:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#[tokio::main]
async fn main() -> Result<()> {
    GooseAttack::initialize()?
        .set_default(GooseDefault::Host, "http://localhost:5000")?
        .set_default(GooseDefault::ReportFile, "report.html")?
        .set_default(GooseDefault::Users, 1)?
        .set_default(GooseDefault::Iterations, 10)?
        .set_default(GooseDefault::RunTime, 5)?
        .register_scenario(
            scenario!("TestScenario")
                .register_transaction(transaction!(loadtest_index))
        )
        .execute()
        .await?;

    Ok(())
}

async fn loadtest_index(user: &mut GooseUser) -> TransactionResult {
    // Tokio sleep for 1 second
    tokio::time::sleep(std::time::Duration::from_secs(1)).await;
    Ok(())
}
jeremyandrews commented 1 year ago

You've hit the same bug as reported in https://github.com/tag1consulting/goose/issues/533 -- we've got a bad assumption in the code here that needs to be fixed.