informix-db/tests/setup-spaces.sh
Ryan Malloy 783b2bec97 Verify Informix 14.10 and 12.10; make the version matrix reproducible
Closes out the field report that prompted 2026.05.08.2. Full integration
suite, same commit, all green:

  Informix 15.0.1.0.3DE     241 / 241
  Informix 14.10.FC7W1DE    241 / 241
  Informix 12.10.FC12W1DE   241 / 241

Including smart-LOB. The 28-type round-trip produces byte-identical wire
output on all three — same type codes, same encoded lengths, same values.
There is no 12-vs-14-vs-15 wire difference for anything we support.

Testing three versions by hand was tedious and undocumented, which is
part of why it never happened. Now:

  make ifx-legacy-up      12.10 on 9089, 14.10 on 9090, alongside 15 on 9088
  make ifx-legacy-setup   blobspace1 + sbspace1 in both
  make test-matrix        the suite against all three

tests/setup-spaces.sh absorbs the per-image differences that made this
annoying: 12.10/14.10 use a flat INFORMIXDIR while 15 nests a versioned
subdirectory; ONCONFIG is named differently across images; `bash -lc`
wipes INFORMIXDIR and makes every utility fail with a misleading
"Unable to read $INFORMIXDIR (/usr/informix)"; and 12.10 DE ships no
ontape at all (the level-0 archive turns out to be unnecessary anyway).
Without blobspace1/sbspace1, ~21 tests fail with errors that look like
driver bugs and aren't.

The documented workflow was validated from scratch — containers removed,
recreated via compose, spaces created via the script, matrix run — rather
than written up afterward from whichever commands happened to work. The
README claim this replaces was wrong precisely because nobody did that.
2026-08-27 00:36:35 -06:00

77 lines
2.8 KiB
Bash
Executable File

#!/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 <container-name>
#
# 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 <container-name>}"
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
'