From 5c34d0bc3baa2a84d383ea901c8a0ef1ebe0a7bd Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Thu, 26 Sep 2024 15:06:39 +0200 Subject: [PATCH 1/3] Re-enable volume service test * remove pushing of cfpersi/nfs-cats test server, use cf-deployment ops file instead: https://github.com/cloudfoundry/cf-deployment/blob/main/operations/test/enable-nfs-test-server.yml * add "volume_service_bind_config" parameter with default values from https://github.com/cloudfoundry/cf-volume-services-acceptance-tests/blob/main/persi_acceptance_suite_test.go#L82 * a working value for "volume_service_create_config" can be found here: https://github.com/cloudfoundry/cf-volume-services-acceptance-tests/blob/main/persi_acceptance_suite_test.go#L76 --- cats_suite_helpers/cats_suite_helpers.go | 3 -- helpers/config/config.go | 1 + helpers/config/config_struct.go | 6 +++ volume_services/volume_services.go | 52 +++--------------------- 4 files changed, 12 insertions(+), 50 deletions(-) diff --git a/cats_suite_helpers/cats_suite_helpers.go b/cats_suite_helpers/cats_suite_helpers.go index 44362631c..38774814a 100644 --- a/cats_suite_helpers/cats_suite_helpers.go +++ b/cats_suite_helpers/cats_suite_helpers.go @@ -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) }) diff --git a/helpers/config/config.go b/helpers/config/config.go index a1069eaa7..d84384ed8 100644 --- a/helpers/config/config.go +++ b/helpers/config/config.go @@ -95,6 +95,7 @@ type CatsConfig interface { GetVolumeServiceName() string GetVolumeServicePlanName() string GetVolumeServiceCreateConfig() string + GetVolumeServiceBindConfig() string GetReporterConfig() reporterConfig diff --git a/helpers/config/config_struct.go b/helpers/config/config_struct.go index 07b199ea6..97946e8b5 100644 --- a/helpers/config/config_struct.go +++ b/helpers/config/config_struct.go @@ -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"` @@ -205,6 +206,7 @@ func getDefaults() config { defaults.VolumeServiceName = ptrToString("") defaults.VolumeServicePlanName = ptrToString("") defaults.VolumeServiceCreateConfig = ptrToString("") + defaults.VolumeServiceBindConfig = ptrToString("") defaults.ReporterConfig = &reporterConfig{} @@ -1141,6 +1143,10 @@ func (c *config) GetVolumeServiceCreateConfig() string { return *c.VolumeServiceCreateConfig } +func (c *config) GetVolumeServiceBindConfig() string { + return *c.VolumeServiceBindConfig +} + func (c *config) GetAdminClient() string { return "" } diff --git a/volume_services/volume_services.go b/volume_services/volume_services.go index 8de003aa8..7e4944699 100644 --- a/volume_services/volume_services.go +++ b/volume_services/volume_services.go @@ -26,7 +26,6 @@ var _ = VolumeServicesDescribe("Volume Services", func() { poraAsset = assets.NewAssets().Pora routerGroupGuid string reservablePorts string - nfsPort = "2049" tcpDomain string ) @@ -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()) @@ -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") @@ -112,15 +83,15 @@ var _ = VolumeServicesDescribe("Volume Services", func() { 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") @@ -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") }) }) @@ -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) From 691058774824b466933e7eb4f89a8aaee71ef0ba Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Fri, 27 Sep 2024 13:01:53 +0200 Subject: [PATCH 2/3] Use new TCP domain config option --- volume_services/volume_services.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/volume_services/volume_services.go b/volume_services/volume_services.go index 7e4944699..a0a518bcd 100644 --- a/volume_services/volume_services.go +++ b/volume_services/volume_services.go @@ -44,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()) @@ -74,10 +74,10 @@ 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") From 779fcca39165b3027224ad22f6f921378b1b7244 Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Fri, 27 Sep 2024 13:14:31 +0200 Subject: [PATCH 3/3] Update README with "volume_service_bind_config" parameter --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 446ae096f..8a06c6a24 100644 --- a/README.md +++ b/README.md @@ -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: