Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mszadkow committed Oct 2, 2024
1 parent 4ac4cb2 commit c199396
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
17 changes: 17 additions & 0 deletions test/e2e/mpi_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -185,6 +186,9 @@ var _ = ginkgo.Describe("MPIJob", func() {
gomega.Expect(condition).To(gomega.BeNil())
condition = getJobCondition(mpiJob, kubeflow.JobSucceeded)
gomega.Expect(condition).To(gomega.BeNil())
launcherJob, err := getLauncherJob(ctx, mpiJob)
gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(launcherJob).To(gomega.BeNil())
launcherPods, err := getLauncherPods(ctx, mpiJob)
gomega.Expect(err).To(gomega.BeNil())
gomega.Expect(len(launcherPods.Items)).To(gomega.Equal(0))
Expand Down Expand Up @@ -681,6 +685,19 @@ func getJobCondition(mpiJob *kubeflow.MPIJob, condType kubeflow.JobConditionType
return nil
}

func getLauncherJob(ctx context.Context, mpiJob *kubeflow.MPIJob) (*batchv1.Job, error) {
result, err := k8sClient.BatchV1().Jobs(mpiJob.Namespace).List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
for _, j := range result.Items {
if metav1.IsControlledBy(&j, mpiJob) {
return &j, nil
}
}
return nil, nil
}

func createMPIJobWithOpenMPI(mpiJob *kubeflow.MPIJob) {
mpiJob.Spec.MPIReplicaSpecs[kubeflow.MPIReplicaTypeLauncher].Template.Spec.Containers = []corev1.Container{
{
Expand Down
10 changes: 5 additions & 5 deletions test/integration/mpi_job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,13 +891,13 @@ func TestMPIJobManagedExternally(t *testing.T) {
if mpiJobHasCondition(mpiJob, kubeflow.JobCreated) {
t.Errorf("MPIJob shouldn't have any condition")
}
// 4. No Pods or Services created
pods, err := getPodsForJob(ctx, s.kClient, mpiJob)
// 4. No Jobs or Services created
lp, err := getLauncherJobForMPIJob(ctx, s.kClient, mpiJob)
if err != nil {
t.Fatalf("Failed getting pods for the job: %v", err)
t.Fatalf("Failed getting launcher jobs: %v", err)
}
if len(pods) > 0 {
t.Fatalf("There should be no pods from job: %v", pods)
if lp != nil {
t.Fatalf("There should be no launcher jobs from job: %v", lp)
}
svcs, err := getServiceForJob(ctx, s.kClient, mpiJob)
if err != nil {
Expand Down

0 comments on commit c199396

Please sign in to comment.