|
| 1 | +/* |
| 2 | +Copyright The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package ai_inference |
| 18 | + |
| 19 | +import ( |
| 20 | + "fmt" |
| 21 | + "strings" |
| 22 | + "testing" |
| 23 | + |
| 24 | + "k8s.io/kops/tests/e2e/scenarios/ai-conformance/validators" |
| 25 | +) |
| 26 | + |
| 27 | +// TestNetworking_AIInference corresponds to the networking/ai_inference conformance requirement, |
| 28 | +// tested using the KubeRay operator as an example of a complex AI operator with a CRD. |
| 29 | +func TestNetworking_AIInference(t *testing.T) { |
| 30 | + // Description: |
| 31 | + // Support the Kubernetes Gateway API with an implementation for advanced traffic management for inference services, |
| 32 | + // which enables capabilities like weighted traffic splitting, |
| 33 | + // header-based routing (for OpenAI protocol headers), |
| 34 | + // and optional integration with service meshes." |
| 35 | + |
| 36 | + h := validators.NewValidatorHarness(t) |
| 37 | + |
| 38 | + h.Logf("# Gateway API support for AI inference") |
| 39 | + |
| 40 | + h.Run("weighted-traffic-splitting", func(h *validators.ValidatorHarness) { |
| 41 | + h.Logf("## Verify Weighted Traffic Splitting") |
| 42 | + ns := h.TestNamespace() |
| 43 | + |
| 44 | + h.ApplyManifest(ns, "testdata/weighted-traffic-splitting.yaml") |
| 45 | + // h.ShellExec(fmt.Sprintf("kubectl wait -n %s --for='jsonpath={.status.jobDeploymentStatus}=Complete' rayjob/rayjob-sample --timeout=300s", ns)) |
| 46 | + |
| 47 | + status := h.ShellExec(fmt.Sprintf("kubectl get httproute weighted-traffic-splitting -n %s -oyaml", ns)) |
| 48 | + if !strings.Contains(status.Stdout(), "Accepted") { |
| 49 | + h.Fatalf("Did not find Accepted message in status: %s", status.Stdout()) |
| 50 | + } else { |
| 51 | + h.Success("Found Accepted message in status, indicating the HTTPRoute was accepted successfully.") |
| 52 | + } |
| 53 | + }) |
| 54 | + |
| 55 | + h.Run("header-based-routing", func(h *validators.ValidatorHarness) { |
| 56 | + h.Logf("## Verify Header Based Routing") |
| 57 | + ns := h.TestNamespace() |
| 58 | + |
| 59 | + h.ApplyManifest(ns, "testdata/header-based-routing.yaml") |
| 60 | + // h.ShellExec(fmt.Sprintf("kubectl wait -n %s --for='jsonpath={.status.jobDeploymentStatus}=Complete' rayjob/rayjob-sample --timeout=300s", ns)) |
| 61 | + |
| 62 | + status := h.ShellExec(fmt.Sprintf("kubectl get httproute header-based-routing -n %s -oyaml", ns)) |
| 63 | + if !strings.Contains(status.Stdout(), "Accepted") { |
| 64 | + h.Fatalf("Did not find Accepted message in status: %s", status.Stdout()) |
| 65 | + } else { |
| 66 | + h.Success("Found Accepted message in status, indicating the HTTPRoute was accepted successfully.") |
| 67 | + } |
| 68 | + }) |
| 69 | + |
| 70 | + if h.AllPassed() { |
| 71 | + h.RecordConformance("networking/ai_inference") |
| 72 | + } |
| 73 | +} |
0 commit comments