From d8269aa5f0d438ca1e8eebe5d75a40ec973e39e5 Mon Sep 17 00:00:00 2001 From: dprotaso Date: Tue, 5 Mar 2024 17:05:16 -0500 Subject: [PATCH 1/3] conformance: Gateway Infrastructure Metadata Include a conformance test and create a feature for this experimental functionality --- .../tests/gateway-infrastructure-metadata.go | 68 +++++++++++++++++++ .../gateway-infrastructure-metadata.yaml | 17 +++++ pkg/features/features.go | 18 +++++ 3 files changed, 103 insertions(+) create mode 100644 conformance/tests/gateway-infrastructure-metadata.go create mode 100644 conformance/tests/gateway-infrastructure-metadata.yaml diff --git a/conformance/tests/gateway-infrastructure-metadata.go b/conformance/tests/gateway-infrastructure-metadata.go new file mode 100644 index 0000000000..d39ef1ae1e --- /dev/null +++ b/conformance/tests/gateway-infrastructure-metadata.go @@ -0,0 +1,68 @@ +/* +Copyright 2023 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 tests + +import ( + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" + "sigs.k8s.io/gateway-api/conformance/utils/suite" +) + +func init() { + ConformanceTests = append(ConformanceTests, GatewayInfraMetadata) +} + +var GatewayInfraMetadata = suite.ConformanceTest{ + ShortName: "GatewayInfraMetadata", + Description: "A Gateway should accept infrastructure metadata", + Features: []suite.SupportedFeature{ + suite.SupportGateway, + suite.SupportGatewayInfrastructureMetadata, + }, + Manifests: []string{ + "tests/gateway-infrastructure-metadata.yaml", + }, + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + gwNN := types.NamespacedName{ + Name: "gateway-infra-metadata", + Namespace: "gateway-conformance-infra", + } + + conditions := []metav1.Condition{ + { + Type: string(gatewayv1.GatewayConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }, + { + Type: string(gatewayv1.GatewayConditionProgrammed), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }, + } + + kubernetes.GatewayMustHaveLatestConditions(t, suite.Client, suite.TimeoutConfig, gwNN) + for _, condition := range conditions { + kubernetes.GatewayMustHaveCondition(t, suite.Client, suite.TimeoutConfig, gwNN, condition) + } + }, +} diff --git a/conformance/tests/gateway-infrastructure-metadata.yaml b/conformance/tests/gateway-infrastructure-metadata.yaml new file mode 100644 index 0000000000..e853e11c3b --- /dev/null +++ b/conformance/tests/gateway-infrastructure-metadata.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: gateway-infra-metadata + namespace: gateway-conformance-infra +spec: + gatewayClassName: "{GATEWAY_CLASS_NAME}" + infrastructure: + labels: + label-key: label-value + annotations: + annotation-key: annotation-value + listeners: + - name: http + port: 8080 + protocol: HTTP diff --git a/pkg/features/features.go b/pkg/features/features.go index fcb6d28019..123f440917 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -63,6 +63,23 @@ var GatewayExtendedFeatures = sets.New( SupportGatewayStaticAddresses, ) +// ----------------------------------------------------------------------------- +// Features - Gateway Conformance (Experimental) +// ----------------------------------------------------------------------------- + +const ( + // SupportGatewayInfrastructureMetadata option indicates that the Gateway is capable + // having annotations and labels which are propagated to underlying resources + SupportGatewayInfrastructureMetadata SupportedFeature = "GatewayInfrastructureMetadata" +) + +// GatewayExperimentalFeatures includes all the supported experimental features, currently only +// available in our experimental release channel. +// Implementations have the flexibility to opt-in for either specific features or the entire set. +var GatewayExperimentalFeatures = sets.New( + SupportGatewayInfrastructureMetadata, +) + // ----------------------------------------------------------------------------- // Features - ReferenceGrant Conformance (Core) // ----------------------------------------------------------------------------- @@ -255,6 +272,7 @@ var GRPCRouteCoreFeatures = sets.New( // NOTE: as new feature sets are added they should be inserted into this set. var AllFeatures = sets.New[SupportedFeature](). Insert(GatewayCoreFeatures.UnsortedList()...). + Insert(GatewayExperimentalFeatures.UnsortedList()...). Insert(GatewayExtendedFeatures.UnsortedList()...). Insert(ReferenceGrantCoreFeatures.UnsortedList()...). Insert(HTTPRouteCoreFeatures.UnsortedList()...). From d2cd2ee36d57c6c86ad9de0296fa67473ed7e9b8 Mon Sep 17 00:00:00 2001 From: dprotaso Date: Tue, 5 Mar 2024 17:11:09 -0500 Subject: [PATCH 2/3] fix copyright year --- conformance/tests/gateway-infrastructure-metadata.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/tests/gateway-infrastructure-metadata.go b/conformance/tests/gateway-infrastructure-metadata.go index d39ef1ae1e..69751db225 100644 --- a/conformance/tests/gateway-infrastructure-metadata.go +++ b/conformance/tests/gateway-infrastructure-metadata.go @@ -1,5 +1,5 @@ /* -Copyright 2023 The Kubernetes Authors. +Copyright 2024 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. From 386f2bf34c874763266aac7962ba69176e73177b Mon Sep 17 00:00:00 2001 From: dprotaso Date: Wed, 17 Apr 2024 20:32:51 -0400 Subject: [PATCH 3/3] rebase --- conformance/tests/gateway-infrastructure-metadata.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conformance/tests/gateway-infrastructure-metadata.go b/conformance/tests/gateway-infrastructure-metadata.go index 69751db225..ecd950edda 100644 --- a/conformance/tests/gateway-infrastructure-metadata.go +++ b/conformance/tests/gateway-infrastructure-metadata.go @@ -25,6 +25,7 @@ import ( gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/pkg/features" ) func init() { @@ -34,9 +35,9 @@ func init() { var GatewayInfraMetadata = suite.ConformanceTest{ ShortName: "GatewayInfraMetadata", Description: "A Gateway should accept infrastructure metadata", - Features: []suite.SupportedFeature{ - suite.SupportGateway, - suite.SupportGatewayInfrastructureMetadata, + Features: []features.SupportedFeature{ + features.SupportGateway, + features.SupportGatewayInfrastructureMetadata, }, Manifests: []string{ "tests/gateway-infrastructure-metadata.yaml",