|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Run the standalone data-lineage jar and check what it produced. |
| 4 | +# |
| 5 | +# This exists because building the dlineage demo proved nothing, twice. Until |
| 6 | +# 2026-07-28 it was a second POM, pom_dlineage.xml, and the only thing CI did |
| 7 | +# with it was `package`: |
| 8 | +# |
| 9 | +# * issue #47 -- it was missing the JAXB dependency the root POM already |
| 10 | +# carried. Compiles perfectly. Dies at runtime on every JDK after 8. |
| 11 | +# * issue #46 -- the documented run command put external_lib/ on the |
| 12 | +# classpath, a directory only the Windows .bat route ever creates, so |
| 13 | +# nobody following the Maven instructions could run the thing at all. |
| 14 | +# |
| 15 | +# Both shipped through a green build. So this runs it. |
| 16 | +# |
| 17 | +# The assertions are about the OUTPUT, not the exit status, and that is the |
| 18 | +# whole point. In issue #47 the process created lineage.json, died before |
| 19 | +# writing a byte into it, and still exited 0. An existence check, or an exit |
| 20 | +# code check, would both have called that a pass. Non-empty and parseable is |
| 21 | +# the weakest check that would actually have caught it. |
| 22 | +# |
| 23 | +# Usage: |
| 24 | +# smoke-dlineage-jar.sh [jar] |
| 25 | +# |
| 26 | +# Exit codes: |
| 27 | +# 0 the jar ran and produced valid, non-empty lineage in both formats |
| 28 | +# 1 anything else |
| 29 | + |
| 30 | +set -euo pipefail |
| 31 | + |
| 32 | +cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit 1 |
| 33 | + |
| 34 | +JAR="${1:-target/gsp_demo_java-1.0-SNAPSHOT-dlineage.jar}" |
| 35 | +SQL="samples/dlineage/demo.sql" |
| 36 | + |
| 37 | +fail() { echo "::error::$*" >&2; exit 1; } |
| 38 | + |
| 39 | +[ -f "$JAR" ] || fail "$JAR was not produced by 'mvn package'" |
| 40 | +[ -f "$SQL" ] || fail "$SQL is missing; the smoke test has no input" |
| 41 | + |
| 42 | +OUT=$(mktemp -d) |
| 43 | +trap 'rm -rf "$OUT"' EXIT |
| 44 | + |
| 45 | +echo "running $JAR on $SQL" |
| 46 | +echo "java: $(java -version 2>&1 | head -1)" |
| 47 | + |
| 48 | +# --- JSON ------------------------------------------------------------------ |
| 49 | +# No classpath, no version number, no external_lib. If this invocation ever |
| 50 | +# needs more than `java -jar`, the packaging has regressed and the README has |
| 51 | +# gone stale with it. |
| 52 | +java -jar "$JAR" /f "$SQL" /o "$OUT/lineage.json" /json \ |
| 53 | + /simpleShowRelationTypes fdd,fdr /filterRelationTypes fdd |
| 54 | + |
| 55 | +[ -s "$OUT/lineage.json" ] || |
| 56 | + fail "lineage.json is empty or missing: the tool ran but produced nothing (cf. issue #47)" |
| 57 | + |
| 58 | +python3 - "$OUT/lineage.json" <<'PY' |
| 59 | +import json, sys |
| 60 | +path = sys.argv[1] |
| 61 | +try: |
| 62 | + d = json.load(open(path)) |
| 63 | +except Exception as e: |
| 64 | + sys.exit("lineage.json is not valid JSON: %s" % e) |
| 65 | +
|
| 66 | +# The shape differs with /graph, so accept either place the relationships live. |
| 67 | +rel = d.get("relationships") or d.get("data", {}).get("sqlflow", {}).get("relationships", []) |
| 68 | +if not rel: |
| 69 | + sys.exit("lineage.json parsed but carries no relationships; " |
| 70 | + "the analyzer returned an empty result") |
| 71 | +print("ok: JSON output, %d relationships" % len(rel)) |
| 72 | +PY |
| 73 | + |
| 74 | +# --- XML ------------------------------------------------------------------- |
| 75 | +# A separate code path, through JAXB, and the one that actually broke. With |
| 76 | +# jaxb-runtime 2.3.3 on JDK 11+ the JSON above still succeeds while this writes |
| 77 | +# a 0-byte file and exits 0, so checking JSON alone is not enough. See the |
| 78 | +# jaxb-runtime comment in pom.xml for why the API and the runtime are |
| 79 | +# deliberately on different versions. |
| 80 | +java -jar "$JAR" /f "$SQL" /o "$OUT/lineage.xml" |
| 81 | + |
| 82 | +[ -s "$OUT/lineage.xml" ] || |
| 83 | + fail "lineage.xml is empty or missing: the JAXB output path failed (cf. issue #47)" |
| 84 | + |
| 85 | +python3 - "$OUT/lineage.xml" <<'PY' |
| 86 | +import sys, xml.dom.minidom |
| 87 | +path = sys.argv[1] |
| 88 | +try: |
| 89 | + doc = xml.dom.minidom.parse(path) |
| 90 | +except Exception as e: |
| 91 | + sys.exit("lineage.xml is not well-formed: %s" % e) |
| 92 | +
|
| 93 | +rel = doc.getElementsByTagName("relationship") |
| 94 | +if not rel: |
| 95 | + sys.exit("lineage.xml is well-formed but carries no <relationship> elements") |
| 96 | +print("ok: XML output, %d relationships" % len(rel)) |
| 97 | +PY |
| 98 | + |
| 99 | +echo "ok: the standalone dlineage jar runs and produces lineage in both formats" |
0 commit comments