-
Notifications
You must be signed in to change notification settings - Fork 21
Refactor PgEmbed usage #384
Conversation
lalithsuresh
commented
Apr 28, 2023
- Conditionally build pg-embed use outside tests using a "dev" feature flag, enabled by default
- Separate PgEmbed out from ProjectDB
- Update Docker build to use non-default builds
* Conditionally build pg-embed use outside tests using a "dev" feature flag, enabled by default * Separate PgEmbed out from ProjectDB * Update Docker build to use non-default builds Signed-off-by: Lalith Suresh <lsuresh@vmware.com>
Signed-off-by: Lalith Suresh <lsuresh@vmware.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #384 +/- ##
==========================================
+ Coverage 72.99% 73.12% +0.13%
==========================================
Files 237 237
Lines 49568 50156 +588
==========================================
+ Hits 36180 36675 +495
- Misses 13388 13481 +93
|
Signed-off-by: Lalith Suresh <lsuresh@vmware.com>
|
|
||
| fn default_db_connection_string() -> String { | ||
| "postgres-embed".to_string() | ||
| "".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be postgres:// now or something similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokio-postgres doesn't fill things in automatically, so "postgres://" does not work.
| use pg_embed::pg_fetch::{PgFetchSettings, PG_V15}; | ||
| use pg_embed::postgres::{PgEmbed, PgSettings}; | ||
| use std::path::PathBuf; | ||
| #[cfg(feature = "dev")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you instead make the
mod pg_setup;in mod.rs
as
#[cfg(feature = "dev")]
mod pg_setup;you wont have to make an extra module (embedded) for it.
| ConnectorType, PipelineId, ProjectDB, ProjectDescr, ProjectId, ProjectStatus, Version, | ||
| }; | ||
| use crate::db::DBError; | ||
| use crate::db::{pg_setup, DBError}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so mod test in mod.rs maybe also needs to be conditionally included with cfg(feature = dev)?
or cargo test --no-default-features might fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the CI workflows to have feature=dev wherever --no-default-features is called. It's better to fail the run than to silently not run the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it will result in a compilation error if you do cargo test --no-default-features which is a bit awkward. You could update to include the crate::db::pg_setup cfg(feature = "dev") and in addition also for cfg(test)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g., cfg(any(test, feature = "dev") might do the trick?
Signed-off-by: Lalith Suresh <lsuresh@vmware.com>
Benchmark resultsNexmark
Galen
LDBC
Nexmark (with Persistence)
|
…ther. Signed-off-by: Lalith Suresh <lsuresh@vmware.com>
c82016c to
bba3d22
Compare