Skip to content

Commit e7a9dd3

Browse files
committed
Implement E2E tests for custom cluster-domain
Signed-off-by: Yuki Iwai <[email protected]>
1 parent 86733ad commit e7a9dd3

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

test/e2e/mpi_job_test.go

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ var _ = ginkgo.Describe("MPIJob", func() {
168168
expectConditionToBeTrue(mpiJob, kubeflow.JobSucceeded)
169169
})
170170

171-
ginkgo.It("should not be updated when managed externaly, only created", func() {
171+
ginkgo.It("should not be updated when managed externally, only created", func() {
172172
mpiJob.Spec.RunPolicy.ManagedBy = ptr.To(kubeflow.MultiKueueController)
173173
ctx := context.Background()
174174
mpiJob = createJob(ctx, mpiJob)
@@ -352,7 +352,7 @@ var _ = ginkgo.Describe("MPIJob", func() {
352352
// Set up the scheduler-plugins.
353353
setUpSchedulerPlugins()
354354
// Set up the mpi-operator so that the scheduler-plugins is used as gang-scheduler.
355-
setupMPIOperator(ctx, mpiJob, enableGangSchedulingFlag, unschedulableResources)
355+
setupMPIOperator(ctx, mpiJob, unschedulableResources, enableGangSchedulingFlag)
356356
})
357357

358358
ginkgo.AfterEach(func() {
@@ -447,7 +447,7 @@ var _ = ginkgo.Describe("MPIJob", func() {
447447
// Set up the volcano-scheduler.
448448
setupVolcanoScheduler()
449449
// Set up the mpi-operator so that the volcano scheduler is used as gang-scheduler.
450-
setupMPIOperator(ctx, mpiJob, enableGangSchedulingFlag, unschedulableResources)
450+
setupMPIOperator(ctx, mpiJob, unschedulableResources, enableGangSchedulingFlag)
451451
})
452452

453453
ginkgo.AfterEach(func() {
@@ -527,6 +527,45 @@ var _ = ginkgo.Describe("MPIJob", func() {
527527
}, foreverTimeout, waitInterval).Should(gomega.Equal(corev1.ConditionTrue))
528528
})
529529
})
530+
531+
// The custom cluster-domain e2e tests.
532+
ginkgo.Context("with custom cluster-domain", func() {
533+
const clusterDomainFlag = "--cluster-domain=cluster.local"
534+
var ctx = context.Background()
535+
536+
ginkgo.BeforeEach(func() {
537+
setupMPIOperator(ctx, mpiJob, nil, clusterDomainFlag)
538+
})
539+
540+
ginkgo.AfterEach(func() {
541+
operator, err := k8sClient.AppsV1().Deployments(mpiOperator).Get(ctx, mpiOperator, metav1.GetOptions{})
542+
oldOperator := operator.DeepCopy()
543+
gomega.Expect(err).Should(gomega.Succeed())
544+
for i, arg := range operator.Spec.Template.Spec.Containers[0].Args {
545+
if arg == clusterDomainFlag {
546+
operator.Spec.Template.Spec.Containers[0].Args = append(
547+
operator.Spec.Template.Spec.Containers[0].Args[:i], operator.Spec.Template.Spec.Containers[0].Args[i+1:]...)
548+
break
549+
}
550+
}
551+
if diff := cmp.Diff(oldOperator, operator); len(diff) != 0 {
552+
_, err = k8sClient.AppsV1().Deployments(mpiOperator).Update(ctx, operator, metav1.UpdateOptions{})
553+
gomega.Expect(err).Should(gomega.Succeed())
554+
gomega.Eventually(func() bool {
555+
ok, err := ensureDeploymentAvailableReplicas(ctx, mpiOperator, mpiOperator)
556+
gomega.Expect(err).Should(gomega.Succeed())
557+
return ok
558+
}, foreverTimeout, waitInterval).Should(gomega.BeTrue())
559+
}
560+
})
561+
562+
ginkgo.When("running as root", func() {
563+
ginkgo.It("should succeed", func() {
564+
mpiJob := createJobAndWaitForCompletion(mpiJob)
565+
expectConditionToBeTrue(mpiJob, kubeflow.JobSucceeded)
566+
})
567+
})
568+
})
530569
})
531570

532571
func resumeJob(ctx context.Context, mpiJob *kubeflow.MPIJob) *kubeflow.MPIJob {
@@ -761,7 +800,7 @@ func cleanUpVolcanoScheduler() {
761800
}
762801

763802
// setupMPIOperator scales down and scales up the MPIOperator replication so that set up gang-scheduler takes effect
764-
func setupMPIOperator(ctx context.Context, mpiJob *kubeflow.MPIJob, enableGangSchedulingFlag string, unschedulableResources *corev1.ResourceList) {
803+
func setupMPIOperator(ctx context.Context, mpiJob *kubeflow.MPIJob, unschedulableResources *corev1.ResourceList, managerFlags ...string) {
765804
ginkgo.By("Scale-In the deployment to 0")
766805
operator, err := k8sClient.AppsV1().Deployments(mpiOperator).Get(ctx, mpiOperator, metav1.GetOptions{})
767806
gomega.Expect(err).Should(gomega.Succeed())
@@ -778,7 +817,7 @@ func setupMPIOperator(ctx context.Context, mpiJob *kubeflow.MPIJob, enableGangSc
778817
gomega.Eventually(func() error {
779818
updatedOperator, err := k8sClient.AppsV1().Deployments(mpiOperator).Get(ctx, mpiOperator, metav1.GetOptions{})
780819
gomega.Expect(err).Should(gomega.Succeed())
781-
updatedOperator.Spec.Template.Spec.Containers[0].Args = append(updatedOperator.Spec.Template.Spec.Containers[0].Args, enableGangSchedulingFlag)
820+
updatedOperator.Spec.Template.Spec.Containers[0].Args = append(updatedOperator.Spec.Template.Spec.Containers[0].Args, managerFlags...)
782821
updatedOperator.Spec.Replicas = ptr.To[int32](1)
783822
_, err = k8sClient.AppsV1().Deployments(mpiOperator).Update(ctx, updatedOperator, metav1.UpdateOptions{})
784823
return err
@@ -791,5 +830,9 @@ func setupMPIOperator(ctx context.Context, mpiJob *kubeflow.MPIJob, enableGangSc
791830
return isNotZero
792831
}, foreverTimeout, waitInterval).Should(gomega.BeTrue())
793832
createMPIJobWithOpenMPI(mpiJob)
794-
mpiJob.Spec.RunPolicy.SchedulingPolicy = &kubeflow.SchedulingPolicy{MinResources: unschedulableResources}
833+
if unschedulableResources != nil {
834+
mpiJob.Spec.RunPolicy.SchedulingPolicy = &kubeflow.SchedulingPolicy{
835+
MinResources: unschedulableResources,
836+
}
837+
}
795838
}

0 commit comments

Comments
 (0)