@@ -28,20 +28,25 @@ func TestEtcdServerProcessConfig(t *testing.T) {
28
28
tcs := []struct {
29
29
name string
30
30
config * EtcdProcessClusterConfig
31
+ expectArgsEquals []string
31
32
expectArgsNotContain []string
32
33
expectArgsContain []string
33
34
mockBinaryVersion * semver.Version
34
35
}{
35
36
{
36
37
name : "Default" ,
37
- config : NewConfig (),
38
- expectArgsContain : []string {
38
+ config : NewConfig (WithDataDirPath ("/tmp/a" )),
39
+ expectArgsEquals : []string {
40
+ "--name=TestEtcdServerProcessConfigDefault-test-0" ,
39
41
"--listen-client-urls=http://localhost:0" ,
40
42
"--advertise-client-urls=http://localhost:0" ,
41
43
"--listen-peer-urls=http://localhost:1" ,
42
44
"--initial-advertise-peer-urls=http://localhost:1" ,
43
45
"--initial-cluster-token=new" ,
46
+ "--data-dir" ,
47
+ "/tmp/a/member-0" ,
44
48
"--snapshot-count=10000" ,
49
+ "--initial-cluster-token=new" ,
45
50
},
46
51
},
47
52
{
@@ -95,6 +100,121 @@ func TestEtcdServerProcessConfig(t *testing.T) {
95
100
},
96
101
mockBinaryVersion : & v3_5_12 ,
97
102
},
103
+ {
104
+ name : "ClientHTTPSeparate" ,
105
+ config : NewConfig (WithClientHTTPSeparate (true )),
106
+ expectArgsContain : []string {
107
+ "--listen-client-http-urls=http://localhost:4" ,
108
+ },
109
+ },
110
+ {
111
+ name : "ForceNewCluster" ,
112
+ config : NewConfig (WithForceNewCluster (true )),
113
+ expectArgsContain : []string {
114
+ "--force-new-cluster=true" ,
115
+ },
116
+ },
117
+ {
118
+ name : "EnableV2" ,
119
+ config : NewConfig (WithEnableV2 (true )),
120
+ expectArgsContain : []string {
121
+ "--enable-v2=true" ,
122
+ },
123
+ },
124
+ {
125
+ name : "MetricsURL" ,
126
+ config : NewConfig (WithMetricsURLScheme ("http" )),
127
+ expectArgsContain : []string {
128
+ "--listen-metrics-urls=http://localhost:2" ,
129
+ },
130
+ },
131
+ {
132
+ name : "Discovery" ,
133
+ config : NewConfig (WithDiscovery ("123" )),
134
+ expectArgsContain : []string {
135
+ "--discovery=123" ,
136
+ },
137
+ },
138
+ {
139
+ name : "ClientTLS" ,
140
+ config : NewConfig (WithClientConnType (ClientTLS )),
141
+ expectArgsContain : []string {
142
+ "--cert-file" ,
143
+ "--key-file" ,
144
+ "--trusted-ca-file" ,
145
+ },
146
+ expectArgsNotContain : []string {
147
+ "--auto-tls" ,
148
+ "--client-cert-auth" ,
149
+ },
150
+ },
151
+ {
152
+ name : "ClientTLSCA" ,
153
+ config : NewConfig (WithClientConnType (ClientTLS ), WithClientCertAuthority (true )),
154
+ expectArgsContain : []string {
155
+ "--cert-file" ,
156
+ "--key-file" ,
157
+ "--trusted-ca-file" ,
158
+ "--client-cert-auth" ,
159
+ },
160
+ expectArgsNotContain : []string {
161
+ "--auto-tls" ,
162
+ },
163
+ },
164
+ {
165
+ name : "ClientAutoTLS" ,
166
+ config : NewConfig (WithClientConnType (ClientTLS ), WithClientAutoTLS (true )),
167
+ expectArgsContain : []string {
168
+ "--auto-tls" ,
169
+ },
170
+ expectArgsNotContain : []string {
171
+ "--cert-file" ,
172
+ "--key-file" ,
173
+ "--trusted-ca-file" ,
174
+ "--client-cert-auth" ,
175
+ },
176
+ },
177
+ {
178
+ name : "PeerTLS" ,
179
+ config : NewConfig (WithIsPeerTLS (true )),
180
+ expectArgsContain : []string {
181
+ "--peer-cert-file" ,
182
+ "--peer-key-file" ,
183
+ "--peer-trusted-ca-file" ,
184
+ },
185
+ expectArgsNotContain : []string {
186
+ "--peer-auto-tls" ,
187
+ "--peer-client-cert-auth" ,
188
+ },
189
+ },
190
+ {
191
+ name : "PeerAutoTLS" ,
192
+ config : NewConfig (WithIsPeerTLS (true ), WithIsPeerAutoTLS (true )),
193
+ expectArgsContain : []string {
194
+ "--peer-auto-tls" ,
195
+ },
196
+ expectArgsNotContain : []string {
197
+ "--peer-cert-file" ,
198
+ "--peer-key-file" ,
199
+ "--peer-trusted-ca-file" ,
200
+ "--peer-client-cert-auth" ,
201
+ },
202
+ },
203
+ {
204
+ name : "RevokeCerts" ,
205
+ config : NewConfig (WithClientRevokeCerts (true )),
206
+ expectArgsContain : []string {
207
+ "--client-crl-file" ,
208
+ "--client-cert-auth" ,
209
+ },
210
+ },
211
+ {
212
+ name : "CipherSuites" ,
213
+ config : NewConfig (WithCipherSuites ([]string {"a" , "b" })),
214
+ expectArgsContain : []string {
215
+ "--cipher-suites" ,
216
+ },
217
+ },
98
218
}
99
219
for _ , tc := range tcs {
100
220
t .Run (tc .name , func (t * testing.T ) {
@@ -110,6 +230,9 @@ func TestEtcdServerProcessConfig(t *testing.T) {
110
230
}
111
231
setGetVersionFromBinary (t , mockGetVersionFromBinary )
112
232
args := tc .config .EtcdServerProcessConfig (t , 0 ).Args
233
+ if len (tc .expectArgsEquals ) != 0 {
234
+ assert .Equal (t , args , tc .expectArgsEquals )
235
+ }
113
236
if len (tc .expectArgsContain ) != 0 {
114
237
assert .Subset (t , args , tc .expectArgsContain )
115
238
}
0 commit comments