-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmultiple_cells_test.go
109 lines (93 loc) · 3.12 KB
/
multiple_cells_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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main_test
import (
"bytes"
"strconv"
"sync"
"time"
"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/gexec"
)
var _ = Describe("when there are multiple Diego Cells", func() {
var (
readWriteAppURL, appName, instanceName string
)
BeforeEach(func() {
if !pConfig.IncludeMultiCell {
Skip("skipping multi cell")
}
instanceName, appName, readWriteAppURL = generateTestNames()
By("Pushing an app bound to a service")
enableServiceAccess(pConfig.ServiceName, cfTestSuiteSetup.RegularUserContext().Org)
pushPoraNoStart(appName, false)
createService(instanceName, testValues.validCreateServiceConfig)
bindAppToService(appName, instanceName, testValues.validBindConfigs[0])
startApp(appName)
})
It("should keep the data across multiple stops and starts", func() {
fname := eventuallyExpect(readWriteAppURL+"/create", "pora")
// start a bunch of simultaneous requests to do file io
var wg sync.WaitGroup
stop := make(chan bool)
wg.Add(10)
for i := 0; i < 10; i++ {
go func() {
defer wg.Done()
for {
get(readWriteAppURL+"/loadtest", printErrorsOff)
time.Sleep(100 * time.Millisecond)
select {
case <-stop:
return
default:
}
}
}()
}
workflowhelpers.AsUser(cfTestSuiteSetup.RegularUserContext(), DEFAULT_TIMEOUT, func() {
for i := 0; i < 20; i++ {
stopResponse := cf.Cf("stop", appName).Wait(DEFAULT_TIMEOUT)
Expect(stopResponse).To(Exit(0))
startResponse := cf.Cf("start", appName).Wait(LONG_TIMEOUT)
Expect(startResponse).To(Exit(0))
}
})
// signal our background load to stop and then wait for it
close(stop)
wg.Wait()
eventuallyExpect(readWriteAppURL+"/read/"+fname, "Hello Persistent World")
eventuallyExpect(readWriteAppURL+"/delete/"+fname, fname)
// clean up any load test files that got left behind on the mount due to apps stopping
// and starting
get(readWriteAppURL+"/loadtestcleanup", printErrorsOn)
})
Context("when the app is scaled across cells", func() {
const appScale = 5
BeforeEach(func() {
workflowhelpers.AsUser(cfTestSuiteSetup.RegularUserContext(), DEFAULT_TIMEOUT, func() {
bindResponse := cf.Cf("scale", appName, "-i", strconv.Itoa(appScale)).Wait(LONG_TIMEOUT)
Expect(bindResponse).To(Exit(0))
Eventually(func() int {
apps := cf.Cf("app", appName).Wait(DEFAULT_TIMEOUT)
Expect(apps).To(Exit(0))
return bytes.Count(apps.Out.Contents(), []byte("running"))
}, LONG_TIMEOUT, POLL_INTERVAL).Should(Equal(appScale))
})
})
It("should be able to create a test file then read it from any instance", func() {
fname := eventuallyExpect(readWriteAppURL+"/create", "pora")
responses := map[string]int{}
for i := 0; i < appScale*10000; i++ {
body := eventuallyExpect(readWriteAppURL+"/read/"+fname, "Hello Persistent World")
responses[body] = 1
if len(responses) >= appScale {
break
}
}
eventuallyExpect(readWriteAppURL+"/delete/"+fname, fname)
Expect(len(responses)).To(Equal(appScale))
})
})
})