You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "FANNG1 (via GitHub)" <gi...@apache.org> on 2026/06/01 06:50:20 UTC
Re: [PR] [#10983] test(lance): add Lance compatibility matrix automation [gravitino]
FANNG1 commented on code in PR #11119:
URL: https://github.com/apache/gravitino/pull/11119#discussion_r3332145960
##########
lance/lance-rest-server/build.gradle.kts:
##########
@@ -169,6 +200,64 @@ tasks {
dependsOn(":catalogs:catalog-lakehouse-generic:jar")
}
}
+
+ // Per-version Test task that only runs LanceSparkRESTServiceIT against a
+ // specific lance-spark-bundle. Each task downloads its bundle through the
+ // matching Sync task and points the IT JVM at it via system property.
+ lanceSparkBundleVersions.forEach { version ->
+ register<Test>(lanceSparkTestTaskName(version)) {
+ group = "verification"
+ description =
+ "Run LanceSparkRESTServiceIT against lance-spark-bundle $version"
+
+ dependsOn(named(lanceSparkPrepareTaskName(version)))
+ dependsOn(named("jar"))
+ val versionTestMode = project.properties["testMode"] as? String ?: "embedded"
+ if (versionTestMode == "embedded") {
+ dependsOn(":catalogs:catalog-lakehouse-generic:jar")
+ }
+
+ testClassesDirs = sourceSets["test"].output.classesDirs
+ classpath = sourceSets["test"].runtimeClasspath
+ useJUnitPlatform()
+ filter { includeTestsMatching("*LanceSparkRESTServiceIT*") }
+
+ val versionBundleDir = lanceSparkBundleDirFor(version)
+ doFirst {
+ val bundleJar =
+ versionBundleDir.get().asFile.listFiles()?.singleOrNull { it.extension == "jar" }
+ ?: throw GradleException(
+ "Expected exactly one Lance Spark bundle jar in " +
+ "${versionBundleDir.get().asFile} for version $version"
+ )
+ systemProperty(lanceSparkBundleJarPathProperty, bundleJar.absolutePath)
+ println("[lance-spark-matrix] running IT against bundle $version -> ${bundleJar.name}")
+ }
+
+ // Send per-version reports to a separate directory so a matrix run
+ // doesn't overwrite results across versions.
+ val versionSlug = version.replace(".", "_").replace("-", "_")
+ reports {
+ html.outputLocation.set(
+ layout.buildDirectory.dir("reports/lance-spark-matrix/$versionSlug")
+ )
+ junitXml.outputLocation.set(
+ layout.buildDirectory.dir("test-results/lance-spark-matrix/$versionSlug")
+ )
+ }
+ }
+ }
+
+ register("lanceSparkMatrixTest") {
Review Comment:
`lanceSparkMatrixTest` depends on all per-version `Test` tasks via a plain `dependsOn` list with no `mustRunAfter` ordering between them. With `--parallel` (or `org.gradle.parallel=true` in `gradle.properties`), Gradle can dispatch multiple per-version tasks concurrently. Each `LanceSparkRESTServiceIT` spins up an embedded `MiniGravitino` instance. Since `findAvailablePort` is a scan rather than an atomic OS-level reservation (TOCTOU), two tasks can both observe the same port as free and then race to bind it, producing intermittent `address already in use` errors that look like test failures rather than infrastructure conflicts.
Consider serializing the tasks with `mustRunAfter`, or set `maxParallelForks = 1` on each per-version `Test` task.
##########
clients/client-python/build.gradle.kts:
##########
@@ -239,6 +239,81 @@ tasks {
finalizedBy(unitCoverageReport)
}
+ // Run tests/integration/test_lance_ray.py against multiple lance-ray
+ // versions. Each version is exercised inside its own venv under
+ // build/lance-ray-matrix/.venv-<version>/ (cached across runs).
+ // Override the matrix with `-PlanceRayVersions=0.4.2,0.4.1,0.4.0`.
+ // Override the bootstrap interpreter with `-PlanceRayPython=/path/to/python`.
+ register("lanceRayMatrixTest") {
+ group = "verification"
+ description =
+ "Run tests/integration/test_lance_ray.py against multiple lance-ray " +
+ "versions. Override with -PlanceRayVersions=<csv> (default: " +
+ "tracks docs/lance-rest-integration.md Compatibility Matrix)."
+
+ val versions = project.findProperty("lanceRayVersions") as? String
+ val keepGoing = project.hasProperty("lanceRayKeepGoing")
+ // Bootstrap interpreter resolution (lowest to highest priority):
+ // 1. system `python3` on PATH (final fallback)
+ // 2. miniforge plugin's conda env (set up by `pythonPlugin {}` block
+ // above), if its `python` exists. This keeps the matrix consistent
+ // with the python toolchain the rest of the python client uses.
+ // 3. `-PlanceRayPython=/path/to/python` explicit override.
+ //
+ // The matrix script provisions its own per-version venvs from this
+ // interpreter, so all that's required is a Python 3 with the `venv`
+ // module — the choice does not affect what lance-ray sees at runtime.
+ val pythonVersion = project.rootProject.extra["pythonVersion"].toString()
+ val osDir = when {
+ org.gradle.internal.os.OperatingSystem.current().isMacOsX -> "MacOSX"
+ org.gradle.internal.os.OperatingSystem.current().isLinux -> "Linux"
+ else -> null
+ }
+ val condaPython = osDir?.let {
+ file("${project.rootDir}/.gradle/python/$it/Miniforge3/envs/python-$pythonVersion/bin/python")
+ }
+ val explicitPython =
+ (project.findProperty("lanceRayPython") as? String)?.takeIf { it.isNotBlank() }
+ val pythonExecutable = when {
+ explicitPython != null -> explicitPython
+ condaPython != null && condaPython.exists() -> condaPython.absolutePath
+ else -> "python3"
+ }
+ val script = projectDir.resolve("scripts/run_lance_ray_matrix.py")
+ val gravitinoHome = file("${project.rootDir}/distribution/package")
+
+ doFirst {
+ gravitinoServer("start")
+ }
+ doLast {
Review Comment:
`gravitinoServer("start")` is placed in a `doFirst` block, but `gravitinoServer("stop")` only lives inside the `finally` of a `doLast` block. In Gradle, if a `doFirst` action throws (e.g. the server fails to start or the script is missing), Gradle aborts the task immediately and **never executes any `doLast` blocks** — the `finally` is unreachable. The server process would be orphaned for the rest of the CI session.
Consider moving the server lifecycle entirely into `doLast` so the `finally` can actually guard it:
```kotlin
doLast {
gravitinoServer("start")
try {
val proc = ProcessBuilder(args).inheritIO().start()
val exit = proc.waitFor()
if (exit != 0) throw GradleException("lance-ray matrix failed with exit code $exit")
} finally {
gravitinoServer("stop")
}
}
```
##########
clients/client-python/scripts/run_lance_ray_matrix.py:
##########
@@ -0,0 +1,329 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Run ``tests/integration/test_lance_ray.py`` against multiple lance-ray
+versions to validate the supported range advertised in the Compatibility
+Matrix (``docs/lance-rest-integration.md``).
+
+For each version we provision a dedicated venv under
+``clients/client-python/build/lance-ray-matrix/.venv-<version>/`` and install
+``ray``, ``lance-ray==<version>``, ``lance-namespace``, ``requests``, plus the
+in-tree ``apache-gravitino`` distribution (editable). The unittest itself is
+launched per-version with ``python -m unittest -v
+tests.integration.test_lance_ray``; results are collected into a pass/fail
+table at the end.
+
+The caller is responsible for starting the Gravitino server (with the
+auxiliary lance-rest service enabled). The Gradle wrapper task
+``:clients:client-python:lanceRayMatrixTest`` handles that. For ad-hoc local
+use::
+
+ distribution/package/bin/gravitino.sh start
+ python3 clients/client-python/scripts/run_lance_ray_matrix.py \
+ --versions 0.4.2,0.4.1 \
+ --gravitino-home distribution/package
+ distribution/package/bin/gravitino.sh stop
+
+Each test class will append its own metalake binding to ``gravitino.conf`` and
+restart the server itself. The matrix runner opts into keeping that binding
+between versions, so back-to-back runs avoid unnecessary Gravitino restarts.
+"""
+
+from __future__ import annotations
+
+import argparse
+import os
+import subprocess
+import sys
+from dataclasses import dataclass
+from pathlib import Path
+from typing import List
+
+# Default version set tracks what the Compatibility Matrix in
+# docs/lance-rest-integration.md claims to support. Keep these in sync.
+DEFAULT_VERSIONS = ["0.4.2", "0.4.1", "0.4.0", "0.3.0"]
+
+
+REPO_ROOT = Path(__file__).resolve().parents[3]
+PYTHON_CLIENT_DIR = REPO_ROOT / "clients" / "client-python"
+DEFAULT_MATRIX_DIR = PYTHON_CLIENT_DIR / "build" / "lance-ray-matrix"
+DEFAULT_GRAVITINO_HOME = REPO_ROOT / "distribution" / "package"
+LANCE_REST_CONF = Path("conf") / "gravitino.conf"
+LANCE_REST_METALAKE_BINDING = (
+ "gravitino.lance-rest.gravitino-metalake = lance_ray_test_metalake"
+)
+
+
+@dataclass
+class VersionResult:
+ version: str
+ status: str # "ok", "fail", "setup-error"
+ details: str
+
+
+def parse_args() -> argparse.Namespace:
+ p = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
+ p.add_argument(
+ "--versions",
+ default=",".join(DEFAULT_VERSIONS),
+ help="Comma-separated list of lance-ray versions to test. "
+ f"Default: {','.join(DEFAULT_VERSIONS)}",
+ )
+ p.add_argument(
+ "--python",
+ default=sys.executable,
+ help="Path to the host python interpreter used to bootstrap each "
+ "version's venv. Default: %(default)s",
+ )
+ p.add_argument(
+ "--matrix-dir",
+ default=str(DEFAULT_MATRIX_DIR),
+ help="Directory under which per-version venvs are created and "
+ "cached across runs. Default: %(default)s",
+ )
+ p.add_argument(
+ "--gravitino-home",
+ default=str(DEFAULT_GRAVITINO_HOME),
+ help="Path to the built Gravitino distribution package. The "
+ "lance-rest aux service must be enabled there. Default: %(default)s",
+ )
+ p.add_argument(
+ "--ray-spec",
+ default="ray==2.55.1",
+ help="Pip spec for ray. Pinned by default so the matrix is "
+ "reproducible across runs and does not drift with PyPI. Override "
+ "(e.g. 'ray') to let pip pick a compatible version per lance-ray. "
+ "Default: %(default)s",
+ )
+ p.add_argument(
+ "--lance-namespace-spec",
+ default="lance-namespace==0.7.5",
+ help="Pip spec for lance-namespace. Pinned by default so the "
+ "matrix is reproducible and does not drift with PyPI. Override "
+ "(e.g. 'lance-namespace') for latest. Default: %(default)s",
+ )
+ p.add_argument(
+ "--keep-going",
+ action="store_true",
+ help="Continue to the next version after a failure instead of "
+ "stopping on the first failed run.",
+ )
+ return p.parse_args()
+
+
+def run(cmd: List[str], **kwargs) -> subprocess.CompletedProcess:
+ print(f"[matrix] $ {' '.join(cmd)}")
+ return subprocess.run(cmd, check=False, **kwargs)
+
+
+def ensure_venv(python: str, venv_dir: Path) -> Path:
+ """Create the venv if it doesn't already exist. Returns the venv python path."""
+ venv_python = venv_dir / "bin" / "python"
+ if not venv_python.exists():
+ venv_dir.parent.mkdir(parents=True, exist_ok=True)
+ rc = run([python, "-m", "venv", str(venv_dir)]).returncode
+ if rc != 0:
+ raise RuntimeError(f"Failed to create venv at {venv_dir}")
+ return venv_python
+
+
+def install_deps(
Review Comment:
`ensure_venv` correctly skips venv creation when the venv already exists, but `install_deps` is called unconditionally after it every run regardless. All three `pip` invocations (upgrade pip/wheel, install lance-ray + ray + lance-namespace, install editable gravitino) re-run even when the venv is fully populated from a prior cached run — so the "cached across runs" claim in the docstring only holds for the venv skeleton, not the packages.
This also makes the matrix fragile in restricted network environments: a run that should succeed from cache will fail at the `pip install` step if PyPI is unavailable.
A simple fix is to write a sentinel file (e.g. `.installed-<version>`) inside the venv dir after a successful `install_deps`, and skip the function when that sentinel exists.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org