Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions tests/common/support/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
jobsetclient "sigs.k8s.io/jobset/client-go/clientset/versioned"
kueueclient "sigs.k8s.io/kueue/client-go/clientset/versioned"

imagev1 "github.com/openshift/client-go/image/clientset/versioned"
Expand All @@ -40,6 +41,7 @@ type Client interface {
Core() kubernetes.Interface
Trainer() trainerclient.Interface
Kubeflow() kubeflowclient.Interface
JobSet() jobsetclient.Interface
Kueue() kueueclient.Interface
Machine() machinev1.Interface
Route() routev1.Interface
Expand All @@ -53,6 +55,7 @@ type testClient struct {
core kubernetes.Interface
trainer trainerclient.Interface
kubeflow kubeflowclient.Interface
jobset jobsetclient.Interface
kueue kueueclient.Interface
machine machinev1.Interface
route routev1.Interface
Expand All @@ -76,6 +79,10 @@ func (t *testClient) Kubeflow() kubeflowclient.Interface {
return t.kubeflow
}

func (t *testClient) JobSet() jobsetclient.Interface {
return t.jobset
}

func (t *testClient) Kueue() kueueclient.Interface {
return t.kueue
}
Expand Down Expand Up @@ -131,6 +138,11 @@ func newTestClient(cfg *rest.Config) (Client, *rest.Config, error) {
return nil, nil, err
}

jobsetClient, err := jobsetclient.NewForConfig(cfg)
if err != nil {
return nil, nil, err
}

kueueClient, err := kueueclient.NewForConfig(cfg)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -170,6 +182,7 @@ func newTestClient(cfg *rest.Config) (Client, *rest.Config, error) {
core: kubeClient,
trainer: trainerClient,
kubeflow: kubeflowClient,
jobset: jobsetClient,
kueue: kueueClient,
machine: machineClient,
route: routeClient,
Expand Down
42 changes: 42 additions & 0 deletions tests/common/support/jobs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2025.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package support

import (
"strings"

batchv1 "k8s.io/api/batch/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func GetJobByNamePattern(test Test, namespace, pattern string) (*batchv1.Job, error) {
test.T().Helper()

jobs, err := test.Client().Core().BatchV1().Jobs(namespace).List(test.Ctx(), metav1.ListOptions{})
if err != nil {
return nil, err
}

for i := range jobs.Items {
job := &jobs.Items[i]
if strings.Contains(job.Name, pattern) {
return job, nil
}
}

return nil, nil
}
38 changes: 38 additions & 0 deletions tests/common/support/jobset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2025.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package support

import (
. "github.com/onsi/gomega"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
jobsetv1alpha2 "sigs.k8s.io/jobset/api/jobset/v1alpha2"
)

// GetSingleJobSet returns the single JobSet in the namespace, expecting exactly one to exist
func GetSingleJobSet(test Test, namespace string) (*jobsetv1alpha2.JobSet, error) {
test.T().Helper()

jobsets, err := test.Client().JobSet().JobsetV1alpha2().JobSets(namespace).List(
test.Ctx(), metav1.ListOptions{})
if err != nil {
return nil, err
}

test.Expect(jobsets.Items).To(HaveLen(1), "Expected exactly one JobSet in namespace")
return &jobsets.Items[0], nil
}
Loading