Skip to content

Commit

Permalink
Create a uniques app whenenver we bind/unbind to a service instance
Browse files Browse the repository at this point in the history
Before this change all tests that were binding to as service instances
were using the buildpack app. When we bind to an app that is ready and
running the app becomes unready for a while and restarts. If we try to
run a task against such an app the operation will fail, because the app
is unready. This change creates a cheap app record and binds/unbinds to
this app to prevent messing with the running app state

Co-authored-by: Yusmen Zabanov <yusmen.zabanov@sap.com>
  • Loading branch information
2 people authored and danail-branekov committed Jan 9, 2025
1 parent e47d419 commit 144f49e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion tests/smoke/bind_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ import (

var _ = Describe("cf bind-service", func() {
var (
appName string
serviceName string
bindSession *Session
)

BeforeEach(func() {
appName = uuid.NewString()
Expect(helpers.Cf("create-app", appName)).To(Exit(0))

serviceName = uuid.NewString()
})

JustBeforeEach(func() {
bindSession = helpers.Cf("bind-service", sharedData.BuildpackAppName, serviceName)
bindSession = helpers.Cf("bind-service", appName, serviceName)
})

Describe("Binding to user-provided service instances", func() {
Expand Down
5 changes: 4 additions & 1 deletion tests/smoke/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ var _ = Describe("list", func() {
BeforeEach(func() {
Expect(helpers.Cf("run-task", sharedData.BuildpackAppName, "-c", "sleep 120")).To(Exit(0))

appName := uuid.NewString()
Expect(helpers.Cf("create-app", appName)).To(Exit(0))

upsiName := uuid.NewString()
Expect(helpers.Cf("create-user-provided-service", upsiName)).To(Exit(0))
Expect(helpers.Cf("bind-service", sharedData.BuildpackAppName, upsiName)).To(Exit(0))
Expect(helpers.Cf("bind-service", appName, upsiName)).To(Exit(0))
})

DescribeTable("authorised users get the resources",
Expand Down
10 changes: 7 additions & 3 deletions tests/smoke/unbind_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@ import (

var _ = Describe("cf unbind-service", func() {
var (
appName string
serviceName string
unbindSession *Session
)
BeforeEach(func() {
appName = uuid.NewString()
Expect(helpers.Cf("create-app", appName)).To(Exit(0))

serviceName = uuid.NewString()
})

JustBeforeEach(func() {
unbindSession = helpers.Cf("unbind-service", sharedData.BuildpackAppName, serviceName)
unbindSession = helpers.Cf("unbind-service", appName, serviceName)
})

Describe("Unbinding from user-provided service instances", func() {
BeforeEach(func() {
Expect(
helpers.Cf("create-user-provided-service", serviceName, "-p", `{"key1":"value1","key2":"value2"}`),
).To(Exit(0))
Expect(helpers.Cf("bind-service", sharedData.BuildpackAppName, serviceName)).To(Exit(0))
Expect(helpers.Cf("bind-service", appName, serviceName)).To(Exit(0))
})

It("succeeds", func() {
Expand All @@ -49,7 +53,7 @@ var _ = Describe("cf unbind-service", func() {
Expect(helpers.Cf("enable-service-access", "sample-service", "-b", brokerName)).To(Exit(0))
session := helpers.Cf("create-service", "sample-service", "sample", serviceName, "-b", brokerName)
Expect(session).To(Exit(0))
Expect(helpers.Cf("bind-service", sharedData.BuildpackAppName, serviceName)).To(Exit(0))
Expect(helpers.Cf("bind-service", appName, serviceName)).To(Exit(0))
})

It("succeeds", func() {
Expand Down

0 comments on commit 144f49e

Please sign in to comment.