|
| 1 | +package os_conf_acceptance_tests_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + . "github.com/onsi/ginkgo" |
| 7 | + . "github.com/onsi/gomega" |
| 8 | + "github.com/onsi/gomega/gbytes" |
| 9 | + "github.com/onsi/gomega/gexec" |
| 10 | +) |
| 11 | + |
| 12 | +var _ = Describe("Limits", func() { |
| 13 | + BeforeEach(func() { |
| 14 | + if boshStemcell == "ubuntu-trusty" { |
| 15 | + Skip("Trusty Stemcells are not supported.") |
| 16 | + } |
| 17 | + }) |
| 18 | + |
| 19 | + Context("when limits are configured", func() { |
| 20 | + It("sets the limits for the monit process", func() { |
| 21 | + session := boshSSH("os-conf/0", "pid=$(ps -e | grep monit | awk '{print $1}'); cat /proc/$pid/limits | grep 'Max open files' | awk '{print $4}'") |
| 22 | + Eventually(session, 30*time.Second).Should(gbytes.Say("60000")) |
| 23 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 24 | + |
| 25 | + session = boshSSH("os-conf/0", "pid=$(ps -e | grep monit | awk '{print $1}'); cat /proc/$pid/limits | grep 'Max open files' | awk '{print $5}'") |
| 26 | + Eventually(session, 30*time.Second).Should(gbytes.Say("100000")) |
| 27 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 28 | + }) |
| 29 | + |
| 30 | + It("sets the limits for the parent process", func() { |
| 31 | + session := boshSSH("os-conf/0", "pid=$(ps -e | grep monit | awk '{print $1}'); pid_parent=$(ps -o ppid:1= -p $pid); cat /proc/$pid_parent/limits | grep 'Max open files' | awk '{print $4}'") |
| 32 | + Eventually(session, 30*time.Second).Should(gbytes.Say("60000")) |
| 33 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 34 | + |
| 35 | + session = boshSSH("os-conf/0", "pid=$(ps -e | grep monit | awk '{print $1}'); pid_parent=$(ps -o ppid:1= -p $pid); cat /proc/$pid_parent/limits | grep 'Max open files' | awk '{print $5}'") |
| 36 | + Eventually(session, 30*time.Second).Should(gbytes.Say("100000")) |
| 37 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 38 | + }) |
| 39 | + |
| 40 | + It("sets the limits for the systemd process", func() { |
| 41 | + session := boshSSH("os-conf/0", "systemctl show | grep 'DefaultLimitNOFILESoft=' | awk -F= '{print $2}'") |
| 42 | + Eventually(session, 30*time.Second).Should(gbytes.Say("60000")) |
| 43 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 44 | + |
| 45 | + session = boshSSH("os-conf/0", "systemctl show | grep 'DefaultLimitNOFILE=' | awk -F= '{print $2}'") |
| 46 | + Eventually(session, 30*time.Second).Should(gbytes.Say("100000")) |
| 47 | + Eventually(session, 30*time.Second).Should(gexec.Exit(0)) |
| 48 | + }) |
| 49 | + }) |
| 50 | +}) |
0 commit comments