diff --git a/mantle/kola/README-kola-ext.md b/mantle/kola/README-kola-ext.md index 9b4380694c..5e60aee4d3 100644 --- a/mantle/kola/README-kola-ext.md +++ b/mantle/kola/README-kola-ext.md @@ -105,8 +105,9 @@ Here's an example `kola.json`: { "architectures": "!s390x ppc64le", "platforms": "qemu-unpriv", - "tags": "sometagname needs-internet othertag" - "additionalDisks": [ "5G" ] + "tags": "sometagname needs-internet othertag", + "additionalDisks": [ "5G" ], + "minMemory": 4096 } ``` @@ -129,6 +130,11 @@ Currently only the `qemu` platform enforces this restriction. The `additionalDisks` key has the same semantics as the `--add-disk` argument to `qemuexec`. It is currently only supported on `qemu-unpriv`. +The `minMemory` key takes a size in MB and ensures that an instance type +with at least the specified amount of memory is used. On QEMU, this is +equivalent to the `--memory` argument to `qemuexec`. This is currently +only enforced on `qemu-unpriv`. + More recently, you can also (useful for shell scripts) include the JSON file inline per test, like this: diff --git a/mantle/kola/harness.go b/mantle/kola/harness.go index cd6cdb4fb7..21c1597687 100644 --- a/mantle/kola/harness.go +++ b/mantle/kola/harness.go @@ -534,6 +534,7 @@ type externalTestMeta struct { Distros string `json:",distros,omitempty"` Tags string `json:",tags,omitempty"` AdditionalDisks []string `json:",additionalDisks,omitempty"` + MinMemory int `json:",minMemory,omitempty"` } // metadataFromTestBinary extracts JSON-in-comment like: @@ -662,6 +663,7 @@ ExecStart=%s Tags: []string{"external"}, AdditionalDisks: targetMeta.AdditionalDisks, + MinMemory: targetMeta.MinMemory, Run: func(c cluster.TestCluster) { mach := c.Machines()[0] @@ -896,7 +898,11 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig userdata = t.UserDataV3 } - if _, err := platform.NewMachines(c, userdata, t.ClusterSize, t.AdditionalDisks); err != nil { + options := platform.MachineOptions{ + AdditionalDisks: t.AdditionalDisks, + MinMemory: t.MinMemory, + } + if _, err := platform.NewMachines(c, userdata, t.ClusterSize, options); err != nil { h.Fatalf("Cluster failed starting machines: %v", err) } } diff --git a/mantle/kola/register/register.go b/mantle/kola/register/register.go index baee1e5669..bc209e8b61 100644 --- a/mantle/kola/register/register.go +++ b/mantle/kola/register/register.go @@ -69,6 +69,9 @@ type Test struct { // "5G"]) -- defaults to none. AdditionalDisks []string + // Minimum amount of memory required for test. + MinMemory int + // 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 diff --git a/mantle/platform/machine/unprivqemu/cluster.go b/mantle/platform/machine/unprivqemu/cluster.go index e2c2502f38..9716c1cd72 100644 --- a/mantle/platform/machine/unprivqemu/cluster.go +++ b/mantle/platform/machine/unprivqemu/cluster.go @@ -112,6 +112,8 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl return nil, errors.Wrapf(err, "parsing memory option") } builder.Memory = int(memory) + } else if options.MinMemory != 0 { + builder.Memory = options.MinMemory } channel := "virtio" diff --git a/mantle/platform/platform.go b/mantle/platform/platform.go index 8c6174daa1..a76ee49909 100644 --- a/mantle/platform/platform.go +++ b/mantle/platform/platform.go @@ -156,6 +156,7 @@ type Flight interface { type MachineOptions struct { AdditionalDisks []string + MinMemory int } // SystemdDropin is a userdata type agnostic struct representing a systemd dropin @@ -354,7 +355,7 @@ func CopyDirToMachine(inputdir string, m Machine, destdir string) error { // NewMachines spawns n instances in cluster c, with // each instance passed the same userdata. -func NewMachines(c Cluster, userdata *conf.UserData, n int, addDisks []string) ([]Machine, error) { +func NewMachines(c Cluster, userdata *conf.UserData, n int, options MachineOptions) ([]Machine, error) { var wg sync.WaitGroup mchan := make(chan Machine, n) @@ -364,9 +365,6 @@ func NewMachines(c Cluster, userdata *conf.UserData, n int, addDisks []string) ( wg.Add(1) go func() { defer wg.Done() - options := MachineOptions{ - AdditionalDisks: addDisks, - } m, err := c.NewMachineWithOptions(userdata, options) if err != nil { errchan <- err