Git Product home page Git Product logo

lorust's Introduction

lorust

load generator rust

A load generator tool written in Rust. Currently supports http api calls and custom scripting support with Rhai.

Build

$ cargo build --release
$ target/release/lorust --help

Usage

Note: The API to the outside world has not been determined yet. Currently, only json based config is supported but this may also change to support other config formats such as TOML, etc. depending on whether they'll be able to meet the needs and make the config more human readable.

Example HttpRequest

{
    "HttpRequest": {
        "method": "POST",
        "url": "https://reqres.in/api/users?page=1",
        "headers": [
            ["Content-Type", "application/json"],
            ["X-ACCESS-TOKEN", "32808ft6-21e4-4gh0-8dad-2348987838"]
        ],
        "body": "...",
        "redirect_limit": 5,
        "timeout": 300
    }
}

Example config (this will likely change):

{
    "functions": [
        {
            "LoadGen": {
                "spawn_rate": "1",
                "timeout": 1,
                "functions_to_execute": [
                    {
                        "HttpRequest": {
                            "url": "https://reqres.in/api/users?page=1",
                            "timeout": 300
                        }
                    },
                    {
                        "RunRhaiCode": {
                            "code": "let user_id = http_response[\"data\"].sample().id;"
                        }
                    },
                    {
                        "RunRhaiCode": {
                            "code": "print(\"Picked user_id: \" + user_id);"
                        }
                    },
                    {
                        "HttpRequest": {
                            "url": "https://reqres.in/api/users/%|user_id|%",
                            "timeout": 300
                        }
                    },
                    {
                        "RunRhaiCode": {
                            "code": "let data = http_response.data; print(data.first_name + \" \" + data.last_name);"
                        }
                    }
                ]
            }
        }
    ]
}

The above config gives the following output:

--- Running function #1 ---
Running load generator with the config:
LoadGenParam { spawn_rate: "1", timeout: 1, max_tasks: None, functions_to_execute: [] }
=== TICK #1, TASK COUNT: 1 ===
=== TICK #2, TASK COUNT: 1 ===
Picked user_id: 3
Emma Wong
Picked user_id: 4
Eve Holt
Load test complete.
TOTAL TASKS: 2
PASSED: 2
FAILED: 0
Collected metrics array size: 4
Printing first 3 entries
[
    {
        "url": "https://reqres.in/api/users?page=1",
        "http_verb": "GET",
        "status_code": 200,
        "response_body_size": 996,
        "time_stamp": "2023-06-17 18:41:47.572695000",
        "response_body": "",
        "upload_total": 0,
        "download_total": 368,
        "upload_speed": 0.0,
        "download_speed": 339.0,
        "namelookup_time": {
            "secs": 1,
            "nanos": 27096000
        },
        "connect_time": {
            "secs": 0,
            "nanos": 6369000
        },
        "tls_handshake_time": {
            "secs": 0,
            "nanos": 35801000
        },
        "starttransfer_time": {
            "secs": 1,
            "nanos": 83679000
        },
        "elapsed_time": {
            "secs": 1,
            "nanos": 83827000
        },
        "redirect_time": {
            "secs": 0,
            "nanos": 0
        }
    },
    {
        "url": "https://reqres.in/api/users/3",
        "http_verb": "GET",
        "status_code": 200,
        "response_body_size": 274,
        "time_stamp": "2023-06-17 18:41:48.660536000",
        "response_body": "",
        "upload_total": 0,
        "download_total": 208,
        "upload_speed": 0.0,
        "download_speed": 7407.0,
        "namelookup_time": {
            "secs": 0,
            "nanos": 1638000
        },
        "connect_time": {
            "secs": 0,
            "nanos": 5441000
        },
        "tls_handshake_time": {
            "secs": 0,
            "nanos": 8274000
        },
        "starttransfer_time": {
            "secs": 0,
            "nanos": 27956000
        },
        "elapsed_time": {
            "secs": 0,
            "nanos": 28080000
        },
        "redirect_time": {
            "secs": 0,
            "nanos": 0
        }
    },
    {
        "url": "https://reqres.in/api/users?page=1",
        "http_verb": "GET",
        "status_code": 200,
        "response_body_size": 996,
        "time_stamp": "2023-06-17 18:41:48.572680000",
        "response_body": "",
        "upload_total": 0,
        "download_total": 368,
        "upload_speed": 0.0,
        "download_speed": 344.0,
        "namelookup_time": {
            "secs": 0,
            "nanos": 27449000
        },
        "connect_time": {
            "secs": 1,
            "nanos": 15540000
        },
        "tls_handshake_time": {
            "secs": 0,
            "nanos": 9175000
        },
        "starttransfer_time": {
            "secs": 1,
            "nanos": 67105000
        },
        "elapsed_time": {
            "secs": 1,
            "nanos": 67367000
        },
        "redirect_time": {
            "secs": 0,
            "nanos": 0
        }
    }
]

lorust's People

Contributors

sazid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.