-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the monolithic smoke test into smaller ones
- Loading branch information
1 parent
b89a55f
commit 873f63a
Showing
6 changed files
with
144 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package smoke_test | ||
|
||
import ( | ||
"crypto/tls" | ||
"fmt" | ||
"net/http" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/types" | ||
) | ||
|
||
var _ = Describe("apps", func() { | ||
It("buildpack app is reachable via its route", func() { | ||
appResponseShould(buildpackAppName, "/", SatisfyAll( | ||
HaveHTTPStatus(http.StatusOK), | ||
HaveHTTPBody(ContainSubstring("Hi, I'm Dorifi!")), | ||
)) | ||
}) | ||
|
||
It("docker app is reachable via its route", func() { | ||
appResponseShould(dockerAppName, "/", SatisfyAll( | ||
HaveHTTPStatus(http.StatusOK), | ||
HaveHTTPBody(ContainSubstring("Hi, I'm not Dora!")), | ||
)) | ||
}) | ||
|
||
It("broker app is reachable via its route", func() { | ||
appResponseShould(brokerAppName, "/", SatisfyAll( | ||
HaveHTTPStatus(http.StatusOK), | ||
HaveHTTPBody(ContainSubstring("Hi, I'm the sample broker!")), | ||
)) | ||
}) | ||
}) | ||
|
||
func appResponseShould(appName, requestPath string, matchExpectations types.GomegaMatcher) { | ||
var httpClient http.Client | ||
httpClient.Transport = &http.Transport{ | ||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, | ||
} | ||
|
||
Eventually(func(g Gomega) { | ||
resp, err := httpClient.Get(fmt.Sprintf("https://%s.%s%s", appName, appsDomain, requestPath)) | ||
g.Expect(err).NotTo(HaveOccurred()) | ||
g.Expect(resp).To(matchExpectations) | ||
}).Should(Succeed()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package smoke_test | ||
|
||
import ( | ||
"net/http" | ||
|
||
"code.cloudfoundry.org/korifi/tests/helpers" | ||
. "code.cloudfoundry.org/korifi/tests/matchers" | ||
|
||
"github.com/google/uuid" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("cf bind-service", func() { | ||
BeforeEach(func() { | ||
serviceName := uuid.NewString() | ||
|
||
Expect( | ||
helpers.Cf("create-user-provided-service", serviceName, "-p", `{"key1":"value1","key2":"value2"}`), | ||
).To(Exit(0)) | ||
|
||
Expect(helpers.Cf("bind-service", buildpackAppName, serviceName)).To(Exit(0)) | ||
Expect(helpers.Cf("restart", buildpackAppName)).To(Exit(0)) | ||
}) | ||
|
||
It("binds the service to the app", func() { | ||
appResponseShould(buildpackAppName, "/env.json", SatisfyAll( | ||
HaveHTTPStatus(http.StatusOK), | ||
HaveHTTPBody( | ||
MatchJSONPath("$.VCAP_SERVICES", SatisfyAll( | ||
MatchJSONPath(`$["user-provided"][0].credentials.key1`, "value1"), | ||
MatchJSONPath(`$["user-provided"][0].credentials.key2`, "value2"), | ||
)), | ||
), | ||
)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package smoke_test | ||
|
||
import ( | ||
"syscall" | ||
|
||
"code.cloudfoundry.org/korifi/tests/helpers" | ||
"github.com/cloudfoundry/cf-test-helpers/cf" | ||
"github.com/onsi/gomega/gbytes" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("cf logs", func() { | ||
Describe("cf logs --recent", func() { | ||
It("prints app recent logs", func() { | ||
Eventually(helpers.Cf("logs", buildpackAppName, "--recent")).Should(gbytes.Say("Listening on port 8080")) | ||
}) | ||
}) | ||
|
||
Describe("cf logs", func() { | ||
It("blocks waiting for new log entries", func() { | ||
logsSession := cf.Cf("logs", buildpackAppName) | ||
defer logsSession.Signal(syscall.SIGQUIT) | ||
|
||
Eventually(logsSession).Should(gbytes.Say("Listening on port 8080")) | ||
outputLen := len(string(logsSession.Out.Contents())) | ||
|
||
Consistently(func(g Gomega) { | ||
Expect(logsSession.ExitCode()).To(Equal(-1)) | ||
Expect(string(logsSession.Out.Contents())).To(HaveLen(outputLen)) | ||
}).Should(Succeed()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package smoke_test | ||
|
||
import ( | ||
"code.cloudfoundry.org/korifi/tests/helpers" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("cf run-task", func() { | ||
It("succeeds", func() { | ||
Eventually(helpers.Cf("run-task", buildpackAppName, "-c", `echo "Hello from the task"`)).Should(Exit(0)) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters