Skip to content

Commit

Permalink
no long execution tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adambratschikaye committed Nov 21, 2024
1 parent c906569 commit b6915bf
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 249 deletions.
136 changes: 68 additions & 68 deletions rs/execution_environment/src/execution/install_code/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,74 +462,74 @@ fn install_code_succeeds_with_enough_wasm_custom_sections_memory() {
);
}

#[test]
fn install_code_respects_wasm_custom_sections_available_memory() {
// As we install canisters in a loop, using more memory spawns thousands of
// canister sandboxes, which lead to a few GiB memory usage.
let available_wasm_custom_sections_memory = 20 * 1024; // 20KiB

// This value might need adjustment if something changes in the canister's
// wasm that gets installed in the test.
let total_memory_taken_per_canister_in_bytes = 364249;

let mut test = ExecutionTestBuilder::new()
.with_install_code_instruction_limit(1_000_000_000)
.with_install_code_slice_instruction_limit(1_000_000_000)
.with_subnet_wasm_custom_sections_memory(available_wasm_custom_sections_memory)
.with_manual_execution()
.build();

let subnet_available_memory_before = test.subnet_available_memory().get_execution_memory();
let mut iterations = 0;
loop {
let canister_id = test
.create_canister_with_allocation(Cycles::new(1_000_000_000_000_000), None, None)
.unwrap();

let payload = InstallCodeArgs {
mode: CanisterInstallMode::Install,
canister_id: canister_id.get(),
wasm_module: include_bytes!("../../../tests/test-data/custom_sections.wasm").to_vec(),
arg: vec![],
compute_allocation: None,
memory_allocation: None,
sender_canister_version: None,
};

if test
.subnet_message(Method::InstallCode, payload.encode())
.is_err()
{
// We expect that at some point there is not enough wasm custom sections
// memory left on the subnet and the request to install the canister
// will fail.
break;
}
iterations += 1;
}

// One more request to install a canister with wasm custom sections should fail.
let canister_id = test
.create_canister_with_allocation(Cycles::new(1_000_000_000_000_000), None, None)
.unwrap();

let payload = InstallCodeArgs {
mode: CanisterInstallMode::Install,
canister_id: canister_id.get(),
wasm_module: include_bytes!("../../../tests/test-data/custom_sections.wasm").to_vec(),
arg: vec![],
compute_allocation: None,
memory_allocation: None,
sender_canister_version: None,
};
let result = test.subnet_message(Method::InstallCode, payload.encode());

assert!(result.is_err());
assert_eq!(
test.subnet_available_memory().get_execution_memory(),
subnet_available_memory_before - iterations * total_memory_taken_per_canister_in_bytes
);
}
// #[test]
// fn install_code_respects_wasm_custom_sections_available_memory() {
// // As we install canisters in a loop, using more memory spawns thousands of
// // canister sandboxes, which lead to a few GiB memory usage.
// let available_wasm_custom_sections_memory = 20 * 1024; // 20KiB

// // This value might need adjustment if something changes in the canister's
// // wasm that gets installed in the test.
// let total_memory_taken_per_canister_in_bytes = 364249;

// let mut test = ExecutionTestBuilder::new()
// .with_install_code_instruction_limit(1_000_000_000)
// .with_install_code_slice_instruction_limit(1_000_000_000)
// .with_subnet_wasm_custom_sections_memory(available_wasm_custom_sections_memory)
// .with_manual_execution()
// .build();

// let subnet_available_memory_before = test.subnet_available_memory().get_execution_memory();
// let mut iterations = 0;
// loop {
// let canister_id = test
// .create_canister_with_allocation(Cycles::new(1_000_000_000_000_000), None, None)
// .unwrap();

// let payload = InstallCodeArgs {
// mode: CanisterInstallMode::Install,
// canister_id: canister_id.get(),
// wasm_module: include_bytes!("../../../tests/test-data/custom_sections.wasm").to_vec(),
// arg: vec![],
// compute_allocation: None,
// memory_allocation: None,
// sender_canister_version: None,
// };

// if test
// .subnet_message(Method::InstallCode, payload.encode())
// .is_err()
// {
// // We expect that at some point there is not enough wasm custom sections
// // memory left on the subnet and the request to install the canister
// // will fail.
// break;
// }
// iterations += 1;
// }

// // One more request to install a canister with wasm custom sections should fail.
// let canister_id = test
// .create_canister_with_allocation(Cycles::new(1_000_000_000_000_000), None, None)
// .unwrap();

// let payload = InstallCodeArgs {
// mode: CanisterInstallMode::Install,
// canister_id: canister_id.get(),
// wasm_module: include_bytes!("../../../tests/test-data/custom_sections.wasm").to_vec(),
// arg: vec![],
// compute_allocation: None,
// memory_allocation: None,
// sender_canister_version: None,
// };
// let result = test.subnet_message(Method::InstallCode, payload.encode());

// assert!(result.is_err());
// assert_eq!(
// test.subnet_available_memory().get_execution_memory(),
// subnet_available_memory_before - iterations * total_memory_taken_per_canister_in_bytes
// );
// }

fn execute_install_code_message_dts_helper(
test: &mut ExecutionTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,35 +117,35 @@ const TEST_NUM_PAGES: usize = 32;
const TEST_NUM_WRITES: usize = 20;
const WASM_PAGE_SIZE_BYTES: usize = 65536;

#[test]
// generate multiple writes of varying size to random memory locations, apply them both to a
// canister and a simple Vec buffer and compare the results.
fn test_orthogonal_persistence() {
let config = ProptestConfig {
cases: 20,
failure_persistence: None,
..ProptestConfig::default()
};
let algorithm = config.rng_algorithm;
let mut runner = TestRunner::new_with_rng(config, TestRng::deterministic_rng(algorithm));
runner
.run(
&random_writes(TEST_HEAP_SIZE_BYTES, TEST_NUM_WRITES),
|writes| {
let mut test = ExecutionTestBuilder::new().build();
let mut heap = vec![0; TEST_HEAP_SIZE_BYTES];
let wat = make_module_wat(TEST_NUM_PAGES);
let canister_id = test.canister_from_wat(wat).unwrap();
// #[test]
// // generate multiple writes of varying size to random memory locations, apply them both to a
// // canister and a simple Vec buffer and compare the results.
// fn test_orthogonal_persistence() {
// let config = ProptestConfig {
// cases: 20,
// failure_persistence: None,
// ..ProptestConfig::default()
// };
// let algorithm = config.rng_algorithm;
// let mut runner = TestRunner::new_with_rng(config, TestRng::deterministic_rng(algorithm));
// runner
// .run(
// &random_writes(TEST_HEAP_SIZE_BYTES, TEST_NUM_WRITES),
// |writes| {
// let mut test = ExecutionTestBuilder::new().build();
// let mut heap = vec![0; TEST_HEAP_SIZE_BYTES];
// let wat = make_module_wat(TEST_NUM_PAGES);
// let canister_id = test.canister_from_wat(wat).unwrap();

for w in &writes {
buf_apply_write(&mut heap, w);
write_bytes(&mut test, canister_id, w.dst, &w.bytes);
// verify the heap
let canister_heap = dump_heap(&mut test, canister_id);
prop_assert_eq!(&heap[..], &canister_heap[..]);
}
Ok(())
},
)
.unwrap();
}
// for w in &writes {
// buf_apply_write(&mut heap, w);
// write_bytes(&mut test, canister_id, w.dst, &w.bytes);
// // verify the heap
// let canister_heap = dump_heap(&mut test, canister_id);
// prop_assert_eq!(&heap[..], &canister_heap[..]);
// }
// Ok(())
// },
// )
// .unwrap();
// }
Loading

0 comments on commit b6915bf

Please sign in to comment.