Skip to content

Commit

Permalink
fix(conformance): fix panic for make test.conformance (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer04 authored May 17, 2024
1 parent 1e5ac3f commit 7c90169
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion controller/gateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}
// If the Gateway is not accepted, do not move on in the reconciliation logic.
if acceptedCondition.Status == metav1.ConditionFalse {
// TODO: clean up Dataplane and Controlplane https://github.com/Kong/gateway-operator/issues/1511
// TODO: clean up Dataplane and Controlplane https://github.com/Kong/gateway-operator/issues/126
return ctrl.Result{}, nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/utils/test/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
"github.com/kong/kubernetes-testing-framework/pkg/environments"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
kubernetesclient "k8s.io/client-go/kubernetes"
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -40,6 +41,10 @@ func NewK8sClients(env environments.Environment) (K8sClients, error) {
if err != nil {
return clients, err
}

if err := apiextensionsv1.AddToScheme(clients.MgrClient.Scheme()); err != nil {
return clients, err
}
if err := gatewayv1.Install(clients.MgrClient.Scheme()); err != nil {
return clients, err
}
Expand Down
13 changes: 4 additions & 9 deletions test/conformance/conformance_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package conformance

import (
"flag"
"fmt"
"os"
"path"
Expand All @@ -15,6 +14,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
conformancev1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
"sigs.k8s.io/gateway-api/conformance/tests"
"sigs.k8s.io/gateway-api/conformance/utils/flags"
"sigs.k8s.io/gateway-api/conformance/utils/suite"

"github.com/kong/gateway-operator/internal/metadata"
Expand All @@ -32,11 +32,6 @@ var skippedTests = []string{
tests.HTTPRouteHeaderMatching.ShortName,
}

var (
shouldCleanup = flag.Bool("cleanup", true, "indicates whether or not the base test resources such as Gateways should be cleaned up after the run.")
showDebug = flag.Bool("debug", false, "indicates whether to execute the conformance tests in debug mode.")
)

func TestGatewayConformance(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -64,8 +59,8 @@ func TestGatewayConformance(t *testing.T) {
suite.ConformanceOptions{
Client: clients.MgrClient,
GatewayClassName: gwc.Name,
Debug: *showDebug,
CleanupBaseResources: *shouldCleanup,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
BaseManifests: conformanceTestsBaseManifests,
SkipTests: skippedTests,
ConformanceProfiles: sets.New(
Expand All @@ -85,7 +80,7 @@ func TestGatewayConformance(t *testing.T) {
require.NoError(t, err)

t.Log("starting the gateway conformance test suite")
cSuite.Setup(t, nil)
cSuite.Setup(t, tests.ConformanceTests)

// To work with individual tests only, you can disable the normal Run call and construct a slice containing a
// single test only, e.g.:
Expand Down
3 changes: 2 additions & 1 deletion test/conformance/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/gateway-api/conformance/utils/flags"
gwapiv1 "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/typed/apis/v1"

"github.com/kong/gateway-operator/config"
Expand Down Expand Up @@ -126,7 +127,7 @@ func TestMain(m *testing.M) {
// for the operator to handle Gateway finalizers.
// If we don't do it then we'll be left with Gateways that have a deleted
// timestamp and finalizers set but no operator running which could handle those.
if *shouldCleanup {
if *flags.CleanupBaseResources {
exitOnErr(waitForConformanceGatewaysToCleanup(ctx, clients.GatewayClient.GatewayV1()))
}

Expand Down

0 comments on commit 7c90169

Please sign in to comment.