Skip to content

Commit

Permalink
bin/test does not run diego
Browse files Browse the repository at this point in the history
  • Loading branch information
Onsi Fakhouri committed May 27, 2014
1 parent 748a93b commit 0b2386c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 71 deletions.
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 $@
38 changes: 12 additions & 26 deletions diego/init_test.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package diego

import (
"fmt"
"os"
"path/filepath"
"testing"
"time"

. "github.com/onsi/ginkgo"
ginkgoconfig "github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"

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

var context helpers.SuiteContext
const (
DEFAULT_TIMEOUT = 30 * time.Second
CF_PUSH_TIMEOUT = 2 * time.Minute
LONG_CURL_TIMEOUT = 2 * time.Minute
)

const CFPushTimeout = 120.0
const DefaultTimeout = 30.0
var context helpers.SuiteContext

func TestApplications(t *testing.T) {
RegisterFailHandler(Fail)
Expand All @@ -34,27 +33,14 @@ func TestApplications(t *testing.T) {
environment.Teardown()
})

componentName := "Diego"

rs := []Reporter{}

if config.ArtifactsDirectory != "" {
os.Setenv(
"CF_TRACE",
filepath.Join(
config.ArtifactsDirectory,
fmt.Sprintf("CATS-TRACE-%s-%d.txt", "DiegoApplications", ginkgoconfig.GinkgoConfig.ParallelNode),
),
)

rs = append(
rs,
reporters.NewJUnitReporter(
filepath.Join(
config.ArtifactsDirectory,
fmt.Sprintf("junit-%s-%d.xml", "DiegoApplications", ginkgoconfig.GinkgoConfig.ParallelNode),
),
),
)
helpers.EnableCFTrace(config, componentName)
rs = append(rs, helpers.NewJUnitReporter(config, componentName))
}

RunSpecsWithDefaultAndCustomReporters(t, "Applications with Diego", rs)
RunSpecsWithDefaultAndCustomReporters(t, componentName, rs)
}
38 changes: 19 additions & 19 deletions diego/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,71 @@ import (
. "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"
"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 = RandomName()
appName = generator.RandomName()

//Diego needs a custom buildpack until the ruby buildpack lands
Eventually(Cf("push", appName, "-p", NewAssets().Dora, "--no-start", "-b=https://github.com/cloudfoundry/cf-buildpack-ruby/archive/master.zip"), CFPushTimeout).Should(Exit(0))
Eventually(Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DefaultTimeout).Should(Exit(0))
Eventually(Cf("start", appName), CFPushTimeout).Should(Exit(0))
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("delete", appName, "-f"), DefaultTimeout).Should(Exit(0))
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(CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!"))
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!"))
})
})

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

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

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

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

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

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

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

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

It("removes the application and makes the app unreachable", func() {
Eventually(Cf("app", appName), DefaultTimeout).Should(Say("not found"))
Expect(CurlAppRoot(appName)).To(ContainSubstring("404"))
Eventually(cf.Cf("app", appName), DEFAULT_TIMEOUT).Should(Say("not found"))
Expect(helpers.CurlAppRoot(appName)).To(ContainSubstring("404"))
})
})
})
23 changes: 10 additions & 13 deletions diego/staging_failure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@ import (
. "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"
"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 = RandomName()
appName = generator.RandomName()

//Diego needs a custom buildpack until the ruby buildpack lands
Eventually(Cf("push", appName, "-p", NewAssets().Dora, "--no-start", "-b=http://example.com/so-not-a-thing/adlfijaskldjlkjaslbnalwieulfjkjsvas.zip"), CFPushTimeout).Should(Exit(0))
Eventually(Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DefaultTimeout).Should(Exit(0))
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("delete", appName, "-f"), DefaultTimeout).Should(Exit(0))
Eventually(cf.Cf("delete", appName, "-f"), DEFAULT_TIMEOUT).Should(Exit(0))
})

It("informs the user", func() {
start := Cf("start", appName)
Eventually(start, CFPushTimeout).Should(Exit(1))

//this fails so fast that the CLI can't stream the logging output, so we grab the recent logs instead
logs := Cf("logs", appName, "--recent").Wait(DefaultTimeout).Out.Contents()
Ω(logs).Should(ContainSubstring("Failed to Download Buildpack"))
start := cf.Cf("start", appName)
Eventually(start, CF_PUSH_TIMEOUT).Should(Exit(1))
Ω(start.Out).Should(Say("Failed to Download Buildpack"))
})
})
24 changes: 12 additions & 12 deletions diego/staging_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import (
. "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"
"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 = RandomName()
appName = generator.RandomName()
})

AfterEach(func() {
Eventually(Cf("delete", appName, "-f"), DefaultTimeout).Should(Exit(0))
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("push", appName, "-p", NewAssets().Dora, "--no-start", "-b=https://github.com/cloudfoundry/cf-buildpack-ruby/archive/master.zip"), CFPushTimeout).Should(Exit(0))
Eventually(Cf("set-env", appName, "CF_DIEGO_BETA", "true"), DefaultTimeout).Should(Exit(0))
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("start", appName)
start := cf.Cf("start", appName)

Eventually(start, CFPushTimeout).Should(Say("Downloading App Package"))
Eventually(start, CFPushTimeout).Should(Say("Downloaded App Package"))
Eventually(start, CFPushTimeout).Should(Say(`Staging\.\.\.`))
Eventually(start, CFPushTimeout).Should(Exit(0))
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 0b2386c

Please sign in to comment.