@@ -47,7 +47,7 @@ func TestEmbedEtcd(t *testing.T) {
47
47
{werr : "expected IP" },
48
48
}
49
49
50
- urls := newEmbedURLs (10 )
50
+ urls := newEmbedURLs (false , 10 )
51
51
52
52
// setup defaults
53
53
for i := range tests {
@@ -105,12 +105,19 @@ func TestEmbedEtcd(t *testing.T) {
105
105
}
106
106
}
107
107
108
- // TestEmbedEtcdGracefulStop ensures embedded server stops
108
+ func TestEmbedEtcdGracefulStopSecure (t * testing.T ) { testEmbedEtcdGracefulStop (t , true ) }
109
+ func TestEmbedEtcdGracefulStopInsecure (t * testing.T ) { testEmbedEtcdGracefulStop (t , false ) }
110
+
111
+ // testEmbedEtcdGracefulStop ensures embedded server stops
109
112
// cutting existing transports.
110
- func TestEmbedEtcdGracefulStop (t * testing.T ) {
113
+ func testEmbedEtcdGracefulStop (t * testing.T , secure bool ) {
111
114
cfg := embed .NewConfig ()
115
+ if secure {
116
+ cfg .ClientTLSInfo = testTLSInfo
117
+ cfg .PeerTLSInfo = testTLSInfo
118
+ }
112
119
113
- urls := newEmbedURLs (2 )
120
+ urls := newEmbedURLs (secure , 2 )
114
121
setupEmbedCfg (cfg , []url.URL {urls [0 ]}, []url.URL {urls [1 ]})
115
122
116
123
cfg .Dir = filepath .Join (os .TempDir (), fmt .Sprintf ("embed-etcd" ))
@@ -123,7 +130,16 @@ func TestEmbedEtcdGracefulStop(t *testing.T) {
123
130
}
124
131
<- e .Server .ReadyNotify () // wait for e.Server to join the cluster
125
132
126
- cli , err := clientv3 .New (clientv3.Config {Endpoints : []string {urls [0 ].String ()}})
133
+ clientCfg := clientv3.Config {
134
+ Endpoints : []string {urls [0 ].String ()},
135
+ }
136
+ if secure {
137
+ clientCfg .TLS , err = testTLSInfo .ClientConfig ()
138
+ if err != nil {
139
+ t .Fatal (err )
140
+ }
141
+ }
142
+ cli , err := clientv3 .New (clientCfg )
127
143
if err != nil {
128
144
t .Fatal (err )
129
145
}
@@ -146,9 +162,13 @@ func TestEmbedEtcdGracefulStop(t *testing.T) {
146
162
}
147
163
}
148
164
149
- func newEmbedURLs (n int ) (urls []url.URL ) {
165
+ func newEmbedURLs (secure bool , n int ) (urls []url.URL ) {
166
+ scheme := "unix"
167
+ if secure {
168
+ scheme = "unixs"
169
+ }
150
170
for i := 0 ; i < n ; i ++ {
151
- u , _ := url .Parse (fmt .Sprintf ("unix ://localhost:%d%06d" , os .Getpid (), i ))
171
+ u , _ := url .Parse (fmt .Sprintf ("%s ://localhost:%d%06d" , scheme , os .Getpid (), i ))
152
172
urls = append (urls , * u )
153
173
}
154
174
return urls
0 commit comments