Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
39 changes: 8 additions & 31 deletions conformance/conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io/fs"
"os"
"slices"
"testing"

Expand All @@ -41,11 +40,10 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/yaml"

// Import necessary types and utilities from the core Gateway API conformance suite.
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" // Import core Gateway API types
confapis "sigs.k8s.io/gateway-api/conformance/apis/v1" // Report struct definition
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" // Import core Gateway API types
// Report struct definition
confflags "sigs.k8s.io/gateway-api/conformance/utils/flags"
apikubernetes "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
confsuite "sigs.k8s.io/gateway-api/conformance/utils/suite"
Expand All @@ -54,6 +52,7 @@ import (

// Import the test definitions package to access the ConformanceTests slice
"sigs.k8s.io/gateway-api-inference-extension/conformance/tests"
"sigs.k8s.io/gateway-api-inference-extension/pkg/consts"

// Import test packages using blank identifier
// This triggers the init() functions in these packages, which register the tests
Expand Down Expand Up @@ -244,13 +243,11 @@ func RunConformanceWithOptions(t *testing.T, opts confsuite.ConformanceOptions)
t.Log("Generating Inference Extension conformance report")
report, err := cSuite.Report() // Use the existing report generation logic.
require.NoError(t, err, "error generating conformance report")

// TODO: Modify the report struct here if channel, version need to be modified.
// Example (requires adding fields to confapis.ConformanceReport):
// report.GatewayAPIInferenceExtensionChannel = opts.GatewayAPIInferenceExtensionChannel
// report.GatewayAPIInferenceExtensionVersion = opts.GatewayAPIInferenceExtensionVersion

err = writeReport(t.Logf, *report, opts.ReportOutputPath)
inferenceReport := GatewayAPIInferenceExtentionConformanceReport{
GatewayAPIInferenceExtensionVersion: consts.BundleVersion,
ConformanceReport: *report,
}
err = inferenceReport.WriteReport(t.Logf, opts.ReportOutputPath)
require.NoError(t, err, "error writing conformance report")
}
}
Expand Down Expand Up @@ -347,23 +344,3 @@ func ensureGatewayAvailableAndReady(t *testing.T, k8sClient client.Client, opts
require.NoErrorf(t, err, "shared gateway %s/%s did not get an address", gatewayNN.Namespace, gatewayNN.Name)
t.Logf("Shared Gateway %s/%s is ready.", gatewayNN.Namespace, gatewayNN.Name)
}

// writeReport writes the generated conformance report to the specified output file or logs it.
// Adapted from the core Gateway API suite.
func writeReport(logf func(string, ...any), report confapis.ConformanceReport, output string) error {
rawReport, err := yaml.Marshal(report)
if err != nil {
return fmt.Errorf("error marshaling report: %w", err)
}

if output != "" {
if err = os.WriteFile(output, rawReport, 0o600); err != nil {
return fmt.Errorf("error writing report file %s: %w", output, err)
}
logf("Conformance report written to %s", output)
} else {
// Log the report YAML to stdout if no output file is specified.
logf("Conformance report:\n%s", string(rawReport))
}
return nil
}
57 changes: 57 additions & 0 deletions conformance/conformancereport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
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 conformance contains the core setup and execution logic
// for the Gateway API Inference Extension conformance test suite.
package conformance

import (
"fmt"
"os"

confapis "sigs.k8s.io/gateway-api/conformance/apis/v1"
"sigs.k8s.io/yaml"
)

// GatewayAPIInferenceExtentionConformanceReport
// GatewayAPIInferenceExtentionConformanceReport is a report of conformance testing results of
// gateway-api-inference-extention including the specific conformance profiles that were tested
// and the results of the tests with summaries and statistics.
type GatewayAPIInferenceExtentionConformanceReport struct {
// GatewayAPIInferenceExtensionVersion is the version of the gateway-api-inference-extention the tests run against.
GatewayAPIInferenceExtensionVersion string
// ConformanceReport is the fields reused from the gateway-api conformance reports.
confapis.ConformanceReport
}

// WriteReport writes the generated conformance report to the specified output file or logs it.
func (report *GatewayAPIInferenceExtentionConformanceReport) WriteReport(logf func(string, ...any), output string) error {
rawReport, err := yaml.Marshal(*report)
if err != nil {
return fmt.Errorf("error marshaling report: %w", err)
}

if output != "" {
if err = os.WriteFile(output, rawReport, 0o600); err != nil {
return fmt.Errorf("error writing report file %s: %w", output, err)
}
logf("Conformance report written to %s", output)
} else {
// Log the report YAML to stdout if no output file is specified.
logf("Conformance report:\n%s", string(rawReport))
}
return nil
}
6 changes: 4 additions & 2 deletions conformance/reports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ This folder stores conformance reports organized first by the version of the Gat

## Implementation Submissions

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/`).
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/`).

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

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

```
# My Inference Gateway Implementation (Gateway Profile Conformance)

General information about the My/Implementation project.
Expand All @@ -48,6 +49,7 @@ The implementation is the owner of its folder and is responsible for:
## Reproduce

Instructions on how to reproduce the claimed report(s).
```

### Table of Contents (within Implementation README)

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

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`).

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/`).
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/`).
2. Add your implementation's `README.md` to this folder, following the structure described above.
3. Add your generated conformance report YAML file(s) to this folder, ensuring they follow the naming convention `<Implementation Version>-<Mode>-<Profile>-report.yaml`.
4. Submit the Pull Request.
22 changes: 22 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
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 consts
Copy link
Contributor

@nirrozenbaum nirrozenbaum Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared offline with @zetxqx my concern about the name selection consts and it's location under pkg which may become a place where everybody put their non related consts, like a centralized place for putting all constants of the repo which I'm generally against.

we agreed to create a version/version.go at the root level to specify versioning related consts (package version).
for example like this project:
https://github.com/kubernetes/kops/blob/master/kops-version.go

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to this PR, but using version.go will also allow us to define in this file CommitSHA and BuildRef vars which are currently located under /epp/pkg/metrics/metrics.go (I don't see how is it related to metrics.go).

var (
// The git hash of the latest commit in the build.
CommitSHA string
// The build ref from the _PULL_BASE_REF from cloud build trigger.
BuildRef string
)

I will push it in a follow up PR. (cc @kfswain)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! thanks @nirrozenbaum , renamed to version/version.go. Could you take another look?

cc: @robscott

Copy link
Collaborator

@kfswain kfswain Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffLuoo wrote this, I believe, to emit the commitSHA to help give context to any logs emitted (so when debugging, you can look at the specific SHA & know what the codebase looked like at that point in time). I think same with the pull base. I believe that is the fork the build is based on. Jeff to confirm however.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I placed the var in metrics.go for adding the metadata metric related to the IG https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/cmd/epp/runner/runner.go#L245. The metric tells you the build hash and version (usually tag) of the image.

Those two variables are passed in from the Dockerfile in go build here: https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/Dockerfile#L25 where the variables are passed in from:

- GIT_TAG=$_GIT_TAG
- EXTRA_TAG=$_PULL_BASE_REF
- DOCKER_BUILDX_CMD=/buildx-entrypoint
- GIT_COMMIT_SHA=$_PULL_BASE_SHA

PULL_BASE_SHA is a keyword that cloudbuild job will use to set the environment variable, check https://docs.prow.k8s.io/docs/jobs/ for environment variables. I used PULL_BASE_REF and PULL_BASE_SHA.

When you add the change, can you make sure the metric will still have the hash and build tag?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffLuoo sure!
thanks for the detailed response 👍


const (
// BundleVersion is the value used for labeling the version of the gateway-api-inference-extension.
BundleVersion = "v0.5.0"
)