forked from cloudfoundry/route-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_suite_test.go
87 lines (69 loc) · 1.87 KB
/
main_suite_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
package main_test
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/MatthiasWinzeler/route-registrar/config"
"github.com/fraenkel/candiedyaml"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"testing"
)
const (
routeRegistrarPackage = "github.com/MatthiasWinzeler/route-registrar/"
)
var (
routeRegistrarBinPath string
pidFile string
configFile string
scriptPath string
rootConfig config.Config
natsPort int
)
func TestRouteRegistrar(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Main Suite")
}
var _ = BeforeSuite(func() {
var err error
routeRegistrarBinPath, err = gexec.Build(routeRegistrarPackage, "-race")
Ω(err).ShouldNot(HaveOccurred())
tempDir, err := ioutil.TempDir(os.TempDir(), "route-registrar")
Ω(err).NotTo(HaveOccurred())
pidFile = filepath.Join(tempDir, "route-registrar.pid")
configFile = filepath.Join(tempDir, "registrar_settings.yml")
scriptPath = filepath.Join(tempDir,"check_node_validity.sh")
})
var _ = AfterSuite(func() {
gexec.CleanupBuildArtifacts()
})
func initConfig() {
natsPort = 42222 + GinkgoParallelNode()
messageBusServers := []config.MessageBusServer{
config.MessageBusServer{
Host: fmt.Sprintf("127.0.0.1:%d", natsPort),
User: "nats",
Password: "nats",
},
}
healthCheckerConfig := &config.HealthCheckerConf{
Name: "riak-cs-cluster",
Interval: 10,
}
rootConfig = config.Config{
MessageBusServers: messageBusServers,
ExternalHost: "riakcs-vcap.me",
ExternalIp: "127.0.0.1",
Port: 8080,
HealthChecker: healthCheckerConfig,
}
}
func writeConfig() {
fileToWrite, err := os.Create(configFile)
Ω(err).ShouldNot(HaveOccurred())
encoder := candiedyaml.NewEncoder(fileToWrite)
err = encoder.Encode(rootConfig)
Ω(err).ShouldNot(HaveOccurred())
}