diff --git a/test/e2e/parallel/space_test.go b/test/e2e/parallel/space_test.go index 46fde9074..b7873b83a 100644 --- a/test/e2e/parallel/space_test.go +++ b/test/e2e/parallel/space_test.go @@ -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 @@ -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")) diff --git a/testsupport/tiers/checks.go b/testsupport/tiers/checks.go index 54c9f7629..d8a0798d7 100644 --- a/testsupport/tiers/checks.go +++ b/testsupport/tiers/checks.go @@ -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"), @@ -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 } @@ -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 } @@ -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) @@ -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) @@ -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)