Skip to content

Commit

Permalink
Merge pull request #66 from bacongobbler/limits-tests
Browse files Browse the repository at this point in the history
feat(tests): add limits tests
  • Loading branch information
Matthew Fisher committed Mar 8, 2016
2 parents 1023dd8 + c54c3c4 commit 003e0e6
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion tests/limits_test.go
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"))
})
})
})

0 comments on commit 003e0e6

Please sign in to comment.