def setUp(self): CommonTestCase.setUp(self) self.srv = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME], hdlr=self.eh) self.disk = Utils.make_disk() self.tgt = self.fs.new_target(self.srv, 'mgt', 0, self.disk.name) self.model = TuningModel() self.model.create_parameter('/dev/null', 1, node_type_list=['mgs'])
def makeTempTuningModel(self, text): """ Create a temporary file instance and returns a TuningModel with it. """ self.f = makeTempFile(text) model = TuningModel(filename=self.f.name) return model
class TuneActionTest(CommonTestCase): def setUp(self): CommonTestCase.setUp(self) self.srv = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME], hdlr=self.eh) self.disk = Utils.make_disk() self.tgt = self.fs.new_target(self.srv, 'mgt', 0, self.disk.name) self.model = TuningModel() self.model.create_parameter('/dev/null', 1, node_type_list=['mgs']) def test_tune_ok(self): """Apply simple tuning is ok""" # Create a working tuning self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 1) act = self.srv.tune(self.model, self.fs.components, 'action') result = self.check_base(self.srv, 'server', act, ACT_OK, ['start', 'done'], 'apply tunings') def test_tuning_depends_on_failed_action(self): """Apply tuning depeding on a failed action does not crash""" # Create a working tuning self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 1) act1 = self.tgt.execute(addopts='/bin/false') act2 = self.srv.tune(self.model, self.fs.components, 'action') act2.depends_on(act1) result = self.check_base(self.tgt, 'comp', act1, ACT_ERROR, ['start', 'failed'], 'execute of MGS (%s)' % self.tgt.dev) def test_tune_dryrun(self): """Apply tuning in dry-run mode""" act = self.srv.tune(self.model, self.fs.components, 'action', dryrun=True) text = 'echo -n 1 > /dev/null' self.check_dryrun(act, text, 'server', 'tune', ['start', 'done'], self.srv, 'apply tunings') def test_tune_error(self): """Apply a bad tuning is correctly reported""" # Add bad tuning self.model.create_parameter('/proc/modules', 1, node_type_list=['mgs']) self.model.create_parameter('/proc/cmdline', 1, node_type_list=['mgs']) self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 3) act = self.srv.tune(self.model, self.fs.components, 'action') result = self.check_base(self.srv, 'server', act, ACT_ERROR, ['start', 'failed'], 'apply tunings') self.assertEqual(result.retcode, None) self.assertEqual(str(result), "'echo -n 1 > /proc/modules' failed\n" "'echo -n 1 > /proc/cmdline' failed")
def get_tuning(cls, fs_conf): """ Tune class method: get TuningModel for a fs configuration. """ # XXX: If no tuning.conf is defined in configuration # we still create a tuning model which will be used for quota. # Be carefull that this could be very confusing for users, who # can think tuning will be applied but is not. tuning = TuningModel() # Is the tuning configuration file name specified? if Globals().get_tuning_file(): # Load the tuning configuration file tuning.parse(filename=Globals().get_tuning_file()) # Add the quota tuning parameters to the tuning model. if Globals().lustre_version_is_smaller('2.4'): cls._add_quota_tuning(tuning, fs_conf) return tuning
class TuneActionTest(CommonTestCase): def setUp(self): CommonTestCase.setUp(self) self.srv = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME], hdlr=self.eh) self.disk = Utils.make_disk() self.tgt = self.fs.new_target(self.srv, 'mgt', 0, self.disk.name) self.model = TuningModel() self.model.create_parameter('/dev/null', 1, node_type_list=['mgs']) def test_tune_ok(self): """Apply simple tuning is ok""" # Create a working tuning self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 1) act = self.srv.tune(self.model, self.fs.components, 'action') result = self.check_base(self.srv, 'server', act, ACT_OK, ['start', 'done'], 'apply tunings') def test_tuning_depends_on_failed_action(self): """Apply tuning depeding on a failed action does not crash""" # Create a working tuning self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 1) act1 = self.tgt.execute(addopts='/bin/false') act2 = self.srv.tune(self.model, self.fs.components, 'action') act2.depends_on(act1) result = self.check_base(self.tgt, 'comp', act1, ACT_ERROR, ['start', 'failed'], 'execute of MGS (%s)' % self.tgt.dev) def test_tune_dryrun(self): """Apply tuning in dry-run mode""" act = self.srv.tune(self.model, self.fs.components, 'action', dryrun=True) text = 'echo -n 1 > /dev/null' self.check_dryrun(act, text, 'server', 'tune', ['start', 'done'], self.srv, 'apply tunings') def test_tune_error(self): """Apply a bad tuning is correctly reported""" # Add bad tuning self.model.create_parameter('/proc/modules', 1, node_type_list=['mgs']) self.model.create_parameter('/proc/cmdline', 1, node_type_list=['mgs']) self.assertEqual(len(self.model.get_params_for_name(None, ['mgs'])), 3) act = self.srv.tune(self.model, self.fs.components, 'action') result = self.check_base(self.srv, 'server', act, ACT_ERROR, ['start', 'failed'], 'apply tunings') self.assertEqual(result.retcode, None) self.assertEqual( str(result), "'echo -n 1 > /proc/modules' failed\n" "'echo -n 1 > /proc/cmdline' failed")
def get_tuning(cls, fs_conf, comps): """ Tune class method: get TuningModel for a fs configuration. """ # XXX: If no tuning.conf is defined in configuration # we still create a tuning model which will be used for quota. # Be carefull that this could be very confusing for users, who # can think tuning will be applied but is not. tuning = TuningModel() # Is the tuning configuration file name specified? if Globals().get_tuning_file(): # Load the tuning configuration file tuning.parse(filename=Globals().get_tuning_file()) # Add the quota tuning parameters to the tuning model. if Globals().lustre_version_is_smaller('2.4'): cls._add_quota_tuning(tuning, fs_conf) cls._add_active_tuning(tuning, comps) return tuning
def __init__(self, filename): self.backend = None self.xmf_path = None self.model = Model() try: self.model.load(filename) except IOError: raise ModelFileIOError("Could not read %s" % filename) # Set nodes to nids mapping using the NidMap helper class self.nid_map = NidMap.fromlist(self.get('nid_map')) # Initialize the tuning model to None if no special tuning configuration # is provided self.tuning_model = TuningModel()
def __init__(self, filename): self.backend = None self.xmf_path = None self.model = Model() try: self.model.load(filename) except IOError: raise ModelFileIOError("Could not read %s" % filename) # Model expands nid_map automatically, just iterate other them self.nid_map = {} for elem in self.get('nid_map'): self.nid_map.setdefault(elem['nodes'], []).append(elem['nids']) # Initialize the tuning model to None if no special tuning configuration # is provided self.tuning_model = TuningModel()
def testExampleFile(self): """test example tuning""" m = TuningModel(filename="../conf/tuning.conf.example") m.parse()