@@ -709,6 +709,91 @@ 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
+ mpiJob := newMPIJob (jobName , pointer .Int32 (1 ), 1 , gpuResourceName , & startTime , & completionTime )
767
+ Expect (testK8sClient .Create (ctx , mpiJob )).Should (Succeed ())
768
+
769
+ template := & mpiJob .Spec .MPIReplicaSpecs [kubeflowv1 .MPIJobReplicaTypeLauncher ].Template
770
+ Expect (len (template .Spec .Containers ) == 1 ).To (BeTrue ())
771
+
772
+ cont := & template .Spec .Containers [0 ]
773
+
774
+ for k , v := range testCase .envVariables {
775
+ cont .Env = append (cont .Env ,
776
+ corev1.EnvVar {
777
+ Name : k ,
778
+ Value : v ,
779
+ },
780
+ )
781
+ }
782
+
783
+ launcher := reconciler .newLauncher (mpiJob , "kubectl-delivery" , false )
784
+
785
+ Expect (len (launcher .Spec .Containers ) == 1 ).To (BeTrue ())
786
+ for expectedKey , expectedValue := range testCase .expectedEnvVariables {
787
+ Expect (launcher .Spec .Containers [0 ].Env ).Should (ContainElements (
788
+ corev1.EnvVar {
789
+ Name : expectedKey ,
790
+ Value : expectedValue ,
791
+ }),
792
+ )
793
+ }
794
+ }
795
+ })
796
+ })
712
797
})
713
798
714
799
func ReplicaStatusMatch (replicaStatuses map [common.ReplicaType ]* common.ReplicaStatus ,
0 commit comments