Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kubectl e2e test #8309

Merged
merged 1 commit into from
May 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ var _ = Describe("kubectl", func() {
)

It("should create and stop a replication controller", func() {
defer cleanup(nautilusPath, updateDemoSelector)
defer cleanup(nautilusPath, ns, updateDemoSelector)

By("creating a replication controller")
runKubectl("create", "-f", nautilusPath, fmt.Sprintf("--namespace=%v", ns))
validateController(c, nautilusImage, 2, "update-demo", updateDemoSelector, getUDData("nautilus.jpg", ns), ns)
})

It("should scale a replication controller", func() {
defer cleanup(nautilusPath, updateDemoSelector)
defer cleanup(nautilusPath, ns, updateDemoSelector)

By("creating a replication controller")
runKubectl("create", "-f", nautilusPath, fmt.Sprintf("--namespace=%v", ns))
Expand All @@ -95,7 +95,7 @@ var _ = Describe("kubectl", func() {

It("should do a rolling update of a replication controller", func() {
// Cleanup all resources in case we fail somewhere in the middle
defer cleanup(updateDemoRoot, updateDemoSelector)
defer cleanup(updateDemoRoot, ns, updateDemoSelector)

By("creating the initial replication controller")
runKubectl("create", "-f", nautilusPath, fmt.Sprintf("--namespace=%v", ns))
Expand All @@ -115,7 +115,7 @@ var _ = Describe("kubectl", func() {
return
}

defer cleanup(guestbookPath, frontendSelector, redisMasterSelector, redisSlaveSelector)
defer cleanup(guestbookPath, ns, frontendSelector, redisMasterSelector, redisSlaveSelector)

By("creating all guestbook components")
runKubectl("create", "-f", guestbookPath, fmt.Sprintf("--namespace=%v", ns))
Expand Down
11 changes: 8 additions & 3 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,17 @@ func expectNoError(err error, explain ...interface{}) {
ExpectWithOffset(1, err).NotTo(HaveOccurred(), explain...)
}

func cleanup(filePath string, selectors ...string) {
// Stops everything from filePath from namespace ns and checks if everything maching selectors from the given namespace is correctly stopped.
func cleanup(filePath string, ns string, selectors ...string) {
By("using stop to clean up resources")
runKubectl("stop", "-f", filePath)
var nsArg string
if ns != "" {
nsArg = fmt.Sprintf("--namespace=%s", ns)
}
runKubectl("stop", "-f", filePath, nsArg)

for _, selector := range selectors {
resources := runKubectl("get", "pods,rc,se", "-l", selector, "--no-headers")
resources := runKubectl("get", "pods,rc,se", "-l", selector, "--no-headers", nsArg)
if resources != "" {
Failf("Resources left running after stop:\n%s", resources)
}
Expand Down