Skip to content

Commit 6c68f73

Browse files
committed
Centralize container image references in e2e tests
Create a dedicated package for container image constants used across e2e tests to provide a single source of truth for image versions. Each image is now defined with three constants: - imageURL: base image path (unexported) - imageTag: version tag (unexported) - Image: combined reference (exported) This structure makes version updates simpler by allowing changes to only the tag constant while keeping the base URL unchanged. Updated test files: - test/e2e/telemetry_metrics_validation_e2e_test.go - test/e2e/thv-operator/virtualmcp/helpers.go - test/e2e/thv-operator/virtualmcp/virtualmcp_discovered_mode_test.go - test/e2e/thv-operator/virtualmcp/virtualmcp_inline_auth_test.go - test/e2e/thv-operator/virtualmcp/virtualmcp_tokenexchange_test.go Fixes #2786 Signed-off-by: 4t8dd <[email protected]>
1 parent cb8a1df commit 6c68f73

File tree

6 files changed

+56
-9
lines changed

6 files changed

+56
-9
lines changed

test/e2e/images/images.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Package images provides centralized container image references for e2e tests.
2+
// This package serves as a single source of truth for all container images used
3+
// in end-to-end testing, making it easier to maintain versions and enabling
4+
// automated dependency updates through tools like Renovate.
5+
//
6+
// Each image is composed of an imageURL (base path) and imageTag (version).
7+
// The complete Image constant combines the URL and tag for use in tests.
8+
package images
9+
10+
const (
11+
yardstickServerImageURL = "ghcr.io/stackloklabs/yardstick/yardstick-server"
12+
yardstickServerImageTag = "0.0.2"
13+
// YardstickServerImage is used in operator tests across multiple transport protocols
14+
// (stdio, SSE, streamable-http) and tenancy modes.
15+
// Note: This image is also referenced in 8 YAML fixture files under
16+
// test/e2e/chainsaw/operator/. Those files are declarative Kubernetes manifests
17+
// and cannot import Go constants directly.
18+
YardstickServerImage = yardstickServerImageURL + ":" + yardstickServerImageTag
19+
20+
gofetchServerImageURL = "ghcr.io/stackloklabs/gofetch/server"
21+
gofetchServerImageTag = "1.0.1"
22+
// GofetchServerImage is used for testing virtual MCP server features, including
23+
// authentication flows and backend aggregation.
24+
GofetchServerImage = gofetchServerImageURL + ":" + gofetchServerImageTag
25+
26+
osvmcpServerImageURL = "ghcr.io/stackloklabs/osv-mcp/server"
27+
osvmcpServerImageTag = "0.0.7"
28+
// OSVMCPServerImage is used for testing discovered mode aggregation and telemetry
29+
// metrics validation.
30+
OSVMCPServerImage = osvmcpServerImageURL + ":" + osvmcpServerImageTag
31+
32+
pythonImageURL = "python"
33+
pythonImageTag = "3.9-slim"
34+
// PythonImage is used for deploying mock OIDC servers and instrumented backend servers
35+
// in Kubernetes tests. These run Flask-based Python services for testing authentication flows.
36+
PythonImage = pythonImageURL + ":" + pythonImageTag
37+
38+
curlImageURL = "curlimages/curl"
39+
curlImageTag = "latest"
40+
// CurlImage is used to query service endpoints and gather statistics during Kubernetes tests.
41+
CurlImage = curlImageURL + ":" + curlImageTag
42+
)

test/e2e/telemetry_metrics_validation_e2e_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616

1717
"github.com/stacklok/toolhive/pkg/transport/types"
1818
"github.com/stacklok/toolhive/test/e2e"
19+
"github.com/stacklok/toolhive/test/e2e/images"
1920
)
2021

2122
var _ = Describe("Telemetry Metrics Validation E2E", Label("telemetry", "metrics", "validation", "e2e"), Serial, func() {
@@ -88,7 +89,7 @@ var _ = Describe("Telemetry Metrics Validation E2E", Label("telemetry", "metrics
8889
"--transport", types.TransportTypeSSE.String(),
8990
"--otel-enable-prometheus-metrics-path",
9091
"--name", inferredName, // Still need explicit name for cleanup
91-
"ghcr.io/stackloklabs/osv-mcp/server:0.0.7",
92+
images.OSVMCPServerImage,
9293
).ExpectSuccess()
9394

9495
// Update workloadName for cleanup

test/e2e/thv-operator/virtualmcp/helpers.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"sigs.k8s.io/controller-runtime/pkg/client"
2222

2323
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
24+
"github.com/stacklok/toolhive/test/e2e/images"
2425
)
2526

2627
// WaitForVirtualMCPServerReady waits for a VirtualMCPServer to reach Ready status
@@ -294,7 +295,7 @@ func DeployMockOIDCServerHTTP(ctx context.Context, c client.Client, namespace, s
294295
Containers: []corev1.Container{
295296
{
296297
Name: "mock-oidc",
297-
Image: "python:3.9-slim",
298+
Image: images.PythonImage,
298299
Command: []string{"sh", "-c"},
299300
Args: []string{MockOIDCServerHTTPScript},
300301
Ports: []corev1.ContainerPort{
@@ -353,7 +354,7 @@ func DeployInstrumentedBackendServer(ctx context.Context, c client.Client, names
353354
Containers: []corev1.Container{
354355
{
355356
Name: "instrumented-backend",
356-
Image: "python:3.9-slim",
357+
Image: images.PythonImage,
357358
Command: []string{"sh", "-c"},
358359
Args: []string{InstrumentedBackendScript},
359360
Ports: []corev1.ContainerPort{
@@ -452,7 +453,7 @@ func GetServiceStats(ctx context.Context, c client.Client, namespace, serviceNam
452453
Containers: []corev1.Container{
453454
{
454455
Name: "curl",
455-
Image: "curlimages/curl:latest",
456+
Image: images.CurlImage,
456457
Command: []string{"curl", "-s", fmt.Sprintf("http://%s.%s.svc.cluster.local:%d/stats", serviceName, namespace, port)},
457458
},
458459
},

test/e2e/thv-operator/virtualmcp/virtualmcp_discovered_mode_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"k8s.io/apimachinery/pkg/types"
1717

1818
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
19+
"github.com/stacklok/toolhive/test/e2e/images"
1920
)
2021

2122
var _ = Describe("VirtualMCPServer Discovered Mode", Ordered, func() {
@@ -67,7 +68,7 @@ var _ = Describe("VirtualMCPServer Discovered Mode", Ordered, func() {
6768
},
6869
Spec: mcpv1alpha1.MCPServerSpec{
6970
GroupRef: mcpGroupName,
70-
Image: "ghcr.io/stackloklabs/gofetch/server:1.0.1",
71+
Image: images.GofetchServerImage,
7172
Transport: "streamable-http",
7273
ProxyPort: 8080,
7374
McpPort: 8080,
@@ -83,7 +84,7 @@ var _ = Describe("VirtualMCPServer Discovered Mode", Ordered, func() {
8384
},
8485
Spec: mcpv1alpha1.MCPServerSpec{
8586
GroupRef: mcpGroupName,
86-
Image: "ghcr.io/stackloklabs/osv-mcp/server:0.0.7",
87+
Image: images.OSVMCPServerImage,
8788
Transport: "streamable-http",
8889
ProxyPort: 8080,
8990
McpPort: 8080,

test/e2e/thv-operator/virtualmcp/virtualmcp_inline_auth_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"k8s.io/apimachinery/pkg/types"
1616

1717
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
18+
"github.com/stacklok/toolhive/test/e2e/images"
1819
)
1920

2021
var _ = Describe("VirtualMCPServer Inline Auth with Anonymous Incoming", Ordered, func() {
@@ -65,7 +66,7 @@ var _ = Describe("VirtualMCPServer Inline Auth with Anonymous Incoming", Ordered
6566
},
6667
Spec: mcpv1alpha1.MCPServerSpec{
6768
GroupRef: mcpGroupName,
68-
Image: "ghcr.io/stackloklabs/gofetch/server:1.0.1",
69+
Image: images.GofetchServerImage,
6970
Transport: "streamable-http",
7071
ProxyPort: 8080,
7172
McpPort: 8080,
@@ -285,7 +286,7 @@ var _ = Describe("VirtualMCPServer Inline Auth with OIDC Incoming", Ordered, fun
285286
},
286287
Spec: mcpv1alpha1.MCPServerSpec{
287288
GroupRef: mcpGroupName,
288-
Image: "ghcr.io/stackloklabs/gofetch/server:1.0.1",
289+
Image: images.GofetchServerImage,
289290
Transport: "streamable-http",
290291
ProxyPort: 8080,
291292
McpPort: 8080,

test/e2e/thv-operator/virtualmcp/virtualmcp_tokenexchange_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/types"
1515

1616
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
17+
"github.com/stacklok/toolhive/test/e2e/images"
1718
)
1819

1920
var _ = Describe("VirtualMCPServer Token Exchange Auth", Ordered, func() {
@@ -110,7 +111,7 @@ var _ = Describe("VirtualMCPServer Token Exchange Auth", Ordered, func() {
110111
},
111112
Spec: mcpv1alpha1.MCPServerSpec{
112113
GroupRef: mcpGroupName,
113-
Image: "ghcr.io/stackloklabs/gofetch/server:1.0.1",
114+
Image: images.GofetchServerImage,
114115
Transport: "streamable-http",
115116
ProxyPort: 8080,
116117
McpPort: 8080,

0 commit comments

Comments
 (0)