Skip to content

Commit

Permalink
Try to enable miri for further cargo tests
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Mar 14, 2023
1 parent 16410a3 commit ffeffce
Show file tree
Hide file tree
Showing 57 changed files with 136 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[profile.default]
slow-timeout = { period = "60s", terminate-after = 2 }

[profile.default-miri]
slow-timeout = { period = "600s", 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
15 changes: 4 additions & 11 deletions ci/test/cargo-test-miri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ set -euo pipefail

# miri artifacts are thoroughly incompatible with normal build artifacts,
# so keep them away from the `target` directory.
export CARGO_TARGET_DIR=miri-target

# At the moment only ore and repr have tests meant to be run under miri.
pkgs=(
repr
ore
)

for pkg in "${pkgs[@]}"; do
(cd src/"$pkg" && cargo miri test miri --all-features)
done
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*'
2 changes: 1 addition & 1 deletion ci/test/pipeline.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ steps:
- id: miri-test
label: Miri test
command: bin/ci-builder run nightly ci/test/cargo-test-miri.sh
inputs: [src/repr]
inputs: [src]
timeout_in_minutes: 30
agents:
queue: builder-linux-x86_64
Expand Down
1 change: 1 addition & 0 deletions src/adapter/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7555,6 +7555,7 @@ mod tests {

// Test that if a large catalog item is somehow committed, then we can still load the catalog.
#[tokio::test]
#[cfg_attr(miri, ignore)] // slow
async fn test_large_catalog_item() {
let view_def = "CREATE VIEW \"materialize\".\"public\".\"v\" AS SELECT 1 FROM (SELECT 1";
let column = ", 1";
Expand Down
6 changes: 3 additions & 3 deletions src/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@

use mz_ore::metrics::MetricsRegistry;

#[cfg(all(not(target_os = "macos"), feature = "jemalloc"))]
#[cfg(all(not(target_os = "macos"), feature = "jemalloc", not(miri)))]
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

/// Registers metrics for the global allocator into the provided registry.
///
/// What metrics are registered varies by platform. Not all platforms use
/// allocators that support metrics.
#[cfg(any(target_os = "macos", not(feature = "jemalloc")))]
#[cfg(any(target_os = "macos", not(feature = "jemalloc"), miri))]
#[allow(clippy::unused_async)]
pub async fn register_metrics_into(_: &MetricsRegistry) {
// No-op on platforms that don't use jemalloc.
Expand All @@ -95,7 +95,7 @@ pub async fn register_metrics_into(_: &MetricsRegistry) {
///
/// What metrics are registered varies by platform. Not all platforms use
/// allocators that support metrics.
#[cfg(all(not(target_os = "macos"), feature = "jemalloc"))]
#[cfg(all(not(target_os = "macos"), feature = "jemalloc", not(miri)))]
pub async fn register_metrics_into(registry: &MetricsRegistry) {
mz_prof::jemalloc::JemallocMetrics::register_into(registry).await;
}
1 change: 1 addition & 0 deletions src/avro/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `deflateInit2_` on OS `linux`
fn deflate_compress_and_decompress() {
let codec = Codec::Deflate;
let mut stream = INPUT.to_vec();
Expand Down
3 changes: 3 additions & 0 deletions src/avro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ mod tests {

//TODO: move where it fits better
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_enum_default() {
let writer_raw_schema = r#"
{
Expand Down Expand Up @@ -488,6 +489,7 @@ mod tests {

//TODO: move where it fits better
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_enum_string_value() {
let raw_schema = r#"
{
Expand Down Expand Up @@ -531,6 +533,7 @@ mod tests {

//TODO: move where it fits better
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_enum_resolution() {
let writer_raw_schema = r#"
{
Expand Down
2 changes: 2 additions & 0 deletions src/avro/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_reader_stream() {
let schema: Schema = SCHEMA.parse().unwrap();
let reader = Reader::with_schema(&schema, ENCODED).unwrap();
Expand Down Expand Up @@ -1026,6 +1027,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_reader_invalid_block() {
let schema: Schema = SCHEMA.parse().unwrap();
let invalid = ENCODED
Expand Down
1 change: 1 addition & 0 deletions src/avro/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2934,6 +2934,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: inline assembly is not supported
fn test_schema_fingerprint() {
use sha2::Sha256;

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 @@ -531,6 +531,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `deflateInit2_` on OS `linux`
fn test_writer_with_codec() {
let schema = Schema::from_str(SCHEMA).unwrap();
let mut writer = Writer::with_codec(schema.clone(), Vec::new(), Codec::Deflate);
Expand Down
4 changes: 4 additions & 0 deletions src/ccsr/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub static SCHEMA_REGISTRY_URL: Lazy<reqwest::Url> =
});

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_method` on OS `linux`
async fn test_client() -> Result<(), anyhow::Error> {
let client = mz_ccsr::ClientConfig::new(SCHEMA_REGISTRY_URL.clone()).build()?;

Expand Down Expand Up @@ -200,6 +201,7 @@ async fn test_client() -> Result<(), anyhow::Error> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_method` on OS `linux`
async fn test_client_subject_and_references() -> Result<(), anyhow::Error> {
let client = mz_ccsr::ClientConfig::new(SCHEMA_REGISTRY_URL.clone()).build()?;

Expand Down Expand Up @@ -305,6 +307,7 @@ async fn test_client_subject_and_references() -> Result<(), anyhow::Error> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_method` on OS `linux`
async fn test_client_errors() -> Result<(), anyhow::Error> {
let invalid_schema_registry_url: reqwest::Url = "data::text/plain,Info".parse().unwrap();
match mz_ccsr::ClientConfig::new(invalid_schema_registry_url).build() {
Expand Down Expand Up @@ -348,6 +351,7 @@ async fn test_client_errors() -> Result<(), anyhow::Error> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `TLS_method` on OS `linux`
async fn test_server_errors() -> Result<(), anyhow::Error> {
// When the schema registry gracefully reports an error by including a
// properly-formatted JSON document in the response, the specific error code
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 @@ -202,6 +202,7 @@ mod tests {
#![proptest_config(ProptestConfig::with_cases(32))]

#[test]
#[cfg_attr(miri, ignore)] // slow
fn timely_config_protobuf_roundtrip(expect in any::<TimelyConfig>() ) {
let actual = protobuf_roundtrip::<_, ProtoTimelyConfig>(&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 @@ -1951,6 +1951,7 @@ mod tests {
proptest! {
#![proptest_config(ProptestConfig::with_cases(10))]
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decContextDefault` on OS `linux`
fn available_collections_protobuf_roundtrip(expect in any::<AvailableCollections>() ) {
let actual = protobuf_roundtrip::<_, ProtoAvailableCollections>(&expect);
assert!(actual.is_ok());
Expand Down
1 change: 1 addition & 0 deletions src/compute-client/src/plan/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@ mod tests {
// ignore by default.
proptest! {
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decContextDefault` on OS `linux`
fn reduce_plan_protobuf_roundtrip(expect in any::<ReducePlan>() ) {
let actual = protobuf_roundtrip::<_, ProtoReducePlan>(&expect);
assert!(actual.is_ok());
Expand Down
4 changes: 4 additions & 0 deletions src/environmentd/tests/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ fn wait_for_refresh(frontegg_server: &MzCloudServer, expires_in_secs: u64) {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`
fn test_auth_expiry() {
// This function verifies that the background expiry refresh task runs. This
// is done by starting a web server that awaits the refresh request, which the
Expand Down Expand Up @@ -870,6 +871,7 @@ fn test_auth_expiry() {

#[allow(clippy::unit_arg)]
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`
fn test_auth_base() {
mz_ore::test::init_logging();

Expand Down Expand Up @@ -1408,6 +1410,7 @@ fn test_auth_base() {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`
fn test_auth_intermediate_ca() {
// Create a CA, an intermediate CA, and a server key pair signed by the
// intermediate CA.
Expand Down Expand Up @@ -1494,6 +1497,7 @@ fn test_auth_intermediate_ca() {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `OPENSSL_init_ssl` on OS `linux`
fn test_auth_admin() {
mz_ore::test::init_logging();

Expand Down
1 change: 1 addition & 0 deletions src/environmentd/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fn cmd() -> Command {
/// This test seems a bit tautological, but it protects against Clap defaults
/// changing and overwriting our custom version output.
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `pipe2` on OS `linux`
fn test_version() {
// We don't make assertions about the build SHA because caching in CI can
// cause the test binary and `environmentd` to have different embedded SHAs.
Expand Down
11 changes: 11 additions & 0 deletions src/environmentd/tests/pgwire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn test_bind_params() {
}

#[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 @@ -200,6 +201,7 @@ fn test_partial_read() {
}

#[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 @@ -214,6 +216,7 @@ fn test_read_many_rows() {
}

#[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,6 +365,7 @@ fn test_conn_startup() {
}

#[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 @@ -396,6 +400,7 @@ fn test_conn_user() {
}

#[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 @@ -405,6 +410,7 @@ fn test_simple_query_no_hang() {
}

#[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 @@ -454,6 +460,7 @@ fn test_copy() {
}

#[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 @@ -501,6 +508,7 @@ fn test_arrays() {
}

#[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 @@ -567,12 +575,15 @@ fn pg_test_inner(dir: PathBuf) {
}

#[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);
}

#[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
7 changes: 7 additions & 0 deletions src/environmentd/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ fn test_source_sink_size_required() {

// Test the POST and WS server endpoints.
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_http_sql() {
// Datadriven directives for WebSocket are "ws-text" and "ws-binary" to send
// text or binary websocket messages that are the input. Output is
Expand Down Expand Up @@ -321,6 +322,7 @@ fn test_http_sql() {

// Test that the server properly handles cancellation requests.
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_cancel_long_running_query() {
let config = util::Config::default().unsafe_mode();
let server = util::start_server(config).unwrap();
Expand Down Expand Up @@ -363,6 +365,7 @@ fn test_cancel_long_running_query() {

// Test that dataflow uninstalls cancelled peeks.
#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_cancel_dataflow_removal() {
let config = util::Config::default().unsafe_mode();
let server = util::start_server(config).unwrap();
Expand Down Expand Up @@ -745,6 +748,7 @@ fn test_old_storage_usage_records_are_reaped_on_restart() {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_default_cluster_sizes() {
let config = util::Config::default()
.with_builtin_cluster_replica_size("1".to_string())
Expand Down Expand Up @@ -776,6 +780,7 @@ fn test_default_cluster_sizes() {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_max_request_size() {
let statement = "SELECT $1::text";
let statement_size = statement.bytes().count();
Expand Down Expand Up @@ -833,6 +838,7 @@ fn test_max_request_size() {
}

#[test]
#[cfg_attr(miri, ignore)] // too slow
fn test_max_statement_batch_size() {
let statement = "SELECT 1;";
let statement_size = statement.bytes().count();
Expand Down Expand Up @@ -914,6 +920,7 @@ fn test_max_statement_batch_size() {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux`
fn test_mz_system_user_admin() {
let config = util::Config::default();
let server = util::start_server(config).unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/expr/src/relation/join_input_mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ mod tests {
use mz_repr::{Datum, ScalarType};

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`
fn try_map_to_input_with_bound_expr_test() {
let input_mapper = JoinInputMapper {
arities: vec![2, 3, 3],
Expand Down
1 change: 1 addition & 0 deletions src/interchange/src/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux`
/// Test that primitive Avro Schema types are allow Datums to be correctly
/// serialized into Avro Values.
///
Expand Down
Loading

0 comments on commit ffeffce

Please sign in to comment.