Skip to content

Commit dc7eed3

Browse files
committed
wip
1 parent a35b9f0 commit dc7eed3

File tree

7 files changed

+29
-20
lines changed

7 files changed

+29
-20
lines changed

mise.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,8 @@ echo '###############################################'
377377
echo '# Test: Showcase'
378378
echo '###############################################'
379379
echo
380-
mise --env tls run proxy:up proxy-tls --extra-args "--detach --wait"
381-
mise --env tls run test:wait_for_postgres_to_quack --port 6432 --max-retries 20 --tls
382-
RUST_BACKTRACE=full cargo run -p showcase
383-
mise --env tls run proxy:down
380+
381+
mise run test:integration:showcase
384382
385383
echo
386384
echo '###############################################'
@@ -637,6 +635,15 @@ else
637635
fi
638636
"""
639637

638+
[tasks."test:integration:showcase"]
639+
description = "Run Showcase integration test"
640+
run = """
641+
mise --env tls run proxy:up proxy-tls --extra-args "--detach --wait"
642+
mise --env tls run test:wait_for_postgres_to_quack --port 6432 --max-retries 20 --tls
643+
RUST_BACKTRACE=full cargo run -p showcase
644+
mise --env tls run proxy:down
645+
"""
646+
640647
[tasks.release]
641648
description = "Publish release artifacts"
642649
depends = ["release:docker"]

packages/cipherstash-proxy/src/postgresql/context/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ where
311311
}
312312

313313
pub fn set_schema_changed(&self) {
314+
debug!(target: CONTEXT,
315+
client_id = self.client_id,
316+
msg = "Schema changed"
317+
);
314318
let _ = self.schema_changed.write().map(|mut guard| *guard = true);
315319
}
316320

@@ -510,15 +514,15 @@ where
510514
}
511515

512516
pub async fn reload_schema(&self) {
513-
match self.reload_sender.send(ReloadCommand::DatabaseSchema) {
514-
Ok(_) => self.set_schema_changed(),
515-
Err(err) => {
517+
let _ = self
518+
.reload_sender
519+
.send(ReloadCommand::DatabaseSchema)
520+
.inspect_err(|err| {
516521
error!(
517522
msg = "Database schema could not be reloaded",
518523
error = err.to_string()
519-
);
520-
}
521-
}
524+
)
525+
});
522526
}
523527

524528
pub fn is_passthrough(&self) -> bool {

packages/cipherstash-proxy/src/postgresql/frontend.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,6 @@ where
746746
let schema_changed = eql_mapper::collect_ddl(self.context.get_table_resolver(), statement);
747747

748748
if schema_changed {
749-
debug!(target: MAPPER,
750-
client_id = self.context.client_id,
751-
msg = "schema changed"
752-
);
753749
self.context.set_schema_changed();
754750
}
755751
}

packages/cipherstash-proxy/src/proxy/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010
use cipherstash_client::encryption::Plaintext;
1111
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
12-
use tracing::warn;
12+
use tracing::{debug, warn};
1313

1414
mod encrypt_config;
1515
mod schema;
@@ -99,6 +99,7 @@ impl Proxy {
9999

100100
pub async fn receive(&mut self) {
101101
while let Some(command) = self.reload_receiver.recv().await {
102+
debug!(msg = "ReloadCommand received", ?command);
102103
match command {
103104
ReloadCommand::DatabaseSchema => self.schema_manager.reload().await,
104105
ReloadCommand::EncryptSchema => self.encrypt_config_manager.reload().await,

packages/showcase/src/data.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
};
99

1010
pub async fn insert_test_data() {
11+
println!("Insert test data");
1112
let medications = [
1213
Medication::new(
1314
"550e8400-e29b-41d4-a716-446655440001",
@@ -496,8 +497,6 @@ pub async fn clear() {
496497
//
497498
// Deleting rows from the eql_v2_configuration table is not officially supported due to the risk of data loss.
498499
//
499-
// TODO: EQL should support safe removal of config rows - at least in some kind of "test" or non-production
500-
// mode.
501500
let sql = r#"
502501
DELETE
503502
FROM public.eql_v2_configuration

packages/showcase/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,18 @@ use crate::{
6666

6767
#[tokio::main]
6868
async fn main() -> Result<(), Box<dyn std::error::Error>> {
69+
println!("🩺 Healthcare Database Showcase - EQL v2 Searchable Encryption");
70+
println!("============================================================");
71+
6972
trace();
7073
clear().await;
74+
7175
setup_schema().await;
7276
insert_test_data().await;
7377
create_enhanced_jsonb_test_data().await;
7478

7579
let client = connect_with_tls(PROXY).await;
7680

77-
println!("🩺 Healthcare Database Showcase - EQL v2 Searchable Encryption");
78-
println!("============================================================");
79-
8081
// Query 1: Get the Aspirin medication ID
8182
let aspirin_id_sql = "SELECT id FROM medications WHERE name = 'Aspirin';";
8283
let rows = client.query(aspirin_id_sql, &[]).await.unwrap();

packages/showcase/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ use crate::common::{reset_schema_to, PROXY};
33
const SCHEMA: &str = include_str!("./schema.sql");
44

55
pub async fn setup_schema() {
6+
println!("Setup schema");
67
reset_schema_to(SCHEMA, PROXY).await
78
}

0 commit comments

Comments
 (0)