|
1 | 1 | package tests |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "sync" |
| 5 | + |
4 | 6 | . "github.com/onsi/ginkgo" |
5 | | - // . "github.com/onsi/gomega" |
| 7 | + . "github.com/onsi/gomega" |
6 | 8 | ) |
7 | 9 |
|
| 10 | +// TODO (bacongobbler): inspect kubectl for limits being applied to manifest |
8 | 11 | var _ = Describe("Limits", func() { |
| 12 | + Context("with a deployed app", func() { |
| 13 | + |
| 14 | + var testApp App |
| 15 | + once := &sync.Once{} |
| 16 | + |
| 17 | + BeforeEach(func() { |
| 18 | + // Set up the Limits test app only once and assume the suite will clean up. |
| 19 | + once.Do(func() { |
| 20 | + testApp = deployApp("example-go") |
| 21 | + }) |
| 22 | + }) |
| 23 | + |
| 24 | + It("can list limits", func() { |
| 25 | + sess, err := execute("deis limits:list -a %s", testApp.Name) |
| 26 | + Expect(err).NotTo(HaveOccurred()) |
| 27 | + Expect(sess).To(SatisfyAll( |
| 28 | + ContainSubstring("=== %s Limits", testApp.Name), |
| 29 | + ContainSubstring("--- Memory\nUnlimited"), |
| 30 | + ContainSubstring("--- CPU\nUnlimited"), |
| 31 | + )) |
| 32 | + }) |
| 33 | + |
| 34 | + It("can set a memory limit", func() { |
| 35 | + sess, err := execute("deis limits:set cmd=64M -a %s", testApp.Name) |
| 36 | + Expect(err).NotTo(HaveOccurred()) |
| 37 | + Expect(sess).To(ContainSubstring("--- Memory\ncmd 64M")) |
| 38 | + // Check that --memory also works too |
| 39 | + sess, err = execute("deis limits:set --memory cmd=128M -a %s", testApp.Name) |
| 40 | + Expect(err).NotTo(HaveOccurred()) |
| 41 | + Expect(sess).To(ContainSubstring("--- Memory\ncmd 128M")) |
| 42 | + }) |
| 43 | + |
| 44 | + It("can set a CPU limit", func() { |
| 45 | + sess, err := execute("deis limits:set --cpu cmd=1024 -a %s", testApp.Name) |
| 46 | + Expect(err).NotTo(HaveOccurred()) |
| 47 | + Expect(sess).To(ContainSubstring("--- CPU\ncmd 1024")) |
| 48 | + }) |
| 49 | + |
| 50 | + It("can unset a memory limit", func() { |
| 51 | + sess, err := execute("deis limits:unset cmd -a %s", testApp.Name) |
| 52 | + Expect(err).NotTo(HaveOccurred(), sess) |
| 53 | + Expect(sess).To(ContainSubstring("--- Memory\nUnlimited")) |
| 54 | + |
| 55 | + // Check that --memory works too |
| 56 | + sess, err = execute("deis limits:set --memory cmd=64M -a %s", testApp.Name) |
| 57 | + Expect(err).NotTo(HaveOccurred(), sess) |
| 58 | + Expect(sess).To(ContainSubstring("--- Memory\ncmd 64M")) |
| 59 | + sess, err = execute("deis limits:unset --memory cmd -a %s", testApp.Name) |
| 60 | + Expect(err).NotTo(HaveOccurred(), sess) |
| 61 | + Expect(sess).To(ContainSubstring("--- Memory\nUnlimited")) |
| 62 | + }) |
9 | 63 |
|
| 64 | + It("can unset a CPU limit", func() { |
| 65 | + sess, err := execute("deis limits:unset --cpu cmd -a %s", testApp.Name) |
| 66 | + Expect(err).NotTo(HaveOccurred(), sess) |
| 67 | + Expect(sess).To(ContainSubstring("--- CPU\nUnlimited")) |
| 68 | + }) |
| 69 | + }) |
10 | 70 | }) |
0 commit comments