volcano.sh/volcano@v1.9.0/test/e2e/jobseq/mpi_plugin.go (about)

     1  /*
     2  Copyright 2022 The Volcano Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package jobseq
    18  
    19  import (
    20  	. "github.com/onsi/ginkgo/v2"
    21  	. "github.com/onsi/gomega"
    22  	vcbatch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
    23  	vcbus "volcano.sh/apis/pkg/apis/bus/v1alpha1"
    24  	e2eutil "volcano.sh/volcano/test/e2e/util"
    25  )
    26  
    27  var _ = Describe("MPI Plugin E2E Test", func() {
    28  	It("will run and complete finally", func() {
    29  		context := e2eutil.InitTestContext(e2eutil.Options{})
    30  		defer e2eutil.CleanupTestContext(context)
    31  
    32  		slot := e2eutil.OneCPU
    33  
    34  		spec := &e2eutil.JobSpec{
    35  			Name: "mpi",
    36  			Min:  1,
    37  			Policies: []vcbatch.LifecyclePolicy{
    38  				{
    39  					Action: vcbus.CompleteJobAction,
    40  					Event:  vcbus.TaskCompletedEvent,
    41  				},
    42  			},
    43  			Plugins: map[string][]string{
    44  				"mpi": {"--master=mpimaster", "--worker=mpiworker", "--port=22"},
    45  			},
    46  			Tasks: []e2eutil.TaskSpec{
    47  				{
    48  					Name:       "mpimaster",
    49  					Img:        e2eutil.DefaultMPIImage,
    50  					Req:        slot,
    51  					Min:        1,
    52  					Rep:        1,
    53  					WorkingDir: "/home",
    54  					// Need sometime waiting for worker node ready
    55  					Command: `mkdir -p /var/run/sshd; /usr/sbin/sshd;
    56  mpiexec --allow-run-as-root --host ${MPI_HOST} -np 2 mpi_hello_world > /home/re`,
    57  				},
    58  				{
    59  					Name:       "mpiworker",
    60  					Img:        e2eutil.DefaultMPIImage,
    61  					Req:        slot,
    62  					Min:        2,
    63  					Rep:        2,
    64  					WorkingDir: "/home",
    65  					Command:    "mkdir -p /var/run/sshd; /usr/sbin/sshd -D;",
    66  				},
    67  			},
    68  		}
    69  
    70  		job := e2eutil.CreateJob(context, spec)
    71  		err := e2eutil.WaitJobPhases(context, job, []vcbatch.JobPhase{
    72  			vcbatch.Pending, vcbatch.Running, vcbatch.Completing, vcbatch.Completed})
    73  		Expect(err).NotTo(HaveOccurred())
    74  	})
    75  })