Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gil/nq-mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
Gil Mizrahi committed Nov 28, 2023
2 parents 0d8b006 + ee25f09 commit 8a0c133
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
with:
status: ${{ job.status }}
notify_when: failure
notification_title: "${{ github.event.commits[0].author.name }}, *nap time is over*! The following commit to <{repo_url}|{repo}> broke the end-to-end tests:"
message_format: "${{ github.event.commits[0].message }}"
notification_title: "${{ github.actor }}, *nap time is over*! The following commit to <{repo_url}|{repo}> broke the end-to-end tests:"
message_format: "${{ github.event.head_commit.message }}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_E2E_SLACK_WEBHOOK_URL }}
85 changes: 58 additions & 27 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions crates/connectors/ndc-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ query-engine-sql = { path = "../../query-engine/sql" }
query-engine-translation = { path = "../../query-engine/translation" }

async-trait = "0.1.74"
percent-encoding = "2.3.0"
percent-encoding = "2.3.1"
prometheus = "0.13.3"
schemars = { version = "0.8.16", features = ["smol_str", "preserve_order"] }
serde = "1.0.192"
serde = "1.0.193"
serde_json = { version = "1.0.108", features = ["raw_value"] }
sqlx = { version = "0.7.2", features = [ "json", "postgres", "runtime-tokio-rustls" ] }
sqlx = { version = "0.7.3", features = [ "json", "postgres", "runtime-tokio-rustls" ] }
thiserror = "1.0"
tokio = { version = "1.34.0", features = ["full"] }
tracing = "0.1.40"
Expand Down
2 changes: 1 addition & 1 deletion crates/query-engine/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ query-engine-sql = { path = "../sql" }
prometheus = "0.13.3"
serde_json = "1.0.108"
sqlformat = "0.2.2"
sqlx = { version = "0.7.2", features = [ "json", "postgres", "runtime-tokio-rustls", "uuid" ] }
sqlx = { version = "0.7.3", features = [ "json", "postgres", "runtime-tokio-rustls", "uuid" ] }
tracing = "0.1.40"
bytes = "1.5.0"
2 changes: 1 addition & 1 deletion crates/query-engine/metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ license = "Apache-2.0"

[dependencies]
schemars = { version = "0.8.16", features = ["smol_str"] }
serde = { version = "1.0.192", features = ["derive"] }
serde = { version = "1.0.193", features = ["derive"] }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod basic {
use tests_common::deployment::{clean_up_deployment, create_fresh_deployment};
use tests_common::request::run_mutation;

#[ignore]
#[tokio::test]
async fn delete_playlist() {
let deployment =
Expand Down
4 changes: 2 additions & 2 deletions crates/tests/tests-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ hyper = { version = "0.14.27", features = ["tcp"] }
jsonschema = { version = "0.17.1", default-features = false, features = ["resolve-http"] }
reqwest = "0.11.22"
schemars = { version = "0.8.16", features = ["smol_str", "preserve_order"] }
serde = "1.0.192"
serde = "1.0.193"
serde_derive = "^1.0"
serde_json = { version = "1.0.108", features = ["raw_value"] }
similar-asserts = "1.5.0"
sqlx = { version = "0.7.2", features = [ "json", "postgres", "runtime-tokio-rustls" ] }
sqlx = { version = "0.7.3", features = [ "json", "postgres", "runtime-tokio-rustls" ] }
tokio = { version = "1.34.0", features = ["full"] }
tokio-postgres = "0.7.10"
tracing = "0.1.40"
Expand Down
24 changes: 6 additions & 18 deletions crates/tests/tests-common/src/deployment/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ use sqlx::postgres::PgConnection;
use sqlx::{Connection, Executor};
use std::str::FromStr;

/// SQL to run when creating a fresh database
const CHINOOK_SQL: &str = include_str!("../../../../../static/chinook-postgres.sql");

/// create a fresh db with a random name, return it's name and connection string
pub async fn create_fresh_database(connection_uri: &str) -> (String, String) {
let id = uuid::Uuid::new_v4();
let db_name = format!("temp-{}", id);
let new_connection_string = populate_database(connection_uri, &db_name).await;
let new_connection_string = create_database_copy(connection_uri, &db_name).await;
(db_name, new_connection_string)
}

/// connect to database with `connection_uri` then create a new empty DB called `new_db_name`
async fn create_empty_database(connection_uri: &str, new_db_name: &str) -> String {
/// connect to database with `connection_uri` then create a new DB called `new_db_name`
/// which is a copy of the `chinook_template` database.
async fn create_database_copy(connection_uri: &str, new_db_name: &str) -> String {
let mut connection = PgConnection::connect(connection_uri).await.unwrap();

let create_db_sql = format!("CREATE DATABASE \"{new_db_name}\"");
let create_db_sql =
format!("CREATE DATABASE \"{new_db_name}\" WITH TEMPLATE chinook_template;");

connection.execute(create_db_sql.as_str()).await.unwrap();

Expand All @@ -37,17 +36,6 @@ pub async fn drop_database(connection_uri: &str, db_name: &str) {
println!("dropped {db_name}")
}

// create and populate new database, returning connection string
async fn populate_database(connection_uri: &str, new_db_name: &str) -> String {
let new_connection_string = create_empty_database(connection_uri, new_db_name).await;

let mut connection = PgConnection::connect(&new_connection_string).await.unwrap();

connection.execute(CHINOOK_SQL).await.unwrap();

new_connection_string
}

// given a connection string, we need to make a new database and return a new connection string
fn replace_database_name(connection_uri: &str, new_db_name: &str) -> String {
let config = tokio_postgres::config::Config::from_str(connection_uri).unwrap();
Expand Down
6 changes: 5 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ services:
target: /var/lib/postgresql/data
- type: bind
source: ./static/chinook-postgres.sql
target: /docker-entrypoint-initdb.d/chinook-postgres.sql
target: /docker-entrypoint-initdb.d/00-chinook-postgres.sql
read_only: true
- type: bind
source: ./static/copy-chinook.sql
target: /docker-entrypoint-initdb.d/01-copy-chinook.sql
read_only: true
healthcheck:
test:
Expand Down
1 change: 0 additions & 1 deletion static/chinook-postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15828,4 +15828,3 @@ INSERT INTO "PlaylistTrack" ("PlaylistId", "TrackId") VALUES (17, 2095);
INSERT INTO "PlaylistTrack" ("PlaylistId", "TrackId") VALUES (17, 2096);
INSERT INTO "PlaylistTrack" ("PlaylistId", "TrackId") VALUES (17, 3290);
INSERT INTO "PlaylistTrack" ("PlaylistId", "TrackId") VALUES (18, 597);

6 changes: 6 additions & 0 deletions static/copy-chinook.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- create a template from the database so we can quickly copy it when
-- we test mutations.
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'postgres' AND pid <> pg_backend_pid();

CREATE DATABASE chinook_template WITH TEMPLATE postgres;

0 comments on commit 8a0c133

Please sign in to comment.