#!/usr/bin/env bash # Create blobspace1 + sbspace1 in an Informix dev container. # # The developer-edition images ship with only rootdbs. BYTE/TEXT tests need a # blobspace; BLOB/CLOB (smart-LOB) tests need an sbspace plus SBSPACENAME set. # Without them, ~21 integration tests fail with errors that look like driver # bugs but are pure server configuration. # # Usage: tests/setup-spaces.sh # # Idempotent: re-running against a container that already has the spaces prints # the server's "already exists" complaint and exits 0. # # Version quirks this handles, learned the hard way: # * INFORMIXDIR differs — 12.10/14.10 use /opt/ibm/informix, 15 nests a # versioned subdirectory (/opt/ibm/informix/v15.0.1.0.3). # * ONCONFIG is named `onconfig` on some images and `onconfig.informix` on # others; we probe for the file rather than guessing. # * `bash -lc` wipes INFORMIXDIR from the environment on these images, which # makes every utility fail with "Unable to read $INFORMIXDIR (/usr/informix)". # Use `bash -c` and export explicitly. # * 12.10 DE ships no `ontape`. The level-0 archive turns out to be # unnecessary for the tests, so we attempt it and shrug if it's missing. set -euo pipefail CONTAINER="${1:?usage: setup-spaces.sh }" docker exec -u informix "$CONTAINER" bash -c ' set -u # Locate INFORMIXDIR: either /opt/ibm/informix or a versioned subdir under it. for cand in /opt/ibm/informix /opt/ibm/informix/v*; do if [ -x "$cand/bin/onspaces" ]; then export INFORMIXDIR="$cand" break fi done if [ -z "${INFORMIXDIR:-}" ]; then echo "could not locate INFORMIXDIR (no bin/onspaces found)" >&2 exit 1 fi export PATH="$INFORMIXDIR/bin:$PATH" export INFORMIXSERVER=informix export INFORMIXSQLHOSTS="$INFORMIXDIR/etc/sqlhosts" # ONCONFIG name varies across images. for cfg in onconfig onconfig.informix; do if [ -f "$INFORMIXDIR/etc/$cfg" ]; then export ONCONFIG="$cfg" break fi done : "${ONCONFIG:?no onconfig found in $INFORMIXDIR/etc}" echo "INFORMIXDIR=$INFORMIXDIR ONCONFIG=$ONCONFIG" SPACES=/opt/ibm/data/spaces mkdir -p "$SPACES" for f in blobspace1 sbspace1; do [ -e "$SPACES/$f" ] || : > "$SPACES/$f" chmod 660 "$SPACES/$f" done onspaces -c -b blobspace1 -g 1 -p "$SPACES/blobspace1" -o 0 -s 50000 2>&1 | grep -vE "^\s*$" || true onspaces -c -S sbspace1 -p "$SPACES/sbspace1" -o 0 -s 50000 -Df "AVG_LO_SIZE=100" 2>&1 | grep -vE "^\s*$" || true onmode -wm SBSPACENAME=sbspace1 2>&1 | tail -1 || true # Level-0 archive. Informix warns it is required after adding a space; in # practice the tests pass without it, and 12.10 DE has no ontape at all. onmode -wm TAPEDEV=/dev/null >/dev/null 2>&1 || true if command -v ontape >/dev/null 2>&1; then ontape -s -L 0 2>&1 | tail -1 || true else echo "ontape not present on this image; skipping level-0 archive" fi '