-
Notifications
You must be signed in to change notification settings - Fork 8
/
happy_path_test.go
66 lines (54 loc) · 2.17 KB
/
happy_path_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main_test
import (
"github.com/cloudfoundry/cf-test-helpers/v2/cf"
"github.com/cloudfoundry/cf-test-helpers/v2/workflowhelpers"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Cloud Foundry Volume Services", func() {
var (
readWriteAppURL, appName, instanceName string
)
BeforeEach(func() {
instanceName, appName, readWriteAppURL = generateTestNames()
})
AfterEach(func() {
workflowhelpers.AsUser(cfTestSuiteSetup.RegularUserContext(), DEFAULT_TIMEOUT, func() {
cf.Cf("logs", appName, "--recent").Wait(DEFAULT_TIMEOUT)
cf.Cf("stop", appName).Wait(DEFAULT_TIMEOUT)
cf.Cf("unbind-service", appName, instanceName).Wait(DEFAULT_TIMEOUT)
cf.Cf("delete-service", instanceName, "-f").Wait(DEFAULT_TIMEOUT)
cf.Cf("delete", appName, "-r", "-f").Wait(DEFAULT_TIMEOUT)
})
})
DescribeTable("given one valid bind config, it can mount volumes",
func(testDocker bool) {
By("Enabling service-access")
enableServiceAccess(pConfig.ServiceName, cfTestSuiteSetup.RegularUserContext().Org)
By("Pushing an app")
pushPoraNoStart(appName, testDocker)
By("Creating a service")
createService(instanceName, testValues.validCreateServiceConfig)
By("Binding the service to the app")
bindAppToService(appName, instanceName, testValues.validBindConfigs[0])
By("Starting the app")
startApp(appName)
By("Verifying that it responds to http requests")
eventuallyExpect(readWriteAppURL, "instance index:")
By("Verifying that the volume mount path is included in the application's environment")
workflowhelpers.AsUser(cfTestSuiteSetup.RegularUserContext(), DEFAULT_TIMEOUT, func() {
env := cf.Cf("env", appName).Wait(DEFAULT_TIMEOUT)
Expect(env).To(Exit(0))
Expect(env).To(Say(pConfig.ServiceName))
Expect(env).To(Say(instanceName))
Expect(env).To(Or(Say("container_path"), Say("container_dir")))
})
By("Verifying that the app is able to write to the volume")
eventuallyExpect(readWriteAppURL+"/write", "Hello Persistent World")
},
Entry("When using a docker app", true),
Entry("When using a non-docker app", false),
)
})