@@ -122,7 +122,7 @@ func testDashboard(t *testing.T) {
122
122
func testIngressController (t * testing.T ) {
123
123
t .Parallel ()
124
124
mk := NewMinikubeRunner (t , "--wait=false" )
125
- kubectlRunner := util .NewKubectlRunner (t )
125
+ kr := util .NewKubectlRunner (t )
126
126
127
127
mk .RunCommand ("addons enable ingress" , true )
128
128
if err := util .WaitForIngressControllerRunning (t ); err != nil {
@@ -138,12 +138,12 @@ func testIngressController(t *testing.T) {
138
138
t .Errorf ("Error getting the file path for current directory: %s" , curdir )
139
139
}
140
140
ingressPath := path .Join (curdir , "testdata" , "nginx-ing.yaml" )
141
- if _ , err := kubectlRunner .RunCommand ([]string {"create" , "-f" , ingressPath }); err != nil {
141
+ if _ , err := kr .RunCommand ([]string {"create" , "-f" , ingressPath }); err != nil {
142
142
t .Fatalf ("creating nginx ingress resource: %v" , err )
143
143
}
144
144
145
145
podPath := path .Join (curdir , "testdata" , "nginx-pod-svc.yaml" )
146
- if _ , err := kubectlRunner .RunCommand ([]string {"create" , "-f" , podPath }); err != nil {
146
+ if _ , err := kr .RunCommand ([]string {"create" , "-f" , podPath }); err != nil {
147
147
t .Fatalf ("creating nginx ingress resource: %v" , err )
148
148
}
149
149
@@ -167,7 +167,7 @@ func testIngressController(t *testing.T) {
167
167
168
168
defer func () {
169
169
for _ , p := range []string {podPath , ingressPath } {
170
- if out , err := kubectlRunner .RunCommand ([]string {"delete" , "-f" , p }); err != nil {
170
+ if out , err := kr .RunCommand ([]string {"delete" , "-f" , p }); err != nil {
171
171
t .Logf ("delete -f %s failed: %v\n output: %s\n " , p , err , out )
172
172
}
173
173
}
@@ -192,51 +192,55 @@ func testServicesList(t *testing.T) {
192
192
}
193
193
func testRegistry (t * testing.T ) {
194
194
t .Parallel ()
195
- minikubeRunner := NewMinikubeRunner (t )
196
- kubectlRunner := util .NewKubectlRunner (t )
197
- minikubeRunner .RunCommand ("addons enable registry" , true )
198
- t .Log ("wait for registry to come up" )
195
+ mk := NewMinikubeRunner (t )
196
+ mk .RunCommand ("addons enable registry" , true )
197
+ client , err := pkgutil .GetClient ()
198
+ if err != nil {
199
+ t .Fatalf ("getting kubernetes client: %v" , err )
200
+ }
201
+ if err := pkgutil .WaitForRCToStabilize (client , "kube-system" , "registry" , time .Minute * 5 ); err != nil {
202
+ t .Fatalf ("waiting for registry replicacontroller to stabilize: %v" , err )
203
+ }
204
+ rs := labels .SelectorFromSet (labels .Set (map [string ]string {"actual-registry" : "true" }))
205
+ if err := pkgutil .WaitForPodsWithLabelRunning (client , "kube-system" , rs ); err != nil {
206
+ t .Fatalf ("waiting for registry pods: %v" , err )
207
+ }
208
+ ps , err := labels .Parse ("kubernetes.io/minikube-addons=registry,actual-registry!=true" )
209
+ if err != nil {
210
+ t .Fatalf ("Unable to parse selector: %v" , err )
211
+ }
212
+ if err := pkgutil .WaitForPodsWithLabelRunning (client , "kube-system" , ps ); err != nil {
213
+ t .Fatalf ("waiting for registry-proxy pods: %v" , err )
214
+ }
199
215
200
- if err := util .WaitForDockerRegistryRunning (t ); err != nil {
201
- t .Fatalf ("waiting for registry to be up: %v" , err )
216
+ ip := strings .TrimSpace (mk .RunCommand ("ip" , true ))
217
+ endpoint := fmt .Sprintf ("http://%s:%d" , ip , 5000 )
218
+ u , err := url .Parse (endpoint )
219
+ if err != nil {
220
+ t .Fatalf ("failed to parse %q: %v" , endpoint , err )
202
221
}
222
+ t .Log ("checking registry access from outside cluster" )
203
223
204
224
// Check access from outside the cluster on port 5000, validing connectivity via registry-proxy
205
225
checkExternalAccess := func () error {
206
- t .Log ("checking registry access from outside cluster" )
207
- _ , out := minikubeRunner .RunDaemon ("ip" )
208
- s , err := readLineWithTimeout (out , 180 * time .Second )
209
-
210
- if err != nil {
211
- t .Fatalf ("failed to read minikubeIP: %v" , err )
212
- }
213
-
214
- registryEndpoint := "http://" + strings .TrimSpace (s ) + ":5000"
215
- u , err := url .Parse (registryEndpoint )
216
-
217
- if err != nil {
218
- t .Fatalf ("failed to parse %q: %v" , s , err )
219
- }
220
-
221
226
resp , err := retryablehttp .Get (u .String ())
222
227
if err != nil {
223
228
t .Errorf ("failed get: %v" , err )
224
229
}
225
230
226
231
if resp .StatusCode != http .StatusOK {
227
- t .Errorf ("%s returned status code %d, expected %d.\n " , registryEndpoint , resp .StatusCode , http .StatusOK )
232
+ t .Errorf ("%s returned status code %d, expected %d.\n " , u , resp .StatusCode , http .StatusOK )
228
233
}
229
-
230
234
return nil
231
235
}
232
236
233
237
if err := util .Retry (t , checkExternalAccess , 2 * time .Second , 5 ); err != nil {
234
238
t .Fatalf (err .Error ())
235
239
}
236
- // check access from inside the cluster via a busybox container running inside cluster
240
+
237
241
t .Log ("checking registry access from inside cluster" )
238
- expectedStr := "200"
239
- out , _ := kubectlRunner .RunCommand ([]string {
242
+ kr := util . NewKubectlRunner ( t )
243
+ out , _ := kr .RunCommand ([]string {
240
244
"run" ,
241
245
"registry-test" ,
242
246
"--restart=Never" ,
@@ -247,16 +251,17 @@ func testRegistry(t *testing.T) {
247
251
"-c" ,
248
252
"wget --spider -S 'http://registry.kube-system.svc.cluster.local' 2>&1 | grep 'HTTP/' | awk '{print $2}'" })
249
253
internalCheckOutput := string (out )
254
+ expectedStr := "200"
250
255
if ! strings .Contains (internalCheckOutput , expectedStr ) {
251
256
t .Fatalf ("ExpectedStr internalCheckOutput to be: %s. Output was: %s" , expectedStr , internalCheckOutput )
252
257
}
253
258
254
259
defer func () {
255
- if _ , err := kubectlRunner .RunCommand ([]string {"delete" , "pod" , "registry-test" }); err != nil {
260
+ if _ , err := kr .RunCommand ([]string {"delete" , "pod" , "registry-test" }); err != nil {
256
261
t .Fatalf ("failed to delete pod registry-test" )
257
262
}
258
263
}()
259
- minikubeRunner .RunCommand ("addons disable registry" , true )
264
+ mk .RunCommand ("addons disable registry" , true )
260
265
}
261
266
func testGvisor (t * testing.T ) {
262
267
mk := NewMinikubeRunner (t , "--wait=false" )
@@ -320,26 +325,26 @@ func testGvisorRestart(t *testing.T) {
320
325
}
321
326
322
327
func createUntrustedWorkload (t * testing.T ) {
323
- kubectlRunner := util .NewKubectlRunner (t )
328
+ kr := util .NewKubectlRunner (t )
324
329
curdir , err := filepath .Abs ("" )
325
330
if err != nil {
326
331
t .Errorf ("Error getting the file path for current directory: %s" , curdir )
327
332
}
328
333
untrustedPath := path .Join (curdir , "testdata" , "nginx-untrusted.yaml" )
329
334
t .Log ("creating pod with untrusted workload annotation" )
330
- if _ , err := kubectlRunner .RunCommand ([]string {"replace" , "-f" , untrustedPath , "--force" }); err != nil {
335
+ if _ , err := kr .RunCommand ([]string {"replace" , "-f" , untrustedPath , "--force" }); err != nil {
331
336
t .Fatalf ("creating untrusted nginx resource: %v" , err )
332
337
}
333
338
}
334
339
335
340
func deleteUntrustedWorkload (t * testing.T ) {
336
- kubectlRunner := util .NewKubectlRunner (t )
341
+ kr := util .NewKubectlRunner (t )
337
342
curdir , err := filepath .Abs ("" )
338
343
if err != nil {
339
344
t .Errorf ("Error getting the file path for current directory: %s" , curdir )
340
345
}
341
346
untrustedPath := path .Join (curdir , "testdata" , "nginx-untrusted.yaml" )
342
- if _ , err := kubectlRunner .RunCommand ([]string {"delete" , "-f" , untrustedPath }); err != nil {
347
+ if _ , err := kr .RunCommand ([]string {"delete" , "-f" , untrustedPath }); err != nil {
343
348
t .Logf ("error deleting untrusted nginx resource: %v" , err )
344
349
}
345
350
}
0 commit comments