-
Notifications
You must be signed in to change notification settings - Fork 300
test: refactor integration test harness to support data layer testing #2664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a723e4
c258eda
da7ddd1
6e314a2
65aacbf
7ba5b05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Mohamedma96 marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| Copyright 2025 The Kubernetes Authors. | ||
|
|
||
| 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 epp | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| configPb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" | ||
| "github.com/google/go-cmp/cmp" | ||
| "github.com/stretchr/testify/require" | ||
| "google.golang.org/protobuf/testing/protocmp" | ||
|
|
||
| "sigs.k8s.io/gateway-api-inference-extension/test/integration" | ||
| ) | ||
|
|
||
| // TestFullDuplexStreamed_DataLayer runs integration tests through the datalayer metrics pipeline. | ||
| // It mirrors a representative subset of hermetic_test.go test cases but uses the data layer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will we be able to run the rest of the tests using the datalayer once the legacy metrics collection code is removed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, there are common tests that are shared among the legacy metrics collection and datalayer, those common test can be used to run the tests for datalayer, the other tests in harness.go (not common) are suited for the legacy metrics collection and I would drop them when the code is removed. |
||
| // (mock DataSource) instead of the standard FakePodMetricsClient. | ||
| func TestFullDuplexStreamed_DataLayer(t *testing.T) { | ||
| // Datalayer tests always run in standard mode with base resources (priority=2 in InferenceObjectives). | ||
| tests := commonTestCases(func(p int) int { return p }) | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| defer cancel() | ||
|
|
||
| h := NewTestHarness(t, ctx, WithStandardMode(), WithDataLayer()) | ||
| h.WithBaseResources().WithPods(tc.pods).WaitForSync(len(tc.pods), modelMyModel) | ||
| if len(tc.pods) > 0 { | ||
| h.WaitForReadyPodsMetric(len(tc.pods)) | ||
| } | ||
|
|
||
| responses, err := integration.StreamedRequest(t, h.Client, tc.requests, len(tc.wantResponses)) | ||
| require.NoError(t, err) | ||
|
|
||
| if diff := cmp.Diff(tc.wantResponses, responses, | ||
| protocmp.Transform(), | ||
| protocmp.SortRepeated(func(a, b *configPb.HeaderValueOption) bool { | ||
| return a.GetHeader().GetKey() < b.GetHeader().GetKey() | ||
| }), | ||
| ); diff != "" { | ||
| t.Errorf("Response mismatch (-want +got): %v", diff) | ||
| } | ||
|
|
||
| if len(tc.wantMetrics) > 0 { | ||
| h.ExpectMetrics(tc.wantMetrics) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be unavoidable as there is no Unregister, but seems odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no lazy initialization, so this is currently safe, but it is a bit brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it seems odd, yet I find no way to prevents registry pollution between different tests, and right, this assumes that registry map is read only during setup function and not any stage later (which is true for now), so for now this will work.
I can remove the defer delete, since only datalayer tests "know" about the mock-metrics-plugin and in case it's not deleted the tests would just overwrite or re-register the plugin which has no actual difference (re-register with same factory func).
What do you suggest?