Skip to content

Commit

Permalink
chore(driver-adapters): refactor query-engine test executor (#5100)
Browse files Browse the repository at this point in the history
* chore(driver-adapters): refactor query-engine test executor, in preparation for schema-engine-wasm playground

* chore: update Node.js version to v20 for Driver Adapters

* feat(driver-adapters-executor): log request on "initializeeSchema"; add brand type + sanity check to SchemaId

* feat(connector-test-kit-rs): use workspace root only, add warnings on config loading errors (hidden behind RUST_LOG=warn)

* fix(driver-adapters-executor): schema path setting

---------

Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
  • Loading branch information
jkomyno and jkomyno authored Dec 30, 2024
1 parent cc0167b commit aef02d5
Show file tree
Hide file tree
Showing 25 changed files with 821 additions and 672 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-driver-adapters-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node_version: ["18"]
node_version: ["20"]
partition: ["1/4", "2/4", "3/4", "4/4"]
env:
LOG_LEVEL: "info" # Set to "debug" to trace the query engine and node process running the driver adapter
Expand Down
96 changes: 94 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion query-engine/connector-test-kit-rs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To run tests through a driver adapters, you should also configure the following
Example:

```shell
export EXTERNAL_TEST_EXECUTOR="$WORKSPACE_ROOT/query-engine/driver-adapters/executor/script/testd.sh"
export EXTERNAL_TEST_EXECUTOR="$WORKSPACE_ROOT/query-engine/driver-adapters/executor/script/testd-qe.sh"
export DRIVER_ADAPTER=neon
export ENGINE=wasm
export DRIVER_ADAPTER_CONFIG ='{ "proxyUrl": "127.0.0.1:5488/v1" }'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ insta = "1.7.1"
# as this is a small crate with little user base.
parse-hyperlinks = "0.23.3"
strip-ansi-escapes = "0.1.1"
log = "0.4.22"
env_logger = "0.11.6"
43 changes: 30 additions & 13 deletions query-engine/connector-test-kit-rs/query-tests-setup/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
CockroachDbConnectorTag, ConnectorTag, ConnectorVersion, MongoDbConnectorTag, MySqlConnectorTag,
PostgresConnectorTag, SqlServerConnectorTag, SqliteConnectorTag, TestResult, VitessConnectorTag,
};
use log::warn;
use qe_setup::driver_adapters::DriverAdapter;
use serde::{Deserialize, Serialize};
use std::{convert::TryFrom, env, fmt::Display, fs::File, io::Read, path::PathBuf};
Expand Down Expand Up @@ -258,6 +259,8 @@ fn exit_with_message(msg: &str) -> ! {
impl TestConfig {
/// Loads a configuration. File-based config has precedence over env config.
pub(crate) fn load() -> Self {
// Use `RUST_LOG=warn` to see warnings about config loading.
env_logger::init();
let config = match Self::from_file().or_else(Self::from_env) {
Some(config) => config,
None => exit_with_message(CONFIG_LOAD_FAILED),
Expand Down Expand Up @@ -326,29 +329,43 @@ impl TestConfig {
}

fn from_file() -> Option<Self> {
let current_dir = env::current_dir().ok();
current_dir
.and_then(|path| Self::try_path(config_path(path)))
.or_else(|| Self::workspace_root().and_then(|path| Self::try_path(config_path(path))))
Self::workspace_root().and_then(|path| Self::try_path(config_path(path)))
}

fn try_path(path: PathBuf) -> Option<Self> {
File::open(path).ok().and_then(|mut f| {
let mut config = String::new();

f.read_to_string(&mut config)
.ok()
.and_then(|_| serde_json::from_str::<TestConfigFromSerde>(&config).ok())
.map(Self::from)
})
File::open(&path)
.map_err(move |err| {
warn!("Could not open file {}: {err}", path.display());
err
})
.ok()
.and_then(|mut f| {
let mut config = String::new();

f.read_to_string(&mut config)
.map_err(|err| {
warn!("Could not read file into string: {err}");
err
})
.ok()
.and_then(|_| {
serde_json::from_str::<TestConfigFromSerde>(&config)
.map_err(|err| {
warn!("Could not deserialize JSON via TestConfigFromSerde: {err}");
err
})
.ok()
})
.map(Self::from)
})
}

fn workspace_root() -> Option<PathBuf> {
env::var("WORKSPACE_ROOT").ok().map(PathBuf::from)
}

pub fn external_test_executor_path(&self) -> Option<String> {
const DEFAULT_TEST_EXECUTOR: &str = "query-engine/driver-adapters/executor/script/testd.sh";
const DEFAULT_TEST_EXECUTOR: &str = "query-engine/driver-adapters/executor/script/testd-qe.sh";
self.with_driver_adapter()
.and_then(|_| {
Self::workspace_root().or_else(|| {
Expand Down
4 changes: 2 additions & 2 deletions query-engine/driver-adapters/executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"description": "",
"private": true,
"scripts": {
"build": "tsup ./src/testd.ts ./src/bench.ts --format esm --dts",
"test": "node --import tsx ./src/testd.ts",
"build": "tsup ./src/testd-qe.ts ./src/bench.ts --format esm --dts",
"test:qe": "node --import tsx ./src/testd-qe.ts",
"clean:d1": "rm -rf ../../connector-test-kit-rs/query-engine-tests/.wrangler"
},
"tsup": {
Expand Down
2 changes: 2 additions & 0 deletions query-engine/driver-adapters/executor/script/testd-qe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
node "$(dirname "${BASH_SOURCE[0]}")/../dist/testd-qe.mjs"
2 changes: 0 additions & 2 deletions query-engine/driver-adapters/executor/script/testd.sh

This file was deleted.

Loading

0 comments on commit aef02d5

Please sign in to comment.