diff --git a/.github/workflows/test-query-engine.yml b/.github/workflows/test-query-engine.yml index 4128fe11ef4d..6c56575dabad 100644 --- a/.github/workflows/test-query-engine.yml +++ b/.github/workflows/test-query-engine.yml @@ -59,6 +59,10 @@ jobs: single_threaded: false connector: "cockroachdb" version: "22.1" + - name: "mysql_8" + single_threaded: false + connector: "mysql" + version: "8" engine_protocol: [graphql, json] relation_load_strategy: [join, query] partition: ["1/4", "2/4", "3/4", "4/4"] @@ -85,6 +89,7 @@ jobs: TEST_CONNECTOR_VERSION: ${{ matrix.database.version }} PRISMA_ENGINE_PROTOCOL: ${{ matrix.engine_protocol }} PRISMA_RELATION_LOAD_STRATEGY: ${{ matrix.relation_load_strategy }} + WORKSPACE_ROOT: ${{ github.workspace }} runs-on: ubuntu-latest steps: @@ -106,12 +111,12 @@ jobs: - name: "Start ${{ matrix.database.name }} (${{ matrix.engine_protocol }})" run: make start-${{ matrix.database.name }} - - run: export WORKSPACE_ROOT=$(pwd) && cargo nextest run -p query-engine-tests --partition hash:${{ matrix.partition }} --test-threads=1 + - run: cargo nextest run -p query-engine-tests --partition hash:${{ matrix.partition }} --test-threads=1 if: ${{ matrix.database.single_threaded }} env: CLICOLOR_FORCE: 1 - - run: export WORKSPACE_ROOT=$(pwd) && cargo nextest run -p query-engine-tests --partition hash:${{ matrix.partition }} --test-threads=8 + - run: cargo nextest run -p query-engine-tests --partition hash:${{ matrix.partition }} --test-threads=8 if: ${{ !matrix.database.single_threaded }} env: CLICOLOR_FORCE: 1 diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/metrics.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/metrics.rs index 50d8f7c0a9ca..2a1cf89e9d3b 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/metrics.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/new/metrics.rs @@ -34,12 +34,12 @@ mod metrics { match runner.connector_version() { Sqlite(_) => assert_eq!(total_queries, 2), - SqlServer(_) => assert_eq!(total_queries, 17), + SqlServer(_) => assert_eq!(total_queries, 10), MongoDb(_) => assert_eq!(total_queries, 5), - CockroachDb(_) => (), // not deterministic - MySql(_) => assert_eq!(total_queries, 12), - Vitess(_) => assert_eq!(total_queries, 11), - Postgres(_) => assert_eq!(total_queries, 7), + CockroachDb(_) => assert_eq!(total_queries, 2), + MySql(_) => assert_eq!(total_queries, 9), + Vitess(_) => assert_eq!(total_queries, 9), + Postgres(_) => assert_eq!(total_queries, 2), } assert_eq!(total_operations, 2); diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/field_reference/failure.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/field_reference/failure.rs index dd7d69d90755..90c1a18849bb 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/field_reference/failure.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/filters/field_reference/failure.rs @@ -253,12 +253,25 @@ mod failure { /// we can't make it work both for MySQL and MariaDB without making MariaDB its own connector. #[connector_test(schema(schemas::json), only(MySql(5.7, 8, "mariadb")))] async fn alphanumeric_json_filter_fails(runner: Runner) -> TestResult<()> { - assert_error!( - runner, - r#"query { findManyTestModel(where: { json: { gt: { _ref: "json", _container: "TestModel" } } }) { id }}"#, - 2009, - "Invalid argument type" - ); + let res = match runner.protocol() { + EngineProtocol::Graphql => runner.query(r#"query { findManyTestModel(where: { json: { gt: { _ref: "json", _container: "TestModel" } } }) { id }}"#).await?, + EngineProtocol::Json => runner.query_json(r#"{ + "modelName": "TestModel", + "action": "findMany", + "query": { + "arguments": { + "where": { + "json": { "gt": { "$type": "FieldRef", "value": { "_ref": "json", "_container": "TestModel" } } } + } + }, + "selection": { + "id": true + } + } + }"#).await?, + }; + + res.assert_failure(2009, Some("Invalid argument type".to_owned())); Ok(()) } diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs index 70e43c344708..e94c14c6c574 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs @@ -173,17 +173,18 @@ fn run_relation_link_test_impl( .await .unwrap(); - test_fn(&runner, &dm).await.unwrap(); + + test_fn(&runner, &dm).with_subscriber(test_tracing_subscriber( + ENV_LOG_LEVEL.to_string(), + metrics_for_subscriber, + log_tx, + )) + .await.unwrap(); teardown_project(&datamodel, Default::default(), runner.schema_id()) .await .unwrap(); } - .with_subscriber(test_tracing_subscriber( - ENV_LOG_LEVEL.to_string(), - metrics_for_subscriber, - log_tx, - )), ); } } @@ -279,37 +280,37 @@ fn run_connector_test_impl( let (log_capture, log_tx) = TestLogCapture::new(); - crate::run_with_tokio( - async { - println!("Used datamodel:\n {}", datamodel.yellow()); - let override_local_max_bind_values = None; - let runner = Runner::load( - datamodel.clone(), - db_schemas, - version, - connector_tag, - override_local_max_bind_values, - metrics, - log_capture, - ) + crate::run_with_tokio(async { + println!("Used datamodel:\n {}", datamodel.yellow()); + let override_local_max_bind_values = None; + let runner = Runner::load( + datamodel.clone(), + db_schemas, + version, + connector_tag, + override_local_max_bind_values, + metrics, + log_capture, + ) + .await + .unwrap(); + let schema_id = runner.schema_id(); + + if let Err(err) = test_fn(runner) + .with_subscriber(test_tracing_subscriber( + ENV_LOG_LEVEL.to_string(), + metrics_for_subscriber, + log_tx, + )) .await - .unwrap(); - let schema_id = runner.schema_id(); - - if let Err(err) = test_fn(runner).await { - panic!("💥 Test failed due to an error: {err:?}"); - } - - crate::teardown_project(&datamodel, db_schemas, schema_id) - .await - .unwrap(); + { + panic!("💥 Test failed due to an error: {err:?}"); } - .with_subscriber(test_tracing_subscriber( - ENV_LOG_LEVEL.to_string(), - metrics_for_subscriber, - log_tx, - )), - ); + + crate::teardown_project(&datamodel, db_schemas, schema_id) + .await + .unwrap(); + }); } pub type LogEmit = UnboundedSender; diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/logging.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/logging.rs index 79d92affe426..5520075e6d30 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/logging.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/logging.rs @@ -1,34 +1,12 @@ use query_core::telemetry::helpers as telemetry_helpers; use query_engine_metrics::MetricRegistry; +use tracing::Subscriber; use tracing_error::ErrorLayer; -use tracing_subscriber::{layer::Layered, prelude::*, Layer, Registry}; +use tracing_subscriber::{prelude::*, Layer}; use crate::LogEmit; -// Pretty ugly. I'm not sure how to make this better -type Sub = Layered< - ErrorLayer< - Layered< - Box< - dyn tracing_subscriber::Layer< - Layered + Send + Sync>, Registry>, - > + Send - + Sync, - >, - Layered + Send + Sync>, Registry>, - >, - >, - Layered< - Box< - dyn tracing_subscriber::Layer + Send + Sync>, Registry>> - + Send - + Sync, - >, - Layered + Send + Sync>, Registry>, - >, ->; - -pub fn test_tracing_subscriber(log_config: String, metrics: MetricRegistry, log_tx: LogEmit) -> Sub { +pub fn test_tracing_subscriber(log_config: String, metrics: MetricRegistry, log_tx: LogEmit) -> impl Subscriber { let filter = telemetry_helpers::env_filter(true, telemetry_helpers::QueryEngineLogLevel::Override(log_config)); let fmt_layer = tracing_subscriber::fmt::layer() diff --git a/query-engine/query-engine-node-api/tmp b/query-engine/query-engine-node-api/tmp new file mode 100644 index 000000000000..e69de29bb2d1