Skip to content

Add Locust Integration for load testing #885

@mcumming

Description

@mcumming

Related to an existing integration?

No

Existing integration

No response

Overview

Many projects could benefit from automated load and performance testing. The Locust project provides a way to automate the testing of your web applications and api's easily.

Usage example

if (builder.Environment.IsDevelopment())
{
    builder.AddLocust("locust")
        .WithLocustDefaults()
        .WithTestsPath(Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "test", "Load")
        .WithHostEndpoint(api.GetEndpoint("https"))
        .WithReference(api)
        .WaitFor(api)
        .WithExplicitStart()
    ;
}

Breaking change?

No

Alternatives

if (builder.Environment.IsDevelopment())
{
    // Add Locust load testing container
    var locustfilePath = Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "test", "Load");
    builder.AddLocust("locust")
        .WithConfiguration(config =>
        {
            config.Host = api.GetEndpoint("https").Property(EndpointProperty.Url);
            config.Locustfile = locustfilePath;

            // Set sensible defaults for load testing that will be used in the start test dialog
            // Host will be dynamically determined from the API endpoint reference at runtime
            config.Users = 10;           // Default number of concurrent users
            config.SpawnRate = 2.0;      // Default spawn rate (users per second)
            config.RunTime = "300s";     // Default 5-minute test run
            config.Processes = -1;       // Use auto process count
        })
        .WithReference(api)
        .WaitFor(api)
        .WithExplicitStart()
    ;
}

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    Staleawaiting responseWaiting for the author of the issue to provide more information or answer a questionintegrationA new .NET Aspire integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions