Skip to content

Commit

Permalink
ci: Run mysql tests on GH Action (#4951)
Browse files Browse the repository at this point in the history
* tmp: debug mysql tests

* Trigger buiild/tests

* Try things

* Copy DA workflow

* Revert

* dump vars

* dbg in test

* Log builtkit

* try capturing mysql logs

* fix clippy errors

* remove panic + add test back

* Fix metrics expectation

They no longer include migration queries

* Fix alphanumeric_json_filter_fails test

* Undo tmp changes

* Uncomment existing tests

* Fix mssql

---------

Co-authored-by: Flavian Desverne <[email protected]>
  • Loading branch information
SevInf and Weakky authored Jul 16, 2024
1 parent 393aa35 commit 7484fd8
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 73 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test-query-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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:
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
71 changes: 36 additions & 35 deletions query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)),
);
}
}
Expand Down Expand Up @@ -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<String>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Box<dyn tracing_subscriber::Layer<Registry> + Send + Sync>, Registry>,
> + Send
+ Sync,
>,
Layered<Box<dyn tracing_subscriber::Layer<Registry> + Send + Sync>, Registry>,
>,
>,
Layered<
Box<
dyn tracing_subscriber::Layer<Layered<Box<dyn tracing_subscriber::Layer<Registry> + Send + Sync>, Registry>>
+ Send
+ Sync,
>,
Layered<Box<dyn tracing_subscriber::Layer<Registry> + 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()
Expand Down
Empty file.

0 comments on commit 7484fd8

Please sign in to comment.