Skip to content

Commit

Permalink
Merge pull request #1760 from michaelbeaumont/fix/conformance_observe…
Browse files Browse the repository at this point in the history
…d_gen

conformance: use Patch to make ObservedGeneration tests robust against conflicts
  • Loading branch information
k8s-ci-robot authored and shaneutt committed Mar 14, 2023
1 parent 71d7400 commit 09a11ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions conformance/tests/gateway-observed-generation-bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/stretchr/testify/require"
"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"
Expand Down Expand Up @@ -69,8 +70,8 @@ var GatewayObservedGenerationBump = suite.ConformanceTest{
},
})

err = s.Client.Update(ctx, mutate)
require.NoErrorf(t, err, "error updating the Gateway: %v", err)
err = s.Client.Patch(ctx, mutate, client.MergeFrom(original))
require.NoErrorf(t, err, "error patching the Gateway: %v", err)

// Ensure the generation and observedGeneration sync up
kubernetes.NamespacesMustBeAccepted(t, s.Client, s.TimeoutConfig, namespaces)
Expand Down
5 changes: 3 additions & 2 deletions conformance/tests/gatewayclass-observed-generation-bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/stretchr/testify/require"
"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"
Expand Down Expand Up @@ -58,8 +59,8 @@ var GatewayClassObservedGenerationBump = suite.ConformanceTest{
desc := "new"
mutate.Spec.Description = &desc

err = s.Client.Update(ctx, mutate)
require.NoErrorf(t, err, "error updating the GatewayClass: %v", err)
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)
Expand Down
5 changes: 3 additions & 2 deletions conformance/tests/httproute-observed-generation-bump.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
Expand Down Expand Up @@ -65,8 +66,8 @@ var HTTPRouteObservedGenerationBump = suite.ConformanceTest{

mutate := original.DeepCopy()
mutate.Spec.Rules[0].BackendRefs[0].Name = "infra-backend-v2"
err = s.Client.Update(ctx, mutate)
require.NoErrorf(t, err, "error updating the HTTPRoute: %v", err)
err = s.Client.Patch(ctx, mutate, client.MergeFrom(original))
require.NoErrorf(t, err, "error patching the HTTPRoute: %v", err)

kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, routeNN, gwNN, acceptedCondition)

Expand Down

0 comments on commit 09a11ae

Please sign in to comment.