Skip to content

Commit

Permalink
kola: use platform.Conf instead of an Ignition spec directly
Browse files Browse the repository at this point in the history
The `platform.Conf` type allows abstracting over the different Ignition
versions so that different tests can use different versions. Using it
instead of the Ignition type directly means that we can now use the
3.2-experimental spec in external tests.

This is needed for testing the new LUKS support in Ignition[1] and the
related rootfs-on-complex-devices work[2].

[1] coreos/ignition#960
[2] coreos/fedora-coreos-config#503

Closes: coreos#1589
  • Loading branch information
jlebon committed Jul 13, 2020
1 parent d4974ee commit f742a9a
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"github.com/kballard/go-shellquote"
"github.com/pkg/errors"

ignv3 "github.com/coreos/ignition/v2/config/v3_0"
ignv3types "github.com/coreos/ignition/v2/config/v3_0/types"
"github.com/coreos/mantle/harness"
"github.com/coreos/mantle/harness/reporters"
"github.com/coreos/mantle/kola/cluster"
Expand All @@ -57,7 +55,6 @@ import (
"github.com/coreos/mantle/platform/machine/unprivqemu"
"github.com/coreos/mantle/sdk"
"github.com/coreos/mantle/system"
"github.com/coreos/mantle/util"
)

// InstalledTestsDir is a directory where "installed" external
Expand Down Expand Up @@ -603,7 +600,7 @@ func runExternalTest(c cluster.TestCluster, mach platform.Machine) error {
}

func registerExternalTest(testname, executable, dependencydir, ignition string, baseMeta externalTestMeta) error {
ignc3, _, err := ignv3.Parse([]byte(ignition))
config, err := conf.Ignition(ignition).Render("", Options.IgnitionVersion == "v2")
if err != nil {
return errors.Wrapf(err, "Parsing config.ign")
}
Expand All @@ -627,26 +624,7 @@ Environment=KOLA_UNIT=%s
Environment=%s=%s
ExecStart=%s
`, KoletExtTestUnit, kolaExtBinDataEnv, kolaExtBinDataDir, remotepath)
runextconfig := ignv3types.Config{
Ignition: ignv3types.Ignition{
Version: "3.0.0",
},
Systemd: ignv3types.Systemd{
Units: []ignv3types.Unit{
{
Name: KoletExtTestUnit,
Contents: &unit,
Enabled: util.BoolToPtr(false),
},
},
},
}

finalIgn := ignv3.Merge(ignc3, runextconfig)
serializedIgn, err := json.Marshal(finalIgn)
if err != nil {
return errors.Wrapf(err, "serializing ignition")
}
config.AddSystemdUnit(KoletExtTestUnit, unit, conf.Enable)

t := &register.Test{
Name: testname,
Expand Down Expand Up @@ -677,7 +655,7 @@ ExecStart=%s
}
},

UserDataV3: conf.Ignition(string(serializedIgn)),
UserDataV3: conf.Ignition(config.String()),
}

// To avoid doubling the duplication here with register.Test, we support
Expand Down

0 comments on commit f742a9a

Please sign in to comment.