Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmv committed Dec 2, 2023
1 parent 05e1314 commit adc25cd
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 42 deletions.
79 changes: 40 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@

name: Test

on: [push, pull_request]
on: [push]

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
# Use the latest stable Rust version for lint checks to
# verify any new Clippy warnings that may appear.
toolchain: stable
default: true
components: clippy, rustfmt
- uses: actions/checkout@v2
- uses: mozilla-actions/[email protected]
- run: sudo apt update
- run: sudo apt install pre-commit
- run: ./lint.sh
# lint:
# runs-on: ubuntu-latest
# timeout-minutes: 5
# env:
# RUSTC_WRAPPER: "sccache"
# SCCACHE_GHA_ENABLED: "true"
# steps:
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# # Use the latest stable Rust version for lint checks to
# # verify any new Clippy warnings that may appear.
# toolchain: stable
# default: true
# components: clippy, rustfmt
# - uses: actions/checkout@v2
# - uses: mozilla-actions/[email protected]
# - run: sudo apt update
# - run: sudo apt install pre-commit
# - run: ./lint.sh

test-individually:
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 2
env:
AZURE_MAPS_KEY: ${{ secrets.AZURE_MAPS_KEY }}
PGSQL_TEST_HOST: ${{ secrets.PGSQL_TEST_HOST }}
Expand All @@ -42,21 +42,22 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: mozilla-actions/[email protected]
- run: ./test.sh all
- run: echo 'export RUST_LOG=trace' >config.env
- run: ./test.sh -f postgres -a postgres -a --nocapture -a --test-threads=1 core

test-workspace:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
AZURE_MAPS_KEY: ${{ secrets.AZURE_MAPS_KEY }}
PGSQL_TEST_HOST: ${{ secrets.PGSQL_TEST_HOST }}
PGSQL_TEST_PORT: ${{ secrets.PGSQL_TEST_PORT }}
PGSQL_TEST_DATABASE: ${{ secrets.PGSQL_TEST_DATABASE }}
PGSQL_TEST_USERNAME: ${{ secrets.PGSQL_TEST_USERNAME }}
PGSQL_TEST_PASSWORD: ${{ secrets.PGSQL_TEST_PASSWORD }}
RUSTC_WRAPPER: "sccache"
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v2
- uses: mozilla-actions/[email protected]
- run: ./test.sh
# test-workspace:
# runs-on: ubuntu-latest
# timeout-minutes: 5
# env:
# AZURE_MAPS_KEY: ${{ secrets.AZURE_MAPS_KEY }}
# PGSQL_TEST_HOST: ${{ secrets.PGSQL_TEST_HOST }}
# PGSQL_TEST_PORT: ${{ secrets.PGSQL_TEST_PORT }}
# PGSQL_TEST_DATABASE: ${{ secrets.PGSQL_TEST_DATABASE }}
# PGSQL_TEST_USERNAME: ${{ secrets.PGSQL_TEST_USERNAME }}
# PGSQL_TEST_PASSWORD: ${{ secrets.PGSQL_TEST_PASSWORD }}
# RUSTC_WRAPPER: "sccache"
# SCCACHE_GHA_ENABLED: "true"
# steps:
# - uses: actions/checkout@v2
# - uses: mozilla-actions/[email protected]
# - run: ./test.sh
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ postgres = [
"dep:tokio",
"sqlx/postgres",
"sqlx/runtime-tokio-rustls",
"tokio/rt-multi-thread",
]
sqlite = [
"dep:futures",
Expand Down
2 changes: 2 additions & 0 deletions core/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ pub mod testutils {
#[tokio::test]
$(#[$extra])?
async fn $name() {
eprintln!("start {}", stringify!($name));
$crate::db::testutils::paste! {
$module :: [< $name >]($setup).await;
}
eprintln!("end {}", stringify!($name));
}
}
];
Expand Down
10 changes: 9 additions & 1 deletion core/src/db/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,18 @@ pub struct PostgresDb {

impl Drop for PostgresDb {
fn drop(&mut self) {
eprintln!("dropping");
let pool = self.pool.clone();
tokio::task::spawn_blocking(move || {
let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(1)
.enable_all()
.build()
.unwrap();
rt.block_on(async move {
eprintln!("closing");
pool.close().await;
eprintln!("closed");
});
});
}
Expand All @@ -359,6 +366,7 @@ impl PostgresDb {
.username(&opts.username)
.password(&opts.password);

eprintln!("connecting");
let pool = pool_options.connect_lazy_with(options);
Ok(Self { pool, max_retries: opts.max_retries })
}
Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ run_tests() {
. ./config.env
fi

info "Testing ${dir} with default features"
# info "Testing ${dir} with default features"
cd "${dir}"
cargo test ${cargo_args} -- --include-ignored ${test_args}
# cargo test ${cargo_args} -- --include-ignored ${test_args}
for feature in ${features}; do
info "Testing ${dir} with feature=${feature}"
cargo test --features="${feature}" ${cargo_args} -- --include-ignored ${test_args}
Expand Down

0 comments on commit adc25cd

Please sign in to comment.