Revision fa166f67 test/py/cfgupgrade_unittest.py

b/test/py/cfgupgrade_unittest.py
156 156
      "instances": {},
157 157
      "nodegroups": {},
158 158
      }
159
    self._TestUpgradeFromData(cfg, dry_run)
160

  
161
  def _TestUpgradeFromData(self, cfg, dry_run):
162
    assert "version" in cfg
163
    from_version = cfg["version"]
159 164
    self._CreateValidConfigDir()
160 165
    utils.WriteFile(self.config_path, data=serializer.DumpJson(cfg))
161 166

  
......
350 355
  def testUpgradeCurrent(self):
351 356
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
352 357

  
353
  def testDowngrade(self):
354
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
358
  def _RunDowngradeUpgrade(self):
355 359
    oldconf = self._LoadConfig()
356 360
    _RunUpgrade(self.tmpdir, False, True, downgrade=True)
357 361
    _RunUpgrade(self.tmpdir, False, True)
358 362
    newconf = self._LoadConfig()
359 363
    self.assertEqual(oldconf, newconf)
360 364

  
361
  def testDowngradeTwice(self):
365
  def testDowngrade(self):
362 366
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
367
    self._RunDowngradeUpgrade()
368

  
369
  def _RunDowngradeTwice(self):
370
    """Make sure that downgrade is idempotent."""
363 371
    _RunUpgrade(self.tmpdir, False, True, downgrade=True)
364 372
    oldconf = self._LoadConfig()
365 373
    _RunUpgrade(self.tmpdir, False, True, downgrade=True)
366 374
    newconf = self._LoadConfig()
367 375
    self.assertEqual(oldconf, newconf)
368 376

  
377
  def testDowngradeTwice(self):
378
    self._TestSimpleUpgrade(constants.CONFIG_VERSION, False)
379
    self._RunDowngradeTwice()
380

  
369 381
  def testUpgradeDryRunFrom_2_0(self):
370 382
    self._TestSimpleUpgrade(constants.BuildVersion(2, 0, 0), True)
371 383

  

Also available in: Unified diff