-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tharsanan1
committed
Feb 16, 2024
1 parent
13acd4a
commit 8e426bd
Showing
3 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
test/integration/integration/tests/gatewayclass-status-and-observed-generation-bump-test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* 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 ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/wso2/apk/test/integration/integration/utils/suite" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/gateway-api/apis/v1beta1" | ||
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes" | ||
) | ||
|
||
func init() { | ||
IntegrationTests = append(IntegrationTests, GatewayClassObservedGenerationBump) | ||
} | ||
|
||
var GatewayClassObservedGenerationBump = suite.IntegrationTest{ | ||
ShortName: "GatewayClassObservedGenerationBump", | ||
Description: "A GatewayClass should update the observedGeneration in all of it's Status.Conditions after an update to the spec", | ||
Manifests: []string{"tests/gatewayclass-observed-generation-bump.yaml"}, | ||
Test: func(t *testing.T, s *suite.IntegrationTestSuite) { | ||
gwc := types.NamespacedName{Name: "gatewayclass-observed-generation-bump"} | ||
|
||
t.Run("observedGeneration should increment", func(t *testing.T) { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) | ||
defer cancel() | ||
|
||
kubernetes.GWCMustHaveAcceptedConditionAny(t, s.Client, s.TimeoutConfig, gwc.Name) | ||
|
||
original := &v1beta1.GatewayClass{} | ||
err := s.Client.Get(ctx, gwc, original) | ||
require.NoErrorf(t, err, "error getting GatewayClass: %v", err) | ||
|
||
// Sanity check | ||
kubernetes.GatewayClassMustHaveLatestConditions(t, original) | ||
|
||
mutate := original.DeepCopy() | ||
desc := "new" | ||
mutate.Spec.Description = &desc | ||
|
||
err = s.Client.Patch(ctx, mutate, client.MergeFrom(original)) | ||
require.NoErrorf(t, err, "error patching the GatewayClass: %v", err) | ||
|
||
// Ensure the generation and observedGeneration sync up | ||
kubernetes.GWCMustHaveAcceptedConditionAny(t, s.Client, s.TimeoutConfig, gwc.Name) | ||
|
||
updated := &v1beta1.GatewayClass{} | ||
err = s.Client.Get(ctx, gwc, updated) | ||
require.NoErrorf(t, err, "error getting GatewayClass: %v", err) | ||
|
||
// Sanity check | ||
kubernetes.GatewayClassMustHaveLatestConditions(t, updated) | ||
|
||
require.NotEqual(t, original.Generation, updated.Generation, "generation should change after an update") | ||
}) | ||
}, | ||
} |
22 changes: 22 additions & 0 deletions
22
.../integration/integration/tests/resources/tests/gatewayclass-observed-generation-bump.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. | ||
# | ||
# WSO2 LLC. licenses this file to you 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.apiVersion: gateway.networking.k8s.io/v1beta1 | ||
|
||
kind: GatewayClass | ||
metadata: | ||
name: gatewayclass-observed-generation-bump | ||
spec: | ||
controllerName: "wso2.com/apk-gateway-default" | ||
description: "oldpppp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters