Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no long execution tests #2735

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ 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
// Limit available custom section memory so that we can hit the limit with
// only a few canisters.
let available_wasm_custom_sections_memory = 1024; // 1 KiB

// This value might need adjustment if something changes in the canister's
// wasm that gets installed in the test.
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();
// }
3 changes: 0 additions & 3 deletions rs/execution_environment/src/hypervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ use crate::execution_environment::{as_round_instructions, CompilationCostHandlin
use crate::metrics::CallTreeMetrics;
use ic_replicated_state::page_map::PageAllocatorFileDescriptor;

#[cfg(test)]
mod tests;

#[doc(hidden)] // pub for usage in tests
pub struct HypervisorMetrics {
accessed_pages: HistogramVec,
Expand Down
5 changes: 5 additions & 0 deletions rs/execution_environment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ use scheduler::SchedulerImpl;
use std::sync::Arc;
use tokio::sync::mpsc::Sender;

#[test]
fn failing_test() {
assert_eq!(1, 2);
}

/// When executing a wasm method of query type, this enum indicates if we are
/// running in an replicated or non-replicated context. This information is
/// needed for various purposes and in particular to support the CoW memory
Expand Down
98 changes: 49 additions & 49 deletions rs/execution_environment/src/scheduler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4464,55 +4464,55 @@ fn should_never_consume_more_than_max_instructions_per_round_in_a_single_executi
);
}

#[test_strategy::proptest]
// This test verifies that the scheduler is deterministic, i.e. given
// the same input, if we execute a round of computation, we always
// get the same result.
fn scheduler_deterministically_produces_same_output_given_same_input(
#[strategy(arb_scheduler_test_double(2..10, 1..20, 1..100, M..B, 1..M, 100, false))] test: (
SchedulerTest,
SchedulerTest,
usize,
NumInstructions,
NumInstructions,
),
) {
let (mut test1, mut test2, _cores, _instructions_per_round, _instructions_per_message) = test;
assert_eq!(test1.state(), test2.state());
test1.execute_round(ExecutionRoundType::OrdinaryRound);
test2.execute_round(ExecutionRoundType::OrdinaryRound);
assert_eq!(test1.state(), test2.state());
}

#[test_strategy::proptest]
// This test verifies that the scheduler can successfully deplete the induction
// pool given sufficient consecutive execution rounds.
fn scheduler_can_deplete_induction_pool_given_enough_execution_rounds(
#[strategy(arb_scheduler_test(2..10, 1..20, 1..100, M..B, 1..M, 100, false))] test: (
SchedulerTest,
usize,
NumInstructions,
NumInstructions,
),
) {
let (mut test, _scheduler_cores, instructions_per_round, instructions_per_message) = test;
let available_messages = get_available_messages(test.state());
let minimum_executed_messages = min(
available_messages,
instructions_per_round / instructions_per_message,
);
let required_rounds = if minimum_executed_messages != 0 {
available_messages / minimum_executed_messages + 1
} else {
1
};
for _ in 0..required_rounds {
test.execute_round(ExecutionRoundType::OrdinaryRound);
}
for canister_state in test.state().canisters_iter() {
assert_eq!(canister_state.system_state.queues().ingress_queue_size(), 0);
}
}
// #[test_strategy::proptest]
// // This test verifies that the scheduler is deterministic, i.e. given
// // the same input, if we execute a round of computation, we always
// // get the same result.
// fn scheduler_deterministically_produces_same_output_given_same_input(
// #[strategy(arb_scheduler_test_double(2..10, 1..20, 1..100, M..B, 1..M, 100, false))] test: (
// SchedulerTest,
// SchedulerTest,
// usize,
// NumInstructions,
// NumInstructions,
// ),
// ) {
// let (mut test1, mut test2, _cores, _instructions_per_round, _instructions_per_message) = test;
// assert_eq!(test1.state(), test2.state());
// test1.execute_round(ExecutionRoundType::OrdinaryRound);
// test2.execute_round(ExecutionRoundType::OrdinaryRound);
// assert_eq!(test1.state(), test2.state());
// }

// #[test_strategy::proptest]
// // This test verifies that the scheduler can successfully deplete the induction
// // pool given sufficient consecutive execution rounds.
// fn scheduler_can_deplete_induction_pool_given_enough_execution_rounds(
// #[strategy(arb_scheduler_test(2..10, 1..20, 1..100, M..B, 1..M, 100, false))] test: (
// SchedulerTest,
// usize,
// NumInstructions,
// NumInstructions,
// ),
// ) {
// let (mut test, _scheduler_cores, instructions_per_round, instructions_per_message) = test;
// let available_messages = get_available_messages(test.state());
// let minimum_executed_messages = min(
// available_messages,
// instructions_per_round / instructions_per_message,
// );
// let required_rounds = if minimum_executed_messages != 0 {
// available_messages / minimum_executed_messages + 1
// } else {
// 1
// };
// for _ in 0..required_rounds {
// test.execute_round(ExecutionRoundType::OrdinaryRound);
// }
// for canister_state in test.state().canisters_iter() {
// assert_eq!(canister_state.system_state.queues().ingress_queue_size(), 0);
// }
// }

#[test_strategy::proptest]
// This test verifies that the scheduler does not lose any canisters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::hypervisor::tests::WasmResult::Reply;
use assert_matches::assert_matches;
use candid::{Decode, Encode};
use ic_base_types::{NumSeconds, PrincipalId};
Expand Down Expand Up @@ -1800,15 +1799,13 @@ fn ic0_msg_reject_fails_if_called_twice() {
.contains("ic0.msg_reject: the call is already replied"));
}

#[test]
fn some_ic0_calls_fail_if_called_with_huge_size() {
fn test(syscall: &str) {
let mut test = ExecutionTestBuilder::new()
// 3T Cycles should be more than enough for a single ingress call.
.with_initial_canister_cycles(3_000_000_000_000)
.build();
let wat = format!(
r#"
fn test_large_syscall(syscall: &str) {
let mut test = ExecutionTestBuilder::new()
// 3T Cycles should be more than enough for a single ingress call.
.with_initial_canister_cycles(3_000_000_000_000)
.build();
let wat = format!(
r#"
(module
(import "ic0" "{syscall}"
(func $ic0_{syscall} (param i32) (param i32))
Expand All @@ -1818,17 +1815,28 @@ fn some_ic0_calls_fail_if_called_with_huge_size() {
)
(memory 1 1)
)"#,
SIZE = u32::MAX
);
let canister_id = test.canister_from_wat(wat).unwrap();
SIZE = u32::MAX
);
let canister_id = test.canister_from_wat(wat).unwrap();

let err = test.ingress(canister_id, "test", vec![]).unwrap_err();
// It must be neither a contract violation nor timeout.
assert_eq!(ErrorCode::CanisterInstructionLimitExceeded, err.code());
}
for syscall in ["msg_reject", "call_data_append", "msg_reply_data_append"] {
test(syscall);
}
let err = test.ingress(canister_id, "test", vec![]).unwrap_err();
// It must be neither a contract violation nor timeout.
assert_eq!(ErrorCode::CanisterInstructionLimitExceeded, err.code());
}

#[test]
fn msg_reject_calls_fail_if_called_with_huge_size() {
test_large_syscall("msg_reject")
}

#[test]
fn call_data_append_calls_fail_if_called_with_huge_size() {
test_large_syscall("call_data_append")
}

#[test]
fn msg_reply_data_append_calls_fail_if_called_with_huge_size() {
test_large_syscall("msg_reply_data_append")
}

#[test]
Expand Down Expand Up @@ -4105,7 +4113,7 @@ fn can_extract_exported_custom_sections() {
// Custom start=0x00028de2 end=0x00028dfc (size=0x0000001a) "icp:private candid:args"
// Custom start=0x00028e02 end=0x00028e30 (size=0x0000002e) "icp:private motoko:stable-types"

let binary = include_bytes!("../../tests/test-data/custom_sections.wasm").to_vec();
let binary = include_bytes!("test-data/custom_sections.wasm").to_vec();
let canister_id = test.canister_from_binary(binary).unwrap();

let execution_state = test.execution_state(canister_id);
Expand Down Expand Up @@ -5461,7 +5469,7 @@ fn call_with_best_effort_response_succeeds() {
)
.unwrap();

assert_eq!(result, Reply(vec![]));
assert_eq!(result, WasmResult::Reply(vec![]));
}

#[test]
Expand Down
Loading