Skip to content

Commit d75f86b

Browse files
kola: set SkipStartMachine and drop unused SSH keys for iso.* (except live-login) tests
The iso.* tests use systemd units that report success or failure via virtio channels and always power off the machine. Because of this, we do not need to SSH into the instance.
1 parent 7a3acdc commit d75f86b

4 files changed

Lines changed: 76 additions & 60 deletions

File tree

mantle/kola/tests/iso/live-as-disk.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package iso
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67

78
"github.com/coreos/coreos-assembler/mantle/kola"
@@ -59,11 +60,6 @@ func isoTestAsDisk(c cluster.TestCluster, opts IsoTestOpts) {
5960
}
6061
config.AddSystemdUnit("live-signal-ok.service", liveSignalOKUnit, conf.Enable)
6162
config.AddSystemdUnit("verify-no-efi-boot-entry.service", verifyNoEFIBootEntry, conf.Enable)
62-
keys, err := qc.Keys()
63-
if err != nil {
64-
c.Fatal(err)
65-
}
66-
config.CopyKeys(keys)
6763

6864
overrideFW := func(builder *platform.QemuBuilder) error {
6965
switch {
@@ -75,28 +71,37 @@ func isoTestAsDisk(c cluster.TestCluster, opts IsoTestOpts) {
7571
return nil
7672
}
7773

78-
errchan := make(chan error)
74+
var isoCompletionOutput *os.File
7975
setupDisks := func(_ platform.QemuMachineOptions, builder *platform.QemuBuilder) error {
80-
output, err := builder.VirtioChannelRead("testisocompletion")
76+
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
77+
if err := builder.AddIso(isopath, "", true); err != nil {
78+
return err
79+
}
80+
81+
isoCompletionOutput, err = builder.VirtioChannelRead("testisocompletion")
8182
if err != nil {
8283
return errors.Wrap(err, "setting up virtio-serial channel")
8384
}
8485

85-
// Read line in a goroutine and send errors to channel
86-
go func() {
87-
errchan <- checkTestOutput(output, []string{liveOKSignal})
88-
}()
89-
90-
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
91-
return builder.AddIso(isopath, "", true)
86+
return nil
9287
}
9388

89+
extra := platform.QemuMachineOptions{}
90+
extra.SkipStartMachine = true
9491
callbacks := qemu.BuilderCallbacks{SetupDisks: setupDisks, OverrideDefaults: overrideFW}
95-
_, err = qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, platform.QemuMachineOptions{}, callbacks)
92+
qm, err := qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, extra, callbacks)
9693
if err != nil {
9794
c.Fatalf("Unable to create test machine: %v", err)
9895
}
9996

97+
errchan := make(chan error)
98+
go func() {
99+
errchan <- qm.IgnitionError()
100+
}()
101+
go func() {
102+
errchan <- checkTestOutput(isoCompletionOutput, []string{liveOKSignal})
103+
}()
104+
100105
err = <-errchan
101106
if err != nil {
102107
c.Fatal(err)

mantle/kola/tests/iso/live-fips.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package iso
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67

78
"github.com/coreos/coreos-assembler/mantle/kola"
@@ -57,11 +58,6 @@ func testLiveFIPS(c cluster.TestCluster) {
5758
config.AddSystemdUnit("fips-verify.service", fipsVerify, conf.Enable)
5859
config.AddSystemdUnit("fips-signal-ok.service", liveSignalOKUnit, conf.Enable)
5960
config.AddSystemdUnit("fips-emergency-target.service", signalFailureUnit, conf.Enable)
60-
keys, err := qc.Keys()
61-
if err != nil {
62-
c.Fatal(err)
63-
}
64-
config.CopyKeys(keys)
6561

6662
overrideFW := func(builder *platform.QemuBuilder) error {
6763
builder.Firmware = "uefi"
@@ -72,28 +68,33 @@ func testLiveFIPS(c cluster.TestCluster) {
7268
return nil
7369
}
7470

75-
errchan := make(chan error)
71+
var isoCompletionOutput *os.File
7672
setupDisks := func(_ platform.QemuMachineOptions, builder *platform.QemuBuilder) error {
77-
output, err := builder.VirtioChannelRead("testisocompletion")
73+
isoCompletionOutput, err = builder.VirtioChannelRead("testisocompletion")
7874
if err != nil {
7975
return errors.Wrap(err, "setting up virtio-serial channel")
8076
}
8177

82-
// Read line in a goroutine and send errors to channel
83-
go func() {
84-
errchan <- checkTestOutput(output, []string{liveOKSignal})
85-
}()
86-
8778
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
8879
return builder.AddIso(isopath, "", false)
8980
}
9081

82+
extra := platform.QemuMachineOptions{}
83+
extra.SkipStartMachine = true
9184
callbacks := qemu.BuilderCallbacks{SetupDisks: setupDisks, OverrideDefaults: overrideFW}
92-
_, err = qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, platform.QemuMachineOptions{}, callbacks)
85+
qm, err := qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, extra, callbacks)
9386
if err != nil {
9487
c.Fatalf("Unable to create test machine: %v", err)
9588
}
9689

90+
errchan := make(chan error)
91+
go func() {
92+
errchan <- qm.IgnitionError()
93+
}()
94+
go func() {
95+
errchan <- checkTestOutput(isoCompletionOutput, []string{liveOKSignal})
96+
}()
97+
9798
err = <-errchan
9899
if err != nil {
99100
c.Fatal(err)

mantle/kola/tests/iso/live-iscsi.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ func isoInstalliScsi(c cluster.TestCluster, opts IsoTestOpts) {
113113
if err != nil {
114114
c.Fatal(err)
115115
}
116-
keys, err := qc.Keys()
117-
if err != nil {
118-
c.Fatal(err)
119-
}
120-
config.CopyKeys(keys)
116+
121117
// Add a failure target to stop the test if something go wrong rather than waiting for the 10min timeout
122118
config.AddSystemdUnit("coreos-test-entered-emergency-target.service", signalFailureUnit, conf.Enable)
123119
config.MountHost("/var/cosaroot", true)
@@ -131,14 +127,14 @@ func isoInstalliScsi(c cluster.TestCluster, opts IsoTestOpts) {
131127
return nil
132128
}
133129

134-
errchan := make(chan error)
130+
var isoCompletionOutput *os.File
135131
setupDisks := func(_ platform.QemuMachineOptions, builder *platform.QemuBuilder) error {
136132
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
137133
if err := builder.AddIso(isopath, "", false); err != nil {
138134
return err
139135
}
140136

141-
output, err := builder.VirtioChannelRead("testisocompletion")
137+
isoCompletionOutput, err = builder.VirtioChannelRead("testisocompletion")
142138
if err != nil {
143139
return errors.Wrap(err, "setting up virtio-serial channel")
144140
}
@@ -171,20 +167,25 @@ func isoInstalliScsi(c cluster.TestCluster, opts IsoTestOpts) {
171167
// qemuexec the nested VM for the test. See resources/iscsi_butane_setup.yaml
172168
builder.MountHost("/", "/var/cosaroot", true)
173169

174-
// Read line in a goroutine and send errors to channel
175-
go func() {
176-
errchan <- checkTestOutput(output, []string{"iscsi-boot-ok"})
177-
}()
178-
179170
return nil
180171
}
181172

173+
extra := platform.QemuMachineOptions{}
174+
extra.SkipStartMachine = true
182175
callbacks := qemu.BuilderCallbacks{SetupDisks: setupDisks, OverrideDefaults: overrideFW}
183-
_, err = qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, platform.QemuMachineOptions{}, callbacks)
176+
qm, err := qc.NewMachineWithQemuOptionsAndBuilderCallbacks(config, extra, callbacks)
184177
if err != nil {
185178
c.Fatalf("Unable to create test machine: %v", err)
186179
}
187180

181+
errchan := make(chan error)
182+
go func() {
183+
errchan <- qm.IgnitionError()
184+
}()
185+
go func() {
186+
errchan <- checkTestOutput(isoCompletionOutput, []string{"iscsi-boot-ok"})
187+
}()
188+
188189
err = <-errchan
189190
if err != nil {
190191
c.Fatal(err)

mantle/kola/tests/iso/live-login.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package iso
22

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67

78
"github.com/coreos/coreos-assembler/mantle/kola"
@@ -25,11 +26,16 @@ func testLiveLogin(c cluster.TestCluster, enableUefi bool, enableUefiSecure bool
2526
fmt.Println(err)
2627
return
2728
}
29+
30+
qc, ok := c.Cluster.(*qemu.Cluster)
31+
if !ok {
32+
c.Fatalf("Unsupported cluster type")
33+
}
34+
2835
butane := conf.Butane(`
2936
variant: fcos
3037
version: 1.1.0`)
3138

32-
errchan := make(chan error)
3339
overrideFW := func(builder *platform.QemuBuilder) error {
3440
switch {
3541
case enableUefiSecure:
@@ -39,34 +45,36 @@ version: 1.1.0`)
3945
}
4046
return nil
4147
}
48+
49+
var isoCompletionOutput *os.File
4250
setupDisks := func(_ platform.QemuMachineOptions, builder *platform.QemuBuilder) error {
51+
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
52+
err := builder.AddIso(isopath, "", false)
53+
if err != nil {
54+
return err
55+
}
56+
4357
// https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/05core/usr/lib/systemd/system/coreos-liveiso-success.service
44-
output, err := builder.VirtioChannelRead("coreos.liveiso-success")
58+
isoCompletionOutput, err = builder.VirtioChannelRead("coreos.liveiso-success")
4559
if err != nil {
4660
return errors.Wrap(err, "setting up virtio-serial channel")
4761
}
4862

49-
// Read line in a goroutine and send errors to channel
50-
go func() {
51-
errchan <- checkTestOutput(output, []string{"coreos-liveiso-success"})
52-
}()
53-
54-
isopath := filepath.Join(kola.CosaBuild.Dir, kola.CosaBuild.Meta.BuildArtifacts.LiveIso.Path)
55-
return builder.AddIso(isopath, "", false)
63+
return nil
5664
}
5765

58-
switch pc := c.Cluster.(type) {
59-
case *qemu.Cluster:
60-
callbacks := qemu.BuilderCallbacks{SetupDisks: setupDisks, OverrideDefaults: overrideFW}
61-
_, err := pc.NewMachineWithQemuOptionsAndBuilderCallbacks(butane, platform.QemuMachineOptions{}, callbacks)
62-
if err != nil {
63-
c.Fatalf("Unable to create test machine: %v", err)
64-
}
65-
default:
66-
c.Fatalf("Unsupported cluster type")
66+
callbacks := qemu.BuilderCallbacks{SetupDisks: setupDisks, OverrideDefaults: overrideFW}
67+
_, err := qc.NewMachineWithQemuOptionsAndBuilderCallbacks(butane, platform.QemuMachineOptions{}, callbacks)
68+
if err != nil {
69+
c.Fatalf("Unable to create test machine: %v", err)
6770
}
6871

69-
err := <-errchan
72+
errchan := make(chan error)
73+
go func() {
74+
errchan <- checkTestOutput(isoCompletionOutput, []string{"coreos-liveiso-success"})
75+
}()
76+
77+
err = <-errchan
7078
if err != nil {
7179
c.Fatal(err)
7280
}
@@ -79,6 +87,7 @@ func isoLiveLogin(c cluster.TestCluster) {
7987
func isoLiveLoginUefi(c cluster.TestCluster) {
8088
testLiveLogin(c, true, false)
8189
}
90+
8291
func isoLiveLoginUefiSecure(c cluster.TestCluster) {
8392
testLiveLogin(c, false, true)
8493
}

0 commit comments

Comments
 (0)