Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mantle/kola/README-kola-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand All @@ -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:

Expand Down
8 changes: 7 additions & 1 deletion mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -662,6 +663,7 @@ ExecStart=%s
Tags: []string{"external"},

AdditionalDisks: targetMeta.AdditionalDisks,
MinMemory: targetMeta.MinMemory,

Run: func(c cluster.TestCluster) {
mach := c.Machines()[0]
Expand Down Expand Up @@ -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)
}
}
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 @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mantle/platform/machine/unprivqemu/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions mantle/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down