Skip to content
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

CI: Updates Makefile and GH Workflow to Support Multiple Gateway API Versions #10390

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .github/workflows/.env/pr-tests/max_versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8sgateway_api_version='v1.2.1'
1 change: 1 addition & 0 deletions .github/workflows/.env/pr-tests/min_versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8sgateway_api_version='v1.1.0'
Copy link
Author

Choose a reason for hiding this comment

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

I initially set this value to v1.0.0 to match .github/workflows/.env/nightly-tests/min_versions.env but the following conformance test consistently failed:

=== RUN   TestConformance/GatewayWithAttachedRoutes/Gateway_listener_should_have_AttachedRoutes_set_even_when_Gateway_has_unresolved_refs
    helpers.go:650: Gateway expected observedGeneration to be updated to 1 for all conditions, only 0/2 were updated. stale conditions are: Accepted (generation 0), Programmed (generation 0)
    helpers.go:655: Conditions matched expectations
    helpers.go:655: Gateway status listeners matched expectations
    helpers.go:681: Accepted condition set to Status True with Reason Accepted, expected Status False
    helpers.go:681: Accepted was not in conditions list [[{ResolvedRefs False 1 2024-12-11 00:21:38 +0000 UTC BackendNotFound Service "does-not-exist" not found} {Accepted True 1 2024-12-11 00:21:38 +0000 UTC Accepted }]]

^ is a test bug that was fixed in kubernetes-sigs/gateway-api@8bd5491 (included in v1.1.0). @sam-heilbron should .github/workflows/.env/nightly-tests/min_versions.env be updated accordingly?

Copy link

Choose a reason for hiding this comment

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

weren't we previously passing conformance on 1.0.0? (before we upgraded to 1.1 / 1.2)

Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Conformance Tests
description: run kubernetes gateway api conformance tests
description: Run Kubernetes Gateway API conformance tests for multiple versions
inputs:
k8sgateway-api-version:
description: The version of the Kubernetes Gateway API CRDs to use for testing
required: true
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -36,6 +40,7 @@ runs:
CLUSTER_NODE_VERSION: ${{ matrix.kube-version.node }}
IMAGE_VARIANT: ${{ matrix.image-variant }}
CONFORMANCE: "true"
CONFORMANCE_VERSION: ${{ inputs.k8sgateway-api-version }}
run: ./ci/kind/setup-kind.sh
- name: Install Gloo Gateway with the k8s gateway integration enabled
shell: bash
Expand All @@ -54,6 +59,8 @@ runs:
- name: Run the kubernetes gateway API conformance tests
shell: bash
run: make conformance
env:
CONFORMANCE_VERSION: ${{ inputs.k8sgateway-api-version }}
- name: Capture debug information when tests fail
if: ${{ failure() }}
shell: bash
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/conformance-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,27 @@ jobs:
- ${{ inputs.image-variant }}
version:
- ${{ inputs.version }}
version-files:

Choose a reason for hiding this comment

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

This is a shift in behavior. Previously, we ran min/max versions on an async schedule (ie not on PRs) and it seems we are shifting that to run this on PRs. This isn't bad per se, I just wanted to call it out. What are we trying to achieve by running min/max on PRs, that running these nightly did not achieve? Or, if we didn't run the min/max for conformance tests nightly, perhaps we should do that instead?

- label: 'min'
file: './.github/workflows/.env/pr-tests/min_versions.env'
- label: 'max'
file: './.github/workflows/.env/pr-tests/max_versions.env'
steps:
# Checkout the branch that initiated the action
- name: Checkout Repository
uses: actions/checkout@v4

# The dotenv action is used to load key-value pairs from files.
# In this case, the file is specified in the matrix and will contain the versions of the tools to use
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: ${{ matrix.version-files.file }}
log-variables: true
# Run the k8s gateway api conformance tests
- name: Run Conformance Tests
uses: ./.github/workflows/composite-actions/kube-gateway-api-conformance-tests

with:
k8sgateway-api-version: ${{ steps.dotenv.outputs.k8sgateway_api_version }}
# TODO(tim): Add support for downloading the test results and creating
# a pull request whenever a new release > 1.17+ is cut.
17 changes: 16 additions & 1 deletion .github/workflows/nightly-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,15 @@ jobs:
- uses: actions/checkout@v4
with:
ref: main
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: ${{ matrix.version-files.file }}

Choose a reason for hiding this comment

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

Looks like the matrix (line 484) does not have version-files defined and is getting its versions from the inline kube-version array. I think k8sgateway_api_version can get added to the nightly env files and then those files can be used here.

log-variables: true
- uses: ./.github/workflows/composite-actions/kube-gateway-api-conformance-tests
with:
k8sgateway-api-version: ${{ steps.dotenv.outputs.k8sgateway_api_version }}

kube_gateway_api_conformance_tests_18:
name: Conformance (branch=v1.18.x, type=Kubernetes Gateway API, version=${{matrix.kube-version.node}} )
Expand All @@ -507,8 +515,15 @@ jobs:
- uses: actions/checkout@v4
with:
ref: v1.18.x
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: ${{ matrix.version-files.file }}

Choose a reason for hiding this comment

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

Same comment as above (version-files not defined in matrix).

Also, this won't work until the env files are backported to 1.18.x

log-variables: true
- uses: ./.github/workflows/composite-actions/kube-gateway-api-conformance-tests

with:
k8sgateway-api-version: ${{ steps.dotenv.outputs.k8sgateway_api_version }}

kube_gateway_api_conformance_tests_17:
name: Conformance (branch=v1.17.x, type=Kubernetes Gateway API, version=${{matrix.kube-version.node}} )
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/regression-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,29 @@ jobs:
# (see https://github.com/solo-io/solo-projects/issues/6094)
image-variant:
- standard
version-files:
- label: 'min'
file: './.github/workflows/.env/pr-tests/min_versions.env'
- label: 'max'
file: './.github/workflows/.env/pr-tests/max_versions.env'

Choose a reason for hiding this comment

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

Can we move the kube-version versions into the env file as well so we don't mix ways of tracking versions? I wouldn't be opposed to re-using the nightly env files, though renaming the files to be more accurate would be tricky.

steps:
# Checkout the branch that initiated the action
- uses: actions/checkout@v4
- id: auto-succeed-tests
if: needs.prepare_env.outputs.should-auto-succeed-regression-tests == 'true'
run: |
echo "Kubernetes Gateway API conformance tests auto-succeeded"
# The dotenv action is used to load key-value pairs from files.
# In this case, the file is specified in the matrix and will contain the versions of the tools to use
- name: Dotenv Action
uses: falti/[email protected]
id: dotenv
with:
path: ${{ matrix.version-files.file }}
log-variables: true
# Run the k8s gateway api conformance tests
- id: run-tests
if: needs.prepare_env.outputs.should-auto-succeed-regression-tests != 'true'
uses: ./.github/workflows/composite-actions/kube-gateway-api-conformance-tests
with:
k8sgateway-api-version: ${{ steps.dotenv.outputs.k8sgateway_api_version }}
50 changes: 36 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ GOLANG_ALPINE_IMAGE_NAME = golang:$(shell go version | egrep -o '([0-9]+\.[0-9]+

TEST_ASSET_DIR ?= $(ROOTDIR)/_test

# Directory to store downloaded conformance tests for different versions
CONFORMANCE_DIR ?= $(TEST_ASSET_DIR)/conformance
# Gateway API version used for conformance testing
CONFORMANCE_VERSION ?= v1.2.0
# Fetch the module directory for the specified version of the Gateway API
GATEWAY_API_MODULE_DIR := $(shell go mod download -json sigs.k8s.io/gateway-api@$(CONFORMANCE_VERSION) | jq -r '.Dir')

# This is the location where assets are placed after a test failure
# This is used by our e2e tests to emit information about the running instance of Gloo Gateway
BUG_REPORT_DIR := $(TEST_ASSET_DIR)/bug_report
Expand Down Expand Up @@ -349,6 +356,7 @@ clean:
rm -rf docs/site*
rm -rf docs/themes
rm -rf docs/resources
rm -rf $(CONFORMANCE_DIR)
git clean -f -X install

.PHONY: clean-tests
Expand Down Expand Up @@ -1235,26 +1243,40 @@ build-test-chart: ## Build the Helm chart and place it in the _test directory
# Targets for running Kubernetes Gateway API conformance tests
#----------------------------------------------------------------------------------

# Pull the conformance test suite from the k8s gateway api repo and copy it into the test dir.
$(TEST_ASSET_DIR)/conformance/conformance_test.go:
mkdir -p $(TEST_ASSET_DIR)/conformance
echo "//go:build conformance" > $@
cat $(shell go list -json -m sigs.k8s.io/gateway-api | jq -r '.Dir')/conformance/conformance_test.go >> $@
go fmt $@
# Download and prepare the conformance test suite for a specific Gateway API version
$(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/conformance_test.go:
mkdir -p $(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)
go mod download sigs.k8s.io/gateway-api@$(CONFORMANCE_VERSION)
cp $(GATEWAY_API_MODULE_DIR)/conformance/conformance_test.go $@

# Install the correct version of Gateway API CRDs in the Kubernetes cluster
install-crds:
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/$(CONFORMANCE_VERSION)/experimental-install.yaml

# Update go.mod to replace Gateway API module with the version used for conformance testing
update-mod:
go mod edit -replace=sigs.k8s.io/gateway-api=$(GATEWAY_API_MODULE_DIR)

# Reset go.mod to remove the replace directive for Gateway API conformance testing
reset-mod:
go mod edit -dropreplace=sigs.k8s.io/gateway-api
go mod tidy

# Common arguments for conformance testing
CONFORMANCE_SUPPORTED_FEATURES ?= -supported-features=Gateway,ReferenceGrant,HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRouteResponseHeaderModification,HTTPRoutePortRedirect,HTTPRouteHostRewrite,HTTPRouteSchemeRedirect,HTTPRoutePathRedirect,HTTPRouteHostRewrite,HTTPRoutePathRewrite,HTTPRouteRequestMirror
CONFORMANCE_SUPPORTED_PROFILES ?= -conformance-profiles=GATEWAY-HTTP
CONFORMANCE_REPORT_ARGS ?= -report-output=$(TEST_ASSET_DIR)/conformance/$(VERSION)-report.yaml -organization=solo.io -project=gloo-gateway -version=$(VERSION) -url=github.com/solo-io/gloo -contact=github.com/solo-io/gloo/issues/new/choose
CONFORMANCE_REPORT_ARGS ?= -report-output=$(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/$(VERSION)-report.yaml -organization=solo.io -project=gloo-gateway -version=$(VERSION) -url=github.com/solo-io/gloo -contact=github.com/solo-io/gloo/issues/new/choose
CONFORMANCE_ARGS := -gateway-class=gloo-gateway $(CONFORMANCE_SUPPORTED_FEATURES) $(CONFORMANCE_SUPPORTED_PROFILES) $(CONFORMANCE_REPORT_ARGS)

.PHONY: conformance ## Run the conformance test suite
conformance: $(TEST_ASSET_DIR)/conformance/conformance_test.go
go test -mod=mod -ldflags=$(LDFLAGS) -tags conformance -test.v $(TEST_ASSET_DIR)/conformance/... -args $(CONFORMANCE_ARGS)
# Run conformance tests for the specified Gateway API version
.PHONY: conformance
conformance: $(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/conformance_test.go install-crds update-mod
@trap "make reset-mod" EXIT; \
go test -mod=mod -ldflags=$(LDFLAGS) -tags conformance -test.v $(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/... -args $(CONFORMANCE_ARGS)

# Run only the specified conformance test. The name must correspond to the ShortName of one of the k8s gateway api
# conformance tests.
conformance-%: $(TEST_ASSET_DIR)/conformance/conformance_test.go
go test -mod=mod -ldflags=$(LDFLAGS) -tags conformance -test.v $(TEST_ASSET_DIR)/conformance/... -args $(CONFORMANCE_ARGS) \
.PHONY: conformance-% ## Run the conformance test suite
conformance-%: $(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/conformance_test.go
go test -mod=mod -ldflags=$(LDFLAGS) -tags conformance -test.v $(CONFORMANCE_DIR)/$(CONFORMANCE_VERSION)/... -args $(CONFORMANCE_ARGS) \
-run-test=$*

#----------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions changelog/v1.19.0-beta3/issue_10359.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/k8sgateway/k8sgateway/issues/10359
resolvesIssue: true
description: >-
Updates the Makefile and conformance GitHub action to support multiple Gateway API versions.