-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from bacongobbler/limits-tests
feat(tests): add limits tests
- Loading branch information
Showing
1 changed file
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,70 @@ | ||
package tests | ||
|
||
import ( | ||
"sync" | ||
|
||
. "github.com/onsi/ginkgo" | ||
// . "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
// TODO (bacongobbler): inspect kubectl for limits being applied to manifest | ||
var _ = Describe("Limits", func() { | ||
Context("with a deployed app", func() { | ||
|
||
var testApp App | ||
once := &sync.Once{} | ||
|
||
BeforeEach(func() { | ||
// Set up the Limits test app only once and assume the suite will clean up. | ||
once.Do(func() { | ||
testApp = deployApp("example-go") | ||
}) | ||
}) | ||
|
||
It("can list limits", func() { | ||
sess, err := execute("deis limits:list -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(sess).To(SatisfyAll( | ||
ContainSubstring("=== %s Limits", testApp.Name), | ||
ContainSubstring("--- Memory\nUnlimited"), | ||
ContainSubstring("--- CPU\nUnlimited"), | ||
)) | ||
}) | ||
|
||
It("can set a memory limit", func() { | ||
sess, err := execute("deis limits:set cmd=64M -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(sess).To(ContainSubstring("--- Memory\ncmd 64M")) | ||
// Check that --memory also works too | ||
sess, err = execute("deis limits:set --memory cmd=128M -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(sess).To(ContainSubstring("--- Memory\ncmd 128M")) | ||
}) | ||
|
||
It("can set a CPU limit", func() { | ||
sess, err := execute("deis limits:set --cpu cmd=1024 -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(sess).To(ContainSubstring("--- CPU\ncmd 1024")) | ||
}) | ||
|
||
It("can unset a memory limit", func() { | ||
sess, err := execute("deis limits:unset cmd -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred(), sess) | ||
Expect(sess).To(ContainSubstring("--- Memory\nUnlimited")) | ||
|
||
// Check that --memory works too | ||
sess, err = execute("deis limits:set --memory cmd=64M -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred(), sess) | ||
Expect(sess).To(ContainSubstring("--- Memory\ncmd 64M")) | ||
sess, err = execute("deis limits:unset --memory cmd -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred(), sess) | ||
Expect(sess).To(ContainSubstring("--- Memory\nUnlimited")) | ||
}) | ||
|
||
It("can unset a CPU limit", func() { | ||
sess, err := execute("deis limits:unset --cpu cmd -a %s", testApp.Name) | ||
Expect(err).NotTo(HaveOccurred(), sess) | ||
Expect(sess).To(ContainSubstring("--- CPU\nUnlimited")) | ||
}) | ||
}) | ||
}) |