|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Mirror package-windows "Verify packaged examples" from unzip through example exes. |
| 3 | +# Usage: local-verify-packaged-examples-windows.sh <path-to-iotdb-session-cpp.zip> [workspace] |
| 4 | +set -euxo pipefail |
| 5 | + |
| 6 | +PKG_TARBALL="${1:?zip path required}" |
| 7 | +GITHUB_WORKSPACE="${2:-$(cd "$(dirname "$0")/../.." && pwd)}" |
| 8 | +CMAKE_GENERATOR="${CMAKE_GENERATOR:-}" |
| 9 | +SKIP_DIST_MVN="${SKIP_DIST_MVN:-0}" |
| 10 | + |
| 11 | +export RUNNER_OS=Windows |
| 12 | +export RUNNER_TEMP="${RUNNER_TEMP:-${TEMP:-/tmp}}" |
| 13 | +TEMP_BASE="$(cygpath -u "${RUNNER_TEMP}")" |
| 14 | +WORKSPACE_BASE="$(cygpath -u "${GITHUB_WORKSPACE}")" |
| 15 | + |
| 16 | +echo "PKG_TARBALL=${PKG_TARBALL}" |
| 17 | +echo "WORKSPACE_BASE=${WORKSPACE_BASE}" |
| 18 | +echo "TEMP_BASE=${TEMP_BASE}" |
| 19 | + |
| 20 | +PKG_UNPACK="${TEMP_BASE}/client-cpp-package" |
| 21 | +rm -rf "${PKG_UNPACK}" |
| 22 | +mkdir -p "${PKG_UNPACK}" |
| 23 | +unzip -q -o "${PKG_TARBALL}" -d "${PKG_UNPACK}" |
| 24 | +# GitHub artifact downloads may be a wrapper zip containing the real package zip + .sha512. |
| 25 | +NESTED_ZIP=$(find "${PKG_UNPACK}" -maxdepth 1 -type f -name 'iotdb-session-cpp-*.zip' ! -name '*.sha512' -print -quit) |
| 26 | +if [ -n "${NESTED_ZIP}" ]; then |
| 27 | + echo "Unpacking nested SDK zip: ${NESTED_ZIP}" |
| 28 | + unzip -q -o "${NESTED_ZIP}" -d "${PKG_UNPACK}" |
| 29 | +fi |
| 30 | +PKG_ROOT=$(find "${PKG_UNPACK}" -mindepth 1 -maxdepth 1 -type d -name 'iotdb-session-cpp-*' -print -quit) |
| 31 | +test -n "${PKG_ROOT}" |
| 32 | +echo "PKG_ROOT=${PKG_ROOT}" |
| 33 | + |
| 34 | +EXAMPLE_BUILD="${TEMP_BASE}/client-cpp-example-smoke" |
| 35 | +rm -rf "${EXAMPLE_BUILD}" |
| 36 | +CMAKE_ARGS=(-S "${PKG_ROOT}/examples" -B "${EXAMPLE_BUILD}" -DIOTDB_SDK_ROOT="${PKG_ROOT}") |
| 37 | +if [ -n "${CMAKE_GENERATOR}" ]; then |
| 38 | + CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}") |
| 39 | +fi |
| 40 | +cmake "${CMAKE_ARGS[@]}" |
| 41 | +cmake --build "${EXAMPLE_BUILD}" --config Release |
| 42 | + |
| 43 | +if [ "${SKIP_DIST_MVN}" = "0" ]; then |
| 44 | + (cd "${WORKSPACE_BASE}" && ./mvnw -pl distribution -am -DskipTests -Dspotless.skip=true package) |
| 45 | +else |
| 46 | + echo "SKIP_DIST_MVN=1: skipping ./mvnw -pl distribution package" |
| 47 | +fi |
| 48 | + |
| 49 | +SERVER_ROOT=$(find "${WORKSPACE_BASE}/distribution/target" -path '*/apache-iotdb-*-all-bin/sbin/windows/start-standalone.bat' -print -quit | sed 's#/sbin/windows/start-standalone.bat##') |
| 50 | +if [ -z "${SERVER_ROOT}" ]; then |
| 51 | + echo "ERROR: no distribution under distribution/target (set SKIP_DIST_MVN=0 to build)" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | +echo "SERVER_ROOT=${SERVER_ROOT}" |
| 55 | + |
| 56 | +START_BAT="$(cygpath -w "${SERVER_ROOT}/sbin/windows/start-standalone.bat")" |
| 57 | +STOP_BAT="$(cygpath -w "${SERVER_ROOT}/sbin/windows/stop-standalone.bat")" |
| 58 | +cmd.exe //c "${START_BAT}" |
| 59 | +trap "cmd.exe //c \"${STOP_BAT}\" || true" EXIT |
| 60 | + |
| 61 | +echo "Waiting for IoTDB RPC on 127.0.0.1:6667..." |
| 62 | +ready=0 |
| 63 | +for _ in $(seq 1 60); do |
| 64 | + if powershell.exe -NoProfile -Command \ |
| 65 | + '(Test-NetConnection -ComputerName 127.0.0.1 -Port 6667 -WarningAction SilentlyContinue).TcpTestSucceeded' \ |
| 66 | + | grep -qi True; then |
| 67 | + ready=1 |
| 68 | + break |
| 69 | + fi |
| 70 | + sleep 2 |
| 71 | +done |
| 72 | +if [ "${ready}" -ne 1 ]; then |
| 73 | + echo "ERROR: IoTDB did not listen on 6667 within 120s" |
| 74 | + ls -la "${SERVER_ROOT}/logs" 2>/dev/null || true |
| 75 | + exit 1 |
| 76 | +fi |
| 77 | + |
| 78 | +for exe in SessionExample.exe AlignedTimeseriesSessionExample.exe TableModelSessionExample.exe tree_example.exe table_example.exe; do |
| 79 | + EXE=$(find "${EXAMPLE_BUILD}" -name "${exe}" -print -quit) |
| 80 | + test -n "${EXE}" |
| 81 | + echo "Running ${EXE}" |
| 82 | + "${EXE}" |
| 83 | +done |
| 84 | +echo "OK: local Windows verify packaged examples smoke passed" |
0 commit comments