Crates.io | rumeter-component |
lib.rs | rumeter-component |
version | 0.1.3 |
source | src |
created_at | 2022-05-28 04:48:46.742658 |
updated_at | 2022-06-03 10:42:41.709038 |
description | 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. |
homepage | https://github.com/jimmyseraph/rumetercar |
repository | https://github.com/jimmyseraph/rumeter |
max_upload_size | |
id | 595598 |
size | 26,116 |
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:
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.
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]
Now only a few sampler has implemented. More commonly used samplers will implement in future version.
This project is licensed under the MIT license.
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.