Skip to content

Commit f78d101

Browse files
committed
cleanup: remove _test suffix
Renames harness and utility files (e.g., harness_test.go -> harness.go) within the EPP integration test suite to align with project conventions. Additionally moves shared global variables (k8sClient, testEnv) to harness.go to ensure visibility for the renamed files, resolving compiler scope issues that arise when separating test logic from infrastructure code.
1 parent 09b77c2 commit f78d101

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,21 @@ import (
2727
"github.com/google/uuid"
2828
"github.com/stretchr/testify/assert"
2929
"github.com/stretchr/testify/require"
30+
"go.uber.org/zap/zapcore"
3031
"google.golang.org/grpc"
3132
corev1 "k8s.io/api/core/v1"
3233
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
35+
"k8s.io/apimachinery/pkg/runtime"
3336
"k8s.io/apimachinery/pkg/runtime/schema"
3437
"k8s.io/apimachinery/pkg/types"
3538
metricsutils "k8s.io/component-base/metrics/testutil"
3639
ctrl "sigs.k8s.io/controller-runtime"
3740
"sigs.k8s.io/controller-runtime/pkg/cache"
41+
"sigs.k8s.io/controller-runtime/pkg/client"
3842
crconfig "sigs.k8s.io/controller-runtime/pkg/config"
43+
"sigs.k8s.io/controller-runtime/pkg/envtest"
44+
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3945
crmetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
4046
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4147

@@ -53,10 +59,22 @@ import (
5359
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/profile"
5460
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/scorer"
5561
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/server"
62+
logutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
5663
epptestutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/testing"
5764
"sigs.k8s.io/gateway-api-inference-extension/test/integration"
5865
)
5966

67+
// Global State (Initialized in TestMain)
68+
var (
69+
k8sClient client.Client
70+
testEnv *envtest.Environment
71+
testScheme = runtime.NewScheme()
72+
logger = zap.New(zap.UseDevMode(true), zap.Level(zapcore.Level(logutil.DEFAULT)))
73+
baseResources []*unstructured.Unstructured
74+
)
75+
76+
const testPoolName = "vllm-llama3-8b-instruct-pool"
77+
6078
// TestHarness encapsulates the environment for a single isolated EPP test run.
6179
// It manages the lifecycle of the controller manager, the EPP server, and the K8s namespace.
6280
type TestHarness struct {

test/integration/epp/hermetic_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,24 @@ import (
3030
envoyTypePb "github.com/envoyproxy/go-control-plane/envoy/type/v3"
3131
"github.com/google/go-cmp/cmp"
3232
"github.com/stretchr/testify/require"
33-
"go.uber.org/zap/zapcore"
3433
"google.golang.org/protobuf/testing/protocmp"
3534
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
36-
"k8s.io/apimachinery/pkg/runtime"
3735
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3836
"k8s.io/apimachinery/pkg/util/yaml"
3937
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
4038
ctrl "sigs.k8s.io/controller-runtime"
4139
"sigs.k8s.io/controller-runtime/pkg/client"
4240
"sigs.k8s.io/controller-runtime/pkg/envtest"
43-
"sigs.k8s.io/controller-runtime/pkg/log/zap"
4441

4542
v1 "sigs.k8s.io/gateway-api-inference-extension/api/v1"
4643
"sigs.k8s.io/gateway-api-inference-extension/apix/v1alpha2"
4744
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metadata"
4845
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metrics"
49-
logutil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/logging"
5046
requtil "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/request"
5147
"sigs.k8s.io/gateway-api-inference-extension/test/integration"
5248
)
5349

5450
const (
55-
testPoolName = "vllm-llama3-8b-instruct-pool"
5651
modelMyModel = "my-model"
5752
modelMyModelTarget = "my-model-12345"
5853
modelSQLLora = "sql-lora"
@@ -64,15 +59,6 @@ const (
6459
modelAfterRewrite = "rewritten-model"
6560
)
6661

67-
// Global State (Initialized in TestMain)
68-
var (
69-
k8sClient client.Client
70-
testEnv *envtest.Environment
71-
testScheme = runtime.NewScheme()
72-
logger = zap.New(zap.UseDevMode(true), zap.Level(zapcore.Level(logutil.DEFAULT)))
73-
baseResources []*unstructured.Unstructured
74-
)
75-
7662
func TestMain(m *testing.M) {
7763
ctrl.SetLogger(logger)
7864

@@ -446,17 +432,3 @@ func loadBaseResources() []*unstructured.Unstructured {
446432
}
447433
return objs
448434
}
449-
450-
// cleanMetric removes indentation from multiline metric strings and ensures a trailing newline exists, which is
451-
// required by the Prometheus text parser.
452-
func cleanMetric(s string) string {
453-
lines := strings.Split(s, "\n")
454-
var cleaned []string
455-
for _, l := range lines {
456-
trimmed := strings.TrimSpace(l)
457-
if trimmed != "" {
458-
cleaned = append(cleaned, trimmed)
459-
}
460-
}
461-
return strings.Join(cleaned, "\n") + "\n"
462-
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,17 @@ func metricReadyPods(count int) string {
180180
inference_pool_ready_pods{%s} %d
181181
`, labelsToString([]label{{"name", testPoolName}}), count)
182182
}
183+
184+
// cleanMetric removes indentation from multiline metric strings and ensures a trailing newline exists, which is
185+
// required by the Prometheus text parser.
186+
func cleanMetric(s string) string {
187+
lines := strings.Split(s, "\n")
188+
var cleaned []string
189+
for _, l := range lines {
190+
trimmed := strings.TrimSpace(l)
191+
if trimmed != "" {
192+
cleaned = append(cleaned, trimmed)
193+
}
194+
}
195+
return strings.Join(cleaned, "\n") + "\n"
196+
}

0 commit comments

Comments
 (0)