-
Notifications
You must be signed in to change notification settings - Fork 12
/
units.go
60 lines (57 loc) · 1.81 KB
/
units.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright The Mantle Authors
// Copyright 2020 Red Hat
// SPDX-License-Identifier: Apache-2.0
package ignition
import (
"github.com/coreos/go-semver/semver"
"github.com/flatcar/mantle/kola/cluster"
"github.com/flatcar/mantle/kola/register"
"github.com/flatcar/mantle/platform/conf"
)
func init() {
register.Register(®ister.Test{
Name: "cl.ignition.instantiated.enable-unit",
Run: enableSystemdInstantiatedService,
ClusterSize: 1,
// This test is normally not related to the cloud environment
Platforms: []string{"qemu", "qemu-unpriv"},
UserData: conf.Ignition(`{
"ignition": {"version": "3.0.0"},
"systemd": {
"units": [{
"name": "echo@.service",
"contents": "[Unit]\nDescription=f\n[Service]\nType=oneshot\nExecStart=/bin/echo %i\nRemainAfterExit=yes\n[Install]\nWantedBy=multi-user.target\n"
},
{
"name": "echo@.timer",
"contents": "[Unit]\nDescription=echo timer template\n[Timer]\nOnUnitInactiveSec=10s\n[Install]\nWantedBy=timers.target"
},
{
"enabled": true,
"name": "echo@bar.service"
},
{
"enabled": true,
"name": "echo@foo.service"
},
{
"enabled": true,
"name": "echo@foo.timer"
}]
}
}`),
Distros: []string{"cl"},
MinVersion: semver.Version{Major: 3185},
})
}
func enableSystemdInstantiatedService(c cluster.TestCluster) {
m := c.Machines()[0]
// MustSSH function will throw an error if the exit code
// of the command is anything other than 0.
_ = c.MustSSH(m, "systemctl -q is-active echo@foo.service")
_ = c.MustSSH(m, "systemctl -q is-active echo@bar.service")
_ = c.MustSSH(m, "systemctl -q is-enabled echo@foo.service")
_ = c.MustSSH(m, "systemctl -q is-enabled echo@bar.service")
_ = c.MustSSH(m, "systemctl -q is-active echo@foo.timer")
_ = c.MustSSH(m, "systemctl -q is-enabled echo@foo.timer")
}