Skip to content

Commit 6775ab1

Browse files
prestistAdam0Brien
authored andcommitted
mantle/kola: copy basic tests into formal kola workflow
`cmd-kola` has non-conformed basic kola tests. These tests do not benefit from the supporting functionality around kola test's such as denylisting or other functionality. reduce `cmd-kola` and conform the basic kola tests. fixes coreos#3418 co-authored-by: AdamOBrien <[email protected]>
1 parent 51bc015 commit 6775ab1

File tree

5 files changed

+94
-45
lines changed

5 files changed

+94
-45
lines changed

mantle/kola/harness.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
18231823

18241824
// drop kolet binary on machines
18251825
if t.ExternalTest != "" || t.NativeFuncs != nil {
1826-
if err := scpKolet(tcluster.Machines()); err != nil {
1826+
if err := ScpKolet(tcluster.Machines()); err != nil {
18271827
h.Fatal(err)
18281828
}
18291829
}
@@ -1890,8 +1890,8 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
18901890
t.Run(tcluster)
18911891
}
18921892

1893-
// scpKolet searches for a kolet binary and copies it to the machine.
1894-
func scpKolet(machines []platform.Machine) error {
1893+
// ScpKolet searches for a kolet binary and copies it to the machine.
1894+
func ScpKolet(machines []platform.Machine) error {
18951895
mArch := Options.CosaBuildArch
18961896
exePath, err := os.Executable()
18971897
if err != nil {

mantle/kola/tests/coretest/core.go

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ import (
1212
"github.com/pborman/uuid"
1313

1414
"github.com/coreos/coreos-assembler/mantle/kola"
15+
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
1516
"github.com/coreos/coreos-assembler/mantle/kola/register"
17+
"github.com/coreos/coreos-assembler/mantle/platform"
18+
"github.com/coreos/coreos-assembler/mantle/platform/machine/qemu"
1619
"github.com/coreos/coreos-assembler/mantle/util"
1720
)
1821

1922
const (
2023
DockerTimeout = time.Second * 60
2124
PortTimeout = time.Second * 3
25+
uefi = "uefi"
26+
uefiSecure = "uefi-secure"
27+
bios = "bios"
2228
)
2329

2430
// RHCOS services we expect disabled/inactive
@@ -37,22 +43,48 @@ var offServices = []string{
3743
"tcsd.service",
3844
}
3945

46+
var nativeFuncs = map[string]register.NativeFuncWrap{
47+
"PortSSH": register.CreateNativeFuncWrap(TestPortSsh),
48+
"DbusPerms": register.CreateNativeFuncWrap(TestDbusPerms),
49+
"ServicesActive": register.CreateNativeFuncWrap(TestServicesActive),
50+
"ReadOnly": register.CreateNativeFuncWrap(TestReadOnlyFs),
51+
"Useradd": register.CreateNativeFuncWrap(TestUseradd),
52+
"MachineID": register.CreateNativeFuncWrap(TestMachineID),
53+
"RHCOSGrowpart": register.CreateNativeFuncWrap(TestRHCOSGrowfs, []string{"fcos"}...),
54+
"FCOSGrowpart": register.CreateNativeFuncWrap(TestFCOSGrowfs, []string{"rhcos"}...),
55+
}
56+
4057
func init() {
4158
register.RegisterTest(&register.Test{
4259
Name: "basic",
4360
Description: "Verify basic functionalities like SSH, systemd services, useradd, etc.",
4461
Run: LocalTests,
4562
ClusterSize: 1,
46-
NativeFuncs: map[string]register.NativeFuncWrap{
47-
"PortSSH": register.CreateNativeFuncWrap(TestPortSsh),
48-
"DbusPerms": register.CreateNativeFuncWrap(TestDbusPerms),
49-
"ServicesActive": register.CreateNativeFuncWrap(TestServicesActive),
50-
"ReadOnly": register.CreateNativeFuncWrap(TestReadOnlyFs),
51-
"Useradd": register.CreateNativeFuncWrap(TestUseradd),
52-
"MachineID": register.CreateNativeFuncWrap(TestMachineID),
53-
"RHCOSGrowpart": register.CreateNativeFuncWrap(TestRHCOSGrowfs, []string{"fcos"}...),
54-
"FCOSGrowpart": register.CreateNativeFuncWrap(TestFCOSGrowfs, []string{"rhcos"}...),
55-
},
63+
NativeFuncs: nativeFuncs,
64+
})
65+
register.RegisterTest(&register.Test{
66+
Name: "basic.uefi",
67+
Description: "Verify basic functionalities like SSH, systemd services, useradd, etc, with UEFI enabled",
68+
Run: uefiWithBasicTests,
69+
Platforms: []string{"qemu"},
70+
ClusterSize: 0,
71+
NativeFuncs: nativeFuncs,
72+
})
73+
register.RegisterTest(&register.Test{
74+
Name: "basic.uefi-secure",
75+
Description: "Verify basic functionalities like SSH, systemd services, useradd, etc, with UEFI Secure Boot enabled",
76+
Run: uefiSecureWithBasicTests,
77+
Platforms: []string{"qemu"},
78+
ClusterSize: 0,
79+
NativeFuncs: nativeFuncs,
80+
})
81+
register.RegisterTest(&register.Test{
82+
Name: "basic.nvme",
83+
Description: "Verify basic functionalities like SSH, systemd services, useradd, etc, with nvme enabled",
84+
Run: nvmeBasicTests,
85+
Platforms: []string{"qemu"},
86+
ClusterSize: 0,
87+
NativeFuncs: nativeFuncs,
5688
})
5789
// TODO: Enable DockerPing/DockerEcho once fixed
5890
// TODO: Only enable PodmanPing on non qemu. Needs:
@@ -92,6 +124,47 @@ func init() {
92124
})
93125
}
94126

127+
func uefiWithBasicTests(c cluster.TestCluster) {
128+
runBasicTests(c, uefi, false)
129+
}
130+
131+
func uefiSecureWithBasicTests(c cluster.TestCluster) {
132+
runBasicTests(c, uefiSecure, false)
133+
}
134+
135+
func nvmeBasicTests(c cluster.TestCluster) {
136+
runBasicTests(c, bios, true)
137+
}
138+
139+
func runBasicTests(c cluster.TestCluster, firmware string, nvme bool) {
140+
var err error
141+
var m platform.Machine
142+
143+
options := platform.QemuMachineOptions{
144+
Firmware: firmware,
145+
Nvme: nvme,
146+
}
147+
switch pc := c.Cluster.(type) {
148+
// These cases have to be separated because when put together to the same case statement
149+
// the golang compiler no longer checks that the individual types in the case have the
150+
// NewMachineWithQemuOptions function, but rather whether platform.Cluster
151+
// does which fails
152+
case *qemu.Cluster:
153+
m, err = pc.NewMachineWithQemuOptions(nil, options)
154+
default:
155+
panic("Unsupported cluster type")
156+
}
157+
if err != nil {
158+
c.Fatal(err)
159+
}
160+
161+
// copy over kolet into the machine
162+
if err := kola.ScpKolet([]platform.Machine{m}); err != nil {
163+
c.Fatal(err)
164+
}
165+
LocalTests(c)
166+
}
167+
95168
func TestPortSsh() error {
96169
//t.Parallel()
97170
err := CheckPort("tcp", "127.0.0.1:22", PortTimeout)

mantle/platform/machine/qemu/cluster.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl
141141
}
142142

143143
channel := "virtio"
144-
if qc.flight.opts.Nvme {
144+
if qc.flight.opts.Nvme || options.Nvme {
145145
channel = "nvme"
146146
}
147147
sectorSize := 0
@@ -194,6 +194,9 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl
194194
if !qc.RuntimeConf().InternetAccess {
195195
builder.RestrictNetworking = true
196196
}
197+
if options.Firmware != "" {
198+
builder.Firmware = options.Firmware
199+
}
197200

198201
inst, err := builder.Exec()
199202
if err != nil {

mantle/platform/qemu.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ type QemuMachineOptions struct {
7373
HostForwardPorts []HostForwardPort
7474
DisablePDeathSig bool
7575
OverrideBackingFile string
76+
Firmware string
77+
Nvme bool
7678
}
7779

7880
// QEMUMachine represents a qemu instance.

src/cmd-kola

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import sys
1010
# Just test these boot to start with. In the future we should at least
1111
# do ostree upgrades with uefi etc. But we don't really need the *full*
1212
# suite...if podman somehow broke with nvme or uefi I'd be amazed and impressed.
13-
BASIC_SCENARIOS = ["nvme=true", "firmware=uefi"]
14-
BASIC_SCENARIOS_SECURE_BOOT = ["firmware=uefi-secure"]
1513
arch = platform.machine()
1614

1715
cosa_dir = os.path.dirname(os.path.abspath(__file__))
@@ -24,9 +22,7 @@ basearch = cmdlib.get_basearch()
2422
# Parse args and dispatch
2523
parser = argparse.ArgumentParser()
2624
parser.add_argument("--build", help="Build ID")
27-
parser.add_argument("--basic-qemu-scenarios", help="Run the basic test across uefi-secure,nvme etc.", action='store_true')
2825
parser.add_argument("--output-dir", help="Output directory")
29-
parser.add_argument("--skip-secure-boot", help="Use with '--basic-qemu-scenarios' to skip the Secure Boot tests", action='store_true')
3026
parser.add_argument("--upgrades", help="Run upgrade tests", action='store_true')
3127
parser.add_argument("subargs", help="Remaining arguments for kola", nargs='*',
3228
default=[])
@@ -58,33 +54,8 @@ subargs = args.subargs or [default_cmd]
5854
kolaargs.extend(subargs)
5955
kolaargs.extend(unknown_args)
6056

61-
if args.basic_qemu_scenarios:
62-
if arch == "x86_64":
63-
os.mkdir(outputdir) # Create the toplevel output dir
64-
for scenario in BASIC_SCENARIOS:
65-
kolaargs.extend(['--output-dir',
66-
os.path.join(outputdir, scenario.replace('=', '-'))])
67-
subargs = kolaargs + ['--qemu-' + scenario, 'basic']
68-
print(subprocess.list2cmdline(subargs), flush=True)
69-
subprocess.check_call(subargs)
70-
if not args.skip_secure_boot:
71-
for scenario in BASIC_SCENARIOS_SECURE_BOOT:
72-
kolaargs.extend(['--output-dir',
73-
os.path.join(outputdir, scenario.replace('=', '-'))])
74-
# See https://issues.redhat.com/browse/COS-2000 - there's
75-
# some bug with shim/grub2 that fails with secure boot on < ~1300MiB of RAM.
76-
# But we're not going to block on that; real world OCP worker nodes are at least 16GiB etc.
77-
subargs = kolaargs + ['--qemu-' + scenario, 'basic'] + ["--qemu-memory", "1536"]
78-
print(subprocess.list2cmdline(subargs), flush=True)
79-
subprocess.check_call(subargs)
80-
else:
81-
# Basic qemu scenarios using nvme and uefi
82-
# are not supported on multi-arch
83-
kolaargs.extend(['--output-dir', outputdir])
84-
subargs = kolaargs + ['basic']
85-
print(subprocess.list2cmdline(subargs), flush=True)
86-
subprocess.check_call(subargs)
87-
elif args.upgrades:
57+
58+
if args.upgrades:
8859
kolaargs.extend(['--output-dir', outputdir])
8960
if '--qemu-image-dir' not in unknown_args:
9061
os.makedirs('tmp/kola-qemu-cache', exist_ok=True)

0 commit comments

Comments
 (0)