forked from concourse/concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatc_rebalance_test.go
88 lines (71 loc) · 2.27 KB
/
atc_rebalance_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
package topgun_test
import (
"os"
"strings"
"time"
. "github.com/concourse/concourse/topgun/common"
_ "github.com/lib/pq"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Rebalancing workers", func() {
var rebalanceInterval = 5 * time.Second
Context("with two TSAs available", func() {
var webInstances []BoshInstance
BeforeEach(func() {
Deploy(
"deployments/concourse.yml",
"-o", "operations/web-instances.yml",
"-v", "web_instances=2",
"-o", "operations/worker-rebalancing.yml",
"-v", "rebalance_interval="+rebalanceInterval.String(),
)
WaitForRunningWorker()
webInstances = JobInstances("web")
})
It("rotates the worker to between both web nodes over a period of time", func() {
Eventually(func() string {
workers := FlyTable("workers", "-d")
return strings.Split(workers[0]["garden address"], ":")[0]
}).Should(SatisfyAny(
Equal(webInstances[0].IP),
Equal(webInstances[0].DNS),
))
Eventually(func() string {
workers := FlyTable("workers", "-d")
return strings.Split(workers[0]["garden address"], ":")[0]
}).Should(SatisfyAny(
Equal(webInstances[1].IP),
Equal(webInstances[1].DNS),
))
})
Context("while the worker is draining", func() {
var buildSession *gexec.Session
var boshStopSession *gexec.Session
BeforeEach(func() {
buildSession = Fly.Start("execute", "-c", "tasks/wait.yml")
Eventually(buildSession).Should(gbytes.Say("executing build"))
Eventually(buildSession).Should(gbytes.Say("waiting for /tmp/stop-waiting"))
boshStopSession = SpawnBosh("stop", "worker/0")
Eventually(WaitForWorkerInState("retiring")).ShouldNot(BeEmpty())
})
AfterEach(func() {
buildSession.Signal(os.Interrupt)
<-buildSession.Exited
<-boshStopSession.Exited
Bosh("start", "worker/0")
})
It("does not rebalance", func() {
originalAddr := FlyTable("workers", "-d")[0]["garden address"]
Expect(originalAddr).ToNot(BeEmpty())
Consistently(func() string {
worker := FlyTable("workers", "-d")[0]
Expect(worker["state"]).To(Equal("retiring"))
return worker["garden address"]
}, 3*rebalanceInterval).Should(Equal(originalAddr))
})
})
})
})