Skip to content

Commit 5a264a6

Browse files
committed
test: put operation should succeed with maximum supported size
Tests that the backend can support the configured maximum value which has been increased to 1 GB [WIP] Test is currently failing. Investigating why.
1 parent fbdd957 commit 5a264a6

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

rust/api/src/kv_store_tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ macro_rules! define_kv_store_tests {
4444
create_test!(put_should_fail_when_global_version_mismatched);
4545
create_test!(put_should_succeed_when_no_global_version_is_given);
4646
create_test!(put_and_delete_should_succeed_as_atomic_transaction);
47+
create_test!(put_should_succeed_with_maximum_supported_value_size);
4748
create_test!(delete_should_succeed_when_item_exists);
4849
create_test!(delete_should_succeed_when_item_does_not_exist);
4950
create_test!(delete_should_be_idempotent);
@@ -266,6 +267,29 @@ pub trait KvStoreTestSuite {
266267
Ok(())
267268
}
268269

270+
async fn put_should_succeed_with_maximum_supported_value_size() -> Result<(), VssError> {
271+
const MAXIMUM_SUPPORTED_VALUE_SIZE: usize = 1024 * 1024 * 1024;
272+
let kv_store = Self::create_store().await;
273+
let ctx = TestContext::new(&kv_store);
274+
275+
// Construct entry that's non-largeobject maximum size
276+
let large_value = vec![0u8; MAXIMUM_SUPPORTED_VALUE_SIZE];
277+
let kv = KeyValue { key: "k1".into(), version: 0, value: Bytes::from(large_value) };
278+
279+
// Put the object in the backend/store
280+
ctx.put_objects(None, vec![kv]).await?;
281+
282+
// Get back and assert equality
283+
let result = ctx.get_object("k1").await?;
284+
assert_eq!(result.value.len(), MAXIMUM_SUPPORTED_VALUE_SIZE);
285+
assert!(result.value.iter().all(|&b| b == 0));
286+
287+
// Delete the object just stored
288+
ctx.delete_object(result).await?;
289+
290+
Ok(())
291+
}
292+
269293
async fn delete_should_succeed_when_item_exists() -> Result<(), VssError> {
270294
let kv_store = Self::create_store().await;
271295
let ctx = TestContext::new(&kv_store);

rust/server/src/vss_service.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use std::future::Future;
1818
use std::pin::Pin;
1919
use std::sync::Arc;
2020

21-
const MAXIMUM_REQUEST_BODY_SIZE: usize = 20 * 1024 * 1024;
22-
const DEFAULT_REQUEST_BODY_SIZE: usize = 10 * 1024 * 1024;
21+
const MAXIMUM_REQUEST_BODY_SIZE: usize = 1024 * 1024 * 1024;
2322

2423
#[derive(Clone)]
2524
pub(crate) struct VssServiceConfig {
@@ -28,20 +27,13 @@ pub(crate) struct VssServiceConfig {
2827

2928
impl VssServiceConfig {
3029
pub fn new(maximum_request_body_size: usize) -> Self {
31-
let capped = maximum_request_body_size.min(MAXIMUM_REQUEST_BODY_SIZE);
32-
if capped < maximum_request_body_size {
33-
eprintln!(
34-
"Warning: maximum_request_body_size {} exceeds limit, capped to {}.",
35-
maximum_request_body_size, MAXIMUM_REQUEST_BODY_SIZE
36-
);
37-
}
38-
Self { maximum_request_body_size: capped }
30+
Self { maximum_request_body_size: maximum_request_body_size.min(MAXIMUM_REQUEST_BODY_SIZE) }
3931
}
4032
}
4133

4234
impl Default for VssServiceConfig {
4335
fn default() -> Self {
44-
Self { maximum_request_body_size: DEFAULT_REQUEST_BODY_SIZE }
36+
Self { maximum_request_body_size: MAXIMUM_REQUEST_BODY_SIZE }
4537
}
4638
}
4739

0 commit comments

Comments
 (0)