github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/sysctls_test.go (about) 1 // Copyright (c) 2019 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package docker 6 7 import ( 8 "strings" 9 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 ) 13 14 var _ = Describe("sysctls", func() { 15 var ( 16 args []string 17 id string 18 stdout string 19 exitCode int 20 ) 21 22 BeforeEach(func() { 23 id = randomDockerName() 24 }) 25 26 AfterEach(func() { 27 Expect(ExistDockerContainer(id)).NotTo(BeTrue()) 28 }) 29 30 Context("sysctls for fs", func() { 31 It("should be applied", func() { 32 fsValue := "512" 33 args = []string{"--name", id, "--rm", "--sysctl", "fs.mqueue.queues_max=" + fsValue, Image, "cat", "/proc/sys/fs/mqueue/queues_max"} 34 stdout, _, exitCode = dockerRun(args...) 35 Expect(exitCode).To(Equal(0)) 36 Expect(stdout).To(ContainSubstring(fsValue)) 37 }) 38 }) 39 40 Context("sysctls for kernel", func() { 41 It("should be applied", func() { 42 kernelValue := "1024" 43 args = []string{"--name", id, "--rm", "--sysctl", "kernel.shmmax=" + kernelValue, Image, "cat", "/proc/sys/kernel/shmmax"} 44 stdout, _, exitCode = dockerRun(args...) 45 Expect(exitCode).To(Equal(0)) 46 Expect(stdout).To(ContainSubstring(kernelValue)) 47 }) 48 }) 49 50 Context("sysctls for net", func() { 51 It("should be applied", func() { 52 pmtuValue := "1024" 53 args = []string{"--name", id, "--rm", "--sysctl", "net.ipv4.route.min_pmtu=" + pmtuValue, Image, "cat", "/proc/sys/net/ipv4/route/min_pmtu"} 54 stdout, _, exitCode = dockerRun(args...) 55 Expect(exitCode).To(Equal(0)) 56 Expect(stdout).To(ContainSubstring(pmtuValue)) 57 }) 58 }) 59 60 Context("sysctl for IP forwarding", func() { 61 It("should be applied", func() { 62 ipforwardValue := "1" 63 args = []string{"--name", id, "--rm", "--sysctl", "net.ipv4.ip_forward=" + ipforwardValue, Image, "cat", "/proc/sys/net/ipv4/ip_forward"} 64 stdout, _, exitCode = dockerRun(args...) 65 Expect(exitCode).To(Equal(0)) 66 Expect(strings.Trim(stdout, " \n\t")).To(Equal(ipforwardValue)) 67 }) 68 }) 69 })