Skip to content

Commit

Permalink
test: kuadrant status on bare k8s
Browse files Browse the repository at this point in the history
Signed-off-by: KevFan <[email protected]>
  • Loading branch information
KevFan committed Nov 11, 2024
1 parent 2dbc3e0 commit 859725f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/bare_k8s/kuadrant_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/controllers"
"github.com/kuadrant/kuadrant-operator/tests"
)

var _ = Describe("Kuadrant controller is disabled", func() {
var _ = Describe("Controller", func() {
var (
testNamespace string
kuadrantName string = "local"
afterEachTimeOut = NodeTimeout(3 * time.Minute)
testTimeOut = SpecTimeout(15 * time.Second)
afterEachTimeOut = NodeTimeout(3 * time.Minute)
)

BeforeEach(func(ctx SpecContext) {
Expand All @@ -30,24 +32,28 @@ var _ = Describe("Kuadrant controller is disabled", func() {
}, afterEachTimeOut)

Context("when default kuadrant CR is created", func() {
It("Status is not populated", func(ctx SpecContext) {
It("Status is populated with missing GatewayProvide", func(ctx SpecContext) {
kuadrantCR := &kuadrantv1beta1.Kuadrant{
TypeMeta: metav1.TypeMeta{
Kind: "Kuadrant",
APIVersion: kuadrantv1beta1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: kuadrantName,
Name: "local",
Namespace: testNamespace,
},
}
Expect(testClient().Create(ctx, kuadrantCR)).ToNot(HaveOccurred())

kObj := &kuadrantv1beta1.Kuadrant{}
err := testClient().Get(ctx, client.ObjectKeyFromObject(kuadrantCR), kObj)
Expect(err).ToNot(HaveOccurred())
// expected empty. The controller should not have updated it
Expect(kObj.Status).To(Equal(kuadrantv1beta1.KuadrantStatus{}))
})
Eventually(func(g Gomega) {
g.Expect(testClient().Get(ctx, client.ObjectKeyFromObject(kuadrantCR), kuadrantCR)).To(Succeed())

cond := meta.FindStatusCondition(kuadrantCR.Status.Conditions, controllers.ReadyConditionType)
g.Expect(cond).ToNot(BeNil())
g.Expect(cond.Status).To(Equal(metav1.ConditionFalse))
g.Expect(cond.Reason).To(Equal("GatewayAPIProviderNotFound"))
g.Expect(cond.Message).To(Equal("GatewayAPI provider not found"))
}).WithContext(ctx).Should(Succeed())
}, testTimeOut)
})
})

0 comments on commit 859725f

Please sign in to comment.