github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/topgun/runtime/default_limits_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  )
     9  
    10  var _ = Describe("An ATC with default resource limits set", func() {
    11  	BeforeEach(func() {
    12  		Deploy(
    13  			"deployments/concourse.yml",
    14  			"-o", "operations/default_limits.yml",
    15  			"-v", "default_task_cpu_limit=512",
    16  			"-v", "default_task_memory_limit=1GB",
    17  		)
    18  	})
    19  
    20  	It("respects the default resource limits, overridding when specified", func() {
    21  		buildSession := Fly.Start("execute", "-c", "tasks/tiny.yml")
    22  		<-buildSession.Exited
    23  
    24  		interceptSession := Fly.Start(
    25  			"intercept",
    26  			"-b", "1",
    27  			"-s", "one-off",
    28  			"--", "sh", "-c",
    29  			"cat /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes; cat /sys/fs/cgroup/cpu/cpu.shares",
    30  		)
    31  		<-interceptSession.Exited
    32  
    33  		Expect(interceptSession.ExitCode()).To(Equal(0))
    34  		Expect(interceptSession).To(gbytes.Say("1073741824\n512"))
    35  
    36  		buildSession = Fly.Start("execute", "-c", "tasks/limits.yml")
    37  		<-buildSession.Exited
    38  
    39  		interceptSession = Fly.Start(
    40  			"intercept",
    41  			"-b", "2",
    42  			"-s", "one-off",
    43  			"--", "sh", "-c",
    44  			"cat /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes; cat /sys/fs/cgroup/cpu/cpu.shares",
    45  		)
    46  		<-interceptSession.Exited
    47  
    48  		Expect(interceptSession.ExitCode()).To(Equal(0))
    49  		Expect(interceptSession).To(gbytes.Say("104857600\n256"))
    50  	})
    51  })