@@ -20,16 +20,11 @@ import (
20
20
"os"
21
21
"path"
22
22
"strings"
23
- "time"
24
-
25
- "golang.org/x/crypto/ssh"
26
- "golang.org/x/net/context"
27
23
28
24
"github.com/coreos/coreos-assembler/mantle/kola"
29
25
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
30
26
"github.com/coreos/coreos-assembler/mantle/kola/register"
31
27
"github.com/coreos/coreos-assembler/mantle/kola/tests/util"
32
- "github.com/coreos/coreos-assembler/mantle/lang/worker"
33
28
"github.com/coreos/coreos-assembler/mantle/platform"
34
29
"github.com/coreos/coreos-assembler/mantle/platform/conf"
35
30
@@ -78,7 +73,8 @@ var crioPodTemplate = `{
78
73
"cgroup_parent": "Burstable-pod-123.slice",
79
74
"security_context": {
80
75
"namespace_options": {
81
- "pid": 1
76
+ "pid": 1,
77
+ "network": 2,
82
78
},
83
79
"capabilities": {
84
80
"add_capabilities": [
@@ -198,25 +194,11 @@ func init() {
198
194
Tags : []string {"crio" , kola .NeedsInternetTag },
199
195
RequiredTag : "openshift" ,
200
196
})
201
- register .RegisterTest (& register.Test {
202
- Run : crioNetwork ,
203
- ClusterSize : 2 ,
204
- Name : "crio.network" ,
205
- Description : "Verify crio containers can make network connections outside of the host." ,
206
- Distros : []string {"rhcos" },
207
- UserData : enableCrioIgn ,
208
- // this test requires net connections outside the host
209
- Tags : []string {"crio" , kola .NeedsInternetTag },
210
- RequiredTag : "openshift" ,
211
- // qemu machines cannot communicate between each other
212
- ExcludePlatforms : []string {"qemu" },
213
- })
214
197
}
215
198
216
199
// crioBaseTests executes multiple tests under the "base" name
217
200
func crioBaseTests (c cluster.TestCluster ) {
218
201
c .Run ("crio-info" , testCrioInfo )
219
- c .Run ("pod-continues-during-service-restart" , crioPodContinuesDuringServiceRestart )
220
202
c .Run ("networks-reliably" , crioNetworksReliably )
221
203
}
222
204
@@ -273,102 +255,6 @@ func genContainer(c cluster.TestCluster, m platform.Machine, podName, imageName
273
255
return path .Base (configPathPod ), path .Base (configPathContainer ), nil
274
256
}
275
257
276
- // crioNetwork ensures that crio containers can make network connections outside of the host
277
- func crioNetwork (c cluster.TestCluster ) {
278
- machines := c .Machines ()
279
- src , dest := machines [0 ], machines [1 ]
280
-
281
- c .Log ("creating ncat containers" )
282
-
283
- // Since genContainer also generates crio pod/container configs,
284
- // there will be a duplicate config file on each machine.
285
- // Thus we only save one set for later use.
286
- crioConfigPod , crioConfigContainer , err := genContainer (c , src , "ncat" , "ncat" , []string {"ncat" , "echo" }, []string {"ncat" })
287
- if err != nil {
288
- c .Fatal (err )
289
- }
290
- _ , _ , err = genContainer (c , dest , "ncat" , "ncat" , []string {"ncat" , "echo" }, []string {"ncat" })
291
- if err != nil {
292
- c .Fatal (err )
293
- }
294
-
295
- listener := func (ctx context.Context ) error {
296
- podID , err := c .SSHf (dest , "sudo crictl runp -T %s %s" , overrideCrioOperationTimeoutSeconds , crioConfigPod )
297
- if err != nil {
298
- return err
299
- }
300
-
301
- containerID , err := c .SSHf (dest , "sudo crictl create -T %s --no-pull %s %s %s" ,
302
- overrideCrioOperationTimeoutSeconds ,
303
- podID , crioConfigContainer , crioConfigPod )
304
- if err != nil {
305
- return err
306
- }
307
-
308
- // This command will block until a message is recieved
309
- output , err := c .SSHf (dest , "sudo timeout 30 crictl exec %s echo 'HELLO FROM SERVER' | timeout 20 ncat --listen 0.0.0.0 9988 || echo 'LISTENER TIMEOUT'" , containerID )
310
- if err != nil {
311
- return err
312
- }
313
- if string (output ) != "HELLO FROM CLIENT" {
314
- return fmt .Errorf ("unexpected result from listener: %s" , output )
315
- }
316
-
317
- return nil
318
- }
319
-
320
- talker := func (ctx context.Context ) error {
321
- // Wait until listener is ready before trying anything
322
- for {
323
- _ , err := c .SSH (dest , "sudo ss -tulpn|grep 9988" )
324
- if err == nil {
325
- break // socket is ready
326
- }
327
-
328
- exit , ok := err .(* ssh.ExitError )
329
- if ! ok || exit .Waitmsg .ExitStatus () != 1 { // 1 is the expected exit of grep -q
330
- return err
331
- }
332
-
333
- select {
334
- case <- ctx .Done ():
335
- return fmt .Errorf ("timeout waiting for server" )
336
- default :
337
- time .Sleep (100 * time .Millisecond )
338
- }
339
- }
340
- podID , err := c .SSHf (src , "sudo crictl runp -T %s %s" , overrideCrioOperationTimeoutSeconds , crioConfigPod )
341
- if err != nil {
342
- return err
343
- }
344
-
345
- containerID , err := c .SSHf (src , "sudo crictl create -T %s --no-pull %s %s %s" ,
346
- overrideCrioOperationTimeoutSeconds ,
347
- podID , crioConfigContainer , crioConfigPod )
348
- if err != nil {
349
- return err
350
- }
351
-
352
- output , err := c .SSHf (src , "sudo crictl exec %s echo 'HELLO FROM CLIENT' | ncat %s 9988" ,
353
- containerID , dest .PrivateIP ())
354
- if err != nil {
355
- return err
356
- }
357
- if string (output ) != "HELLO FROM SERVER" {
358
- return fmt .Errorf (`unexpected result from listener: "%s"` , output )
359
- }
360
-
361
- return nil
362
- }
363
-
364
- ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
365
- defer cancel ()
366
-
367
- if err := worker .Parallel (ctx , listener , talker ); err != nil {
368
- c .Fatal (err )
369
- }
370
- }
371
-
372
258
// crioNetworksReliably verifies that crio containers have a reliable network
373
259
func crioNetworksReliably (c cluster.TestCluster ) {
374
260
m := c .Machines ()[0 ]
@@ -394,7 +280,7 @@ func crioNetworksReliably(c cluster.TestCluster) {
394
280
output = output + string (c .MustSSH (m , fmt .Sprintf ("sudo crictl exec %s ping -i 0.2 %s -w 1 >/dev/null && echo PASS || echo FAIL" , containerID , hostIP )))
395
281
}
396
282
397
- numPass := strings .Count (string ( output ) , "PASS" )
283
+ numPass := strings .Count (output , "PASS" )
398
284
if numPass != 10 {
399
285
c .Fatalf ("Expected 10 passes, but received %d passes with output: %s" , numPass , output )
400
286
}
@@ -437,32 +323,3 @@ func testCrioInfo(c cluster.TestCluster) {
437
323
}
438
324
439
325
}
440
-
441
- // crioPodContinuesDuringServiceRestart verifies that a crio pod does not
442
- // stop when the service is restarted
443
- func crioPodContinuesDuringServiceRestart (c cluster.TestCluster ) {
444
- m := c .Machines ()[0 ]
445
-
446
- crioConfigPod , crioConfigContainer , err := genContainer (
447
- c , m , "restart-test" , "sleep" ,
448
- []string {"bash" , "sleep" , "echo" }, []string {"bash" })
449
- if err != nil {
450
- c .Fatal (err )
451
- }
452
- cmdCreatePod := fmt .Sprintf ("sudo crictl runp -T %s %s" , overrideCrioOperationTimeoutSeconds , crioConfigPod )
453
- podID := c .MustSSH (m , cmdCreatePod )
454
- containerID := c .MustSSH (m , fmt .Sprintf ("sudo crictl create -T %s --no-pull %s %s %s" ,
455
- overrideCrioOperationTimeoutSeconds ,
456
- podID , crioConfigContainer , crioConfigPod ))
457
-
458
- cmd := fmt .Sprintf ("sudo crictl exec %s bash -c \" sleep 25 && echo PASS > /tmp/test/restart-test\" " , containerID )
459
- c .RunCmdSync (m , cmd )
460
- time .Sleep (3 * time .Second )
461
- c .RunCmdSync (m , "sudo systemctl restart crio" )
462
- time .Sleep (25 * time .Second )
463
- output := strings .TrimSuffix (string (c .MustSSH (m , "cat /tmp/test/restart-test" )), "\n " )
464
-
465
- if output != "PASS" {
466
- c .Fatalf ("Pod did not continue during service restart. Output=%s, Command=%s" , output , cmd )
467
- }
468
- }
0 commit comments