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

new appstudio limits and quotas #861

Closed
wants to merge 14 commits into from
26 changes: 25 additions & 1 deletion test/e2e/parallel/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCreateSpace(t *testing.T) {
hostAwait := awaitilities.Host()
memberAwait := awaitilities.Member1()

t.Run("create space", func(t *testing.T) {
t.Run("create appstudio tier space", func(t *testing.T) {
// when
space, _, _ := CreateSpace(t, awaitilities, testspace.WithTierName("appstudio"), testspace.WithSpecTargetCluster(memberAwait.ClusterName))
// then
Expand All @@ -49,6 +49,30 @@ func TestCreateSpace(t *testing.T) {
})
})

t.Run("create appstudiolarge tier space", func(t *testing.T) {
// when
space, _, _ := CreateSpace(t, awaitilities, testspace.WithTierName("appstudiolarge"), testspace.WithSpecTargetCluster(memberAwait.ClusterName))
// then
VerifyResourcesProvisionedForSpace(t, awaitilities, space.Name, UntilSpaceHasStatusTargetCluster(memberAwait.ClusterName))

t.Run("delete space", func(t *testing.T) {
// now, delete the Space and expect that the NSTemplateSet will be deleted as well,
// along with its associated namespace

// when
err := hostAwait.Client.Delete(context.TODO(), space)

// then
require.NoError(t, err)
err = hostAwait.WaitUntilSpaceAndSpaceBindingsDeleted(t, space.Name)
require.NoError(t, err)
err = memberAwait.WaitUntilNSTemplateSetDeleted(t, space.Name)
require.NoError(t, err)
err = memberAwait.WaitUntilNamespaceDeleted(t, space.Name, "appstudiolarge")
require.NoError(t, err)
})
})

t.Run("failed to create space - unknown target member cluster", func(t *testing.T) {
// given & when
s, _, _ := CreateSpace(t, awaitilities, testspace.WithTierName("appstudio"), testspace.WithSpecTargetCluster("unknown"))
Expand Down
55 changes: 41 additions & 14 deletions testsupport/tiers/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,10 @@ type appstudioTierChecks struct {
tierName string
}

func (a *appstudioTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObjectsCheck {
checks := []namespaceObjectsCheck{
resourceQuotaComputeDeploy("20", "32Gi", "1750m", "32Gi"),
resourceQuotaComputeBuild("120", "128Gi", "12", "64Gi"),
resourceQuotaStorage("50Gi", "200Gi", "50Gi", "30"),
limitRange("2", "2Gi", "10m", "256Mi"),
numberOfLimitRanges(1),
func commonAppstudioTierChecks() []namespaceObjectsCheck {
return []namespaceObjectsCheck{
gitOpsServiceLabel(),
appstudioWorkSpaceNameLabel(),
environment("development"),
resourceQuotaToolchainCrds("32"),
resourceQuotaAppstudioCrds("512", "512", "512"),
resourceQuotaAppstudioCrdsBuild("512"),
Expand All @@ -459,7 +453,19 @@ func (a *appstudioTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObje
pipelineServiceAccount(),
pipelineRunnerRoleBinding(),
}
}

func (a *appstudioTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObjectsCheck {
checks := []namespaceObjectsCheck{
resourceQuotaComputeDeploy("", "32Gi", "1750m", "32Gi"),
resourceQuotaComputeBuild("", "128Gi", "12", "64Gi"),
resourceQuotaStorage("50Gi", "200Gi", "50Gi", "30"),
limitRange("", "2Gi", "200m", "256Mi"),
numberOfLimitRanges(1),
environment("development"),
}

checks = append(checks, commonAppstudioTierChecks()...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(6))...)
return checks
}
Expand Down Expand Up @@ -552,6 +558,21 @@ func (a *appstudiolargeTierChecks) GetClusterObjectChecks() []clusterObjectsChec
pipelineRunnerClusterRole())
}

func (a *appstudiolargeTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObjectsCheck {
checks := []namespaceObjectsCheck{
resourceQuotaComputeDeploy("", "32Gi", "1750m", "32Gi"),
resourceQuotaComputeBuild("", "512Gi", "24", "128Gi"),
resourceQuotaStorage("50Gi", "200Gi", "50Gi", "30"),
limitRange("", "2Gi", "200m", "256Mi"),
numberOfLimitRanges(1),
environment("development"),
}

checks = append(checks, commonAppstudioTierChecks()...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(6))...)
return checks
}

type appstudioEnvTierChecks struct {
tierName string
}
Expand Down Expand Up @@ -732,8 +753,10 @@ func resourceQuotaComputeDeploy(cpuLimit, memoryLimit, cpuRequest, memoryRequest
Scopes: []corev1.ResourceQuotaScope{corev1.ResourceQuotaScopeNotTerminating},
Hard: make(map[corev1.ResourceName]resource.Quantity),
}
spec.Hard[corev1.ResourceLimitsCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
if cpuLimit != "" {
spec.Hard[corev1.ResourceLimitsCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
}
spec.Hard[corev1.ResourceLimitsMemory], err = resource.ParseQuantity(memoryLimit)
require.NoError(t, err)
spec.Hard[corev1.ResourceRequestsCPU], err = resource.ParseQuantity(cpuRequest)
Expand All @@ -754,8 +777,10 @@ func resourceQuotaComputeBuild(cpuLimit, memoryLimit, cpuRequest, memoryRequest
Scopes: []corev1.ResourceQuotaScope{corev1.ResourceQuotaScopeTerminating},
Hard: make(map[corev1.ResourceName]resource.Quantity),
}
spec.Hard[corev1.ResourceLimitsCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
if cpuLimit != "" {
spec.Hard[corev1.ResourceLimitsCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
}
spec.Hard[corev1.ResourceLimitsMemory], err = resource.ParseQuantity(memoryLimit)
require.NoError(t, err)
spec.Hard[corev1.ResourceRequestsCPU], err = resource.ParseQuantity(cpuRequest)
Expand Down Expand Up @@ -967,8 +992,10 @@ func limitRange(cpuLimit, memoryLimit, cpuRequest, memoryRequest string) namespa
lr, err := memberAwait.WaitForLimitRange(t, ns, "resource-limits")
require.NoError(t, err)
def := make(map[corev1.ResourceName]resource.Quantity)
def[corev1.ResourceCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
if cpuLimit != "" {
def[corev1.ResourceCPU], err = resource.ParseQuantity(cpuLimit)
require.NoError(t, err)
}
def[corev1.ResourceMemory], err = resource.ParseQuantity(memoryLimit)
require.NoError(t, err)
defReq := make(map[corev1.ResourceName]resource.Quantity)
Expand Down