Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/invocation-plane-services/vanity-gateway/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ go_library(
# VCS build info (absent under Bazel).
x_defs = {
"ai-api-gateway-service/gateway.version": "{STABLE_VERSION}",
"github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/version.Service": "nvcf-ai-api-gateway-service",
"github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/version.Version": "{STABLE_VERSION}",
"github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/version.GitHash": "{STABLE_GIT_COMMIT_FULL}",
},
deps = [
"//src/invocation-plane-services/vanity-gateway/gateway",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ go_library(
"@com_github_nvidia_nvcf_go//pkg/nvkit/logs",
"@com_github_nvidia_nvcf_go//pkg/nvkit/servers",
"@com_github_nvidia_nvcf_go//pkg/nvkit/tracing",
"@com_github_nvidia_nvcf_src_libraries_go_lib//pkg/version",
"@com_github_valyala_bytebufferpool//:bytebufferpool",
"@io_opentelemetry_go_contrib_instrumentation_net_http_otelhttp//:otelhttp",
"@io_opentelemetry_go_otel//:otel",
Expand Down Expand Up @@ -59,6 +60,7 @@ go_test(
srcs = [
"gateway_test.go",
"h2_test.go",
"info_test.go",
"openai_director_test.go",
"shadow_metrics_test.go",
"shadow_test.go",
Expand All @@ -70,6 +72,7 @@ go_test(
deps = [
"//src/invocation-plane-services/vanity-gateway/gateway_config",
"@com_github_carlmjohnson_versioninfo//:versioninfo",
"@com_github_nvidia_nvcf_src_libraries_go_lib//pkg/version",
"@com_github_goccy_go_json//:go-json",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
Expand Down
3 changes: 3 additions & 0 deletions src/invocation-plane-services/vanity-gateway/gateway/h2.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
"go.uber.org/zap"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"

golibversion "github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/version"
)

const (
Expand Down Expand Up @@ -110,6 +112,7 @@ func buildChiMux(mappings *config.GatewayConfig, serverConfig Config) (*chi.Mux,

r.Use(hostRouter.Handler)
r.With(serverTelemetry).Get(healthPath, healthManager.HandlerFunc)
r.With(serverTelemetry).Get("/info", golibversion.Handler().ServeHTTP)
return r, nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
SPDX-FileCopyrightText: Copyright (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0

Licensed 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.
*/

package gateway

import (
config "ai-api-gateway-service/gateway_config"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"

golibversion "github.com/NVIDIA/nvcf/src/libraries/go/lib/pkg/version"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// newInfoTestMux builds the top-level chi router with a minimal, valid config.
// The /info handler does not depend on any mapping or upstream, so an empty
// GatewayConfig pointed at a throwaway backend is enough to exercise it.
func newInfoTestMux(t *testing.T) http.Handler {
t.Helper()

backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
t.Cleanup(backend.Close)

mux, err := buildChiMux(&config.GatewayConfig{}, Config{
NvcfApiEndpoint: backend.URL,
PrivateModelNameRegexPattern: "^$",
})
require.NoError(t, err)
return mux
}

func TestBuildChiMux_Info(t *testing.T) {
golibversion.Service = "nvcf-ai-api-gateway-service"
golibversion.Version = "test-1.0.0"
golibversion.GitHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
t.Cleanup(func() {
golibversion.Service = ""
golibversion.Version = ""
golibversion.GitHash = ""
})

mux := newInfoTestMux(t)

w := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/info", nil)
mux.ServeHTTP(w, r)

assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))

var info map[string]string
require.NoError(t, json.Unmarshal(w.Body.Bytes(), &info))
assert.Equal(t, "nvcf-ai-api-gateway-service", info["service"])
assert.Equal(t, "test-1.0.0", info["version"])
assert.Equal(t, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", info["commit"])
}

func TestBuildChiMux_Info_RejectsNonGET(t *testing.T) {
mux := newInfoTestMux(t)

for _, method := range []string{
http.MethodHead,
http.MethodPost,
http.MethodPut,
http.MethodPatch,
http.MethodDelete,
http.MethodOptions,
} {
t.Run(method, func(t *testing.T) {
w := httptest.NewRecorder()
r := httptest.NewRequest(method, "/info", nil)
mux.ServeHTTP(w, r)

assert.Equal(t, http.StatusMethodNotAllowed, w.Code)
assert.Equal(t, http.MethodGet, w.Header().Get("Allow"))
assert.Empty(t, w.Body.String())
})
}
}
43 changes: 22 additions & 21 deletions src/invocation-plane-services/vanity-gateway/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.25.0

require (
github.com/NVIDIA/nvcf-go v1.0.1
github.com/NVIDIA/nvcf/src/libraries/go/lib v0.0.0-20260728185909-afca4ec2fb26
github.com/carlmjohnson/versioninfo v0.22.5
github.com/felixge/httpsnoop v1.0.4
github.com/fsnotify/fsnotify v1.9.0
Expand All @@ -18,27 +19,27 @@ require (
github.com/stretchr/testify v1.11.1
github.com/valyala/bytebufferpool v1.0.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel v1.44.0
go.opentelemetry.io/otel/exporters/prometheus v0.65.0
go.opentelemetry.io/otel/metric v1.43.0
go.opentelemetry.io/otel/sdk v1.43.0
go.opentelemetry.io/otel/sdk/metric v1.43.0
go.opentelemetry.io/otel/trace v1.43.0
go.opentelemetry.io/otel/metric v1.44.0
go.opentelemetry.io/otel/sdk v1.44.0
go.opentelemetry.io/otel/sdk/metric v1.44.0
go.opentelemetry.io/otel/trace v1.44.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792
golang.org/x/net v0.48.0
golang.org/x/sync v0.19.0
google.golang.org/grpc v1.74.2
golang.org/x/net v0.55.0
golang.org/x/sync v0.20.0
google.golang.org/grpc v1.79.3
gopkg.in/yaml.v3 v3.0.1
sigs.k8s.io/controller-runtime v0.21.0
sigs.k8s.io/yaml v1.6.0
)

require (
cloud.google.com/go/compute/metadata v0.7.0 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
github.com/KimMachineGun/automemlimit v0.7.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
Expand All @@ -60,7 +61,7 @@ require (
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -76,7 +77,7 @@ require (
github.com/oklog/run v1.1.0 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pelletier/go-toml/v2 v2.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
Expand All @@ -95,22 +96,22 @@ require (
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.62.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.65.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.37.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.42.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.42.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/term v0.43.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/time v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260209200024-4cfbd4190f57 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
Loading
Loading