Skip to content

Commit

Permalink
ratelimitpolicy v1beta3: more integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
  • Loading branch information
eguzki committed Sep 25, 2024
1 parent 916338e commit 0fe564a
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3"
"github.com/kuadrant/kuadrant-operator/controllers"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/tests"
Expand Down Expand Up @@ -52,17 +52,17 @@ var _ = Describe("limitador cluster controller", func() {
tests.DeleteNamespace(ctx, testClient(), testNamespace)
}, afterEachTimeOut)

policyFactory := func(mutateFns ...func(policy *kuadrantv1beta2.RateLimitPolicy)) *kuadrantv1beta2.RateLimitPolicy {
policy := &kuadrantv1beta2.RateLimitPolicy{
policyFactory := func(mutateFns ...func(policy *kuadrantv1beta3.RateLimitPolicy)) *kuadrantv1beta3.RateLimitPolicy {
policy := &kuadrantv1beta3.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
APIVersion: kuadrantv1beta3.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "rlp",
Namespace: testNamespace,
},
Spec: kuadrantv1beta2.RateLimitPolicySpec{},
Spec: kuadrantv1beta3.RateLimitPolicySpec{},
}

for _, mutateFn := range mutateFns {
Expand All @@ -88,7 +88,7 @@ var _ = Describe("limitador cluster controller", func() {
Context("RateLimitPolicy attached to the gateway", func() {

var (
gwPolicy *kuadrantv1beta2.RateLimitPolicy
gwPolicy *kuadrantv1beta3.RateLimitPolicy
gwRoute *gatewayapiv1.HTTPRoute
)

Expand All @@ -98,15 +98,15 @@ var _ = Describe("limitador cluster controller", func() {
Expect(err).ToNot(HaveOccurred())
Eventually(tests.RouteIsAccepted(ctx, testClient(), client.ObjectKeyFromObject(gwRoute))).WithContext(ctx).Should(BeTrue())

gwPolicy = policyFactory(func(policy *kuadrantv1beta2.RateLimitPolicy) {
gwPolicy = policyFactory(func(policy *kuadrantv1beta3.RateLimitPolicy) {
policy.Name = "gw"
policy.Spec.TargetRef.Group = gatewayapiv1.GroupName
policy.Spec.TargetRef.Kind = "Gateway"
policy.Spec.TargetRef.Name = TestGatewayName
policy.Spec.Defaults = &kuadrantv1beta2.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta2.Limit{
policy.Spec.Defaults = &kuadrantv1beta3.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta3.Limit{
"l1": {
Rates: []kuadrantv1beta2.Rate{
Rates: []kuadrantv1beta3.Rate{
{
Limit: 1, Duration: 3, Unit: "minute",
},
Expand Down
38 changes: 19 additions & 19 deletions tests/envoygateway/wasm_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3"
"github.com/kuadrant/kuadrant-operator/controllers"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/rlptools/wasm"
Expand Down Expand Up @@ -50,17 +50,17 @@ var _ = Describe("wasm controller", func() {
tests.DeleteNamespace(ctx, testClient(), testNamespace)
}, afterEachTimeOut)

policyFactory := func(mutateFns ...func(policy *kuadrantv1beta2.RateLimitPolicy)) *kuadrantv1beta2.RateLimitPolicy {
policy := &kuadrantv1beta2.RateLimitPolicy{
policyFactory := func(mutateFns ...func(policy *kuadrantv1beta3.RateLimitPolicy)) *kuadrantv1beta3.RateLimitPolicy {
policy := &kuadrantv1beta3.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
APIVersion: kuadrantv1beta3.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "rlp",
Namespace: testNamespace,
},
Spec: kuadrantv1beta2.RateLimitPolicySpec{},
Spec: kuadrantv1beta3.RateLimitPolicySpec{},
}

for _, mutateFn := range mutateFns {
Expand All @@ -77,7 +77,7 @@ var _ = Describe("wasm controller", func() {
Context("RateLimitPolicy attached to the gateway", func() {

var (
gwPolicy *kuadrantv1beta2.RateLimitPolicy
gwPolicy *kuadrantv1beta3.RateLimitPolicy
gwRoute *gatewayapiv1.HTTPRoute
)

Expand All @@ -87,15 +87,15 @@ var _ = Describe("wasm controller", func() {
Expect(err).ToNot(HaveOccurred())
Eventually(tests.RouteIsAccepted(ctx, testClient(), client.ObjectKeyFromObject(gwRoute))).WithContext(ctx).Should(BeTrue())

gwPolicy = policyFactory(func(policy *kuadrantv1beta2.RateLimitPolicy) {
gwPolicy = policyFactory(func(policy *kuadrantv1beta3.RateLimitPolicy) {
policy.Name = "gw"
policy.Spec.TargetRef.Group = gatewayapiv1.GroupName
policy.Spec.TargetRef.Kind = "Gateway"
policy.Spec.TargetRef.Name = TestGatewayName
policy.Spec.Defaults = &kuadrantv1beta2.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta2.Limit{
policy.Spec.Defaults = &kuadrantv1beta3.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta3.Limit{
"l1": {
Rates: []kuadrantv1beta2.Rate{
Rates: []kuadrantv1beta3.Rate{
{
Limit: 1, Duration: 3, Unit: "minute",
},
Expand Down Expand Up @@ -158,12 +158,12 @@ var _ = Describe("wasm controller", func() {
AllOf: []wasm.PatternExpression{
{
Selector: "request.url_path",
Operator: wasm.PatternOperator(kuadrantv1beta2.StartsWithOperator),
Operator: wasm.PatternOperator(kuadrantv1beta3.StartsWithOperator),
Value: "/toy",
},
{
Selector: "request.method",
Operator: wasm.PatternOperator(kuadrantv1beta2.EqualOperator),
Operator: wasm.PatternOperator(kuadrantv1beta3.EqualOperator),
Value: "GET",
},
},
Expand Down Expand Up @@ -225,7 +225,7 @@ var _ = Describe("wasm controller", func() {
Context("RateLimitPolicy attached to the route", func() {

var (
routePolicy *kuadrantv1beta2.RateLimitPolicy
routePolicy *kuadrantv1beta3.RateLimitPolicy
gwRoute *gatewayapiv1.HTTPRoute
)

Expand All @@ -235,15 +235,15 @@ var _ = Describe("wasm controller", func() {
Expect(err).ToNot(HaveOccurred())
Eventually(tests.RouteIsAccepted(ctx, testClient(), client.ObjectKeyFromObject(gwRoute))).WithContext(ctx).Should(BeTrue())

routePolicy = policyFactory(func(policy *kuadrantv1beta2.RateLimitPolicy) {
routePolicy = policyFactory(func(policy *kuadrantv1beta3.RateLimitPolicy) {
policy.Name = "route"
policy.Spec.TargetRef.Group = gatewayapiv1.GroupName
policy.Spec.TargetRef.Kind = "HTTPRoute"
policy.Spec.TargetRef.Name = TestHTTPRouteName
policy.Spec.Defaults = &kuadrantv1beta2.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta2.Limit{
policy.Spec.Defaults = &kuadrantv1beta3.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta3.Limit{
"l1": {
Rates: []kuadrantv1beta2.Rate{
Rates: []kuadrantv1beta3.Rate{
{
Limit: 1, Duration: 3, Unit: "minute",
},
Expand Down Expand Up @@ -305,12 +305,12 @@ var _ = Describe("wasm controller", func() {
AllOf: []wasm.PatternExpression{
{
Selector: "request.url_path",
Operator: wasm.PatternOperator(kuadrantv1beta2.StartsWithOperator),
Operator: wasm.PatternOperator(kuadrantv1beta3.StartsWithOperator),
Value: "/toy",
},
{
Selector: "request.method",
Operator: wasm.PatternOperator(kuadrantv1beta2.EqualOperator),
Operator: wasm.PatternOperator(kuadrantv1beta3.EqualOperator),
Value: "GET",
},
},
Expand Down
16 changes: 8 additions & 8 deletions tests/istio/limitador_cluster_envoyfilter_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
kuadrantv1beta3 "github.com/kuadrant/kuadrant-operator/api/v1beta3"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant"
"github.com/kuadrant/kuadrant-operator/tests"
Expand Down Expand Up @@ -79,27 +79,27 @@ var _ = Describe("Limitador Cluster EnvoyFilter controller", func() {
Context("RLP targeting Gateway", func() {
It("EnvoyFilter created when RLP exists and deleted with RLP is deleted", func(ctx SpecContext) {
// create ratelimitpolicy
rlp := &kuadrantv1beta2.RateLimitPolicy{
rlp := &kuadrantv1beta3.RateLimitPolicy{
TypeMeta: metav1.TypeMeta{
Kind: "RateLimitPolicy",
APIVersion: kuadrantv1beta2.GroupVersion.String(),
APIVersion: kuadrantv1beta3.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: rlpName,
Namespace: testNamespace,
},
Spec: kuadrantv1beta2.RateLimitPolicySpec{
Spec: kuadrantv1beta3.RateLimitPolicySpec{
TargetRef: gatewayapiv1alpha2.LocalPolicyTargetReference{
Group: gatewayapiv1.GroupName,
Kind: "Gateway",
Name: gatewayapiv1.ObjectName(TestGatewayName),
},
RateLimitPolicyCommonSpec: kuadrantv1beta2.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta2.Limit{
RateLimitPolicyCommonSpec: kuadrantv1beta3.RateLimitPolicyCommonSpec{
Limits: map[string]kuadrantv1beta3.Limit{
"l1": {
Rates: []kuadrantv1beta2.Rate{
Rates: []kuadrantv1beta3.Rate{
{
Limit: 1, Duration: 3, Unit: kuadrantv1beta2.TimeUnit("minute"),
Limit: 1, Duration: 3, Unit: kuadrantv1beta3.TimeUnit("minute"),
},
},
},
Expand Down
Loading

0 comments on commit 0fe564a

Please sign in to comment.