Skip to content

Commit

Permalink
miri: Enable tests using epoll_wait
Browse files Browse the repository at this point in the history
Based on recent segfaults we definitely want more Miri testing.
  • Loading branch information
def- committed Jun 16, 2023
1 parent ec2b183 commit 90d6131
Show file tree
Hide file tree
Showing 59 changed files with 137 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slow-timeout = { period = "60s", terminate-after = 2 }

[profile.default-miri]
slow-timeout = { period = "600s", terminate-after = 2 }
slow-timeout = { period = "1200s", terminate-after = 2 }

# For a given configuration parameter, the first override to match wins. Keep
# these sorted in order from most specific to least specific.
Expand Down
7 changes: 7 additions & 0 deletions bin/ci-builder
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ case "$cmd" in
--env NIGHTLY_CANARY_CONFLUENT_CLOUD_API_SECRET
--env NO_COLOR
--env PYPI_TOKEN
# For Miri with nightly Rust
--env ZOOKEEPER_ADDR
--env KAFKA_ADDRS
--env SCHEMA_REGISTRY_URL
--env POSTGRES_URL
--env COCKROACH_URL
--env MZ_SOFT_ASSERTIONS
)

if [[ $detach_container == "true" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions ci/test/cargo-test-miri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ set -euo pipefail
# so keep them away from the `target` directory.
export CARGO_TARGET_DIR="$PWD/miri-target"
export MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-strict-provenance"
# exclude netwrok based tests, they mostly fail on epoll_wait
cargo miri nextest run -j"$(nproc)" --no-fail-fast --workspace --exclude 'mz-adapter*' --exclude 'mz-environmentd*' --exclude 'mz-expr*' --exclude 'mz-compute-client*' --exclude 'mz-persist-client*' --exclude 'mz-ssh-util*' --exclude 'mz-rocksdb*'
# exclude network-based and more complex tests which run out of memory
cargo miri nextest run -j"$(nproc)" --no-fail-fast --workspace --exclude 'mz-environmentd*' --exclude 'mz-compute-client*' --exclude 'mz-ssh-util*' --exclude 'mz-rocksdb*'
35 changes: 21 additions & 14 deletions ci/test/cargo-test/mzcompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@


def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
parser.add_argument("--miri", action="store_true")
parser.add_argument("args", nargs="*")
args = parser.parse_args()
c.up("zookeeper", "kafka", "schema-registry", "postgres", "cockroach")
Expand Down Expand Up @@ -116,17 +117,23 @@ def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
],
env=env,
)
cpu_count = os.cpu_count()
assert cpu_count
spawn.runv(
[
"cargo",
"nextest",
"run",
"--profile=ci",
# Most tests don't use 100% of a CPU core, so run two tests per CPU.
f"--test-threads={cpu_count * 2}",
*args.args,
],
env=env,
)
if args.miri:
spawn.runv(
["bin/ci-builder", "run", "nightly", "ci/test/cargo-test-miri.sh"],
env=env,
)
else:
cpu_count = os.cpu_count()
assert cpu_count
spawn.runv(
[
"cargo",
"nextest",
"run",
"--profile=ci",
# Most tests don't use 100% of a CPU core, so run two tests per CPU.
f"--test-threads={cpu_count * 2}",
*args.args,
],
env=env,
)
19 changes: 17 additions & 2 deletions ci/test/pipeline.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,24 @@ steps:

- id: miri-test
label: Miri test
command: bin/ci-builder run nightly ci/test/cargo-test-miri.sh
inputs: [src]
timeout_in_minutes: 30
timeout_in_minutes: 60
artifact_paths: [junit_*.xml, target/nextest/ci/junit_cargo-test.xml]
inputs:
- Cargo.lock
- "**/Cargo.toml"
- "**/*.rs"
- "**/*.proto"
- "**/testdata/**"
env:
AWS_DEFAULT_REGION: "us-east-1"
# cargo-test's coverage is handled separately by cargo-llvm-cov
BUILDKITE_MZCOMPOSE_PLUGIN_SKIP_COVERAGE: "true"
plugins:
- ./ci/plugins/scratch-aws-access: ~
- ./ci/plugins/mzcompose:
composition: cargo-test
args: [--miri]
agents:
queue: builder-linux-x86_64
coverage: skip
Expand Down
7 changes: 7 additions & 0 deletions src/adapter/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8399,6 +8399,7 @@ mod tests {
/// search paths, so do not require schema qualification on system objects such
/// as types.
#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_minimal_qualification() {
Catalog::with_debug(NOW_ZERO.clone(), |catalog| async move {
struct TestCase {
Expand Down Expand Up @@ -8471,6 +8472,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_catalog_revision() {
let debug_stash_factory = DebugStashFactory::new().await;
{
Expand Down Expand Up @@ -8506,6 +8508,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_effective_search_path() {
Catalog::with_debug(NOW_ZERO.clone(), |catalog| async move {
let mz_catalog_schema = (
Expand Down Expand Up @@ -8651,6 +8654,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_builtin_migration() {
enum ItemNamespace {
System,
Expand Down Expand Up @@ -9305,6 +9309,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_normalized_create() {
Catalog::with_debug(NOW_ZERO.clone(), |catalog| {
let catalog = catalog.for_system_session();
Expand Down Expand Up @@ -9489,6 +9494,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_object_type() {
let debug_stash_factory = DebugStashFactory::new().await;
let stash = debug_stash_factory.open_debug().await;
Expand All @@ -9508,6 +9514,7 @@ mod tests {
}

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_get_privileges() {
let debug_stash_factory = DebugStashFactory::new().await;
let stash = debug_stash_factory.open_debug().await;
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/src/catalog/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4185,6 +4185,7 @@ mod tests {
// Connect to a running Postgres server and verify that our builtin
// types and functions match it, in addition to some other things.
#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_compare_builtins_postgres() {
async fn inner(catalog: Catalog) {
// Verify that all builtin functions:
Expand Down Expand Up @@ -4511,6 +4512,7 @@ mod tests {

// Make sure pg views don't use types that only exist in Materialize.
#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_pg_views_forbidden_types() {
Catalog::with_debug(SYSTEM_TIME.clone(), |catalog| async move {
let conn_catalog = catalog.for_system_session();
Expand Down
6 changes: 6 additions & 0 deletions src/adapter/src/catalog/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2036,6 +2036,7 @@ mod test {

proptest! {
#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_database_key_roundtrip(key: DatabaseKey) {
let proto = key.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand All @@ -2044,6 +2045,7 @@ mod test {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_database_value_roundtrip(value: DatabaseValue) {
let proto = value.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand All @@ -2052,6 +2054,7 @@ mod test {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_schema_key_roundtrip(key: SchemaKey) {
let proto = key.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand All @@ -2060,6 +2063,7 @@ mod test {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_schema_value_roundtrip(value: SchemaValue) {
let proto = value.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand All @@ -2068,6 +2072,7 @@ mod test {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_item_key_roundtrip(key: ItemKey) {
let proto = key.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand All @@ -2076,6 +2081,7 @@ mod test {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn proptest_item_value_roundtrip(value: ItemValue) {
let proto = value.into_proto();
let round = proto.into_rust().expect("to roundtrip");
Expand Down
2 changes: 2 additions & 0 deletions src/adapter/src/config/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ mod tests {
use super::SynchronizedParameters;

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux`
fn test_github_18189() {
let vars = SystemVars::default();
let mut sync = SynchronizedParameters::new(vars);
Expand All @@ -156,6 +157,7 @@ mod tests {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux`
fn test_vars_are_synced() {
let vars = SystemVars::default();
let sync = SynchronizedParameters::new(vars);
Expand Down
1 change: 1 addition & 0 deletions src/adapter/src/coord/peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ mod tests {
use super::*;

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`
fn test_fast_path_plan_as_text() {
let typ = RelationType::new(vec![ColumnType {
scalar_type: ScalarType::String,
Expand Down
1 change: 1 addition & 0 deletions src/adapter/tests/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ use mz_repr::ScalarType;
use mz_sql::plan::PlanContext;

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn test_parameter_type_inference() {
let test_cases = vec![
(
Expand Down
1 change: 1 addition & 0 deletions src/adapter/tests/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ use tokio::sync::Mutex;
// catalog.

#[mz_ore::test(tokio::test)]
#[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
async fn datadriven() {
datadriven::walk_async("tests/testdata/sql", |mut f| async {
// The datadriven API takes an `FnMut` closure, and can't express to Rust that
Expand Down
1 change: 1 addition & 0 deletions src/adapter/tests/timestamp_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ fn parse_query_when(s: &str) -> QueryWhen {
/// returns the chosen timestamp. Append `full` as an argument to it to see the entire
/// TimestampDetermination.
#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux`
fn test_timestamp_selection() {
datadriven::walk("tests/testdata/timestamp_selection", |tf| {
let mut f = Frontiers {
Expand Down
1 change: 1 addition & 0 deletions src/avro/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ mod tests {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn test_writer_roundtrip() {
let schema = Schema::from_str(SCHEMA).unwrap();
let make_record = |a: i64, b| {
Expand Down
1 change: 1 addition & 0 deletions src/cluster-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ mod tests {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // slow
fn cluster_startup_epoch_protobuf_roundtrip(expect in any::<ClusterStartupEpoch>() ) {
let actual = protobuf_roundtrip::<_, ProtoClusterStartupEpoch>(&expect);
assert!(actual.is_ok());
Expand Down
1 change: 1 addition & 0 deletions src/compute-client/src/plan/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ mod tests {
#![proptest_config(ProptestConfig::with_cases(32))]

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `decContextDefault` on OS `linux`
fn join_plan_protobuf_roundtrip(expect in any::<JoinPlan>() ) {
let actual = protobuf_roundtrip::<_, ProtoJoinPlan>(&expect);
assert!(actual.is_ok());
Expand Down
1 change: 1 addition & 0 deletions src/compute-client/src/plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,7 @@ mod tests {
proptest! {
#![proptest_config(ProptestConfig::with_cases(10))]
#[mz_ore::test]
#[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `decContextDefault` on OS `linux`
fn get_plan_protobuf_roundtrip(expect in any::<GetPlan>()) {
let actual = protobuf_roundtrip::<_, ProtoGetPlan>(&expect);
assert!(actual.is_ok());
Expand Down
1 change: 1 addition & 0 deletions src/compute-client/src/protocol/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ mod tests {
#![proptest_config(ProptestConfig::with_cases(32))]

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // error: unsupported operation: can't call foreign function `decContextDefault` on OS `linux`
fn peek_protobuf_roundtrip(expect in any::<Peek>() ) {
let actual = protobuf_roundtrip::<_, ProtoPeek>(&expect);
assert!(actual.is_ok());
Expand Down
11 changes: 0 additions & 11 deletions src/environmentd/tests/pgwire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ fn test_bind_params() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_partial_read() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand All @@ -198,7 +197,6 @@ fn test_partial_read() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_read_many_rows() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand All @@ -213,7 +211,6 @@ fn test_read_many_rows() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_conn_startup() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand Down Expand Up @@ -362,7 +359,6 @@ fn test_conn_startup() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_conn_user() {
let server = util::start_server(util::Config::default()).unwrap();

Expand Down Expand Up @@ -397,7 +393,6 @@ fn test_conn_user() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_simple_query_no_hang() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand All @@ -407,7 +402,6 @@ fn test_simple_query_no_hang() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_copy() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand Down Expand Up @@ -457,7 +451,6 @@ fn test_copy() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_arrays() {
let server = util::start_server(util::Config::default().unsafe_mode()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand Down Expand Up @@ -505,7 +498,6 @@ fn test_arrays() {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_record_types() {
let server = util::start_server(util::Config::default()).unwrap();
let mut client = server.connect(postgres::NoTls).unwrap();
Expand Down Expand Up @@ -573,15 +565,12 @@ fn pg_test_inner(dir: PathBuf, flags: &[&'static str]) {
}

#[mz_ore::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_pgtest() {
let dir: PathBuf = ["..", "..", "test", "pgtest"].iter().collect();
pg_test_inner(dir, &[]);
}

#[mz_ore::test]
// unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
#[cfg_attr(miri, ignore)]
// Materialize's differences from Postgres' responses.
fn test_pgtest_mz() {
let dir: PathBuf = ["..", "..", "test", "pgtest-mz"].iter().collect();
Expand Down
Loading

0 comments on commit 90d6131

Please sign in to comment.