Skip to content

Commit ea8bdf9

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 8e9ad26 + fe44241 commit ea8bdf9

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

tests/kfto/support.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/gomega"
2626
prometheusapiv1 "github.com/prometheus/client_golang/api/prometheus/v1"
2727
prometheusmodel "github.com/prometheus/common/model"
28+
2829
corev1 "k8s.io/api/core/v1"
2930

3031
"github.com/opendatahub-io/distributed-workloads/tests/common/support"

tests/kfto/validating_admission_policy_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
// The Validating Admission Policy feature gate is GA and enabled by default from OCP v4.17 (k8s v1.30)
4040

4141
var (
42+
err error
4243
ns *corev1.Namespace
4344
nsNoLabel *corev1.Namespace
4445
rf *kueuev1beta1.ResourceFlavor
@@ -56,20 +57,19 @@ func TestValidatingAdmissionPolicy(t *testing.T) {
5657

5758
Tags(t, Sanity)
5859

59-
// Create a namespace
60-
ns = CreateTestNamespaceWithName(test, uniqueSuffix("vap"))
61-
defer test.Client().Core().CoreV1().Namespaces().Delete(test.Ctx(), ns.Name, metav1.DeleteOptions{})
62-
63-
// Get the latest version of the namespace
64-
ns, err := test.Client().Core().CoreV1().Namespaces().Get(test.Ctx(), ns.Name, metav1.GetOptions{})
65-
test.Expect(err).ToNot(HaveOccurred())
66-
67-
// Add the 'kueue.openshift.io/managed' label
68-
ns.Labels = map[string]string{
69-
"kueue.openshift.io/managed": "true",
70-
}
71-
_, err = test.Client().Core().CoreV1().Namespaces().Update(test.Ctx(), ns, metav1.UpdateOptions{})
72-
test.Expect(err).ToNot(HaveOccurred())
60+
// Create namespace with unique name and required labels
61+
var AsDefaultQueueNamespace = ErrorOption[*corev1.Namespace](func(ns *corev1.Namespace) error {
62+
if ns.Labels == nil {
63+
ns.Labels = make(map[string]string)
64+
}
65+
ns.Labels["kueue.openshift.io/managed"] = "true"
66+
return nil
67+
})
68+
ns = CreateTestNamespaceWithName(
69+
test,
70+
uniqueSuffix("vap"),
71+
AsDefaultQueueNamespace,
72+
)
7373

7474
// Create a namespace that will not receive the `kueue.x-k8s.io/queue-name` label
7575
nsNoLabel = CreateTestNamespaceWithName(test, uniqueSuffix("vap-nl"))

0 commit comments

Comments
 (0)