Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions src/nginx/integration/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T
context("templated with env vars", func() {
it("builds and runs the app", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"OVERRIDE": `'{ "abcd": 12345 }{ \'ef\' : "ab" }'`,
}).
Expand All @@ -44,18 +45,17 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T

Eventually(deployment).Should(Serve(ContainSubstring(`{ "abcd": 12345 }{ 'ef' : "ab" }`)).WithEndpoint("test"))


Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET /test HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET /test HTTP/1.1" 200`)))
})
})

context("templated with env vars with include", func() {
it("builds and runs the app", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"OVERRIDE": `'{ "abcd": 12345 }{ \'ef\' : "ab" }'`,
}).
Expand All @@ -68,49 +68,49 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET /test HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET /test HTTP/1.1" 200`)))
})
})

context("with no specified pid", func() {
it("builds and runs the app", func() {
deployment, _, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "without_pid"))
Expect(err).NotTo(HaveOccurred())

Eventually(deployment).Should(Serve(ContainSubstring("Exciting Content")))

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))

})
})

context("with a specified pid", func() {
it("builds and runs the app", func() {
deployment, _, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "with_pid"))
Expect(err).NotTo(HaveOccurred())

Eventually(deployment).Should(Serve(ContainSubstring("Exciting Content")))

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))

})
})

context("with no specified version", func() {
it("builds and runs the app and uses mainline", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "unspecified_version"))
Expect(err).NotTo(HaveOccurred())

Expand All @@ -121,15 +121,15 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))
})
})

context("with an app specifying mainline", func() {
it("builds and runs the app", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "mainline"))
Expect(err).NotTo(HaveOccurred())

Expand All @@ -139,34 +139,34 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))
})
})

context("with an app specifying stable", func() {
it("builds and runs the app", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "stable"))
Expect(err).NotTo(HaveOccurred())

Eventually(logs).Should(ContainSubstring(`Requested nginx version: stable => 1.26.`))
Eventually(logs).Should(ContainSubstring(`Warning: usage of "stable" versions of NGINX is discouraged in most cases by the NGINX team.`))

Eventually(deployment).Should(Serve(ContainSubstring("Exciting Content")))

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))
})
})

context("with an app unavailable version", func() {
it("the build fails and logs and error", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "unavailable_version"))
Expect(err).To(HaveOccurred())

Expand All @@ -177,6 +177,7 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T
context("with using the stream module", func() {
it("builds and runs the app", func() {
deployment, _, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "with_stream_module"))
Expect(err).NotTo(HaveOccurred())

Expand All @@ -187,6 +188,7 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T
context("with an app that has no access to logging", func() {
it("logs a warning and builds and runs the app", func() {
deployment, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "no_logging"))
Expect(err).NotTo(HaveOccurred())

Expand All @@ -199,16 +201,16 @@ func testDefault(platform switchblade.Platform, fixtures string) func(*testing.T
context("an Openresty app", func() {
it("builds and runs the app", func() {
deployment, _, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
Execute(name, filepath.Join(fixtures, "default", "openresty"))
Expect(err).NotTo(HaveOccurred())

Eventually(deployment).Should(Serve(ContainSubstring("<p>hello, world</p>")))

Eventually(func() string {
logs, _ := deployment.RuntimeLogs()
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`),
))
return logs
}, "10s", "1s").Should(Or(ContainSubstring(`NginxLog "GET / HTTP/1.1" 200`)))
})
})
}
Expand Down
9 changes: 9 additions & 0 deletions src/nginx/integration/dynatrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying a Go app with Dynatrace agent with configured network zone", func() {
it("checks if networkzone setting was successful", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -59,6 +60,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("when deploying with Dynatrace agent with single credentials service", func() {
it("checks if Dynatrace injection was successful", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -83,6 +85,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("when deploying with Dynatrace agent with two credentials services", func() {
it("checks if detection of second service with credentials works", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -108,6 +111,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("when deploying with Dynatrace agent with failing agent download and ignoring errors", func() {
it("checks if skipping download errors works", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -130,6 +134,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying a with Dynatrace agent with two dynatrace services", func() {
it("check if service detection isn't disturbed by a service with tags", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand Down Expand Up @@ -157,6 +162,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying with Dynatrace agent with single credentials service and without manifest.json", func() {
it("checks if Dynatrace injection was successful", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -181,6 +187,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying Dynatrace agent with failing agent download and checking retry", func() {
it("checks if retrying downloads works", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand All @@ -204,6 +211,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying Dynatrace agent with single credentials service and a redis service", func() {
it("checks if Dynatrace injection was successful", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand Down Expand Up @@ -239,6 +247,7 @@ func testDynatrace(platform switchblade.Platform, fixtures, uri string) func(*te
context("deploying Dynatrace agent with single credentials service", func() {
it("checks if agent config update via API was successful", func() {
_, logs, err := platform.Deploy.
WithBuildpacks("nginx_buildpack").
WithEnv(map[string]string{
"BP_DEBUG": "true",
}).
Expand Down
Loading