Skip to content

Commit 5d735f3

Browse files
committed
comment
1 parent 94bb0fa commit 5d735f3

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

test/e2e/parallel/user_workloads_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,13 @@ func TestIdlerAndPriorityClass(t *testing.T) {
3838
podsToIdle := prepareWorkloads(t, await.Member1(), idler.Name, wait.WithSandboxPriorityClass())
3939
podsNoise := prepareWorkloads(t, await.Member1(), idlerNoise.Name, wait.WithSandboxPriorityClass())
4040

41-
// Create a Claw workload only in the dev namespace (the one being idled).
42-
// Not added to prepareWorkloads to avoid exceeding the ClusterResourceQuota pod limit
43-
// when workloads are created in multiple namespaces for the same user.
44-
clawDeployment := createClaw(t, memberAwait, "test-idler-claw", idler.Name)
45-
podsToIdle, err := memberAwait.WaitForPods(t, idler.Name, len(podsToIdle)+int(*clawDeployment.Spec.Replicas),
46-
wait.PodRunning(), wait.WithPodLabel("idler", "idler"), wait.WithSandboxPriorityClass())
47-
require.NoError(t, err)
48-
4941
// Create more noise pods in non-user namespace
5042
memberAwait.CreateNamespace(t, "workloads-noise")
5143
externalNsPodsNoise := prepareWorkloads(t, await.Member1(), "workloads-noise", wait.WithOriginalPriorityClass())
5244

5345
// Set a short timeout for one of the idler to trigger pod idling
5446
// The idler is currently updating its status since it's already been idling the pods. So we need to keep trying to update.
55-
idler, err = wait.For(t, memberAwait.Awaitility, &toolchainv1alpha1.Idler{}).
47+
idler, err := wait.For(t, memberAwait.Awaitility, &toolchainv1alpha1.Idler{}).
5648
Update(idler.Name, memberAwait.Namespace, func(i *toolchainv1alpha1.Idler) {
5749
i.Spec.TimeoutSeconds = 5
5850
})
@@ -182,6 +174,10 @@ func prepareWorkloads(t *testing.T, memberAwait *wait.MemberAwaitility, namespac
182174
aapDeployment := createAAP(t, memberAwait, "test-idler-aap", namespace)
183175
n = n + int(*aapDeployment.Spec.Replicas)
184176

177+
// Create a Claw resource
178+
clawDeployment := createClaw(t, memberAwait, "test-idler-claw", namespace)
179+
n = n + int(*clawDeployment.Spec.Replicas)
180+
185181
// Create a DataVolume resource with manual PVC and Pod
186182
createDataVolume(t, memberAwait, "test-idler-datavolume", namespace)
187183
n = n + 1

testsupport/wait/member.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
1616
"github.com/codeready-toolchain/toolchain-common/pkg/test"
17+
"github.com/codeready-toolchain/toolchain-e2e/testsupport/cleanup"
1718
appstudiov1 "github.com/codeready-toolchain/toolchain-e2e/testsupport/appstudio/api/v1alpha1"
1819
"github.com/davecgh/go-spew/spew"
1920
"github.com/ghodss/yaml"
@@ -1415,6 +1416,16 @@ func (a *MemberAwaitility) Create(t *testing.T, obj client.Object) error {
14151416
})
14161417
}
14171418

1419+
// CreateWithCleanup tries to create the object until success and schedules cleanup at test end.
1420+
// Workaround for https://github.com/kubernetes/kubernetes/issues/67761
1421+
func (a *MemberAwaitility) CreateWithCleanup(t *testing.T, obj client.Object) error {
1422+
if err := a.Create(t, obj); err != nil {
1423+
return err
1424+
}
1425+
cleanup.AddCleanTasks(t, a.Client, obj)
1426+
return nil
1427+
}
1428+
14181429
// PodWaitCriterion a struct to compare with a given Pod
14191430
type PodWaitCriterion struct {
14201431
Match func(*corev1.Pod) bool

0 commit comments

Comments
 (0)