Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom scaling triggers #1112

Merged
merged 73 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
eed35a3
Create ScaledObjects instead of HPAs
Richard87 May 10, 2024
44a08ad
fix dependencies
Richard87 May 10, 2024
3d9835d
Merge branch 'refs/heads/master' into create-scaling-objects-instead-…
Richard87 May 10, 2024
9697649
update mocks and test infrastructure with new kedaClient
Richard87 May 10, 2024
32f59c2
fail tests instead of panicks
Richard87 May 10, 2024
27f6959
change test to verify ScaledObjects instead of HPAs
Richard87 May 10, 2024
90b9738
remove legacy code
Richard87 May 10, 2024
7237aa7
revert gomod change
Richard87 May 10, 2024
5fe72a4
fix bugi n makefile
Richard87 May 10, 2024
4aa7659
move kedaclient to kubeutil
Richard87 May 10, 2024
ba8c465
refactor validation, add more details to tests, configure default min…
Richard87 May 13, 2024
b9275a5
refactor validation, add more details to tests, configure default min…
Richard87 May 13, 2024
2099cd9
cleanup naming
Richard87 May 13, 2024
75f4c27
retain keda label
Richard87 May 13, 2024
bac3d0a
use json-patch v5
Richard87 May 13, 2024
c405532
use threeway patch
Richard87 May 13, 2024
e2201e3
update gomod
Richard87 May 13, 2024
3891ca9
rename default target
Richard87 May 13, 2024
249f3a2
Update CRD with new horizontal scaling triggers
Richard87 May 8, 2024
66eee2d
Add validation to stop if Triggers and Resources are both defined
Richard87 May 13, 2024
c93df68
Add minimum replica validation with/without other trigger types than …
Richard87 May 14, 2024
5bf2799
fix panics
Richard87 May 15, 2024
55dc231
remove outdatad validation
Richard87 May 15, 2024
12a42b1
Add Builder, cleanup tests
Richard87 May 15, 2024
d166c5f
added todo
Richard87 May 15, 2024
c262805
move horizontalscaling tests, add trigger tests
Richard87 May 16, 2024
92c71b2
implement CRON and AzureServiceBus triggers, and tests (Authenticatio…
Richard87 May 16, 2024
e0ebde9
implement CRON and AzureServiceBus triggers, and tests (Authenticatio…
Richard87 May 16, 2024
f2f111d
cleanup
Richard87 May 16, 2024
db0656a
limit components and job names to 50 characters, fix tests that valid…
Richard87 May 16, 2024
9974555
validate unique trigger names
Richard87 May 16, 2024
0ddc6a7
validate unique trigger names add tests
Richard87 May 16, 2024
ecdcbf4
remove unneeded interface, added test for auth object
Richard87 May 21, 2024
ce58a88
Create authentication ref, tests
Richard87 May 21, 2024
6c0ce21
create auth refs, cleanup tests
Richard87 May 21, 2024
5953833
Merge scaling config on deploy step
Richard87 May 22, 2024
db94223
fix tests
Richard87 May 22, 2024
194b20b
Merge branch 'refs/heads/master' into replace-hpa-with-keda
Richard87 May 23, 2024
8cc5e6d
fix merge conflicts
Richard87 May 23, 2024
5724149
cleanup Builder withHorizontalScaling
Richard87 May 23, 2024
b8b0ef1
fix linting
Richard87 May 23, 2024
c62443c
fix type in recconcile => reconcile
Richard87 May 23, 2024
f3e423b
fix type in recconcile => reconcile
Richard87 May 23, 2024
b6fbe43
rename Stop to end
Richard87 May 23, 2024
78cc9e3
rename Stop to end
Richard87 May 23, 2024
7e0481b
revert changing to much to end
Richard87 May 23, 2024
cdf7feb
create correct Cron trigger
Richard87 May 23, 2024
e74bb55
rename RadixTrigger to RadixHorizontalScalingTrigger
Richard87 May 23, 2024
a538596
added generated files
Richard87 May 23, 2024
6a5a9cf
replace *Trigger with Trigger
Richard87 May 27, 2024
b300d93
change default metrictype of resources to AverageValue
Richard87 May 27, 2024
f9179bc
change default metrictype of resources to AverageValue
Richard87 May 27, 2024
e98d737
Add spacing
Richard87 May 27, 2024
bc47d7e
add required metric type and change default to AverageValue
Richard87 May 27, 2024
2ba44dc
Add defaults and minium requirements
Richard87 May 27, 2024
6ebf86b
add list validation definition
Richard87 May 27, 2024
01005f6
add required field to Trigger
Richard87 May 27, 2024
b73bc58
Added requirements to azure service bus
Richard87 May 27, 2024
e8cdc34
replace pointers with values where possible
Richard87 May 27, 2024
a3b197a
add max/min properties
Richard87 May 27, 2024
d93d883
add updated schema
Richard87 May 27, 2024
91bbb2b
validate cron, bugfix name regex
Richard87 May 28, 2024
8eb96e8
bump chart
Richard87 May 28, 2024
4e6890e
remove unused error
Richard87 May 28, 2024
2392850
remove unused interface
Richard87 May 28, 2024
a6b9491
use proper api version
Richard87 May 28, 2024
d46be53
Added todo
Richard87 May 28, 2024
35880f9
only set namespace if configured
Richard87 May 28, 2024
8c9e725
cleanup azure service bus metadata
Richard87 May 28, 2024
ba75d79
garbage collection of trigger auths
Richard87 May 28, 2024
f2e1ea8
added todo
Richard87 May 29, 2024
c829592
replaced todo with simple cleanup assertion
Richard87 May 29, 2024
5f53ecc
return error, ignore lint errors
Richard87 May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ ifndef HAS_MOCKGEN
endif
ifndef HAS_CONTROLLER_GEN
go install sigs.k8s.io/controller-tools/cmd/[email protected]
endif
endif
4 changes: 2 additions & 2 deletions charts/radix-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: radix-operator
version: 1.34.1
appVersion: 1.54.1
version: 1.35.0
appVersion: 1.55.0
kubeVersion: ">=1.24.0"
description: Radix Operator
keywords:
Expand Down
397 changes: 391 additions & 6 deletions charts/radix-operator/templates/radixapplication.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion charts/radix-operator/templates/radixdnsalias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ spec:
properties:
appName:
description: Name of the application the DNS alias used in.
maxLength: 253
maxLength: 50
minLength: 1
pattern: ^(([a-z0-9][-a-z0-9]*)?[a-z0-9])?$
type: string
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.70.0
github.com/prometheus-operator/prometheus-operator/pkg/client v0.70.0
github.com/prometheus/client_golang v1.19.0
github.com/robfig/cron/v3 v3.0.1
github.com/rs/zerolog v1.32.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ github.com/prometheus/common v0.53.0 h1:U2pL9w9nmJwJDa4qqLQ3ZaePJ6ZTwt7cMD3AG3+a
github.com/prometheus/common v0.53.0/go.mod h1:BrxBKv3FWBIGXw89Mg1AeBq7FSyRzXWI3l3e7W3RN5U=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
Expand Down
394 changes: 390 additions & 4 deletions json-schema/radixapplication.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/apis/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ func (deploy *Deployment) garbageCollectComponentsNoLongerInSpec(ctx context.Con
return err
}

err = deploy.garbageCollectTriggerAuthsNoLongerInSpec(ctx)
if err != nil {
return err
}

err = deploy.garbageCollectServicesNoLongerInSpec(ctx)
if err != nil {
return err
Expand Down
540 changes: 222 additions & 318 deletions pkg/apis/deployment/deployment_test.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pkg/apis/deployment/environmentvariables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Test_GetEnvironmentVariables(t *testing.T) {
envName := "dev"
componentName := "any-component"
testEnv := setupTestEnv(t)
defer teardownTest()
defer TeardownTest()

t.Run("Get env vars", func(t *testing.T) {
rd := testEnv.applyRdComponent(t, appName, envName, componentName, func(componentBuilder utils.DeployComponentBuilder) {
Expand Down Expand Up @@ -94,7 +94,7 @@ func Test_getEnvironmentVariablesForRadixOperator(t *testing.T) {
envName := "dev"
componentName := "any-component"
testEnv := setupTestEnv(t)
defer teardownTest()
defer TeardownTest()

rd := testEnv.applyRdComponent(t, appName, envName, componentName, func(componentBuilder utils.DeployComponentBuilder) {
componentBuilder.WithEnvironmentVariables(map[string]string{
Expand Down Expand Up @@ -134,7 +134,7 @@ func Test_RemoveFromConfigMapEnvVarsNotExistingInRadixDeployment(t *testing.T) {
namespace := utils.GetEnvironmentNamespace(appName, env)
componentName := "any-component"
testEnv := setupTestEnv(t)
defer teardownTest()
defer TeardownTest()
t.Run("Remove obsolete env-vars from config-maps", func(t *testing.T) {
//goland:noinspection GoUnhandledErrorResult
_, err := testEnv.kubeUtil.CreateConfigMap(context.Background(), namespace, &corev1.ConfigMap{ObjectMeta: metav1.ObjectMeta{Name: kube.GetEnvVarsConfigMapName(componentName)}, Data: map[string]string{
Expand Down Expand Up @@ -426,7 +426,7 @@ func (testEnv *testEnvProps) applyRdComponent(t *testing.T, appName string, envN
WithEmptyStatus().
WithComponents(componentBuilder)

rd, err := applyDeploymentWithSync(testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.certClient, radixDeployBuilder)
rd, err := ApplyDeploymentWithSync(testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.certClient, radixDeployBuilder)
assert.NoError(t, err)
return rd
}
Expand All @@ -441,13 +441,13 @@ func (testEnv *testEnvProps) applyRdJobComponent(t *testing.T, appName string, e
WithEmptyStatus().
WithJobComponents(jobBuilder)

rd, err := applyDeploymentWithSync(testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.certClient, radixDeployBuilder)
rd, err := ApplyDeploymentWithSync(testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.certClient, radixDeployBuilder)
assert.NoError(t, err)
return rd
}

func setupTestEnv(t *testing.T) *testEnvProps {
testEnv := testEnvProps{}
testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.secretproviderclient, testEnv.certClient = setupTest(t)
testEnv.testUtil, testEnv.kubeclient, testEnv.kubeUtil, testEnv.radixclient, testEnv.kedaClient, testEnv.prometheusclient, testEnv.secretproviderclient, testEnv.certClient = SetupTest(t)
return &testEnv
}
5 changes: 5 additions & 0 deletions pkg/apis/deployment/kubedeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (deploy *Deployment) reconcileDeployment(ctx context.Context, deployCompone
if err != nil {
return err
}

err = deploy.deleteTargetAuthenticationIfExists(ctx, deployComponent.GetName())
if err != nil {
return err
}
}

err = deploy.createOrUpdateCsiAzureVolumeResources(ctx, desiredDeployment)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/deployment/kubedeployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func Test_UpdateResourcesInDeployment(t *testing.T) {
}

func applyDeploymentWithSyncWithComponentResources(t *testing.T, origRequests, origLimits map[string]string) Deployment {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
rd, _ := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient,
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
rd, _ := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient,
utils.ARadixDeployment().
WithComponents(utils.NewDeployComponentBuilder().
WithName("comp1").
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/deployment/oauthproxyresourcemanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,29 +214,29 @@ func (s *OAuthProxyResourceManagerTestSuite) Test_Sync_OauthDeploymentReplicas()
{
name: "component with hpa and default config",
rd: utils.NewDeploymentBuilder().WithAppName(appName).WithEnvironment("qa").
WithComponent(baseComp().WithHorizontalScaling(pointers.Ptr[int32](3), 4, pointers.Ptr[int32](1), pointers.Ptr[int32](1))).
WithComponent(baseComp().WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(3).WithMaxReplicas(4).WithCPUTrigger(1).WithMemoryTrigger(1).Build())).
BuildRD(),
expectedReplicas: 1,
},
{
name: "component with hpa and replicas set to 1",
rd: utils.NewDeploymentBuilder().WithAppName(appName).WithEnvironment("qa").
WithComponent(baseComp().WithReplicas(pointers.Ptr(1)).WithHorizontalScaling(pointers.Ptr[int32](3), 4, pointers.Ptr[int32](1), pointers.Ptr[int32](1))).
WithComponent(baseComp().WithReplicas(pointers.Ptr(1)).WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(3).WithMaxReplicas(4).WithCPUTrigger(1).WithMemoryTrigger(1).Build())).
BuildRD(),
expectedReplicas: 1,
},
{
name: "component with hpa and replicas set to 2",
rd: utils.NewDeploymentBuilder().WithAppName(appName).WithEnvironment("qa").
WithComponent(baseComp().WithReplicas(pointers.Ptr(2)).WithHorizontalScaling(pointers.Ptr[int32](3), 4, pointers.Ptr[int32](1), pointers.Ptr[int32](1))).
WithComponent(baseComp().WithReplicas(pointers.Ptr(2)).WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(3).WithMaxReplicas(4).WithCPUTrigger(1).WithMemoryTrigger(1).Build())).
BuildRD(),
expectedReplicas: 1,
},
{

name: "component with hpa and replicas set to 0",
rd: utils.NewDeploymentBuilder().WithAppName(appName).WithEnvironment("qa").
WithComponent(baseComp().WithReplicas(pointers.Ptr(0)).WithHorizontalScaling(pointers.Ptr[int32](3), 4, pointers.Ptr[int32](1), pointers.Ptr[int32](1))).
WithComponent(baseComp().WithReplicas(pointers.Ptr(0)).WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(3).WithMaxReplicas(4).WithCPUTrigger(1).WithMemoryTrigger(1).Build())).
BuildRD(),
expectedReplicas: 0,
},
Expand Down
55 changes: 27 additions & 28 deletions pkg/apis/deployment/pdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ import (
"github.com/equinor/radix-operator/pkg/apis/kube"
"github.com/equinor/radix-operator/pkg/apis/test"
"github.com/equinor/radix-operator/pkg/apis/utils"
"github.com/equinor/radix-operator/pkg/apis/utils/numbers"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

func TestHorizontalScaleChangePDB(t *testing.T) {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
defer teardownTest()
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
defer TeardownTest()
anyAppName := "anyappname"
anyEnvironmentName := "test"
componentOneName := "componentOneName"
componentTwoName := "componentTwoName"
componentThreeName := "componentThreeName"

// Test
_, err := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -34,7 +33,7 @@ func TestHorizontalScaleChangePDB(t *testing.T) {
WithPublicPort("http").
WithDNSAppAlias(true).
WithReplicas(test.IntPtr(4)).
WithHorizontalScaling(numbers.Int32Ptr(2), 4, nil, nil),
WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(2).WithMaxReplicas(4).Build()),
utils.NewDeployComponentBuilder().
WithName(componentTwoName).
WithPort("http", 6379).
Expand All @@ -43,7 +42,7 @@ func TestHorizontalScaleChangePDB(t *testing.T) {
utils.NewDeployComponentBuilder().
WithName(componentThreeName).
WithPort("http", 3000).
WithPublicPort("http").WithHorizontalScaling(nil, 2, nil, nil)))
WithPublicPort("http").WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMaxReplicas(2).Build())))

assert.NoError(t, err)
envNamespace := utils.GetEnvironmentNamespace(anyAppName, anyEnvironmentName)
Expand All @@ -61,7 +60,7 @@ func TestHorizontalScaleChangePDB(t *testing.T) {
assert.Equal(t, int32(1), pdbs.Items[0].Spec.MinAvailable.IntVal)

// Remove components
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -88,16 +87,16 @@ func TestHorizontalScaleChangePDB(t *testing.T) {
}

func TestObjectSynced_MultiComponentToOneComponent_HandlesPdbChange(t *testing.T) {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
defer teardownTest()
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
defer TeardownTest()
anyAppName := "anyappname"
anyEnvironmentName := "test"
componentOneName := "componentOneName"
componentTwoName := "componentTwoName"
componentThreeName := "componentThreeName"

// Test
_, err := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand Down Expand Up @@ -134,7 +133,7 @@ func TestObjectSynced_MultiComponentToOneComponent_HandlesPdbChange(t *testing.T
assert.Equal(t, int32(1), pdbs.Items[0].Spec.MinAvailable.IntVal)

// Remove components
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -161,16 +160,16 @@ func TestObjectSynced_MultiComponentToOneComponent_HandlesPdbChange(t *testing.T
}

func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
defer teardownTest()
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
defer TeardownTest()
anyAppName := "anyappname"
anyEnvironmentName := "test"
componentOneName := "componentOneName"
componentTwoName := "componentTwoName"
envNamespace := utils.GetEnvironmentNamespace(anyAppName, anyEnvironmentName)

// Define one component with >1 replicas and one component with <2 replicas
_, err := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -197,7 +196,7 @@ func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
assert.Equal(t, int32(1), pdbs.Items[0].Spec.MinAvailable.IntVal)

// Define two components with <2 replicas
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -222,7 +221,7 @@ func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
assert.Equal(t, 0, len(pdbs.Items))

// Define one component with >1 replicas and one component with <2 replicas
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand Down Expand Up @@ -250,7 +249,7 @@ func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
assert.Equal(t, int32(1), pdbs.Items[0].Spec.MinAvailable.IntVal)

// Delete component with >1 replicas. Expect PDBs to be removed
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -271,7 +270,7 @@ func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
componentThreeName := "componentThreeName"

// Set 3 components with >1 replicas. Expect 3 PDBs
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand Down Expand Up @@ -306,16 +305,16 @@ func TestObjectSynced_ScalingReplicas_HandlesChange(t *testing.T) {
}

func TestObjectSynced_HorizontalScalingReplicas_HandlesChange(t *testing.T) {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
defer teardownTest()
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
defer TeardownTest()
anyAppName := "anyappname"
anyEnvironmentName := "test"
componentOneName := "componentOneName"
componentTwoName := "componentTwoName"
envNamespace := utils.GetEnvironmentNamespace(anyAppName, anyEnvironmentName)

// Define one component with >1 replicas and one component with <2 replicas
_, err := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -325,7 +324,7 @@ func TestObjectSynced_HorizontalScalingReplicas_HandlesChange(t *testing.T) {
WithPort("http", 8080).
WithPublicPort("http").
WithReplicas(test.IntPtr(4)).
WithHorizontalScaling(numbers.Int32Ptr(4), 6, nil, nil),
WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(4).WithMaxReplicas(6).Build()),
utils.NewDeployComponentBuilder().
WithName(componentTwoName).
WithPort("http", 6379).
Expand All @@ -343,7 +342,7 @@ func TestObjectSynced_HorizontalScalingReplicas_HandlesChange(t *testing.T) {
assert.Equal(t, int32(1), pdbs.Items[0].Spec.MinAvailable.IntVal)

// Define two components with <2 replicas
_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand All @@ -354,7 +353,7 @@ func TestObjectSynced_HorizontalScalingReplicas_HandlesChange(t *testing.T) {
WithPublicPort("http").
WithDNSAppAlias(true).
WithReplicas(test.IntPtr(1)).
WithHorizontalScaling(numbers.Int32Ptr(1), 6, nil, nil),
WithHorizontalScaling(utils.NewHorizontalScalingBuilder().WithMinReplicas(1).WithMaxReplicas(6).Build()),
utils.NewDeployComponentBuilder().
WithName(componentTwoName).
WithPort("http", 6379).
Expand All @@ -370,15 +369,15 @@ func TestObjectSynced_HorizontalScalingReplicas_HandlesChange(t *testing.T) {
}

func TestObjectSynced_UpdatePdb_HandlesChange(t *testing.T) {
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := setupTest(t)
defer teardownTest()
tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, _, certClient := SetupTest(t)
defer TeardownTest()
anyAppName := "anyappname"
anyEnvironmentName := "test"
componentOneName := "componentOneName"
envNamespace := utils.GetEnvironmentNamespace(anyAppName, anyEnvironmentName)

// Define a component with >1 replicas
_, err := applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err := ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand Down Expand Up @@ -408,7 +407,7 @@ func TestObjectSynced_UpdatePdb_HandlesChange(t *testing.T) {
assert.Equal(t, "wrong", pdbWithWrongLabels.ObjectMeta.Labels[kube.RadixComponentLabel])
assert.Equal(t, "wrong", pdbWithWrongLabels.Spec.Selector.MatchLabels[kube.RadixComponentLabel])

_, err = applyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
_, err = ApplyDeploymentWithSync(tu, client, kubeUtil, radixclient, kedaClient, prometheusclient, certClient, utils.ARadixDeployment().
WithAppName(anyAppName).
WithEnvironment(anyEnvironmentName).
WithJobComponents().
Expand Down
Loading
Loading