rumeter-component

Crates.iorumeter-component
lib.rsrumeter-component
version0.1.3
sourcesrc
created_at2022-05-28 04:48:46.742658
updated_at2022-06-03 10:42:41.709038
descriptionA load test platform for writing a load test script by rust. Just like JMeter, but it prefer using like SDK, not a GUI tool.
homepagehttps://github.com/jimmyseraph/rumetercar
repositoryhttps://github.com/jimmyseraph/rumeter
max_upload_size
id595598
size26,116
Karma (jimmyseraph)

documentation

README

RuMeter

A load test platform for writing a load test script by rust. Just like JMeter, but it prefer using like SDK, not a GUI tool. It is:

  • Fast RuMeter's zero-cost abstractions give you bare-metal performance.
  • Extensiable RuMeter is easy to use and develop your own components.
  • Script RuMeter is just an SDK, and the best way to use it is using in your script.

Example

A basic HTTP API load test with RuMeter.

Make sure you add the dependence on your Cargo.toml:

[dependencies]
rumeter-component = "0.1.3"

Then, you should define your own controller first. Your controller must implement trait Controller:

#[derive(Default, Clone)]
pub struct SimpleController;

#[async_trait]
impl Controller for SimpleController {
    async fn run(&self) -> Vec<RecordData> {
        let mut headers = HeaderMap::new();
        headers.append("Access-Token", HeaderValue::from_static("123456"));
        let samp = HttpSampler::new(
            "test hello",
            "http://127.0.0.1:8088/hello", 
            Method::GET, 
            headers,
            None,
        );
        let re = samp.run().await;
        vec![re]
    }
}

Then, on your main.rs:

#[tokio::main]
async fn main() ->  Result<(), Box<dyn std::error::Error>> {

    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::INFO)
        .with_span_events(FmtSpan::CLOSE)
        .init();

    let group = ThreadGroup::new(10, Duration::from_secs(1), -1, Some(Duration::from_secs(300)));
    // let group = ThreadGroup::new(10, Duration::from_secs(1), 10, None);

    let out = FileOutput::new(File::create("http.rtl").unwrap());
    group.start(SimpleController::default(), Arc::new(Mutex::new(out))).await;
    info!("test finished");
    Ok(())
}

more examples can be found here.

generate load test report

The rtl(RuMeter Test Log) file is a csv type file. You can use JMeter to generate the html style report like this:

$ jmeter -g [your.rtl] -o [report_path]

Todo

Now only a few sampler has implemented. More commonly used samplers will implement in future version.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in RuMeter by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 14

cargo fmt