def testFileStoragePathsDryRun(self): self.assertFalse(os.path.exists(self.file_storage_paths)) self._TestSimpleUpgrade(version.BuildVersion(2, 6, 0), True, file_storage_dir=self.tmpdir, shared_file_storage_dir="/tmp") self.assertFalse(os.path.exists(self.file_storage_paths))
def testRapiUsersDryRun(self): self.assertFalse(os.path.exists(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) utils.WriteFile(self.rapi_users_path_pre24, data="some user\n") self._TestSimpleUpgrade(version.BuildVersion(2, 3, 0), True) self.assertFalse(os.path.isdir(os.path.dirname(self.rapi_users_path))) self.assertTrue(os.path.isfile(self.rapi_users_path_pre24) and not os.path.islink(self.rapi_users_path_pre24)) self.assertFalse(os.path.exists(self.rapi_users_path))
def testFileStoragePathsSharedOnly(self): self.assertFalse(os.path.exists(self.file_storage_paths)) self._TestSimpleUpgrade(version.BuildVersion(2, 5, 0), False, file_storage_dir=None, shared_file_storage_dir=self.tmpdir) lines = utils.ReadFile(self.file_storage_paths).splitlines() self.assertTrue(lines.pop(0).startswith("# ")) self.assertTrue(lines.pop(0).startswith("# cfgupgrade")) self.assertEqual(lines.pop(0), self.tmpdir) self.assertFalse(lines)
def testRapiUsers24AndAboveDryRun(self): self.assertFalse(os.path.exists(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) os.mkdir(os.path.dirname(self.rapi_users_path)) utils.WriteFile(self.rapi_users_path, data="other user\n") self._TestSimpleUpgrade(version.BuildVersion(2, 3, 0), True) self.assertTrue(os.path.isfile(self.rapi_users_path) and not os.path.islink(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) self.assertEqual(utils.ReadFile(self.rapi_users_path), "other user\n")
def testConfigVersion(self): self.failUnless(constants.CONFIG_MAJOR >= 0 and constants.CONFIG_MAJOR <= 99) self.failUnless(constants.CONFIG_MINOR >= 0 and constants.CONFIG_MINOR <= 99) self.failUnless(constants.CONFIG_REVISION >= 0 and constants.CONFIG_REVISION <= 9999) self.failUnless(constants.CONFIG_VERSION >= 0 and constants.CONFIG_VERSION <= 99999999) self.failUnless(version.BuildVersion(0, 0, 0) == 0) self.failUnless(version.BuildVersion(10, 10, 1010) == 10101010) self.failUnless(version.BuildVersion(12, 34, 5678) == 12345678) self.failUnless(version.BuildVersion(99, 99, 9999) == 99999999) self.failUnless(version.SplitVersion(00000000) == (0, 0, 0)) self.failUnless(version.SplitVersion(10101010) == (10, 10, 1010)) self.failUnless(version.SplitVersion(12345678) == (12, 34, 5678)) self.failUnless(version.SplitVersion(99999999) == (99, 99, 9999)) self.failUnless(version.SplitVersion(constants.CONFIG_VERSION) == (constants.CONFIG_MAJOR, constants.CONFIG_MINOR, constants.CONFIG_REVISION))
def testRapiUsers24AndAbove(self): self.assertFalse(os.path.exists(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) os.mkdir(os.path.dirname(self.rapi_users_path)) utils.WriteFile(self.rapi_users_path, data="other user\n") self._TestSimpleUpgrade(version.BuildVersion(2, 3, 0), False) self.assert_(os.path.islink(self.rapi_users_path_pre24)) self.assert_(os.path.isfile(self.rapi_users_path)) self.assertEqual(os.readlink(self.rapi_users_path_pre24), self.rapi_users_path) for path in [self.rapi_users_path, self.rapi_users_path_pre24]: self.assertEqual(utils.ReadFile(path), "other user\n")
def testFileStoragePathsBoth(self): self.assertFalse(os.path.exists(self.file_storage_paths)) self._TestSimpleUpgrade(version.BuildVersion(2, 6, 0), False, file_storage_dir=self.tmpdir, shared_file_storage_dir="/tmp") lines = utils.ReadFile(self.file_storage_paths).splitlines() self.assertTrue(lines.pop(0).startswith("# ")) self.assertTrue(lines.pop(0).startswith("# cfgupgrade")) self.assertEqual(lines.pop(0), self.tmpdir) self.assertEqual(lines.pop(0), "/tmp") self.assertFalse(lines) self.assertEqual(os.stat(self.file_storage_paths).st_mode & 0777, 0600, msg="Wrong permissions")
def UpgradeAll(self): self.config_data["version"] = version.BuildVersion( TARGET_MAJOR, TARGET_MINOR, 0) self.UpgradeRapiUsers() self.UpgradeWatcher() steps = [ self.UpgradeFileStoragePaths, self.UpgradeNetworks, self.UpgradeCluster, self.UpgradeGroups, self.UpgradeInstances, self.UpgradeTopLevelDisks, self.UpgradeNodeIndices, self.UpgradeInstanceIndices, self.UpgradeFilters, self.UpgradeDiskNodes, self.UpgradeDiskTemplate ] for s in steps: s() return not self.errors
def testRapiUsersExistingTarget(self): self.assertFalse(os.path.exists(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) os.mkdir(os.path.dirname(self.rapi_users_path)) utils.WriteFile(self.rapi_users_path, data="other user\n") utils.WriteFile(self.rapi_users_path_pre24, data="hello world\n") self.assertRaises(Exception, self._TestSimpleUpgrade, version.BuildVersion(2, 2, 0), False) for path in [self.rapi_users_path, self.rapi_users_path_pre24]: self.assert_(os.path.isfile(path) and not os.path.islink(path)) self.assertEqual(utils.ReadFile(self.rapi_users_path), "other user\n") self.assertEqual(utils.ReadFile(self.rapi_users_path_pre24), "hello world\n")
def testRapiUsersExistingSymlinkDryRun(self): self.assertFalse(os.path.exists(self.rapi_users_path)) self.assertFalse(os.path.exists(self.rapi_users_path_pre24)) os.mkdir(os.path.dirname(self.rapi_users_path)) os.symlink(self.rapi_users_path, self.rapi_users_path_pre24) utils.WriteFile(self.rapi_users_path, data="hello world\n") self._TestSimpleUpgrade(version.BuildVersion(2, 2, 0), True) self.assertTrue(os.path.islink(self.rapi_users_path_pre24)) self.assertTrue(os.path.isfile(self.rapi_users_path) and not os.path.islink(self.rapi_users_path)) self.assertEqual(os.readlink(self.rapi_users_path_pre24), self.rapi_users_path) for path in [self.rapi_users_path, self.rapi_users_path_pre24]: self.assertEqual(utils.ReadFile(path), "hello world\n")
def testUpgradeDryRunFrom_2_6(self): self._TestSimpleUpgrade(version.BuildVersion(2, 6, 0), True)
def testUpgradeFrom_2_7(self): self._TestSimpleUpgrade(version.BuildVersion(2, 7, 0), False)
def DowngradeAll(self): self.config_data["version"] = version.BuildVersion( DOWNGRADE_MAJOR, DOWNGRADE_MINOR, 0) self.DowngradeSshKeyParams() return not self.errors
def DowngradeAll(self): self.DowngradeCluster(self.config_data["cluster"]) self.config_data["version"] = version.BuildVersion( DOWNGRADE_MAJOR, DOWNGRADE_MINOR, 0) return True