From 4a9d5bb5e01a28ab18009fcc168112d41970b1d0 Mon Sep 17 00:00:00 2001 From: Alex Suraci Date: Thu, 3 Apr 2014 15:29:23 -0700 Subject: [PATCH 1/5] add diego staging + lifecycle tests --- diego/init_test.go | 47 +++++++++++++++++++++++ diego/lifecycle_test.go | 78 +++++++++++++++++++++++++++++++++++++++ diego/staging_log_test.go | 35 ++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 diego/init_test.go create mode 100644 diego/lifecycle_test.go create mode 100644 diego/staging_log_test.go diff --git a/diego/init_test.go b/diego/init_test.go new file mode 100644 index 000000000..4623ab264 --- /dev/null +++ b/diego/init_test.go @@ -0,0 +1,47 @@ +package diego + +import ( + "fmt" + "os" + "path/filepath" + "testing" + + . "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" +) + +func TestApplications(t *testing.T) { + RegisterFailHandler(Fail) + + config := helpers.LoadConfig() + + helpers.SetupEnvironment(t, helpers.NewContext(config)) + + 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), + ), + ), + ) + } + + RunSpecsWithDefaultAndCustomReporters(t, "Applications with Diego", rs) +} diff --git a/diego/lifecycle_test.go b/diego/lifecycle_test.go new file mode 100644 index 000000000..ec07e86e3 --- /dev/null +++ b/diego/lifecycle_test.go @@ -0,0 +1,78 @@ +package diego + +import ( + "time" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/vito/cmdtest/matchers" + + . "github.com/cloudfoundry/cf-acceptance-tests/helpers" + . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" + . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" +) + +var _ = Describe("Application staging with Diego", func() { + var appName string + + BeforeEach(func() { + appName = RandomName() + + Expect(Cf("push", appName, "-p", NewAssets().Dora, "--no-start")).To(ExitWithTimeout(0, 30*time.Second)) + Expect(Cf("set-env", appName, "CF_DIEGO_BETA", "true")).To(ExitWith(0)) + Expect(Cf("start", appName)).To(Say("App started")) + }) + + AfterEach(func() { + Expect(Cf("delete", appName, "-f")).To(Say("OK")) + }) + + Describe("pushing", func() { + It("makes the app reachable via its bound route", func() { + Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + }) + }) + + Describe("stopping", func() { + BeforeEach(func() { + Expect(Cf("stop", appName)).To(Say("OK")) + }) + + It("makes the app unreachable", func() { + Eventually(Curling(appName, "/", LoadConfig().AppsDomain), 5.0).Should(Say("404")) + }) + + Describe("and then starting", func() { + BeforeEach(func() { + Expect(Cf("start", appName)).To(Say("App started")) + }) + + It("makes the app reachable again", func() { + Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + }) + }) + }) + + Describe("updating", func() { + It("is reflected through another push", func() { + Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + + Expect(Cf("push", appName, "-p", NewAssets().HelloWorld)).To(Say("App started")) + + Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hello, world!")) + }) + }) + + Describe("deleting", func() { + BeforeEach(func() { + Expect(Cf("delete", appName, "-f")).To(Say("OK")) + }) + + It("removes the application", func() { + Expect(Cf("app", appName)).To(Say("not found")) + }) + + It("makes the app unreachable", func() { + Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("404")) + }) + }) +}) diff --git a/diego/staging_log_test.go b/diego/staging_log_test.go new file mode 100644 index 000000000..a1c597a5a --- /dev/null +++ b/diego/staging_log_test.go @@ -0,0 +1,35 @@ +package diego + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/vito/cmdtest/matchers" + + . "github.com/cloudfoundry/cf-acceptance-tests/helpers" + . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" + . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" +) + +var _ = PDescribe("An application being staged with Diego", func() { + var appName string + + BeforeEach(func() { + appName = RandomName() + }) + + AfterEach(func() { + Expect(Cf("delete", appName, "-f")).To(Say("OK")) + }) + + It("has its staging log streamed during a push", func() { + Expect(Cf("push", appName, "-p", NewAssets().Dora, "--no-start")).To(ExitWith(0)) + Expect(Cf("set-env", appName, "CF_DIEGO_BETA", "true")).To(ExitWith(0)) + + start := Cf("start", appName) + + Expect(start).To(Say("Downloading app package")) + Expect(start).To(Say("Downloaded app package")) + Expect(start).To(Say("Compiling")) + Expect(start).To(Say("App started")) + }) +}) From 977c73469dd0faadb3219147c93d65cadeaa7ef3 Mon Sep 17 00:00:00 2001 From: Alex Suraci Date: Tue, 8 Apr 2014 13:07:42 -0700 Subject: [PATCH 2/5] fix SetupEnvironment in diego suite --- diego/init_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diego/init_test.go b/diego/init_test.go index 4623ab264..6ddcfd8b0 100644 --- a/diego/init_test.go +++ b/diego/init_test.go @@ -19,7 +19,7 @@ func TestApplications(t *testing.T) { config := helpers.LoadConfig() - helpers.SetupEnvironment(t, helpers.NewContext(config)) + helpers.SetupEnvironment(helpers.NewContext(config)) rs := []Reporter{} From 2c520c706938e6540188a91b7f42679cadfa75ba Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Tue, 6 May 2014 11:52:01 -0700 Subject: [PATCH 3/5] Bring diego tests into the gexec world Add staging failure test --- diego/init_test.go | 15 ++++++++++++- diego/lifecycle_test.go | 40 +++++++++++++++++------------------ diego/staging_failure_test.go | 36 +++++++++++++++++++++++++++++++ diego/staging_log_test.go | 20 ++++++++++-------- 4 files changed, 80 insertions(+), 31 deletions(-) create mode 100644 diego/staging_failure_test.go diff --git a/diego/init_test.go b/diego/init_test.go index 6ddcfd8b0..0afc3dba9 100644 --- a/diego/init_test.go +++ b/diego/init_test.go @@ -14,12 +14,25 @@ import ( "github.com/cloudfoundry/cf-acceptance-tests/helpers" ) +var context helpers.SuiteContext + +const CFPushTimeout = 120.0 +const DefaultTimeout = 30.0 + func TestApplications(t *testing.T) { RegisterFailHandler(Fail) config := helpers.LoadConfig() + context = helpers.NewContext(config) + environment := helpers.NewEnvironment(context) + + BeforeSuite(func() { + environment.Setup() + }) - helpers.SetupEnvironment(helpers.NewContext(config)) + AfterSuite(func() { + environment.Teardown() + }) rs := []Reporter{} diff --git a/diego/lifecycle_test.go b/diego/lifecycle_test.go index ec07e86e3..796bca71c 100644 --- a/diego/lifecycle_test.go +++ b/diego/lifecycle_test.go @@ -1,10 +1,10 @@ package diego import ( - "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - . "github.com/vito/cmdtest/matchers" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" . "github.com/cloudfoundry/cf-acceptance-tests/helpers" . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" @@ -17,62 +17,60 @@ var _ = Describe("Application staging with Diego", func() { BeforeEach(func() { appName = RandomName() - Expect(Cf("push", appName, "-p", NewAssets().Dora, "--no-start")).To(ExitWithTimeout(0, 30*time.Second)) - Expect(Cf("set-env", appName, "CF_DIEGO_BETA", "true")).To(ExitWith(0)) - Expect(Cf("start", appName)).To(Say("App started")) + //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)) }) AfterEach(func() { - Expect(Cf("delete", appName, "-f")).To(Say("OK")) + Eventually(Cf("delete", appName, "-f"), DefaultTimeout).Should(Exit(0)) }) Describe("pushing", func() { It("makes the app reachable via its bound route", func() { - Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) }) }) Describe("stopping", func() { BeforeEach(func() { - Expect(Cf("stop", appName)).To(Say("OK")) + Eventually(Cf("stop", appName), DefaultTimeout).Should(Exit(0)) }) It("makes the app unreachable", func() { - Eventually(Curling(appName, "/", LoadConfig().AppsDomain), 5.0).Should(Say("404")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("404")) }) Describe("and then starting", func() { BeforeEach(func() { - Expect(Cf("start", appName)).To(Say("App started")) + Eventually(Cf("start", appName), DefaultTimeout).Should(Exit(0)) }) It("makes the app reachable again", func() { - Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) }) }) }) Describe("updating", func() { It("is reflected through another push", func() { - Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hi, I'm Dora!")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) - Expect(Cf("push", appName, "-p", NewAssets().HelloWorld)).To(Say("App started")) + Eventually(Cf("push", appName, "-p", NewAssets().HelloWorld), CFPushTimeout).Should(Exit(0)) - Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("Hello, world!")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hello, world!")) }) }) Describe("deleting", func() { BeforeEach(func() { - Expect(Cf("delete", appName, "-f")).To(Say("OK")) + Eventually(Cf("delete", appName, "-f"), DefaultTimeout).Should(Exit(0)) }) - It("removes the application", func() { - Expect(Cf("app", appName)).To(Say("not found")) - }) - - It("makes the app unreachable", func() { - Eventually(Curling(appName, "/", LoadConfig().AppsDomain)).Should(Say("404")) + It("removes the application and makes the app unreachable", func() { + Eventually(Cf("app", appName), DefaultTimeout).Should(Say("not found")) + Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("404")) }) }) }) diff --git a/diego/staging_failure_test.go b/diego/staging_failure_test.go new file mode 100644 index 000000000..5370b248e --- /dev/null +++ b/diego/staging_failure_test.go @@ -0,0 +1,36 @@ +package diego + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + . "github.com/onsi/gomega/gexec" + + . "github.com/cloudfoundry/cf-acceptance-tests/helpers" + . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" + . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" +) + +var _ = Describe("When staging fails", func() { + var appName string + + BeforeEach(func() { + appName = 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)) + }) + + AfterEach(func() { + Eventually(Cf("delete", appName, "-f"), DefaultTimeout).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")) + }) +}) diff --git a/diego/staging_log_test.go b/diego/staging_log_test.go index a1c597a5a..1f8a73d26 100644 --- a/diego/staging_log_test.go +++ b/diego/staging_log_test.go @@ -3,14 +3,15 @@ package diego import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - . "github.com/vito/cmdtest/matchers" + . "github.com/onsi/gomega/gbytes" + . "github.com/onsi/gomega/gexec" . "github.com/cloudfoundry/cf-acceptance-tests/helpers" . "github.com/pivotal-cf-experimental/cf-test-helpers/cf" . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) -var _ = PDescribe("An application being staged with Diego", func() { +var _ = Describe("An application being staged with Diego", func() { var appName string BeforeEach(func() { @@ -18,18 +19,19 @@ var _ = PDescribe("An application being staged with Diego", func() { }) AfterEach(func() { - Expect(Cf("delete", appName, "-f")).To(Say("OK")) + Eventually(Cf("delete", appName, "-f"), DefaultTimeout).Should(Exit(0)) }) It("has its staging log streamed during a push", func() { - Expect(Cf("push", appName, "-p", NewAssets().Dora, "--no-start")).To(ExitWith(0)) - Expect(Cf("set-env", appName, "CF_DIEGO_BETA", "true")).To(ExitWith(0)) + //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)) start := Cf("start", appName) - Expect(start).To(Say("Downloading app package")) - Expect(start).To(Say("Downloaded app package")) - Expect(start).To(Say("Compiling")) - Expect(start).To(Say("App started")) + 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)) }) }) From 0630bd6741989add97b224e7fb5ab48d2fa229e1 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 7 May 2014 11:34:36 -0700 Subject: [PATCH 4/5] sync up with master --- diego/lifecycle_test.go | 16 ++++++++-------- diego/staging_failure_test.go | 4 ++-- diego/staging_log_test.go | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/diego/lifecycle_test.go b/diego/lifecycle_test.go index 796bca71c..2f0462842 100644 --- a/diego/lifecycle_test.go +++ b/diego/lifecycle_test.go @@ -6,9 +6,9 @@ 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/pivotal-cf-experimental/cf-test-helpers/cf" - . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("Application staging with Diego", func() { @@ -29,7 +29,7 @@ var _ = Describe("Application staging with Diego", func() { Describe("pushing", func() { It("makes the app reachable via its bound route", func() { - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!")) }) }) @@ -39,7 +39,7 @@ var _ = Describe("Application staging with Diego", func() { }) It("makes the app unreachable", func() { - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("404")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("404")) }) Describe("and then starting", func() { @@ -48,18 +48,18 @@ var _ = Describe("Application staging with Diego", func() { }) It("makes the app reachable again", func() { - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!")) }) }) }) Describe("updating", func() { It("is reflected through another push", func() { - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hi, I'm Dora!")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("Hi, I'm Dora!")) Eventually(Cf("push", appName, "-p", NewAssets().HelloWorld), CFPushTimeout).Should(Exit(0)) - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("Hello, world!")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("Hello, world!")) }) }) @@ -70,7 +70,7 @@ var _ = Describe("Application staging with Diego", func() { It("removes the application and makes the app unreachable", func() { Eventually(Cf("app", appName), DefaultTimeout).Should(Say("not found")) - Eventually(CurlFetcher(appName, "/", LoadConfig().AppsDomain), DefaultTimeout).Should(ContainSubstring("404")) + Expect(CurlAppRoot(appName)).To(ContainSubstring("404")) }) }) }) diff --git a/diego/staging_failure_test.go b/diego/staging_failure_test.go index 5370b248e..82a547060 100644 --- a/diego/staging_failure_test.go +++ b/diego/staging_failure_test.go @@ -5,9 +5,9 @@ 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/pivotal-cf-experimental/cf-test-helpers/cf" - . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("When staging fails", func() { diff --git a/diego/staging_log_test.go b/diego/staging_log_test.go index 1f8a73d26..bb37aedb0 100644 --- a/diego/staging_log_test.go +++ b/diego/staging_log_test.go @@ -6,9 +6,9 @@ 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/pivotal-cf-experimental/cf-test-helpers/cf" - . "github.com/pivotal-cf-experimental/cf-test-helpers/generator" ) var _ = Describe("An application being staged with Diego", func() { From 0b2386c26c2541813cb320a259f4811fa8445602 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Tue, 27 May 2014 15:53:51 -0700 Subject: [PATCH 5/5] bin/test does not run diego --- bin/test | 2 +- bin/test_con_diego | 9 +++++++++ diego/init_test.go | 38 +++++++++++------------------------ diego/lifecycle_test.go | 38 +++++++++++++++++------------------ diego/staging_failure_test.go | 23 +++++++++------------ diego/staging_log_test.go | 24 +++++++++++----------- 6 files changed, 63 insertions(+), 71 deletions(-) create mode 100755 bin/test_con_diego 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 index 0afc3dba9..d94e2c00d 100644 --- a/diego/init_test.go +++ b/diego/init_test.go @@ -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) @@ -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) } diff --git a/diego/lifecycle_test.go b/diego/lifecycle_test.go index 2f0462842..4d8996a16 100644 --- a/diego/lifecycle_test.go +++ b/diego/lifecycle_test.go @@ -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")) }) }) }) diff --git a/diego/staging_failure_test.go b/diego/staging_failure_test.go index 82a547060..332b6998b 100644 --- a/diego/staging_failure_test.go +++ b/diego/staging_failure_test.go @@ -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")) }) }) diff --git a/diego/staging_log_test.go b/diego/staging_log_test.go index bb37aedb0..10c2a7642 100644 --- a/diego/staging_log_test.go +++ b/diego/staging_log_test.go @@ -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)) }) })