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
|
package test_helpers
import (
. "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/internal/parallel_support"
"github.com/onsi/ginkgo/v2/reporters"
. "github.com/onsi/gomega"
)
func SetUpServerAndClient(numNodes int) (parallel_support.Server, parallel_support.Client, map[int]chan interface{}) {
server, err := parallel_support.NewServer(numNodes, reporters.NoopReporter{})
Ω(err).ShouldNot(HaveOccurred())
server.Start()
client := parallel_support.NewClient(server.Address())
Eventually(client.Connect).Should(BeTrue())
exitChannels := map[int]chan interface{}{}
for node := 1; node <= numNodes; node++ {
c := make(chan interface{})
exitChannels[node] = c
server.RegisterAlive(node, func() bool {
select {
case <-c:
return false
default:
return true
}
})
}
DeferCleanup(server.Close)
DeferCleanup(client.Close)
return server, client, exitChannels
}
|