From c4bc2977422007a553d34eae4e4e7365ff6ac6d8 Mon Sep 17 00:00:00 2001 From: Tinson Lai Date: Thu, 6 Aug 2026 05:07:38 +0000 Subject: [PATCH] test(inference): share the stopped foreign-container cases Signed-off-by: Tinson Lai --- .../serving/managed-cluster-discovery.test.ts | 33 +++--------------- .../serving/managed-cluster-executor.test.ts | 34 +++---------------- .../managed-cluster-fixture.test-support.ts | 33 ++++++++++++++++-- .../serving/managed-cluster-lifecycle.test.ts | 34 +++---------------- 4 files changed, 43 insertions(+), 91 deletions(-) diff --git a/src/lib/inference/serving/managed-cluster-discovery.test.ts b/src/lib/inference/serving/managed-cluster-discovery.test.ts index 8b601164037..cb18b8047f2 100644 --- a/src/lib/inference/serving/managed-cluster-discovery.test.ts +++ b/src/lib/inference/serving/managed-cluster-discovery.test.ts @@ -22,7 +22,10 @@ import { parseManagedClusterHostObservation, probeManagedClusterManagedServingCapability, } from "./managed-cluster-discovery.js"; -import { FIXTURE_MANAGED_CLUSTER_PRESET_ID } from "./managed-cluster-fixture.test-support.js"; +import { + FIXTURE_MANAGED_CLUSTER_PRESET_ID, + STOPPED_FOREIGN_CONTAINER_FIXTURES, +} from "./managed-cluster-fixture.test-support.js"; import { MANAGED_CLUSTER_MANAGED_LABEL } from "./managed-cluster-materialize.js"; import { type ManagedVllmSshBinding, @@ -44,34 +47,6 @@ const REQUIRED_CAPABILITIES = [ "host.gpu.cdi_healthy", ] as const; -type StoppedForeignContainerFixture = { - readonly signal: string; - readonly name: string; - readonly image: string; - readonly labels: Readonly>; -}; - -const STOPPED_FOREIGN_CONTAINER_FIXTURES: readonly StoppedForeignContainerFixture[] = [ - { - signal: "name", - name: "foreign-vllm-server", - image: "example.invalid/inference:latest", - labels: {}, - }, - { - signal: "image", - name: "foreign-inference", - image: "vllm/vllm-openai:latest", - labels: {}, - }, - { - signal: "managed label", - name: "foreign-inference", - image: "example.invalid/inference:latest", - labels: { [MANAGED_CLUSTER_MANAGED_LABEL]: "foreign" }, - }, -]; - function expectDetectedCluster( detected: ReturnType, ): ManagedClusterDetectedManagedServingCapability { diff --git a/src/lib/inference/serving/managed-cluster-executor.test.ts b/src/lib/inference/serving/managed-cluster-executor.test.ts index 3c9e7580c49..66bd6adebbb 100644 --- a/src/lib/inference/serving/managed-cluster-executor.test.ts +++ b/src/lib/inference/serving/managed-cluster-executor.test.ts @@ -10,10 +10,12 @@ import { inspectManagedClusterVllmNodesSync, type ManagedClusterVllmExecutorRuntimeDeps, } from "./managed-cluster-executor.js"; -import { fixtureManagedClusterPlan } from "./managed-cluster-fixture.test-support.js"; +import { + fixtureManagedClusterPlan, + STOPPED_FOREIGN_CONTAINER_FIXTURES, +} from "./managed-cluster-fixture.test-support.js"; import { MANAGED_CLUSTER_API_KEY_FINGERPRINT_LABEL, - MANAGED_CLUSTER_MANAGED_LABEL, MANAGED_CLUSTER_TRANSACTION_LABEL, type ManagedClusterVllmPlan, type ManagedClusterVllmRole, @@ -37,34 +39,6 @@ type DockerCaptureOptions = NonNullable< Parameters[1] >; -type StoppedForeignContainerFixture = { - readonly signal: string; - readonly name: string; - readonly image: string; - readonly labels: Readonly>; -}; - -const STOPPED_FOREIGN_CONTAINER_FIXTURES: readonly StoppedForeignContainerFixture[] = [ - { - signal: "name", - name: "foreign-vllm-server", - image: "example.invalid/inference:latest", - labels: {}, - }, - { - signal: "image", - name: "foreign-inference", - image: "vllm/vllm-openai:latest", - labels: {}, - }, - { - signal: "managed label", - name: "foreign-inference", - image: "example.invalid/inference:latest", - labels: { [MANAGED_CLUSTER_MANAGED_LABEL]: "foreign" }, - }, -]; - function bindPlan(fixture: ManagedVllmSshBindingFixture): ManagedClusterVllmPlan { const plan = fixtureManagedClusterPlan(); return { diff --git a/src/lib/inference/serving/managed-cluster-fixture.test-support.ts b/src/lib/inference/serving/managed-cluster-fixture.test-support.ts index 8b0da18e353..b6534c1358d 100644 --- a/src/lib/inference/serving/managed-cluster-fixture.test-support.ts +++ b/src/lib/inference/serving/managed-cluster-fixture.test-support.ts @@ -5,10 +5,10 @@ import { isManagedClusterInferenceServingRecipe, MANAGED_CLUSTER_VLLM_MATERIALIZER_REF, } from "./adapter-registry.js"; -import { loadManagedInferenceCatalog } from "./catalog-loader.js"; import { managedInferenceDigest } from "./catalog-integrity.js"; -import type { ResolvedManagedInferenceSelection } from "./types.js"; +import { loadManagedInferenceCatalog } from "./catalog-loader.js"; import { + MANAGED_CLUSTER_MANAGED_LABEL, type ManagedClusterVllmPlan, materializeManagedClusterVllmPlan, } from "./managed-cluster-materialize.js"; @@ -19,6 +19,35 @@ import { managedClusterTopologyOutputDigest, managedClusterTopologySubjectDigest, } from "./managed-cluster-topology.js"; +import type { ResolvedManagedInferenceSelection } from "./types.js"; + +export type StoppedForeignContainerFixture = { + readonly signal: string; + readonly name: string; + readonly image: string; + readonly labels: Readonly>; +}; + +export const STOPPED_FOREIGN_CONTAINER_FIXTURES: readonly StoppedForeignContainerFixture[] = [ + { + signal: "name", + name: "foreign-vllm-server", + image: "example.invalid/inference:latest", + labels: {}, + }, + { + signal: "image", + name: "foreign-inference", + image: "vllm/vllm-openai:latest", + labels: {}, + }, + { + signal: "managed label", + name: "foreign-inference", + image: "example.invalid/inference:latest", + labels: { [MANAGED_CLUSTER_MANAGED_LABEL]: "foreign" }, + }, +]; function fixtureCatalogDefinitions() { const catalog = loadManagedInferenceCatalog(); diff --git a/src/lib/inference/serving/managed-cluster-lifecycle.test.ts b/src/lib/inference/serving/managed-cluster-lifecycle.test.ts index 94e0d69486e..c4f8b5b60cc 100644 --- a/src/lib/inference/serving/managed-cluster-lifecycle.test.ts +++ b/src/lib/inference/serving/managed-cluster-lifecycle.test.ts @@ -3,7 +3,10 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; -import { fixtureManagedClusterPlan } from "./managed-cluster-fixture.test-support.js"; +import { + fixtureManagedClusterPlan, + STOPPED_FOREIGN_CONTAINER_FIXTURES, +} from "./managed-cluster-fixture.test-support.js"; import { classifyManagedClusterExistingState, cleanupManagedClusterManagedVllm, @@ -16,7 +19,6 @@ import { } from "./managed-cluster-lifecycle.js"; import { MANAGED_CLUSTER_API_KEY_FINGERPRINT_LABEL, - MANAGED_CLUSTER_MANAGED_LABEL, MANAGED_CLUSTER_TRANSACTION_LABEL, type ManagedClusterVllmPlan, type ManagedClusterVllmRole, @@ -28,34 +30,6 @@ const TRANSACTION_ID = "b".repeat(32); const HEAD_ID = "1".repeat(64); const WORKER_ID = "2".repeat(64); -type StoppedForeignContainerFixture = { - readonly signal: string; - readonly name: string; - readonly image: string; - readonly labels: Readonly>; -}; - -const STOPPED_FOREIGN_CONTAINER_FIXTURES: readonly StoppedForeignContainerFixture[] = [ - { - signal: "name", - name: "foreign-vllm-server", - image: "example.invalid/inference:latest", - labels: {}, - }, - { - signal: "image", - name: "foreign-inference", - image: "vllm/vllm-openai:latest", - labels: {}, - }, - { - signal: "managed label", - name: "foreign-inference", - image: "example.invalid/inference:latest", - labels: { [MANAGED_CLUSTER_MANAGED_LABEL]: "foreign" }, - }, -]; - type Harness = ReturnType; function managedContainer(