Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable volume service test #1257

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ include_app_syslog_tcp
* `volume_service_name`: The name of the volume service provided by the volume service broker.
* `volume_service_plan_name`: The name of the plan of the service provided by the volume service broker.
* `volume_service_create_config`: The JSON configuration that is used when volume service is created.
* `volume_service_bind_config`: The JSON configuration for the volume service binding configuration.

#### Buildpack Names
Many tests specify a buildpack when pushing an app, so that on diego the app staging process completes in less time. The default names for the buildpacks are as follows; if you have buildpacks with different names, you can override them by setting different names:
Expand Down
3 changes: 0 additions & 3 deletions cats_suite_helpers/cats_suite_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ func VolumeServicesDescribe(description string, callback func()) bool {
if !Config.GetIncludeVolumeServices() {
Skip(skip_messages.SkipVolumeServicesMessage)
}
if Config.GetIncludeDocker() {
Skip(skip_messages.SkipVolumeServicesDockerEnabledMessage)
}
})
Describe(description, callback)
})
Expand Down
1 change: 1 addition & 0 deletions helpers/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type CatsConfig interface {
GetVolumeServiceName() string
GetVolumeServicePlanName() string
GetVolumeServiceCreateConfig() string
GetVolumeServiceBindConfig() string

GetReporterConfig() reporterConfig

Expand Down
6 changes: 6 additions & 0 deletions helpers/config/config_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type config struct {
VolumeServiceName *string `json:"volume_service_name"`
VolumeServicePlanName *string `json:"volume_service_plan_name"`
VolumeServiceCreateConfig *string `json:"volume_service_create_config"`
VolumeServiceBindConfig *string `json:"volume_service_bind_config"`

IncludeAppSyslogTCP *bool `json:"include_app_syslog_tcp"`
IncludeApps *bool `json:"include_apps"`
Expand Down Expand Up @@ -204,6 +205,7 @@ func getDefaults() config {
defaults.VolumeServiceName = ptrToString("")
defaults.VolumeServicePlanName = ptrToString("")
defaults.VolumeServiceCreateConfig = ptrToString("")
defaults.VolumeServiceBindConfig = ptrToString("")

defaults.ReporterConfig = &reporterConfig{}

Expand Down Expand Up @@ -1135,6 +1137,10 @@ func (c *config) GetVolumeServiceCreateConfig() string {
return *c.VolumeServiceCreateConfig
}

func (c *config) GetVolumeServiceBindConfig() string {
return *c.VolumeServiceBindConfig
}

func (c *config) GetAdminClient() string {
return ""
}
Expand Down
60 changes: 9 additions & 51 deletions volume_services/volume_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var _ = VolumeServicesDescribe("Volume Services", func() {
poraAsset = assets.NewAssets().Pora
routerGroupGuid string
reservablePorts string
nfsPort = "2049"
tcpDomain string
)

Expand All @@ -36,10 +35,7 @@ var _ = VolumeServicesDescribe("Volume Services", func() {
appName = random_name.CATSRandomName("APP")

workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
session := cf.Cf("enable-feature-flag", "diego_docker").Wait()
Expect(session).To(Exit(0), "cannot enable diego_docker feature flag")

session = cf.Cf("curl", "/routing/v1/router_groups").Wait()
session := cf.Cf("curl", "/routing/v1/router_groups").Wait()
Expect(session).To(Exit(0), "cannot retrieve current router groups")

routerGroupGuid, reservablePorts = routerGroupIdAndPorts(session.Out.Contents())
Expand All @@ -48,7 +44,7 @@ var _ = VolumeServicesDescribe("Volume Services", func() {
session = cf.Cf("curl", fmt.Sprintf("/routing/v1/router_groups/%s", routerGroupGuid), "-X", "PUT", "-d", payload).Wait()
Expect(session).To(Exit(0), "cannot update tcp router group to allow nfs traffic")

tcpDomain = fmt.Sprintf("tcp.%s", Config.GetAppsDomain())
tcpDomain = Config.GetTCPDomain()

session = cf.Cf("create-shared-domain", tcpDomain, "--router-group", "default-tcp").Wait()
Eventually(session).Should(Exit())
Expand All @@ -61,31 +57,6 @@ var _ = VolumeServicesDescribe("Volume Services", func() {

})

By("pushing an nfs server")
Expect(cf.Cf("push", "nfs", "--docker-image", "cfpersi/nfs-cats", "--health-check-type", "process", "--no-start").
Wait(Config.CfPushTimeoutDuration())).To(Exit(0), "cannot push the nfs server app")

session := cf.Cf("create-route", tcpDomain, "--port", nfsPort).Wait()
Expect(session).To(Exit(0), "cannot create a tcp route for the nfs server app")

nfsGuid := GuidForAppName("nfs")
workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
session := cf.Cf("curl", "/v3/routes").Wait()
Expect(session).To(Exit(0), "cannot retrieve current routes")

routes := &Routes{}
err := json.Unmarshal(session.Out.Contents(), routes)
Expect(err).NotTo(HaveOccurred())

routeId := nfsRouteGuid(routes)

session = cf.Cf("curl", fmt.Sprintf("/v3/routes/%s/destinations", routeId), "-X", "POST", "-d", fmt.Sprintf(`{"destinations": [{"app": {"guid": "%s"}, "port": %s}]}`, nfsGuid, nfsPort)).Wait()
Expect(session).To(Exit(0), "cannot create a tcp route mapping to the nfs server app")
})

session = cf.Cf("start", "nfs").Wait(Config.CfPushTimeoutDuration())
Expect(session).To(Exit(0), "cannot start the nfs server app")

workflowhelpers.AsUser(TestSetup.AdminUserContext(), TestSetup.ShortTimeout(), func() {
session := cf.Cf("enable-service-access", serviceName, "-o", TestSetup.RegularUserContext().Org).Wait()
Expect(session).To(Exit(0), "cannot enable nfs service access")
Expand All @@ -103,24 +74,24 @@ var _ = VolumeServicesDescribe("Volume Services", func() {

By("creating a service")
var createServiceSession *Session
if Config.GetVolumeServiceCreateConfig() != "" {
createServiceSession = cf.Cf("create-service", serviceName, Config.GetVolumeServicePlanName(), serviceInstanceName, "-c", Config.GetVolumeServiceCreateConfig())
} else {
if Config.GetVolumeServiceCreateConfig() == "" {
createServiceSession = cf.Cf("create-service", serviceName, Config.GetVolumeServicePlanName(), serviceInstanceName, "-c", fmt.Sprintf(`{"share": "%s/"}`, tcpDomain))
} else {
createServiceSession = cf.Cf("create-service", serviceName, Config.GetVolumeServicePlanName(), serviceInstanceName, "-c", Config.GetVolumeServiceCreateConfig())
}
Expect(createServiceSession.Wait(TestSetup.ShortTimeout())).To(Exit(0), "cannot create an nfs service instance")

By("binding the service")
var bindSession *Session
if Config.GetVolumeServiceCreateConfig() != "" {
bindSession = cf.Cf("bind-service", appName, serviceInstanceName)
if Config.GetVolumeServiceBindConfig() == "" {
bindSession = cf.Cf("bind-service", appName, serviceInstanceName, "-c", `{"uid": "1000", "gid": "1000"}`)
} else {
bindSession = cf.Cf("bind-service", appName, serviceInstanceName, "-c", `{"uid": "2000", "gid": "2000"}`)
bindSession = cf.Cf("bind-service", appName, serviceInstanceName, "-c", Config.GetVolumeServiceBindConfig())
}
Expect(bindSession.Wait(TestSetup.ShortTimeout())).To(Exit(0), "cannot bind the nfs service instance to the test app")

By("starting the app")
session = cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())
session := cf.Cf("start", appName).Wait(Config.CfPushTimeoutDuration())
Eventually(session).Should(Exit())
if session.ExitCode() != 0 {
cf.Cf("logs", appName, "--recent")
Expand All @@ -133,9 +104,6 @@ var _ = VolumeServicesDescribe("Volume Services", func() {
payload := fmt.Sprintf(`{ "reservable_ports":"%s", "name":"default-tcp", "type": "tcp"}`, reservablePorts)
session := cf.Cf("curl", fmt.Sprintf("/routing/v1/router_groups/%s", routerGroupGuid), "-X", "PUT", "-d", payload).Wait()
Expect(session).To(Exit(0), "cannot retrieve current router groups")

session = cf.Cf("disable-feature-flag", "diego_docker").Wait()
Expect(session).To(Exit(0), "cannot disable diego_docker feature flag")
})
})

Expand All @@ -144,16 +112,6 @@ var _ = VolumeServicesDescribe("Volume Services", func() {
})
})

func nfsRouteGuid(routes *Routes) string {
for _, resource := range routes.Resources {
if resource.Port != 0 && resource.Port == 2049 {
return resource.GUID
}
}
Fail("Unable to find a valid tcp route for port 2049")
return ""
}

func routerGroupIdAndPorts(routerGroupOutput []byte) (guid, ports string) {
routerGroups := &[]RouterGroup{}
err := json.Unmarshal(routerGroupOutput, routerGroups)
Expand Down