diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/binary.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/binary.rs index df3b7017a5e9..2b7b82590ccd 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/binary.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/binary.rs @@ -1,42 +1,28 @@ use crate::{ConnectorTag, RunnerInterface, TestError, TestResult, TxResult}; -use hyper::{Body, HeaderMap, Method, Request, Response}; +use hyper::{Body, Method, Request, Response}; use query_core::{schema::QuerySchemaRef, TxId}; use query_engine::opt::PrismaOpt; use query_engine::server::routes; -use query_engine::state::{self, State}; +use query_engine::state::{setup, State}; use query_engine_metrics::MetricRegistry; use request_handlers::{GQLBatchResponse, GQLError, GQLResponse, GraphQlBody, MultiQuery, PrismaResponse}; pub struct BinaryRunner { connector_tag: ConnectorTag, current_tx_id: Option, - additional_headers: Option, state: State, } -impl BinaryRunner { - pub(crate) fn set_additional_headers(&mut self, headers: Option) { - self.additional_headers = headers; - } -} - #[async_trait::async_trait] impl RunnerInterface for BinaryRunner { async fn load(datamodel: String, connector_tag: ConnectorTag, metrics: MetricRegistry) -> TestResult { - let opts = PrismaOpt::from_list(&[ - "binary", - "--enable-raw-queries", - "--enable-logs-in-response", - "--datamodel", - &datamodel, - ]); - let state = state::setup(&opts, false, Some(metrics)).await.unwrap(); + let opts = PrismaOpt::from_list(&["binary", "--enable-raw-queries", "--datamodel", &datamodel]); + let state = setup(&opts, false, Some(metrics)).await.unwrap(); Ok(BinaryRunner { state, connector_tag, current_tx_id: None, - additional_headers: None, }) } @@ -51,12 +37,6 @@ impl RunnerInterface for BinaryRunner { builder = builder.header("X-transaction-id", tx_id); } - if let Some(headers) = &self.additional_headers { - for (key, value) in headers { - builder = builder.header(key, value); - } - } - let req = builder.body(Body::from(body)).unwrap(); let resp = routes(self.state.clone(), req).await.unwrap(); @@ -83,17 +63,13 @@ impl RunnerInterface for BinaryRunner { let mut builder = Request::builder().method(Method::POST); + // Garren: basically if there is a current_tx_id we run it as a transaction + // I don't fully understand how ITX works and I need to do this to pass the tests if self.current_tx_id.is_some() { - let tx_id: String = self.current_tx_id.clone().unwrap().to_string(); + let tx_id: String = self.current_tx_id.as_ref().unwrap().clone().to_string(); builder = builder.header("X-transaction-id", tx_id); } - if let Some(headers) = &self.additional_headers { - for (key, value) in headers { - builder = builder.header(key, value); - } - } - let req = builder.body(Body::from(body)).unwrap(); let resp = routes(self.state.clone(), req).await.unwrap(); diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/mod.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/mod.rs index 8c4ed028399e..d6706a33e262 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/mod.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/runner/mod.rs @@ -2,11 +2,8 @@ mod binary; mod direct; mod node_api; -use std::collections::HashMap; - pub use binary::*; pub use direct::*; -use hyper::HeaderMap; pub use node_api::*; use query_core::{schema::QuerySchemaRef, TxId}; use query_engine_metrics::MetricRegistry; @@ -165,29 +162,6 @@ impl Runner { } } - pub fn set_headers(&mut self, headers: HashMap) { - match &mut self.inner { - RunnerType::Direct(_) => todo!(), - RunnerType::NodeApi(_) => todo!(), - RunnerType::Binary(r) => { - let map = Some(HeaderMap::from_iter( - headers - .into_iter() - .map(|(k, v)| (k.parse().unwrap(), v.parse().unwrap())), - )); - r.set_additional_headers(map) - } - } - } - - pub fn clear_headers(&mut self) { - match &mut self.inner { - RunnerType::Direct(_) => todo!(), - RunnerType::NodeApi(_) => todo!(), - RunnerType::Binary(r) => r.set_additional_headers(None), - } - } - async fn direct(datamodel: String, connector_tag: ConnectorTag, metrics: MetricRegistry) -> TestResult { let runner = DirectRunner::load(datamodel, connector_tag, metrics).await?;