Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ jobs:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Its data is in memory: every test makes and drops a database, and
# waiting for the disk to sync each one is most of what that costs.
options: >-
--tmpfs /var/lib/postgresql/data
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
Expand All @@ -169,7 +172,12 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- run: cargo clippy --locked -p meshrmm-server --all-targets -- -D warnings
# The tests' data directories and SQLite databases are in memory too:
# the server syncs its key, its database and each checkpoint to the
# disk, which on a real disk takes longer than the tests themselves.
- run: cargo test --locked -p meshrmm-server
env:
TMPDIR: /dev/shm
- run: python3 -m unittest discover -s scripts/tests -v
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ dbg_macro = "deny"
todo = "deny"
unimplemented = "deny"

# Unoptimized, Argon2 takes about a third of a second for each password, and
# the server's tests hash one for every account they create.
[profile.dev.package.argon2]
opt-level = 3

[profile.dev.package.blake2]
opt-level = 3

[profile.server-release]
inherits = "release"
codegen-units = 1
Expand Down
8 changes: 8 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ sh scripts/test-server-postgres.sh # arguments go to cargo test

It starts a throwaway PostgreSQL in a temporary directory, which needs only
PostgreSQL's `initdb` and `pg_ctl` installed, and removes it afterwards.

Each test starts a server of its own in a temporary directory, and that
server syncs its key, its database and each checkpoint to the disk. On a real
disk those waits are most of the tests' time, so on Linux keep the
directories in memory: `TMPDIR=/dev/shm cargo test --locked -p
meshrmm-server` takes about half as long. The script above and CI do that
already, and CI keeps its PostgreSQL's data in memory as well.

`tests/schema_parity.rs` checks that the two backends' migrations make the
same tables and columns; change both `server/migrations/sqlite` and
`server/migrations/postgres` together.
Expand Down
8 changes: 8 additions & 0 deletions scripts/test-server-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@
# Debian's packages put them. The cluster lives in a temporary directory,
# listens only on 127.0.0.1 (port 54329, or MESHRMM_TEST_POSTGRES_PORT) and is
# removed when the tests end.
#
# Where the system has /dev/shm (Linux), the cluster and the tests' own data
# are kept there, in memory, unless TMPDIR says where to put them: waiting
# for a real disk to sync them takes longer than the tests themselves.
set -eu

SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
ROOT_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
PORT=${MESHRMM_TEST_POSTGRES_PORT:-54329}
if [ -z "${TMPDIR:-}" ] && [ -d /dev/shm ] && [ -w /dev/shm ]; then
TMPDIR=/dev/shm
export TMPDIR
fi

if ! command -v initdb >/dev/null 2>&1; then
if command -v pg_config >/dev/null 2>&1; then
Expand Down
Loading