@@ -709,6 +709,93 @@ var _ = Describe("MPIJob controller", func() {
709
709
})
710
710
})
711
711
712
+ Context ("Test launcher's Intel MPI handling" , func () {
713
+ It ("Should create a launcher job with Intel MPI env variables" , func () {
714
+ getIMPIValues := func (envs []corev1.EnvVar ) (bootstrap , exec string ) {
715
+ for _ , env := range envs {
716
+ if env .Name == "I_MPI_HYDRA_BOOTSTRAP" {
717
+ bootstrap = env .Value
718
+ }
719
+ if env .Name == "I_MPI_HYDRA_BOOTSTRAP_EXEC" {
720
+ exec = env .Value
721
+ }
722
+ }
723
+
724
+ return bootstrap , exec
725
+ }
726
+
727
+ By ("By creating MPIJobs with and without preset env variables" )
728
+
729
+ testCases := map [string ]struct {
730
+ envVariables map [string ]string
731
+ expectedAdded int
732
+ }{
733
+ "withoutIMPIValues" : {
734
+ envVariables : map [string ]string {"X_MPI_HYDRA_BOOTSTRAP" : "foo" },
735
+ expectedAdded : 2 ,
736
+ },
737
+ "withIMPIBootstrap" : {
738
+ envVariables : map [string ]string {"I_MPI_HYDRA_BOOTSTRAP" : "RSH" },
739
+ expectedAdded : 1 ,
740
+ },
741
+ "withIMPIBootstrapExec" : {
742
+ envVariables : map [string ]string {"I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" },
743
+ expectedAdded : 1 ,
744
+ },
745
+ "withIMPIBootstrapAndExec" : {
746
+ envVariables : map [string ]string {
747
+ "I_MPI_HYDRA_BOOTSTRAP" : "RSH" ,
748
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" ,
749
+ },
750
+ expectedAdded : 0 ,
751
+ },
752
+ }
753
+
754
+ for testName , testCase := range testCases {
755
+ ctx := context .Background ()
756
+ startTime := metav1 .Now ()
757
+ completionTime := metav1 .Now ()
758
+
759
+ jobName := "test-launcher-creation-" + strings .ToLower (testName )
760
+
761
+ var replicas int32 = 1
762
+ mpiJob := newMPIJob (jobName , & replicas , 1 , gpuResourceName , & startTime , & completionTime )
763
+ Expect (testK8sClient .Create (ctx , mpiJob )).Should (Succeed ())
764
+
765
+ template := & mpiJob .Spec .MPIReplicaSpecs [kubeflowv1 .MPIJobReplicaTypeLauncher ].Template
766
+ Expect (len (template .Spec .Containers ) == 1 ).To (BeTrue ())
767
+
768
+ cont := & template .Spec .Containers [0 ]
769
+
770
+ for k , v := range testCase .envVariables {
771
+ cont .Env = append (cont .Env ,
772
+ corev1.EnvVar {
773
+ Name : k ,
774
+ Value : v ,
775
+ },
776
+ )
777
+ }
778
+
779
+ launcher := reconciler .newLauncher (mpiJob , "kubectl-delivery" , false )
780
+
781
+ Expect (len (launcher .Spec .Containers ) == 1 ).To (BeTrue ())
782
+
783
+ bootstrap , exec := getIMPIValues (launcher .Spec .Containers [0 ].Env )
784
+
785
+ if val , found := testCase .envVariables ["I_MPI_HYDRA_BOOTSTRAP" ]; found {
786
+ Expect (bootstrap ).To (BeEquivalentTo (val ))
787
+ } else {
788
+ Expect (bootstrap ).To (BeEquivalentTo (iMPIDefaultBootstrap ))
789
+ }
790
+
791
+ if val , found := testCase .envVariables ["I_MPI_HYDRA_BOOTSTRAP_EXEC" ]; found {
792
+ Expect (exec ).To (BeEquivalentTo (val ))
793
+ } else {
794
+ Expect (exec ).To (BeEquivalentTo ("/etc/mpi/kubexec.sh" ))
795
+ }
796
+ }
797
+ })
798
+ })
712
799
})
713
800
714
801
func ReplicaStatusMatch (replicaStatuses map [common.ReplicaType ]* common.ReplicaStatus ,
0 commit comments