Пример #1
0
func (s *filesSuite) TestGetFilesToBackUpMissing(c *gc.C) {
	paths := backups.Paths{
		DataDir: "/var/lib/juju",
		LogsDir: "/var/log/juju",
	}
	s.createFiles(c, paths, s.root, "0")

	missing := []string{
		"/var/lib/juju/nonce.txt",
		"/home/ubuntu/.ssh/authorized_keys",
		"/var/log/juju/all-machines.log",
		"/var/log/juju/machine-0.log",
	}
	for _, filename := range missing {
		err := os.Remove(filepath.Join(s.root, filename))
		c.Assert(err, jc.ErrorIsNil)
	}

	files, err := backups.GetFilesToBackUp(s.root, &paths, "0")
	c.Assert(err, jc.ErrorIsNil)

	expected := []string{
		filepath.Join(s.root, "/etc/rsyslog.d/spam-juju.conf"),
		filepath.Join(s.root, "/var/lib/juju/agents/machine-0.conf"),
		filepath.Join(s.root, "/var/lib/juju/server.pem"),
		filepath.Join(s.root, "/var/lib/juju/shared-secret"),
		filepath.Join(s.root, "/var/lib/juju/system-identity"),
		filepath.Join(s.root, "/var/lib/juju/tools"),
	}
	// This got re-created.
	expected = append(expected, filepath.Join(s.root, "/home/ubuntu/.ssh/authorized_keys"))
	c.Check(files, jc.SameContents, expected)
	s.checkSameStrings(c, files, expected)
}
Пример #2
0
func (s *filesSuite) TestGetFilesToBackUpMachine10(c *gc.C) {
	paths := backups.Paths{
		DataDir: "/var/lib/juju",
		LogsDir: "/var/log/juju",
	}
	s.createFiles(c, paths, s.root, "10")

	files, err := backups.GetFilesToBackUp(s.root, &paths, "10")
	c.Assert(err, jc.ErrorIsNil)

	expected := []string{
		filepath.Join(s.root, "/etc/rsyslog.d/spam-juju.conf"),
		filepath.Join(s.root, "/home/ubuntu/.ssh/authorized_keys"),
		filepath.Join(s.root, "/var/lib/juju/agents/machine-10.conf"),
		filepath.Join(s.root, "/var/lib/juju/nonce.txt"),
		filepath.Join(s.root, "/var/lib/juju/server.pem"),
		filepath.Join(s.root, "/var/lib/juju/shared-secret"),
		filepath.Join(s.root, "/var/lib/juju/system-identity"),
		filepath.Join(s.root, "/var/lib/juju/tools"),
		filepath.Join(s.root, "/var/log/juju/all-machines.log"),
		filepath.Join(s.root, "/var/log/juju/machine-10.log"),
	}
	c.Check(files, jc.SameContents, expected)
	s.checkSameStrings(c, files, expected)
}