@@ -709,6 +709,101 @@ 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
+ By ("By creating MPIJobs with and without preset env variables" )
715
+
716
+ testCases := map [string ]struct {
717
+ envVariables map [string ]string
718
+ expectedEnvVariables map [string ]string
719
+ }{
720
+ "withoutIMPIValues" : {
721
+ envVariables : map [string ]string {
722
+ "X_MPI_HYDRA_BOOTSTRAP" : "foo" ,
723
+ },
724
+ expectedEnvVariables : map [string ]string {
725
+ "I_MPI_HYDRA_BOOTSTRAP" : iMPIDefaultBootstrap ,
726
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : fmt .Sprintf ("%s/%s" , configMountPath , kubexecScriptName ),
727
+ },
728
+ },
729
+ "withIMPIBootstrap" : {
730
+ envVariables : map [string ]string {
731
+ "I_MPI_HYDRA_BOOTSTRAP" : "RSH" ,
732
+ },
733
+ expectedEnvVariables : map [string ]string {
734
+ "I_MPI_HYDRA_BOOTSTRAP" : "RSH" ,
735
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : fmt .Sprintf ("%s/%s" , configMountPath , kubexecScriptName ),
736
+ },
737
+ },
738
+ "withIMPIBootstrapExec" : {
739
+ envVariables : map [string ]string {
740
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" ,
741
+ },
742
+ expectedEnvVariables : map [string ]string {
743
+ "I_MPI_HYDRA_BOOTSTRAP" : iMPIDefaultBootstrap ,
744
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" ,
745
+ },
746
+ },
747
+ "withIMPIBootstrapAndExec" : {
748
+ envVariables : map [string ]string {
749
+ "I_MPI_HYDRA_BOOTSTRAP" : "RSH" ,
750
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" ,
751
+ },
752
+ expectedEnvVariables : map [string ]string {
753
+ "I_MPI_HYDRA_BOOTSTRAP" : "RSH" ,
754
+ "I_MPI_HYDRA_BOOTSTRAP_EXEC" : "/script.sh" ,
755
+ },
756
+ },
757
+ }
758
+
759
+ for testName , testCase := range testCases {
760
+ ctx := context .Background ()
761
+ startTime := metav1 .Now ()
762
+ completionTime := metav1 .Now ()
763
+
764
+ jobName := "test-launcher-creation-" + strings .ToLower (testName )
765
+
766
+ var replicas int32 = 1
767
+ mpiJob := newMPIJob (jobName , & replicas , 1 , gpuResourceName , & startTime , & completionTime )
768
+ Expect (testK8sClient .Create (ctx , mpiJob )).Should (Succeed ())
769
+
770
+ template := & mpiJob .Spec .MPIReplicaSpecs [kubeflowv1 .MPIJobReplicaTypeLauncher ].Template
771
+ Expect (len (template .Spec .Containers ) == 1 ).To (BeTrue ())
772
+
773
+ cont := & template .Spec .Containers [0 ]
774
+
775
+ for k , v := range testCase .envVariables {
776
+ cont .Env = append (cont .Env ,
777
+ corev1.EnvVar {
778
+ Name : k ,
779
+ Value : v ,
780
+ },
781
+ )
782
+ }
783
+
784
+ launcher := reconciler .newLauncher (mpiJob , "kubectl-delivery" , false )
785
+
786
+ Expect (len (launcher .Spec .Containers ) == 1 ).To (BeTrue ())
787
+
788
+ boot := false
789
+ bexec := false
790
+
791
+ for _ , env := range launcher .Spec .Containers [0 ].Env {
792
+ if env .Name == "I_MPI_HYDRA_BOOTSTRAP" {
793
+ Expect (env .Value ).To (BeEquivalentTo (testCase .expectedEnvVariables [env .Name ]))
794
+ boot = true
795
+ }
796
+ if env .Name == "I_MPI_HYDRA_BOOTSTRAP_EXEC" {
797
+ Expect (env .Value ).To (BeEquivalentTo (testCase .expectedEnvVariables [env .Name ]))
798
+ bexec = true
799
+ }
800
+ }
801
+
802
+ Expect (boot ).To (BeEquivalentTo (true ))
803
+ Expect (bexec ).To (BeEquivalentTo (true ))
804
+ }
805
+ })
806
+ })
712
807
})
713
808
714
809
func ReplicaStatusMatch (replicaStatuses map [common.ReplicaType ]* common.ReplicaStatus ,
0 commit comments