Skip to content

Commit

Permalink
Merge branch 'diego'
Browse files Browse the repository at this point in the history
  • Loading branch information
Onsi Fakhouri committed May 27, 2014
2 parents 74c85d7 + 0b2386c commit a973aec
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ set -e -x

go install -v github.com/onsi/ginkgo/ginkgo
echo "RUNNING LOCAL CODE"
ginkgo -r -slowSpecThreshold=120 $@
ginkgo -r -skipPackage=diego -slowSpecThreshold=120 $@
9 changes: 9 additions & 0 deletions bin/test_con_diego
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e -x

. $(dirname $0)/goenv

go install -v github.com/onsi/ginkgo/ginkgo
echo "RUNNING LOCAL CODE"
ginkgo -r -slowSpecThreshold=120 $@
46 changes: 46 additions & 0 deletions diego/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package diego

import (
"testing"
"time"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/cloudfoundry/cf-acceptance-tests/helpers"
)

const (
DEFAULT_TIMEOUT = 30 * time.Second
CF_PUSH_TIMEOUT = 2 * time.Minute
LONG_CURL_TIMEOUT = 2 * time.Minute
)

var context helpers.SuiteContext

func TestApplications(t *testing.T) {
RegisterFailHandler(Fail)

config := helpers.LoadConfig()
context = helpers.NewContext(config)
environment := helpers.NewEnvironment(context)

BeforeSuite(func() {
environment.Setup()
})

AfterSuite(func() {
environment.Teardown()
})

componentName := "Diego"

rs := []Reporter{}

if config.ArtifactsDirectory != "" {
helpers.EnableCFTrace(config, componentName)
rs = append(rs, helpers.NewJUnitReporter(config, componentName))
}

RunSpecsWithDefaultAndCustomReporters(t, componentName, rs)
}
76 changes: 76 additions & 0 deletions diego/lifecycle_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package diego

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"

"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry/cf-acceptance-tests/helpers"
)

var _ = Describe("Application staging with Diego", func() {
var appName string

BeforeEach(func() {
appName = generator.RandomName()

//Diego needs a custom buildpack until the ruby buildpack lands
Eventually(cf.Cf("push", appName, "-p", helpers.NewAssets().Dora, "--no-start", "-b=https://github.com/cloudfoundry/cf-buildpack-ruby/archive/master.zip"), CF_PUSH_TIMEOUT).Should(Exit(0))
Eventually(cf.Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DEFAULT_TIMEOUT).Should(Exit(0))
Eventually(cf.Cf("start", appName), CF_PUSH_TIMEOUT).Should(Exit(0))
})

AfterEach(func() {
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})

Describe("pushing", func() {
It("makes the app reachable via its bound route", func() {
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!"))
})
})

Describe("stopping", func() {
BeforeEach(func() {
Eventually(cf.Cf("stop", appName), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("makes the app unreachable", func() {
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("404"))
})

Describe("and then starting", func() {
BeforeEach(func() {
Eventually(cf.Cf("start", appName), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("makes the app reachable again", func() {
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!"))
})
})
})

Describe("updating", func() {
It("is reflected through another push", func() {
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!"))

Eventually(cf.Cf("push", appName, "-p", helpers.NewAssets().HelloWorld), CF_PUSH_TIMEOUT).Should(Exit(0))

Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("Hello, world!"))
})
})

Describe("deleting", func() {
BeforeEach(func() {
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("removes the application and makes the app unreachable", func() {
Eventually(cf.Cf("app", appName), DEFAULT_TIMEOUT).Should(Say("not found"))
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("404"))
})
})
})
33 changes: 33 additions & 0 deletions diego/staging_failure_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package diego

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"

"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry/cf-acceptance-tests/helpers"
)

var _ = Describe("When staging fails", func() {
var appName string

BeforeEach(func() {
appName = generator.RandomName()

//Diego needs a custom buildpack until the ruby buildpack lands
Eventually(cf.Cf("push", appName, "-p", helpers.NewAssets().Dora, "--no-start", "-b=http://example.com/so-not-a-thing/adlfijaskldjlkjaslbnalwieulfjkjsvas.zip"), CF_PUSH_TIMEOUT).Should(Exit(0))
Eventually(cf.Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DEFAULT_TIMEOUT).Should(Exit(0))
})

AfterEach(func() {
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("informs the user", func() {
start := cf.Cf("start", appName)
Eventually(start, CF_PUSH_TIMEOUT).Should(Exit(1))
Ω(start.Out).Should(Say("Failed to Download Buildpack"))
})
})
37 changes: 37 additions & 0 deletions diego/staging_log_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package diego

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"

"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/generator"
"github.com/cloudfoundry/cf-acceptance-tests/helpers"
)

var _ = Describe("An application being staged with Diego", func() {
var appName string

BeforeEach(func() {
appName = generator.RandomName()
})

AfterEach(func() {
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("has its staging log streamed during a push", func() {
//Diego needs a custom buildpack until the ruby buildpack lands
Eventually(cf.Cf("push", appName, "-p", helpers.NewAssets().Dora, "--no-start", "-b=https://github.com/cloudfoundry/cf-buildpack-ruby/archive/master.zip"), CF_PUSH_TIMEOUT).Should(Exit(0))
Eventually(cf.Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DEFAULT_TIMEOUT).Should(Exit(0))

start := cf.Cf("start", appName)

Eventually(start, CF_PUSH_TIMEOUT).Should(Say("Downloading App Package"))
Eventually(start, CF_PUSH_TIMEOUT).Should(Say("Downloaded App Package"))
Eventually(start, CF_PUSH_TIMEOUT).Should(Say(`Staging\.\.\.`))
Eventually(start, CF_PUSH_TIMEOUT).Should(Exit(0))
})
})

0 comments on commit a973aec

Please sign in to comment.