Skip to content

Commit

Permalink
Test old deployment versions
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljharvey committed Nov 1, 2023
1 parent f4a79d7 commit ad8b394
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/tests/databases-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ tests-common = { path = "../tests-common" }
axum = "0.6.20"
insta = { version = "1.34.0", features = ["json"] }
schemars = { version = "0.8.15", features = ["smol_str", "preserve_order"] }
serde_json = "1.0.107"
test-each = "0.2.1"
tokio = { version = "1.33.0", features = ["full"] }
21 changes: 21 additions & 0 deletions crates/tests/databases-tests/src/deployment_snapshot_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#[cfg(test)]
mod deployment_snapshots {
use ndc_postgres::configuration;
use std::fs;
use std::path::PathBuf;

// each time we run `just generate-chinook-configuration` we save the old
// Postgres deployment in `static/deployment-snapshots`. This test parses each snapshot to
// ensure we are still able to understand old versions
#[test_each::path(glob = "static/deployment-snapshots/**/*.json", name(segments = 2))]
fn test_snapshot(deployment_path: PathBuf) {
let file = fs::File::open(deployment_path).expect("fs::File::open");

let deployment_json_value: serde_json::Value =
serde_json::from_reader(file).expect("serde_json::from_reader");

let _decoded_configuration: configuration::RawConfiguration =
serde_json::from_value(deployment_json_value.clone())
.expect("Unable to deserialize as RawConfiguration");
}
}
1 change: 1 addition & 0 deletions crates/tests/databases-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ pub mod cockroach;
pub mod postgres;

pub mod capabilities_tests;
pub mod deployment_snapshot_tests;
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ test *args: start-dependencies create-aurora-deployment
# re-generate the deployment configuration file
generate-chinook-configuration: build start-dependencies
./scripts/archive-old-deployment.sh '{{POSTGRES_CHINOOK_DEPLOYMENT}}'
exit 0
./scripts/generate-chinook-configuration.sh 'ndc-postgres' '{{POSTGRESQL_CONNECTION_STRING}}' '{{POSTGRES_CHINOOK_DEPLOYMENT}}'
./scripts/generate-chinook-configuration.sh 'ndc-postgres' '{{CITUS_CONNECTION_STRING}}' '{{CITUS_CHINOOK_DEPLOYMENT}}'
./scripts/generate-chinook-configuration.sh 'ndc-postgres' '{{COCKROACH_CONNECTION_STRING}}' '{{COCKROACH_CHINOOK_DEPLOYMENT}}'
Expand Down
7 changes: 3 additions & 4 deletions scripts/archive-old-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ CURRENT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null && echo "$P

SNAPSHOT_DIR="$(realpath ${CURRENT_DIR}/../static/deployment-snapshots)"

# create snapshot dir if does not exist
mkdir -p "$SNAPSHOT_DIR"

# create filename from hash of contents
NEW_FILENAME="$(sha256sum "${CHINOOK_DEPLOYMENT}" | cut -f1 -d' ').json"

echo "$SNAPSHOT_DIR"

echo "${CHINOOK_DEPLOYMENT}"

# copy current deployment to new filename
cp "${CHINOOK_DEPLOYMENT}" "${SNAPSHOT_DIR}/${NEW_FILENAME}"

0 comments on commit ad8b394

Please sign in to comment.