This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfiguration_test.go
185 lines (178 loc) · 3.19 KB
/
configuration_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
package config
import (
"fmt"
)
func Example_parseMaster() {
txtConfig := `Master "leader" {
host = "localhost"
port = 5051
leader = true
}
Master "follower" {
host = "localhost"
port = 5052
}
dieafter = 1`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
// Output:
// <nil>
// [{localhost 5051 true} {localhost 5052 false}]
// []
// <nil>
// &{localhost 8086 mesos 30}
// 30
// 1
}
func Example_parseSlave() {
txtConfig := `Slave "0" {
host = "localhost"
port = 5051
}
slave "1" {
host = "localhost"
port = 5052
}
lapse=100
dieAfter = 1`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
// Output:
// <nil>
// []
// [{localhost 5051} {localhost 5052}]
// <nil>
// &{localhost 8086 mesos 30}
// 100
// 1
}
func Example_parseMarathon() {
txtConfig := `Marathon {
Server "0" {
host = "marathon1"
port = 8080
}
Server "1" {
host = "marathon2"
port = 8080
}
}
DieAfter = 1`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
// Output:
// <nil>
// []
// []
// &{[{marathon1 8080} {marathon2 8080}] false 0 0}
// &{localhost 8086 mesos 30}
// 30
// 1
}
func Example_parseMarathonWithEvents() {
txtConfig := `Marathon {
events = true
host = "localhost"
port = 8088
bufferSize = 10000
Server "0" {
host = "marathon1"
port = 8080
}
Server "1" {
host = "marathon2"
port = 8080
}
}
DieAfter = 1`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
// Output:
// <nil>
// []
// []
// &{[{marathon1 8080} {marathon2 8080}] true localhost 8088 10000}
// &{localhost 8086 mesos 30}
// 30
// 1
}
func Example_parseInfluxDB() {
txtConfig := `influxdb {
host = "influx"
port = 18086
db = "custom"
}`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
fmt.Println(c.HAProxy)
// Output:
// <nil>
// []
// []
// <nil>
// &{influx 18086 custom 30}
// 30
// 3600
// <nil>
}
func Example_parseHAProxy() {
txtConfig := `haproxy {
user = "admin"
password = "admin"
endPoint = "haproxy_stats"
}`
cp := ConfigParser{}
c, _ := cp.ParseConfig(txtConfig)
fmt.Println(c.MesosDNS)
fmt.Println(c.Master)
fmt.Println(c.Slave)
fmt.Println(c.Marathon)
fmt.Println(c.InfluxDB)
fmt.Println(c.Lapse)
fmt.Println(c.DieAfter)
fmt.Println(c.HAProxy)
// Output:
// <nil>
// []
// []
// <nil>
// &{localhost 8086 mesos 30}
// 30
// 3600
// &{admin admin haproxy_stats 0}
}