28c2ffb84f
Reference-count the process-global ONNX Runtime across embedder and routing-head sessions, make close idempotent, and require named proof that both aggregate routing gates executed rather than self-skipped (V-716). Owner explicitly requested direct commits to master.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package router
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
// TestONNXRuntimeCanBeReacquired pins the process-global lifecycle itself.
|
|
// The model gates exercise live sessions; this smaller check proves that the
|
|
// last lease unloads a managed environment and that a later gate can acquire
|
|
// it again. It is opt-in for the same reason as every model measurement.
|
|
func TestONNXRuntimeCanBeReacquired(t *testing.T) {
|
|
lib := os.Getenv("MAVEN_ONNX_LIB")
|
|
if lib == "" {
|
|
t.Skip("MAVEN_ONNX_LIB unset — see AGENTS.md § Embedder model for intent routing")
|
|
}
|
|
if _, err := os.Stat(lib); err != nil {
|
|
t.Skipf("missing %s: %v", lib, err)
|
|
}
|
|
|
|
first, err := AcquireONNXRuntime(lib)
|
|
if err != nil {
|
|
t.Fatalf("first acquire: %v", err)
|
|
}
|
|
if err := first.Close(); err != nil {
|
|
t.Fatalf("first close: %v", err)
|
|
}
|
|
if err := first.Close(); err != nil {
|
|
t.Fatalf("idempotent close: %v", err)
|
|
}
|
|
|
|
second, err := AcquireONNXRuntime(lib)
|
|
if err != nil {
|
|
t.Fatalf("reacquire after last close: %v", err)
|
|
}
|
|
if err := second.Close(); err != nil {
|
|
t.Fatalf("second close: %v", err)
|
|
}
|
|
}
|