Ejemplo n.º 1
0
func (s *initSystemSuite) TestInstallCommandsShutdown(c *gc.C) {
	name := "juju-shutdown-job"
	conf, err := service.ShutdownAfterConf("cloud-final")
	c.Assert(err, jc.ErrorIsNil)
	svc, err := systemd.NewService(name, conf, s.dataDir)
	c.Assert(err, jc.ErrorIsNil)
	commands, err := svc.InstallCommands()
	c.Assert(err, jc.ErrorIsNil)

	test := systemdtesting.WriteConfTest{
		Service: name,
		DataDir: s.dataDir,
		Expected: `
[Unit]
Description=juju shutdown job
After=syslog.target
After=network.target
After=systemd-user-sessions.service
After=cloud-final

[Service]
ExecStart=/sbin/shutdown -h now
ExecStopPost=/bin/systemctl disable juju-shutdown-job.service

[Install]
WantedBy=multi-user.target
`[1:],
	}
	test.CheckCommands(c, commands)
}
Ejemplo n.º 2
0
func (*agentSuite) TestShutdownAfterConf(c *gc.C) {
	conf, err := service.ShutdownAfterConf("spam")
	c.Assert(err, jc.ErrorIsNil)

	c.Check(conf, jc.DeepEquals, common.Conf{
		Desc:         "juju shutdown job",
		Transient:    true,
		AfterStopped: "spam",
		ExecStart:    "/sbin/shutdown -h now",
	})
	renderer := &shell.BashRenderer{}
	c.Check(conf.Validate(renderer), jc.ErrorIsNil)
}
Ejemplo n.º 3
0
func (*agentSuite) TestShutdownAfterConfMissingServiceName(c *gc.C) {
	_, err := service.ShutdownAfterConf("")

	c.Check(err, gc.ErrorMatches, `.*missing "after" service name.*`)
}