Ejemplo n.º 1
0
func (s *mongoRestoreSuite) TestMongoRestoreArgsForVersion(c *gc.C) {
	dir := filepath.Join(agent.DefaultDataDir, "db")
	versionNumber := version.Number{}
	versionNumber.Major = 1
	versionNumber.Minor = 21
	args, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(args, gc.HasLen, 5)
	c.Assert(args[0:5], jc.DeepEquals, []string{
		"--drop",
		"--journal",
		"--dbpath",
		dir,
		"/some/fake/path",
	})

	versionNumber.Major = 1
	versionNumber.Minor = 22
	args, err = backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(args, gc.HasLen, 6)
	c.Assert(args[0:6], jc.DeepEquals, []string{
		"--drop",
		"--journal",
		"--oplogReplay",
		"--dbpath",
		dir,
		"/some/fake/path",
	})

	versionNumber.Major = 0
	versionNumber.Minor = 0
	_, err = backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
	c.Assert(err, gc.ErrorMatches, "this backup file is incompatible with the current version of juju")
}
Ejemplo n.º 2
0
func (s *mongoRestoreSuite) TestMongoRestoreArgsForOldVersion(c *gc.C) {
	versionNumber := version.Number{}
	versionNumber.Major = 0
	versionNumber.Minor = 0
	_, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
	c.Assert(err, gc.ErrorMatches, "this backup file is incompatible with the current version of juju")
}
Ejemplo n.º 3
0
func (s *mongoRestoreSuite) TestMongoRestoreArgsForVersion121(c *gc.C) {
	dir := filepath.Join(agent.DefaultPaths.DataDir, "db")
	versionNumber := version.Number{}
	versionNumber.Major = 1
	versionNumber.Minor = 21
	args, err := backups.MongoRestoreArgsForVersion(versionNumber, "/some/fake/path")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(args, gc.HasLen, 5)
	c.Assert(args[0:5], jc.DeepEquals, []string{
		"--drop",
		"--journal",
		"--dbpath",
		dir,
		"/some/fake/path",
	})
}