2022-10-28 21:52:39 +03:00
|
|
|
#!/usr/bin/env just --justfile
|
|
|
|
set shell := ["bash", "-c"]
|
|
|
|
|
2023-02-06 22:32:28 +03:00
|
|
|
export PGPORT := "5411"
|
|
|
|
export DATABASE_URL := "postgres://postgres:postgres@localhost:" + PGPORT + "/db"
|
2022-10-28 21:52:39 +03:00
|
|
|
export CARGO_TERM_COLOR := "always"
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
# export RUST_LOG := "debug"
|
2022-10-28 21:52:39 +03:00
|
|
|
# export RUST_BACKTRACE := "1"
|
|
|
|
|
|
|
|
@_default:
|
2022-10-31 23:28:21 +03:00
|
|
|
just --list --unsorted
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
# Start Martin server and a test database
|
2022-12-27 09:56:27 +03:00
|
|
|
run *ARGS: start
|
2022-11-02 21:00:05 +03:00
|
|
|
cargo run -- {{ARGS}}
|
2022-10-28 21:52:39 +03:00
|
|
|
|
2022-12-10 10:40:01 +03:00
|
|
|
# Start Martin server and open a test page
|
2022-12-27 09:56:27 +03:00
|
|
|
debug-page *ARGS: start
|
2022-12-10 10:40:01 +03:00
|
|
|
open tests/debug.html # run will not exit, so open debug page first
|
|
|
|
just run {{ARGS}}
|
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
# Run PSQL utility against the test database
|
2023-01-01 08:03:21 +03:00
|
|
|
psql *ARGS:
|
2022-11-30 19:57:27 +03:00
|
|
|
psql {{ARGS}} {{DATABASE_URL}}
|
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
# Perform cargo clean to delete all build files
|
2022-11-30 19:57:27 +03:00
|
|
|
clean: clean-test stop
|
2022-10-28 21:52:39 +03:00
|
|
|
cargo clean
|
|
|
|
|
|
|
|
# Delete test output files
|
2023-01-01 08:03:21 +03:00
|
|
|
[private]
|
2022-10-28 21:52:39 +03:00
|
|
|
clean-test:
|
|
|
|
rm -rf tests/output
|
|
|
|
|
|
|
|
# Start a test database
|
2022-12-27 09:56:27 +03:00
|
|
|
start: (docker-up "db")
|
2022-12-04 08:34:44 +03:00
|
|
|
|
2023-02-06 22:32:28 +03:00
|
|
|
# Start an ssl-enabled test database
|
|
|
|
start-ssl: (docker-up "db-ssl")
|
|
|
|
|
2022-12-04 08:34:44 +03:00
|
|
|
# Start a legacy test database
|
|
|
|
start-legacy: (docker-up "db-legacy")
|
|
|
|
|
|
|
|
# Start a specific test database, e.g. db or db-legacy
|
2023-01-01 08:03:21 +03:00
|
|
|
[private]
|
|
|
|
docker-up name:
|
2022-12-04 08:34:44 +03:00
|
|
|
docker-compose up -d {{name}}
|
2023-02-06 22:32:28 +03:00
|
|
|
docker-compose run --rm db-is-ready
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
alias _down := stop
|
|
|
|
alias _stop-db := stop
|
|
|
|
|
|
|
|
# Stop the test database
|
|
|
|
stop:
|
|
|
|
docker-compose down
|
|
|
|
|
|
|
|
# Run benchmark tests
|
2022-12-27 09:56:27 +03:00
|
|
|
bench: start
|
2022-10-28 21:52:39 +03:00
|
|
|
cargo bench
|
|
|
|
|
2023-01-01 08:03:21 +03:00
|
|
|
|
2022-10-28 21:52:39 +03:00
|
|
|
# Run all tests using a test database
|
2023-01-01 08:03:21 +03:00
|
|
|
test: (docker-up "db") test-unit test-int
|
|
|
|
|
2023-02-06 22:32:28 +03:00
|
|
|
# Run all tests using an SSL connection to a test database. Expected output won't match.
|
|
|
|
test-ssl: (docker-up "ssl") test-unit clean-test
|
|
|
|
tests/test.sh
|
|
|
|
|
|
|
|
# Run all tests using the oldest supported version of the database
|
2023-01-01 08:03:21 +03:00
|
|
|
test-legacy: (docker-up "db-legacy") test-unit test-int
|
2022-10-28 21:52:39 +03:00
|
|
|
|
2022-11-19 18:52:58 +03:00
|
|
|
# Run Rust unit and doc tests (cargo test)
|
2023-01-01 08:03:21 +03:00
|
|
|
test-unit *ARGS:
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
cargo test --all-targets {{ARGS}}
|
|
|
|
cargo test --all-targets --all-features {{ARGS}}
|
2022-11-19 18:52:58 +03:00
|
|
|
cargo test --doc
|
2022-10-28 21:52:39 +03:00
|
|
|
|
|
|
|
# Run integration tests
|
2023-01-01 08:03:21 +03:00
|
|
|
test-int: clean-test
|
2023-02-07 09:05:47 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
2022-10-28 21:52:39 +03:00
|
|
|
tests/test.sh
|
2023-01-01 08:03:21 +03:00
|
|
|
if ( ! diff --brief --recursive --new-file tests/output tests/expected ); then
|
|
|
|
echo "** Expected output does not match actual output"
|
|
|
|
echo "** If this is expected, run 'just bless' to update expected output"
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
exit 1
|
2023-01-01 08:03:21 +03:00
|
|
|
else
|
|
|
|
echo "Expected output matches actual output"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run integration tests and save its output as the new expected output
|
|
|
|
bless: start clean-test
|
|
|
|
tests/test.sh
|
|
|
|
rm -rf tests/expected
|
|
|
|
mv tests/output tests/expected
|
2022-12-27 09:56:27 +03:00
|
|
|
|
|
|
|
# Run code coverage on tests and save its output in the coverage directory. Parameter could be html or lcov.
|
|
|
|
coverage FORMAT='html':
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
if ! command -v grcov &> /dev/null; then \
|
|
|
|
echo "grcov could not be found. Installing..." ;\
|
|
|
|
cargo install grcov ;\
|
|
|
|
fi
|
|
|
|
if ! rustup component list | grep llvm-tools-preview &> /dev/null; then \
|
|
|
|
echo "llvm-tools-preview could not be found. Installing..." ;\
|
|
|
|
rustup component add llvm-tools-preview ;\
|
|
|
|
fi
|
|
|
|
|
|
|
|
just clean
|
|
|
|
just start
|
|
|
|
|
|
|
|
PROF_DIR=target/prof
|
|
|
|
mkdir -p "$PROF_DIR"
|
|
|
|
PROF_DIR=$(realpath "$PROF_DIR")
|
|
|
|
|
|
|
|
OUTPUT_RESULTS_DIR=target/coverage/{{FORMAT}}
|
|
|
|
mkdir -p "$OUTPUT_RESULTS_DIR"
|
|
|
|
|
|
|
|
export CARGO_INCREMENTAL=0
|
|
|
|
export RUSTFLAGS=-Cinstrument-coverage
|
|
|
|
# Avoid problems with relative paths
|
|
|
|
export LLVM_PROFILE_FILE=$PROF_DIR/cargo-test-%p-%m.profraw
|
|
|
|
export MARTIN_PORT=3111
|
|
|
|
|
|
|
|
cargo test --all-targets
|
|
|
|
cargo test --all-targets --all-features
|
|
|
|
tests/test.sh
|
|
|
|
|
|
|
|
set -x
|
|
|
|
grcov --binary-path ./target/debug \
|
|
|
|
-s . \
|
|
|
|
-t {{FORMAT}} \
|
|
|
|
--branch \
|
|
|
|
--ignore 'benches/*' \
|
|
|
|
--ignore 'tests/*' \
|
|
|
|
--ignore-not-existing \
|
|
|
|
-o target/coverage/{{FORMAT}} \
|
|
|
|
--llvm \
|
|
|
|
"$PROF_DIR"
|
|
|
|
{ set +x; } 2>/dev/null
|
|
|
|
|
|
|
|
# if this is html, open it in the browser
|
|
|
|
if [ "{{FORMAT}}" = "html" ]; then
|
|
|
|
open "$OUTPUT_RESULTS_DIR/index.html"
|
|
|
|
fi
|
2022-10-31 23:28:21 +03:00
|
|
|
|
2022-11-02 21:00:05 +03:00
|
|
|
# Build martin docker image
|
|
|
|
docker-build:
|
2023-03-16 23:01:33 +03:00
|
|
|
docker build -t ghcr.io/maplibre/martin .
|
2022-11-02 21:00:05 +03:00
|
|
|
|
|
|
|
# Build and run martin docker image
|
|
|
|
docker-run *ARGS:
|
2023-03-16 23:01:33 +03:00
|
|
|
docker run -it --rm --net host -e DATABASE_URL -v $PWD/tests:/tests ghcr.io/maplibre/martin {{ARGS}}
|
2022-11-02 21:00:05 +03:00
|
|
|
|
2022-10-31 23:28:21 +03:00
|
|
|
# Do any git command, ensuring that the testing environment is set up. Accepts the same arguments as git.
|
2022-11-30 19:57:27 +03:00
|
|
|
[no-exit-message]
|
2022-12-27 09:56:27 +03:00
|
|
|
git *ARGS: start
|
2022-10-31 23:28:21 +03:00
|
|
|
git {{ARGS}}
|
2022-12-10 10:40:01 +03:00
|
|
|
|
2022-12-22 09:35:29 +03:00
|
|
|
# Run cargo fmt and cargo clippy
|
|
|
|
lint:
|
|
|
|
cargo fmt --all -- --check
|
2023-04-08 09:37:30 +03:00
|
|
|
cargo clippy --workspace --all-targets --all-features -- -D warnings
|
2022-12-22 09:35:29 +03:00
|
|
|
|
2022-12-10 10:40:01 +03:00
|
|
|
# These steps automatically run before git push via a git hook
|
2023-01-01 08:03:21 +03:00
|
|
|
[private]
|
2022-12-27 09:56:27 +03:00
|
|
|
git-pre-push: stop start
|
2022-12-19 05:24:06 +03:00
|
|
|
rustc --version
|
|
|
|
cargo --version
|
2022-12-22 09:35:29 +03:00
|
|
|
just lint
|
2022-12-10 10:40:01 +03:00
|
|
|
just test
|