github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/topgun/both/image_artifact_test.go (about)

     1  package topgun_test
     2  
     3  import (
     4  	. "github.com/pf-qiu/concourse/v6/topgun/common"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/gomega"
     7  	"github.com/onsi/gomega/gbytes"
     8  	"github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("A job with a task using an image within the plan", func() {
    12  	BeforeEach(func() {
    13  		Deploy(
    14  			"deployments/concourse.yml",
    15  			"-o", "operations/add-other-worker.yml",
    16  			"-o", "operations/other-worker-tagged.yml",
    17  		)
    18  
    19  		Fly.Run("set-pipeline", "-n", "-p", "image-artifact", "-c", "pipelines/image-artifact.yml")
    20  		Fly.Run("unpause-pipeline", "-p", "image-artifact")
    21  	})
    22  
    23  	Describe("running the job", func() {
    24  		var jobName string
    25  		var jobSession *gexec.Session
    26  
    27  		BeforeEach(func() {
    28  			jobName = ""
    29  		})
    30  
    31  		JustBeforeEach(func() {
    32  			jobSession = Fly.Start("trigger-job", "-w", "-j", "image-artifact/"+jobName)
    33  			<-jobSession.Exited
    34  		})
    35  
    36  		Context("when the artifact is found on the worker", func() {
    37  			BeforeEach(func() {
    38  				jobName = "artifact-test-found-locally"
    39  			})
    40  
    41  			It("uses the specified image artifact to run the task", func() {
    42  				// Simultaneously test that it's using the image artifact instead of the
    43  				// image resource, and also that the files are mounted with the right
    44  				// permissions for a non-privileged task. If it's using the image
    45  				// resource, bash won't be installed and .bashrc won't exist. If the
    46  				// file permissions are set up for a privileged task, the contents of
    47  				// /root won't be accessible to the task's "fake root" user
    48  				Expect(jobSession).To(gbytes.Say(".bashrc"))
    49  			})
    50  		})
    51  
    52  		Context("when the artifact is found on another worker", func() {
    53  			BeforeEach(func() {
    54  				jobName = "artifact-test-stream-in"
    55  			})
    56  
    57  			It("uses the specified image artifact to run the task", func() {
    58  				Expect(jobSession).To(gbytes.Say(".bashrc"))
    59  			})
    60  		})
    61  	})
    62  })