| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/usr/bin/env bash
- # Build and run the C++ test suite in Debian 13, because the Void dev host
- # cannot: protobuf 35 removed google/protobuf/map_field_inl.h, which the
- # database's generated protos include, so libsmartbotic-db-client neither
- # compiles nor links there.
- #
- # Runs smartbotic-database inside the same container, so the ApiFixture
- # integration tests actually execute instead of GTEST_SKIP()ing.
- #
- # packaging/devstack/run-tests.sh # whole suite
- # packaging/devstack/run-tests.sh 'ApiFixture.*' # a ctest -R filter
- set -euo pipefail
- REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
- BASE_IMAGE="${BASE_IMAGE:-smartbotic-vectorapi-build-base:debian13}"
- DEB_REPO_DIR="${DEB_REPO_DIR:-/data/dev/smartbotics/smartbotics-deb-repo}"
- # The client version is DERIVED from build.sh's pin rather than written here.
- # These used to be hardcoded at 2.12.0 and were eight releases stale, which is
- # the exact failure this file's own warning describes: the TEST path can sit on
- # a different client than the RELEASE path, and then a green suite is not
- # evidence about the packages. Two places holding one version is one too many,
- # so there is now a single source and this reads it.
- DB_CLIENT_VERSION="${DB_CLIENT_VERSION:-$(
- sed -n 's/^DB_CLIENT_VERSION="\${DB_CLIENT_VERSION:-\(.*\)}"$/\1/p' "$REPO/packaging/build.sh"
- )}"
- [[ -n "$DB_CLIENT_VERSION" ]] || {
- echo "could not read DB_CLIENT_VERSION out of packaging/build.sh" >&2; exit 1; }
- # The DATABASE server version is a separate choice from the client: default to
- # the deploy target so the integration tests meet the server prod will run,
- # rather than whichever one happened to be current when this line was written.
- DB_VERSION="${DB_VERSION:-2.20.1-1}"
- DB_DEB="${DB_DEB:-$DEB_REPO_DIR/dist/smartbotic-database_${DB_VERSION}_amd64.deb}"
- CLIENT_DEV_DEB="${CLIENT_DEV_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client-dev_${DB_CLIENT_VERSION}_amd64.deb}"
- CLIENT_DEB="${CLIENT_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client_${DB_CLIENT_VERSION}_amd64.deb}"
- FILTER="${1:-}"
- # BUILD_RUNNER=ON also builds and tests the QuickJS runner. Off by default
- # because it vendors QuickJS from GitHub at configure time.
- BUILD_RUNNER="${BUILD_RUNNER:-OFF}"
- docker image inspect "$BASE_IMAGE" >/dev/null 2>&1 || {
- echo "base image $BASE_IMAGE missing; build it with packaging/build.sh --rebuild-base" >&2
- exit 1
- }
- [[ -f "$DB_DEB" ]] || { echo "database deb not found: $DB_DEB" >&2; exit 1; }
- # The build tree is kept inside the container (a named volume) rather than in
- # the repo: objects built against Debian's toolchain must never be mixed with
- # whatever the host left in build/.
- docker run --rm \
- -v "$REPO:/src:ro" \
- -v svapi-testbuild:/build \
- -v "$DB_DEB:/tmp/db.deb:ro" \
- -v "$CLIENT_DEB:/tmp/client.deb:ro" \
- -v "$CLIENT_DEV_DEB:/tmp/client-dev.deb:ro" \
- -e "CTEST_FILTER=$FILTER" \
- -e "BUILD_RUNNER=$BUILD_RUNNER" \
- "$BASE_IMAGE" bash -euo pipefail -c '
- apt-get update -qq >/dev/null
- apt-get install -y -qq --no-install-recommends \
- /tmp/client.deb /tmp/client-dev.deb /tmp/db.deb >/dev/null 2>&1 || \
- dpkg -i /tmp/client.deb /tmp/client-dev.deb /tmp/db.deb >/dev/null 2>&1 || true
- mkdir -p /var/lib/smartbotic-database
- /usr/bin/smartbotic-database --config /etc/smartbotic-database/config.json >/tmp/db.log 2>&1 &
- for i in $(seq 1 60); do
- (exec 3<>/dev/tcp/127.0.0.1/9004) 2>/dev/null && break
- sleep 1
- done
- (exec 3<>/dev/tcp/127.0.0.1/9004) 2>/dev/null || { echo "database never came up:"; tail -20 /tmp/db.log; exit 1; }
- cmake -B /build -G Ninja -DCMAKE_BUILD_TYPE=Release \
- -DBUILD_TESTS=ON -DBUILD_WEBUI=OFF \
- -DBUILD_RUNNER="${BUILD_RUNNER}" -S /src
- cmake --build /build -j"$(nproc)"
- if [[ -n "${CTEST_FILTER:-}" ]]; then
- ctest --test-dir /build --output-on-failure -R "$CTEST_FILTER"
- else
- ctest --test-dir /build --output-on-failure
- fi
- '
|