Skip to content

Commit 8609f3a

Browse files
committed
Add test coverage for JobSet Workflow Orchestration
1 parent 54395f4 commit 8609f3a

File tree

3 files changed

+630
-0
lines changed

3 files changed

+630
-0
lines changed

tests/common/support/jobs.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package support
18+
19+
import (
20+
"strings"
21+
22+
batchv1 "k8s.io/api/batch/v1"
23+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
)
25+
26+
func GetJobByNamePattern(test Test, namespace, pattern string) (*batchv1.Job, error) {
27+
test.T().Helper()
28+
29+
jobs, err := test.Client().Core().BatchV1().Jobs(namespace).List(test.Ctx(), metav1.ListOptions{})
30+
if err != nil {
31+
return nil, err
32+
}
33+
34+
for _, job := range jobs.Items {
35+
if strings.Contains(job.Name, pattern) {
36+
return &job, nil
37+
}
38+
}
39+
40+
return nil, nil
41+
}

tests/common/support/jobset.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2025.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package support
18+
19+
import (
20+
. "github.com/onsi/gomega"
21+
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
24+
"k8s.io/apimachinery/pkg/runtime/schema"
25+
)
26+
27+
const (
28+
jobsetGroup = "jobset.x-k8s.io"
29+
jobsetVersion = "v1alpha2"
30+
)
31+
32+
var jobsetOperatorGVR = schema.GroupVersionResource{
33+
Group: jobsetGroup,
34+
Version: jobsetVersion,
35+
Resource: "jobsets",
36+
}
37+
38+
func GetSingleJobSet(test Test, namespace string) (*unstructured.Unstructured, error) {
39+
test.T().Helper()
40+
41+
jobsets, err := test.Client().Dynamic().Resource(jobsetOperatorGVR).Namespace(namespace).List(
42+
test.Ctx(), metav1.ListOptions{})
43+
if err != nil {
44+
return nil, err
45+
}
46+
47+
test.Expect(jobsets.Items).To(HaveLen(1), "Expected exactly one JobSet in namespace")
48+
return &jobsets.Items[0], nil
49+
}

0 commit comments

Comments
 (0)