@@ -62,14 +62,16 @@ func init() {
62
62
// with a slight change, where the script originally run by MCO is run from
63
63
// ignition: https://github.com/RHsyseng/rhcos-slb/blob/161a421f8fdcdb4b08fb6366daa8fe1b75cbe095/init-interfaces.sh.
64
64
register .RegisterTest (& register.Test {
65
- Run : InitInterfacesTest ,
66
- ClusterSize : 0 ,
67
- Name : "rhcos.network.init-interfaces-test" ,
68
- Description : "Verify init-interfaces script works in both fresh setup and reboot." ,
69
- Timeout : 40 * time .Minute ,
70
- Distros : []string {"rhcos" },
71
- Platforms : []string {"qemu" },
72
- Tags : []string {"openshift" },
65
+ Run : InitInterfacesTest ,
66
+ ClusterSize : 1 ,
67
+ Name : "rhcos.network.init-interfaces-test" ,
68
+ Description : "Verify init-interfaces script works in both fresh setup and reboot." ,
69
+ Timeout : 40 * time .Minute ,
70
+ Distros : []string {"rhcos" },
71
+ Platforms : []string {"qemu" },
72
+ Tags : []string {"openshift" },
73
+ AdditionalNics : 2 ,
74
+ UserData : userdata ,
73
75
})
74
76
}
75
77
@@ -395,6 +397,44 @@ RequiredBy=multi-user.target
395
397
`
396
398
)
397
399
400
+ var userdata = conf .Ignition (fmt .Sprintf (`{
401
+ "ignition": {
402
+ "version": "3.2.0"
403
+ },
404
+ "storage": {
405
+ "files": [
406
+ {
407
+ "path": "/usr/local/bin/capture-macs",
408
+ "contents": { "source": "data:text/plain;base64,%s" },
409
+ "mode": 493
410
+ },
411
+ {
412
+ "path": "/var/init-interfaces.sh",
413
+ "contents": { "source": "data:text/plain;base64,%s" },
414
+ "mode": 493
415
+ }
416
+ ]
417
+ },
418
+ "systemd": {
419
+ "units": [
420
+ {
421
+ "contents": "%s",
422
+ "enabled": true,
423
+ "name": "capture-macs.service"
424
+ },
425
+ {
426
+ "contents": "%s",
427
+ "enabled": true,
428
+ "name": "setup-ovs.service"
429
+ }
430
+ ]
431
+ }
432
+ }` ,
433
+ base64 .StdEncoding .EncodeToString ([]byte (captureMacsScript )),
434
+ base64 .StdEncoding .EncodeToString ([]byte (initInterfacesScript )),
435
+ strings .Replace (captureMacsSystemdContents , "\n " , "\\ n" , - 1 ),
436
+ strings .Replace (initInterfacesSystemdContents , "\n " , "\\ n" , - 1 )))
437
+
398
438
// NetworkAdditionalNics verifies that additional NICs are created on the node
399
439
func NetworkAdditionalNics (c cluster.TestCluster ) {
400
440
primaryMac := "52:55:00:d1:56:00"
@@ -413,8 +453,10 @@ func InitInterfacesTest(c cluster.TestCluster) {
413
453
primaryMac := "52:55:00:d1:56:00"
414
454
secondaryMac := "52:55:00:d1:56:01"
415
455
416
- setupWithInterfacesTest (c , primaryMac , secondaryMac )
417
456
m := c .Machines ()[0 ]
457
+ // Add karg needed for the ignition to configure the network properly.
458
+ addKernelArgs (c , m , []string {fmt .Sprintf ("macAddressList=%s,%s" , primaryMac , secondaryMac )})
459
+
418
460
err := simulateNewInstallation (c , m , []string {primaryMac , secondaryMac })
419
461
if err != nil {
420
462
c .Fatalf ("failed to simulate new setup with no connections: %v" , err )
@@ -504,71 +546,6 @@ func setupMultipleNetworkTest(c cluster.TestCluster, primaryMac, secondaryMac st
504
546
addKernelArgs (c , m , []string {fmt .Sprintf ("macAddressList=%s,%s" , primaryMac , secondaryMac )})
505
547
}
506
548
507
- func setupWithInterfacesTest (c cluster.TestCluster , primaryMac , secondaryMac string ) {
508
- var userdata = conf .Ignition (fmt .Sprintf (`{
509
- "ignition": {
510
- "version": "3.2.0"
511
- },
512
- "storage": {
513
- "files": [
514
- {
515
- "path": "/usr/local/bin/capture-macs",
516
- "contents": { "source": "data:text/plain;base64,%s" },
517
- "mode": 493
518
- },
519
- {
520
- "path": "/var/init-interfaces.sh",
521
- "contents": { "source": "data:text/plain;base64,%s" },
522
- "mode": 493
523
- }
524
- ]
525
- },
526
- "systemd": {
527
- "units": [
528
- {
529
- "contents": "%s",
530
- "enabled": true,
531
- "name": "capture-macs.service"
532
- },
533
- {
534
- "contents": "%s",
535
- "enabled": true,
536
- "name": "setup-ovs.service"
537
- }
538
- ]
539
- }
540
- }` ,
541
- base64 .StdEncoding .EncodeToString ([]byte (captureMacsScript )),
542
- base64 .StdEncoding .EncodeToString ([]byte (initInterfacesScript )),
543
- strings .Replace (captureMacsSystemdContents , "\n " , "\\ n" , - 1 ),
544
- strings .Replace (initInterfacesSystemdContents , "\n " , "\\ n" , - 1 )))
545
-
546
- options := platform.QemuMachineOptions {
547
- MachineOptions : platform.MachineOptions {
548
- AdditionalNics : 2 ,
549
- },
550
- }
551
-
552
- var m platform.Machine
553
- var err error
554
- switch pc := c .Cluster .(type ) {
555
- // These cases have to be separated because when put together to the same case statement
556
- // the golang compiler no longer checks that the individual types in the case have the
557
- // NewMachineWithQemuOptions function, but rather whether platform.Cluster
558
- // does which fails
559
- case * qemu.Cluster :
560
- m , err = pc .NewMachineWithQemuOptions (userdata , options )
561
- default :
562
- panic ("unreachable" )
563
- }
564
- if err != nil {
565
- c .Fatal (err )
566
- }
567
-
568
- // Add karg needed for the ignition to configure the network properly.
569
- addKernelArgs (c , m , []string {fmt .Sprintf ("macAddressList=%s,%s" , primaryMac , secondaryMac )})
570
- }
571
-
572
549
func simulateNewInstallation (c cluster.TestCluster , m platform.Machine , macConnectionsToDelete []string ) error {
573
550
macConnectionMap , err := getMacConnectionMap (c , m )
574
551
if err != nil {
0 commit comments