diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yaml index 5aa460b67..206d80277 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yaml @@ -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 }} diff --git a/Cargo.lock b/Cargo.lock index 282595ced..6296aaa77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,6 +135,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-write-file" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c232177ba50b16fe7a4588495bd474a62a9e45a8e4ca6fd7d0b7ac29d164631e" +dependencies = [ + "nix", + "rand", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -1310,9 +1320,9 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "libsqlite3-sys" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ "cc", "pkg-config", @@ -1378,6 +1388,15 @@ version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -1552,6 +1571,19 @@ dependencies = [ "tokio", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", + "pin-utils", +] + [[package]] name = "nom" version = "7.1.3" @@ -1921,9 +1953,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "phf" @@ -2497,9 +2529,9 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -2536,9 +2568,9 @@ checksum = "794e44574226fc701e3be5c651feb7939038fc67fb73f6f4dd5c4ba90fd3be70" [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -2805,9 +2837,9 @@ dependencies = [ [[package]] name = "sqlx" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e50c216e3624ec8e7ecd14c6a6a6370aad6ee5d8cfc3ab30b5162eeeef2ed33" +checksum = "dba03c279da73694ef99763320dea58b51095dfe87d001b1d4b5fe78ba8763cf" dependencies = [ "sqlx-core", "sqlx-macros", @@ -2818,9 +2850,9 @@ dependencies = [ [[package]] name = "sqlx-core" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" +checksum = "d84b0a3c3739e220d94b3239fd69fb1f74bc36e16643423bd99de3b43c21bfbd" dependencies = [ "ahash", "atoi", @@ -2862,9 +2894,9 @@ dependencies = [ [[package]] name = "sqlx-macros" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a793bb3ba331ec8359c1853bd39eed32cdd7baaf22c35ccf5c92a7e8d1189ec" +checksum = "89961c00dc4d7dffb7aee214964b065072bff69e36ddb9e2c107541f75e4f2a5" dependencies = [ "proc-macro2", "quote", @@ -2875,10 +2907,11 @@ dependencies = [ [[package]] name = "sqlx-macros-core" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4ee1e104e00dedb6aa5ffdd1343107b0a4702e862a84320ee7cc74782d96fc" +checksum = "d0bd4519486723648186a08785143599760f7cc81c52334a55d6a83ea1e20841" dependencies = [ + "atomic-write-file", "dotenvy", "either", "heck", @@ -2901,9 +2934,9 @@ dependencies = [ [[package]] name = "sqlx-mysql" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" +checksum = "e37195395df71fd068f6e2082247891bc11e3289624bbc776a0cdfa1ca7f1ea4" dependencies = [ "atoi", "base64 0.21.5", @@ -2944,9 +2977,9 @@ dependencies = [ [[package]] name = "sqlx-postgres" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" +checksum = "d6ac0ac3b7ccd10cc96c7ab29791a7dd236bd94021f31eec7ba3d46a74aa1c24" dependencies = [ "atoi", "base64 0.21.5", @@ -2984,9 +3017,9 @@ dependencies = [ [[package]] name = "sqlx-sqlite" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" +checksum = "210976b7d948c7ba9fced8ca835b11cbb2d677c59c79de41ac0d397e14547490" dependencies = [ "atoi", "flume", @@ -3002,6 +3035,7 @@ dependencies = [ "sqlx-core", "tracing", "url", + "urlencoding", "uuid", ] @@ -3732,12 +3766,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.24.0" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b291546d5d9d1eab74f069c77749f2cb8504a12caa20f0f2de93ddbf6f411888" -dependencies = [ - "rustls-webpki", -] +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" [[package]] name = "whoami" diff --git a/crates/connectors/ndc-postgres/Cargo.toml b/crates/connectors/ndc-postgres/Cargo.toml index dfcb27e07..fbaeae491 100644 --- a/crates/connectors/ndc-postgres/Cargo.toml +++ b/crates/connectors/ndc-postgres/Cargo.toml @@ -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" diff --git a/crates/query-engine/execution/Cargo.toml b/crates/query-engine/execution/Cargo.toml index e03aaa9c7..7bff0a027 100644 --- a/crates/query-engine/execution/Cargo.toml +++ b/crates/query-engine/execution/Cargo.toml @@ -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" diff --git a/crates/query-engine/metadata/Cargo.toml b/crates/query-engine/metadata/Cargo.toml index a4ef27a20..5b9a59409 100644 --- a/crates/query-engine/metadata/Cargo.toml +++ b/crates/query-engine/metadata/Cargo.toml @@ -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"] } diff --git a/crates/tests/databases-tests/src/postgres/mutation_tests.rs b/crates/tests/databases-tests/src/postgres/mutation_tests.rs index 206ceb586..b6678a938 100644 --- a/crates/tests/databases-tests/src/postgres/mutation_tests.rs +++ b/crates/tests/databases-tests/src/postgres/mutation_tests.rs @@ -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 = diff --git a/crates/tests/tests-common/Cargo.toml b/crates/tests/tests-common/Cargo.toml index e781a1a17..34d68c414 100644 --- a/crates/tests/tests-common/Cargo.toml +++ b/crates/tests/tests-common/Cargo.toml @@ -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" diff --git a/crates/tests/tests-common/src/deployment/database.rs b/crates/tests/tests-common/src/deployment/database.rs index 3d86115fe..88213727e 100644 --- a/crates/tests/tests-common/src/deployment/database.rs +++ b/crates/tests/tests-common/src/deployment/database.rs @@ -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(); @@ -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(); diff --git a/docker-compose.yaml b/docker-compose.yaml index 492bf94e6..b26460865 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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: diff --git a/static/chinook-postgres.sql b/static/chinook-postgres.sql index 4704c5818..04983151f 100644 --- a/static/chinook-postgres.sql +++ b/static/chinook-postgres.sql @@ -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); - diff --git a/static/copy-chinook.sql b/static/copy-chinook.sql new file mode 100644 index 000000000..e8739a681 --- /dev/null +++ b/static/copy-chinook.sql @@ -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;