Skip to content

Commit 72bf2d0

Browse files
authored
feat(conformance): add version for conformance test report. (#1133)
* feat(conformance): add version for conformance test report. * add conformance.go update. * remove redundancy. * update release.md * fix typos. * fix typos. * rename to version.go.
1 parent 48966b8 commit 72bf2d0

File tree

5 files changed

+91
-33
lines changed

5 files changed

+91
-33
lines changed

RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
The Kubernetes Template Project is released on an as-needed basis. The process is as follows:
44

5+
1. Update `version/version.go` with the new semver tag
56
1. An issue is proposing a new release with a changelog since the last release
67
1. All [OWNERS](OWNERS) must LGTM this release
78
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`

conformance/conformance.go

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"errors"
2424
"fmt"
2525
"io/fs"
26-
"os"
2726
"slices"
2827
"testing"
2928

@@ -41,11 +40,10 @@ import (
4140
"k8s.io/apimachinery/pkg/util/sets"
4241
"sigs.k8s.io/controller-runtime/pkg/client"
4342
k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
44-
"sigs.k8s.io/yaml"
4543

4644
// Import necessary types and utilities from the core Gateway API conformance suite.
47-
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" // Import core Gateway API types
48-
confapis "sigs.k8s.io/gateway-api/conformance/apis/v1" // Report struct definition
45+
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" // Import core Gateway API types
46+
// Report struct definition
4947
confflags "sigs.k8s.io/gateway-api/conformance/utils/flags"
5048
apikubernetes "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
5149
confsuite "sigs.k8s.io/gateway-api/conformance/utils/suite"
@@ -54,6 +52,7 @@ import (
5452

5553
// Import the test definitions package to access the ConformanceTests slice
5654
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
55+
"sigs.k8s.io/gateway-api-inference-extension/version"
5756

5857
// Import test packages using blank identifier
5958
// This triggers the init() functions in these packages, which register the tests
@@ -244,13 +243,11 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
244243
t.Log("Generating Inference Extension conformance report")
245244
report, err := cSuite.Report() // Use the existing report generation logic.
246245
require.NoError(t, err, "error generating conformance report")
247-
248-
// TODO: Modify the report struct here if channel, version need to be modified.
249-
// Example (requires adding fields to confapis.ConformanceReport):
250-
// report.GatewayAPIInferenceExtensionChannel = opts.GatewayAPIInferenceExtensionChannel
251-
// report.GatewayAPIInferenceExtensionVersion = opts.GatewayAPIInferenceExtensionVersion
252-
253-
err = writeReport(t.Logf, *report, opts.ReportOutputPath)
246+
inferenceReport := GatewayAPIInferenceExtensionConformanceReport{
247+
GatewayAPIInferenceExtensionVersion: version.BundleVersion,
248+
ConformanceReport: *report,
249+
}
250+
err = inferenceReport.WriteReport(t.Logf, opts.ReportOutputPath)
254251
require.NoError(t, err, "error writing conformance report")
255252
}
256253
}
@@ -347,23 +344,3 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
347344
require.NoErrorf(t, err, "shared gateway %s/%s did not get an address", gatewayNN.Namespace, gatewayNN.Name)
348345
t.Logf("Shared Gateway %s/%s is ready.", gatewayNN.Namespace, gatewayNN.Name)
349346
}
350-
351-
// writeReport writes the generated conformance report to the specified output file or logs it.
352-
// Adapted from the core Gateway API suite.
353-
func writeReport(logf func(string, ...any), report confapis.ConformanceReport, output string) error {
354-
rawReport, err := yaml.Marshal(report)
355-
if err != nil {
356-
return fmt.Errorf("error marshaling report: %w", err)
357-
}
358-
359-
if output != "" {
360-
if err = os.WriteFile(output, rawReport, 0o600); err != nil {
361-
return fmt.Errorf("error writing report file %s: %w", output, err)
362-
}
363-
logf("Conformance report written to %s", output)
364-
} else {
365-
// Log the report YAML to stdout if no output file is specified.
366-
logf("Conformance report:\n%s", string(rawReport))
367-
}
368-
return nil
369-
}

conformance/conformancereport.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2025 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 conformance contains the core setup and execution logic
18+
// for the Gateway API Inference Extension conformance test suite.
19+
package conformance
20+
21+
import (
22+
"fmt"
23+
"os"
24+
25+
confapis "sigs.k8s.io/gateway-api/conformance/apis/v1"
26+
"sigs.k8s.io/yaml"
27+
)
28+
29+
// GatewayAPIInferenceExtensionConformanceReport is a report of conformance testing results of
30+
// gateway-api-inference-extension including the specific conformance profiles that were tested
31+
// and the results of the tests with summaries and statistics.
32+
type GatewayAPIInferenceExtensionConformanceReport struct {
33+
// GatewayAPIInferenceExtensionVersion is the version of the gateway-api-inference-extension the tests run against.
34+
GatewayAPIInferenceExtensionVersion string
35+
// ConformanceReport is the fields reused from the gateway-api conformance reports.
36+
confapis.ConformanceReport
37+
}
38+
39+
// WriteReport writes the generated conformance report to the specified output file or logs it.
40+
func (report *GatewayAPIInferenceExtensionConformanceReport) WriteReport(logf func(string, ...any), output string) error {
41+
rawReport, err := yaml.Marshal(*report)
42+
if err != nil {
43+
return fmt.Errorf("error marshaling report: %w", err)
44+
}
45+
46+
if output != "" {
47+
if err = os.WriteFile(output, rawReport, 0o600); err != nil {
48+
return fmt.Errorf("error writing report file %s: %w", output, err)
49+
}
50+
logf("Conformance report written to %s", output)
51+
} else {
52+
// Log the report YAML to stdout if no output file is specified.
53+
logf("Conformance report:\n%s", string(rawReport))
54+
}
55+
return nil
56+
}

conformance/reports/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ This folder stores conformance reports organized first by the version of the Gat
2727

2828
## Implementation Submissions
2929

30-
Each implementation conformant with a specific profile of a specific version of the Gateway API Inference Extension should have its own folder within the corresponding version and profile directory (e.g., `/conformance/reports/v0.3.0/Gateway/my-implementation/`).
30+
Each implementation conformant with a specific profile of a specific version of the Gateway API Inference Extension should have its own folder within the corresponding version and profile directory (e.g., `/conformance/reports/v0.3.0/gateway/my-implementation/`).
3131

3232
The implementation is the owner of its folder and is responsible for:
3333

3434
1. Uploading one or more conformance reports (YAML files).
3535
2. Maintaining a mandatory `README.md` file within their folder, structured as follows:
3636

37+
```
3738
# My Inference Gateway Implementation (Gateway Profile Conformance)
3839
3940
General information about the My/Implementation project.
@@ -48,6 +49,7 @@ The implementation is the owner of its folder and is responsible for:
4849
## Reproduce
4950
5051
Instructions on how to reproduce the claimed report(s).
52+
```
5153

5254
### Table of Contents (within Implementation README)
5355

@@ -89,7 +91,7 @@ To be accepted, submitted conformance reports must comply with the following rul
8991

9092
Conformance reports demonstrating a `success` result for a specific profile (e.g., `Gateway`) should be submitted via Pull Request directly to this repository (`kubernetes-sigs/gateway-api-inference-extension`).
9193

92-
1. Create a new folder structure under `/conformance/reports/<extension-version>/<profile-name>/` named after your implementation (e.g., `/conformance/reports/v0.3.0/Gateway/my-implementation/`).
94+
1. Create a new folder structure under `/conformance/reports/<extension-version>/<profile-name>/` named after your implementation (e.g., `/conformance/reports/v0.3.0/gateway/my-implementation/`).
9395
2. Add your implementation's `README.md` to this folder, following the structure described above.
9496
3. Add your generated conformance report YAML file(s) to this folder, ensuring they follow the naming convention `<Implementation Version>-<Mode>-<Profile>-report.yaml`.
9597
4. Submit the Pull Request.

version/version.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2025 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 version
18+
19+
const (
20+
// BundleVersion is the value used for labeling the version of the gateway-api-inference-extension.
21+
BundleVersion = "v0.4.0-dev"
22+
)

0 commit comments

Comments
 (0)