diff --git a/bin/test b/bin/test index 0a71fba71..6c769f319 100755 --- a/bin/test +++ b/bin/test @@ -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 $@ diff --git a/bin/test_con_diego b/bin/test_con_diego new file mode 100755 index 000000000..0a71fba71 --- /dev/null +++ b/bin/test_con_diego @@ -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 $@ diff --git a/diego/init_test.go b/diego/init_test.go new file mode 100644 index 000000000..d94e2c00d --- /dev/null +++ b/diego/init_test.go @@ -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) +} diff --git a/diego/lifecycle_test.go b/diego/lifecycle_test.go new file mode 100644 index 000000000..4d8996a16 --- /dev/null +++ b/diego/lifecycle_test.go @@ -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")) + }) + }) +}) diff --git a/diego/staging_failure_test.go b/diego/staging_failure_test.go new file mode 100644 index 000000000..332b6998b --- /dev/null +++ b/diego/staging_failure_test.go @@ -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")) + }) +}) diff --git a/diego/staging_log_test.go b/diego/staging_log_test.go new file mode 100644 index 000000000..10c2a7642 --- /dev/null +++ b/diego/staging_log_test.go @@ -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)) + }) +})