This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 4c27e2c058 feat: add `concurrent` and `buffer` parameters into
FuzzInput (#3921)
4c27e2c058 is described below
commit 4c27e2c0581aa236bbe460a32fb177074d3e8ad1
Author: Weny Xu <[email protected]>
AuthorDate: Sat Jan 6 19:44:31 2024 +0900
feat: add `concurrent` and `buffer` parameters into FuzzInput (#3921)
---
core/fuzz/fuzz_writer.rs | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/core/fuzz/fuzz_writer.rs b/core/fuzz/fuzz_writer.rs
index 866dfb718b..df40e84590 100644
--- a/core/fuzz/fuzz_writer.rs
+++ b/core/fuzz/fuzz_writer.rs
@@ -32,11 +32,23 @@ const MAX_DATA_SIZE: usize = 16 * 1024 * 1024;
#[derive(Debug, Clone)]
struct FuzzInput {
actions: Vec<WriteAction>,
+ buffer: Option<usize>,
+ concurrent: Option<usize>,
}
impl Arbitrary<'_> for FuzzInput {
fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> {
let mut actions = vec![];
+ let buffer = if u.int_in_range(0..=1)? == 1 {
+ Some(u.int_in_range(1..=8 * 1024 * 1024)?)
+ } else {
+ None
+ };
+ let concurrent = if u.int_in_range(0..=1)? == 1 {
+ Some(u.int_in_range(0..=16)?)
+ } else {
+ None
+ };
let count = u.int_in_range(128..=1024)?;
@@ -45,7 +57,11 @@ impl Arbitrary<'_> for FuzzInput {
actions.push(WriteAction::Write(size));
}
- Ok(FuzzInput { actions })
+ Ok(FuzzInput {
+ actions,
+ buffer,
+ concurrent,
+ })
}
}
@@ -62,7 +78,15 @@ async fn fuzz_writer(op: Operator, input: FuzzInput) ->
Result<()> {
let checker = WriteChecker::new(total_size);
- let mut writer = op.writer_with(&path).buffer(8 * 1024 * 1024).await?;
+ let mut writer = op.writer_with(&path);
+ if let Some(buffer) = input.buffer {
+ writer = writer.buffer(buffer);
+ }
+ if let Some(concurrent) = input.concurrent {
+ writer = writer.concurrent(concurrent);
+ }
+
+ let mut writer = writer.await?;
for chunk in checker.chunks() {
writer.write(chunk.clone()).await?;