Skip to content

Commit 003e0e6

Browse files
author
Matthew Fisher
committed
Merge pull request #66 from bacongobbler/limits-tests
feat(tests): add limits tests
2 parents 1023dd8 + c54c3c4 commit 003e0e6

1 file changed

Lines changed: 61 additions & 1 deletion

File tree

tests/limits_test.go

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,70 @@
11
package tests
22

33
import (
4+
"sync"
5+
46
. "github.com/onsi/ginkgo"
5-
// . "github.com/onsi/gomega"
7+
. "github.com/onsi/gomega"
68
)
79

10+
// TODO (bacongobbler): inspect kubectl for limits being applied to manifest
811
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+
})
963

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+
})
1070
})

0 commit comments

Comments
 (0)