def setUp(self): super(StorageHandleSanityCheck, self).setUp() options = main.Options() options.force = True options.verbose = True options.yes = True options.config = "my_config" options.interactive = True options.debug = True self.storage.set_globals(options) self.dev = self.storage.dev self.vol = self.storage.vol self.pool = self.storage.pool
def setUp(self): super(MultipathFunctionCheck, self).setUp() self._options = main.Options() self._addPool('mapper', []) # some standard, non-mp devices self._addDevice('/dev/sdc', 2684354560) self._addDevice('/dev/sdc1', 2042177280, 1) self._addDevice('/dev/sdc2', 29826161, 2) self._addDevice('/dev/sdc3', 1042177280, 3) # two mp volumes self.createMP("dm-90", "mpatha", 11489037516, ["sda", "sdb"]) self.createMP("dm-91", "mpathb", 11489037, ["sdd", "sde", "sdf"])
def test_create_fs(self): options = main.Options() for fs in main.EXTN: options.force = True options.verbose = True options.yes = False options.config = "my_new_config" options.interactive = False self.storage.set_globals(options) self.storage._create_fs(fs, "/dev/foo/bar") self.assertEqual('mkfs.{0} -v -F /dev/foo/bar'.format(fs), self.run_data[-1]) options.force = False options.verbose = False self.storage.set_globals(options) self.storage._create_fs(fs, "/dev/foo/bar") self.assertEqual('mkfs.{0} /dev/foo/bar'.format(fs), self.run_data[-1]) options.force = True self.storage.set_globals(options) self.storage._create_fs(fs, "/dev/foo/bar") self.assertEqual('mkfs.{0} -F /dev/foo/bar'.format(fs), self.run_data[-1]) options.force = False options.verbose = True self.storage.set_globals(options) self.storage._create_fs(fs, "/dev/foo/bar") self.assertEqual('mkfs.{0} -v /dev/foo/bar'.format(fs), self.run_data[-1]) options.force = True options.verbose = True self.storage.set_globals(options) self.storage._create_fs("xfs", "/dev/foo/bar") self.assertEqual('mkfs.xfs -f /dev/foo/bar', self.run_data[-1]) options.force = False options.verbose = False self.storage.set_globals(options) self.storage._create_fs("xfs", "/dev/foo/bar") self.assertEqual('mkfs.xfs /dev/foo/bar', self.run_data[-1]) options.force = True self.storage.set_globals(options) self.storage._create_fs("xfs", "/dev/foo/bar") self.assertEqual('mkfs.xfs -f /dev/foo/bar', self.run_data[-1]) options.force = False options.verbose = True self.storage.set_globals(options) self.storage._create_fs("xfs", "/dev/foo/bar") self.assertEqual('mkfs.xfs /dev/foo/bar', self.run_data[-1])
def test_set_globals_propagation(self): options = main.Options() options.force = False options.verbose = False options.yes = False options.config = "my_config" options.interactive = False options.debug = False self.storage.set_globals(options) # Check initial variables self.assertFalse(self.storage.options.force) self.assertFalse(self.storage.options.verbose) self.assertFalse(self.storage.options.yes) self.assertEqual(self.storage.options.config, "my_config") self.assertFalse(self.storage.options.interactive) self.assertFalse(self.storage.options.debug) # Check initial variables for source in self.dev, self.vol, self.pool: self.assertFalse(source.options.force) self.assertFalse(source.options.verbose) self.assertFalse(source.options.yes) self.assertFalse(source.options.interactive) self.assertFalse(source.options.debug) self.assertEqual(source.options.config, "my_config") self.assert_(isinstance(source._data, dict)) self.assert_(len(source._data) > 0) self.assert_(isinstance(source.header, list)) self.assert_(len(source.header) > 0) self.assert_(isinstance(source.attrs, list)) self.assert_(len(source.attrs) > 0) self.assert_(isinstance(source.types, list)) self.assert_(len(source.types) > 0) for item in source._data.values(): self.assertFalse(item.options.force) self.assertFalse(item.options.verbose) self.assertFalse(item.options.yes) self.assertFalse(item.options.interactive) self.assertFalse(item.options.debug) self.assertEqual(item.options.config, "my_config")