Skip to content

Commit

Permalink
Add tests around FTs in Kserve before removal
Browse files Browse the repository at this point in the history
JIRA: https://issues.redhat.com/browse/RHOAIENG-18045

Some of these tests will change when the code changes, and the hope is
that those test changes will give more clarity and confidence in the
code changes.
  • Loading branch information
grdryn committed Feb 27, 2025
1 parent 73d70b8 commit b4e19d3
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/e2e/kserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
k8serr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -44,6 +45,9 @@ func kserveTestSuite(t *testing.T) {
t.Run("Validate FeatureTrackers", componentCtx.validateFeatureTrackers)
t.Run("Validate model controller", componentCtx.validateModelControllerInstance)
t.Run("Validate operands have OwnerReferences", componentCtx.ValidateOperandsOwnerReferences)
t.Run("Validate Kserve owns FeatureTrackers", componentCtx.ValidateKserveOwnsFeatureTrackers)
t.Run("Validate FeatureTrackers own children", componentCtx.ValidateFeatureTrackersOwnChildren)
t.Run("Validate KnativeServing Structure", componentCtx.ValidateKnativeServingStructure)
t.Run("Validate default certs", componentCtx.validateDefaultCertsAvailable)
t.Run("Validate update operand resources", componentCtx.ValidateUpdateDeploymentsResources)
t.Run("Validate component disabled", componentCtx.ValidateComponentDisabled)
Expand Down Expand Up @@ -206,3 +210,60 @@ func (c *KserveTestCtx) validateDefaultCertsAvailable(t *testing.T) {
g.Expect(ctrlPlaneSecret.Type).Should(Equal(defaultIngressSecret.Type))
g.Expect(defaultIngressSecret.Data).Should(Equal(ctrlPlaneSecret.Data))
}

func (c *KserveTestCtx) ValidateKserveOwnsFeatureTrackers(t *testing.T) {
g := c.NewWithT(t)

fts := []string{
c.ApplicationNamespace + "-kserve-external-authz",
c.ApplicationNamespace + "-serverless-serving-gateways",
c.ApplicationNamespace + "-serverless-serving-deployment",
c.ApplicationNamespace + "-serverless-net-istio-secret-filtering",
}

for _, ft := range fts {
g.Get(
gvk.FeatureTracker, types.NamespacedName{Name: ft},
).Eventually(300).Should(
jq.Match(`.metadata.ownerReferences | any(.kind == "%s")`, gvk.Kserve.Kind),
`Ensuring Kserve ownership of FeatureTracker %s`, ft,
)
}
}

func (c *KserveTestCtx) ValidateFeatureTrackersOwnChildren(t *testing.T) {
g := c.NewWithT(t)

children := []struct {
gvk schema.GroupVersionKind
nn types.NamespacedName
}{
{gvk.KnativeServing, types.NamespacedName{Namespace: "knative-serving", Name: "knative-serving"}},
{gvk.ServiceMeshMember, types.NamespacedName{Namespace: "knative-serving", Name: "default"}},
{gvk.EnvoyFilter, types.NamespacedName{Namespace: "istio-system", Name: "activator-host-header"}},
{gvk.EnvoyFilter, types.NamespacedName{Namespace: "istio-system", Name: "envoy-oauth-temp-fix-after"}},
{gvk.EnvoyFilter, types.NamespacedName{Namespace: "istio-system", Name: "envoy-oauth-temp-fix-before"}},
{gvk.EnvoyFilter, types.NamespacedName{Namespace: "istio-system", Name: "kserve-inferencegraph-host-header"}},
{gvk.AuthorizationPolicy, types.NamespacedName{Namespace: "istio-system", Name: "kserve-inferencegraph"}},
{gvk.AuthorizationPolicy, types.NamespacedName{Namespace: "istio-system", Name: "kserve-predictor"}},
{gvk.Gateway, types.NamespacedName{Namespace: "istio-system", Name: "kserve-local-gateway"}},
{gvk.Gateway, types.NamespacedName{Namespace: "knative-serving", Name: "knative-ingress-gateway"}},
{gvk.Gateway, types.NamespacedName{Namespace: "knative-serving", Name: "knative-local-gateway"}},
}

for _, child := range children {
g.Get(child.gvk, child.nn).Eventually(300).Should(
jq.Match(`.metadata.ownerReferences | any(.kind == "%s")`, gvk.FeatureTracker.Kind),
`Checking if %s/%s in %s has expected owner refs`, child.gvk, child.nn.Name, child.nn.Namespace,
)
}
}

func (c *KserveTestCtx) ValidateKnativeServingStructure(t *testing.T) {
g := c.NewWithT(t)

g.Get(gvk.KnativeServing, types.NamespacedName{Namespace: "knative-serving", Name: "knative-serving"}).Eventually(300).Should(And(
jq.Match(`.spec.workloads | length == 3`),
jq.Match(`.metadata.annotations."serverless.openshift.io/default-enable-http2" == "true"`),
), `Ensuring KnativeServing has content from both templates`)
}

0 comments on commit b4e19d3

Please sign in to comment.