Skip to content

Commit

Permalink
kola/external-tests: add appendFirstbootKernelArgs support in kola.json
Browse files Browse the repository at this point in the history
Add the ability to specify firstboot kernel arguments to transiently
append to the default kernel arguments for the first boot of the machine.
This will be useful when testing workflows that use kernel arguments
for network configuration.

For now, this only supports the qemu platform.
  • Loading branch information
dustymabe committed Feb 3, 2022
1 parent c350ea6 commit f690451
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 35 deletions.
6 changes: 5 additions & 1 deletion docs/kola/external-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ Here's an example `kola.json`:
"minMemory": 4096,
"minDisk": 15,
"additionalNics": 2,
"appendKernelArgs": "ip=bond0:dhcp bond=bond0:ens5,ens6:mode=active-backup,miimon=100"
"appendKernelArgs": "enforcing=0"
"appendFirstbootKernelArgs": "ip=bond0:dhcp bond=bond0:ens5,ens6:mode=active-backup,miimon=100"
"timeoutMin": 8,
"exclusive": true,
"conflicts": ["ext.config.some-test", "podman.some-other-test"]
Expand Down Expand Up @@ -244,6 +245,9 @@ to `qemuexec`. It is currently only supported on `qemu-unpriv`.
The `appendKernelArgs` key has the same semantics at the `--kargs` argument to
`qemuexec`. It is currently only supported on `qemu-unpriv`.

The `appendFirstbootKernelArgs` key has the same semantics at the `--firstbootkargs`
argument to `qemuexec`. It is currently only supported on `qemu-unpriv`.

The `timeoutMin` key takes a positive integer and specifies a timeout for the test
in minutes. After the specified amount of time, the test will be interrupted.

Expand Down
57 changes: 30 additions & 27 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,19 +747,20 @@ func RunUpgradeTests(patterns []string, rerun bool, pltfrm, outputDir string, pr

// externalTestMeta is parsed from kola.json in external tests
type externalTestMeta struct {
Architectures string `json:"architectures,omitempty"`
Platforms string `json:"platforms,omitempty"`
Distros string `json:"distros,omitempty"`
Tags string `json:"tags,omitempty"`
RequiredTag string `json:"requiredTag,omitempty"`
AdditionalDisks []string `json:"additionalDisks,omitempty"`
MinMemory int `json:"minMemory,omitempty"`
MinDiskSize int `json:"minDisk,omitempty"`
AdditionalNics int `json:"additionalNics,omitempty"`
AppendKernelArgs string `json:"appendKernelArgs,omitempty"`
Exclusive bool `json:"exclusive"`
TimeoutMin int `json:"timeoutMin"`
Conflicts []string `json:"conflicts"`
Architectures string `json:"architectures,omitempty"`
Platforms string `json:"platforms,omitempty"`
Distros string `json:"distros,omitempty"`
Tags string `json:"tags,omitempty"`
RequiredTag string `json:"requiredTag,omitempty"`
AdditionalDisks []string `json:"additionalDisks,omitempty"`
MinMemory int `json:"minMemory,omitempty"`
MinDiskSize int `json:"minDisk,omitempty"`
AdditionalNics int `json:"additionalNics,omitempty"`
AppendKernelArgs string `json:"appendKernelArgs,omitempty"`
AppendFirstbootKernelArgs string `json:"appendFirstbootKernelArgs,omitempty"`
Exclusive bool `json:"exclusive"`
TimeoutMin int `json:"timeoutMin"`
Conflicts []string `json:"conflicts"`
}

// metadataFromTestBinary extracts JSON-in-comment like:
Expand Down Expand Up @@ -923,13 +924,14 @@ ExecStart=%s
DependencyDir: destDirs,
Tags: []string{"external"},

AdditionalDisks: targetMeta.AdditionalDisks,
MinMemory: targetMeta.MinMemory,
MinDiskSize: targetMeta.MinDiskSize,
AdditionalNics: targetMeta.AdditionalNics,
AppendKernelArgs: targetMeta.AppendKernelArgs,
NonExclusive: !targetMeta.Exclusive,
Conflicts: targetMeta.Conflicts,
AdditionalDisks: targetMeta.AdditionalDisks,
MinMemory: targetMeta.MinMemory,
MinDiskSize: targetMeta.MinDiskSize,
AdditionalNics: targetMeta.AdditionalNics,
AppendKernelArgs: targetMeta.AppendKernelArgs,
AppendFirstbootKernelArgs: targetMeta.AppendFirstbootKernelArgs,
NonExclusive: !targetMeta.Exclusive,
Conflicts: targetMeta.Conflicts,

Run: func(c cluster.TestCluster) {
mach := c.Machines()[0]
Expand Down Expand Up @@ -1342,13 +1344,14 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
var userdata *conf.UserData = t.UserData

options := platform.MachineOptions{
MultiPathDisk: t.MultiPathDisk,
AdditionalDisks: t.AdditionalDisks,
MinMemory: t.MinMemory,
MinDiskSize: t.MinDiskSize,
AdditionalNics: t.AdditionalNics,
AppendKernelArgs: t.AppendKernelArgs,
SkipStartMachine: true,
MultiPathDisk: t.MultiPathDisk,
AdditionalDisks: t.AdditionalDisks,
MinMemory: t.MinMemory,
MinDiskSize: t.MinDiskSize,
AdditionalNics: t.AdditionalNics,
AppendKernelArgs: t.AppendKernelArgs,
AppendFirstbootKernelArgs: t.AppendFirstbootKernelArgs,
SkipStartMachine: true,
}

// Providers sometimes fail to bring up a machine within a
Expand Down
3 changes: 3 additions & 0 deletions mantle/kola/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Test struct {
// Additional kernel arguments to append to the defaults.
AppendKernelArgs string

// Additional first boot kernel arguments to append to the defaults.
AppendFirstbootKernelArgs string

// ExternalTest is a path to a binary that will be uploaded
ExternalTest string
// DependencyDir is a path to directory that will be uploaded, normally used by external tests
Expand Down
4 changes: 4 additions & 0 deletions mantle/platform/machine/aws/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
return nil, errors.New("platform aws does not support appending kernel arguments")
}

if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform aws does not support appending firstboot kernel arguments")
}

conf, err := ac.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_EC2_IPV4_PUBLIC}",
"$private_ipv4": "${COREOS_EC2_IPV4_LOCAL}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/azure/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
if options.AppendKernelArgs != "" {
return nil, errors.New("platform azure does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform azure does not support appending firstboot kernel arguments")
}

conf, err := ac.RenderUserData(userdata, map[string]string{
"$private_ipv4": "${COREOS_AZURE_IPV4_DYNAMIC}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/do/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (dc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
if options.AppendKernelArgs != "" {
return nil, errors.New("platform do does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform do does not support appending firstboot kernel arguments")
}

conf, err := dc.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_DIGITALOCEAN_IPV4_PUBLIC_0}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/esx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func (ec *cluster) NewMachineWithOptions(userdata *platformConf.UserData, option
if options.AppendKernelArgs != "" {
return nil, errors.New("platform esx does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform esx does not support appending firstboot kernel arguments")
}

conf, err := ec.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_ESX_IPV4_PUBLIC_0}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/gcloud/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (gc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
if options.AppendKernelArgs != "" {
return nil, errors.New("platform gce does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform gce does not support appending firstboot kernel arguments")
}

conf, err := gc.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_GCE_IP_EXTERNAL_0}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/openstack/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (oc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
if options.AppendKernelArgs != "" {
return nil, errors.New("platform openstack does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform openstack does not support appending firstboot kernel arguments")
}

conf, err := oc.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_OPENSTACK_IPV4_PUBLIC}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/packet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (pc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
if options.AppendKernelArgs != "" {
return nil, errors.New("platform packet does not support appending kernel arguments")
}
if options.AppendFirstbootKernelArgs != "" {
return nil, errors.New("platform packet does not support appending firstboot kernel arguments")
}

conf, err := pc.RenderUserData(userdata, map[string]string{
"$public_ipv4": "${COREOS_PACKET_IPV4_PUBLIC_0}",
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/qemuiso/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl
if options.AppendKernelArgs != "" {
builder.AppendKernelArgs = options.AppendKernelArgs
}
if options.AppendFirstbootKernelArgs != "" {
builder.AppendFirstbootKernelArgs = options.AppendFirstbootKernelArgs
}

inst, err := builder.Exec()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions mantle/platform/machine/unprivqemu/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl
if options.AppendKernelArgs != "" {
builder.AppendKernelArgs = options.AppendKernelArgs
}
if options.AppendFirstbootKernelArgs != "" {
builder.AppendFirstbootKernelArgs = options.AppendFirstbootKernelArgs
}
if !qc.RuntimeConf().InternetAccess {
builder.RestrictNetworking = true
}
Expand Down
15 changes: 8 additions & 7 deletions mantle/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ type Flight interface {
}

type MachineOptions struct {
MultiPathDisk bool
AdditionalDisks []string
MinMemory int
MinDiskSize int
AdditionalNics int
AppendKernelArgs string
SkipStartMachine bool // Skip platform.StartMachine on machine bringup
MultiPathDisk bool
AdditionalDisks []string
MinMemory int
MinDiskSize int
AdditionalNics int
AppendKernelArgs string
AppendFirstbootKernelArgs string
SkipStartMachine bool // Skip platform.StartMachine on machine bringup
}

// SystemdDropin is a userdata type agnostic struct representing a systemd dropin
Expand Down

0 comments on commit f690451

Please sign in to comment.