Skip to content

Commit

Permalink
wasmplugin controller: integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Dec 14, 2023
1 parent 1cb0113 commit e0778af
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 9 deletions.
31 changes: 26 additions & 5 deletions controllers/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import (
"path/filepath"
"time"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"

"github.com/google/uuid"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
Expand All @@ -30,6 +27,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
)

func ApplyKuadrantCR(namespace string) {
Expand Down Expand Up @@ -285,14 +285,35 @@ func testRouteIsAccepted(routeKey client.ObjectKey) func() bool {
return func() bool {
route := &gatewayapiv1.HTTPRoute{}
err := k8sClient.Get(context.Background(), routeKey, route)
return err == nil && common.IsHTTPRouteAccepted(route)

if err != nil {
logf.Log.V(1).Info("httpRoute not read", "route", routeKey, "error", err)
return false
}

if !common.IsHTTPRouteAccepted(route) {
logf.Log.V(1).Info("httpRoute not accepted", "route", routeKey)
return false
}

return true
}
}

func testGatewayIsReady(gateway *gatewayapiv1.Gateway) func() bool {
return func() bool {
existingGateway := &gatewayapiv1.Gateway{}
err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(gateway), existingGateway)
return err == nil && meta.IsStatusConditionTrue(existingGateway.Status.Conditions, common.GatewayProgrammedConditionType)
if err != nil {
logf.Log.V(1).Info("gateway not read", "gateway", client.ObjectKeyFromObject(gateway), "error", err)
return false
}

if !meta.IsStatusConditionTrue(existingGateway.Status.Conditions, common.GatewayProgrammedConditionType) {
logf.Log.V(1).Info("gateway not programmed", "gateway", client.ObjectKeyFromObject(gateway))
return false
}

return true
}
}
Loading

0 comments on commit e0778af

Please sign in to comment.