Beispiel #1
0
    def test_unique_id_failover(self):
        """test target.uniqueid()"""
        fs1 = FileSystem('uniqueid')
        srv1a = Server('foo1', ['foo1@tcp'])
        srv1b = Server('foo2', ['foo2@tcp'])
        tgt1 = fs1.new_target(srv1a, 'ost', 0, '/dev/null')
        tgt1.add_server(srv1b)

        fs2 = FileSystem('uniqueid')
        srv2a = Server('foo1', ['foo1@tcp'])
        srv2b = Server('foo2', ['foo2@tcp'])
        tgt2 = fs2.new_target(srv2a, 'ost', 0, '/dev/null')
        tgt2.add_server(srv2b)
        tgt2.failover(NodeSet('foo2'))

        self.assertEqual(tgt2.uniqueid(), tgt1.uniqueid())
Beispiel #2
0
 def setUp(self):
     CommonTestCase.setUp(self)
     srv1 = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME],
                   hdlr=self.eh)
     self.fs.local_server = srv1
     self.disk = Utils.make_disk()
     self.tgt = self.fs.new_target(srv1, 'mgt', 0, self.disk.name)
Beispiel #3
0
 def testManaged(self):
     """test ComponentGroup.managed()"""
     fs = FileSystem('comp')
     grp = ComponentGroup()
     comp1 = Component(fs, Server('foo1', ['foo1@tcp']), mode="external")
     grp.add(comp1)
     comp2 = Component(fs, Server('foo2', ['foo2@tcp']))
     grp.add(comp2)
     comp3 = Component(fs, Server('foo3', ['foo3@tcp']), enabled=False)
     grp.add(comp3)
     comp4 = Component(fs, Server('foo4', ['foo4@tcp']))
     grp.add(comp4)
     offgrp = grp.managed()
     self.assertEqual(len(offgrp), 2)
     self.assertTrue(comp2 in offgrp)
     self.assertTrue(comp4 in offgrp)
Beispiel #4
0
    def testGenericComponent(self):
        """test ComponentGroup simple methods"""
        fs = FileSystem('comp')
        grp = ComponentGroup()
        self.assertEqual(len(grp), 0)
        comp = Component(fs, Server('foo', ['foo@tcp']))
        comp.TYPE = 'A'

        # add()
        grp.add(comp)
        # __len__
        self.assertEqual(len(grp), 1)
        # __str__
        self.assertEqual(str(grp), 'comp-A')
        # __getitem__
        self.assertEqual(grp[comp.uniqueid()], comp)
        # __contains__
        self.assertTrue(comp in grp)
        # __iter__
        self.assertEqual(list(iter(grp)), [comp])
        # Could not add() twice the same component
        try:
            grp.add(comp)
        except KeyError, error:
            txt = "'A component with id comp-A-foo@tcp already exists.'"
            self.assertEqual(str(error), txt)
Beispiel #5
0
 def test_start_client_two_nids(self):
     """test command line start client (mgs two nids)"""
     srv = Server('localhost', ['localhost@tcp','localhost@o2ib'])
     self.fs.new_target(srv, 'mgt', 0, '/dev/root')
     client = self.fs.new_client(self.srv1, "/foo")
     action = StartClient(client)
     self.check_cmd(action, 'mkdir -p "/foo" && ' +
           '/bin/mount -t lustre localhost@tcp,localhost@o2ib:/action /foo')
Beispiel #6
0
 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'])
Beispiel #7
0
    def testIsLocal(self):
        """test is_local()"""
        fqdn = socket.getfqdn()
        shortname = socket.gethostname().split('.', 1)[0]

        # Test shortname is local()
        srv = Server(shortname, ['%s@tcp' % shortname])
        self.assertTrue(srv.is_local())

        # Test fqdn is local()
        srv = Server(fqdn, ['%s@tcp' % fqdn])
        self.assertTrue(srv.is_local())

        # Test a dummy shortname should not be local
        shortname = shortname + "-shine-false-suffix"
        srv = Server(shortname, ['%s@tcp' % shortname])
        self.assertFalse(srv.is_local())

        # Test a false domain name with a good hostname
        othername = shortname + ".shine-false-tld"
        srv = Server(othername, ['%s@tcp' % othername])
        self.assertFalse(srv.is_local())

        # Test something else should not be local
        othername = fqdn + ".shine-false-tld"
        srv = Server(othername, ['%s@tcp' % othername])
        self.assertFalse(srv.is_local())

        # Check hostname methods are rightly seen as local
        self.assertTrue(Server(Server.hostname_short(), ['foo']).is_local())
        self.assertTrue(Server(Server.hostname_long(), ['foo']).is_local())
Beispiel #8
0
 def test_tunefs_target_network_zero3(self):
     """test command line tunefs network with non-zero suffix"""
     self.fs.new_target(self.srv1, 'mgt', 0, '/dev/root')
     ost = self.fs.new_target(self.srv1, 'ost', 0, '/dev/root', network='o2ib1')
     ost.add_server(self.srv2)
     ost.add_server(Server('localhost3', ['localhost3@o2ib1']))
     action = Tunefs(ost)
     self.check_cmd_tunefs(action, '"--mgsnode=localhost@tcp" ' +
                        '"--failnode=localhost3@o2ib1" --network=o2ib1 /dev/root')
Beispiel #9
0
 def test_tunefs_target_network(self):
     """test command line tunefs network"""
     self.fs.new_target(self.srv1, 'mgt', 0, '/dev/root')
     ost = self.fs.new_target(self.srv1, 'ost', 0, '/dev/root', network='tcp')
     ost.add_server(self.srv2)
     ost.add_server(Server('localhost3', ['localhost3@o2ib']))
     action = Tunefs(ost)
     self.check_cmd_tunefs(action, '"--mgsnode=localhost@tcp" ' +
                        '"--failnode=localhost2@tcp" --network=tcp /dev/root')
Beispiel #10
0
    def testSimple(self):
        """test ServerGroup simple tests"""
        grp = ServerGroup()
        self.assertEqual(len(grp), 0)

        srv = Server('foo', ['foo@tcp'])
        grp.append(srv)
        self.assertEqual(len(grp), 1)
        self.assertEqual(grp[0], srv)
Beispiel #11
0
 def test_format_target_network_zero(self):
     """test command line format (network with zero suffix)"""
     self.fs.new_target(self.srv1, 'mgt', 0, '/dev/root')
     tgt = self.fs.new_target(self.srv1, 'ost', 0, '/dev/root', network='o2ib0')
     tgt.add_server(self.srv2)
     tgt.add_server(Server('localhost3', ['localhost3@o2ib']))
     tgt.full_check(mountdata=False)
     action = Format(tgt)
     self.check_cmd_format(action, '--ost --index=0 ' +
       '"--mgsnode=localhost@tcp" "--failnode=localhost3@o2ib" ' +
       '--network=o2ib0 /dev/root')
Beispiel #12
0
 def test_format_target_ost_failnodes_network(self):
     """test command line format (OST with 2 failnodes and network)"""
     self.fs.new_target(self.srv1, 'mgt', 0, '/dev/root')
     tgt = self.fs.new_target(self.srv1, 'ost', 0, '/dev/root', network='tcp')
     tgt.add_server(self.srv2)
     tgt.add_server(Server('localhost3', ['localhost3@o2ib']))
     tgt.full_check(mountdata=False)
     action = Format(tgt)
     self.check_cmd_format(action, '--ost --index=0 ' +
       '"--mgsnode=localhost@tcp" "--failnode=localhost2@tcp" ' +
       '--network=tcp /dev/root')
Beispiel #13
0
 def testFilterSupports(self):
     """test ComponentGroup.filter(supports and key)"""
     fs = FileSystem('comp')
     grp = ComponentGroup()
     comp1 = Component(fs, Server('foo1', ['foo1@tcp']))
     comp1.state = MOUNTED
     grp.add(comp1)
     comp2 = Component(fs, Server('foo2', ['foo2@tcp']))
     comp2.state = OFFLINE
     grp.add(comp2)
     comp3 = Component(fs, Server('foo3', ['foo3@tcp']))
     comp3.state = MOUNTED
     grp.add(comp3)
     comp4 = Component(fs, Server('foo4', ['foo4@tcp']))
     comp4.state = OFFLINE
     grp.add(comp4)
     offgrp = grp.filter(supports='is_external', key=lambda comp: comp.state == OFFLINE)
     self.assertEqual(len(offgrp), 2)
     self.assertTrue(comp2 in offgrp)
     self.assertTrue(comp4 in offgrp)
Beispiel #14
0
 def testGroupBy(self):
     """test ComponentGroup.groupby()"""
     fs = FileSystem('comp')
     grp = ComponentGroup()
     comp1 = Component(fs, Server('foo1', ['foo1@tcp']), mode="external")
     grp.add(comp1)
     comp2 = Component(fs, Server('foo2', ['foo2@tcp']))
     grp.add(comp2)
     comp3 = Component(fs, Server('foo3', ['foo3@tcp']), mode="external")
     grp.add(comp3)
     comp4 = Component(fs, Server('foo4', ['foo4@tcp']))
     grp.add(comp4)
     results = [[mode, list(comps)] for mode, comps in grp.groupby(attr='_mode')]
     self.assertEqual(len(results), 2)
     self.assertEqual(results[0][0], "external")
     self.assertTrue(comp1 in results[0][1])
     self.assertTrue(comp3 in results[0][1])
     self.assertEqual(results[1][0], "managed")
     self.assertTrue(comp2 in results[1][1])
     self.assertTrue(comp4 in results[1][1])
Beispiel #15
0
 def test_format_target_ost_two_failnodes(self):
     """test command line format (OST with 2 failnodes)"""
     self.fs.new_target(self.srv1, 'mgt', 0, self.block1)
     tgt = self.fs.new_target(self.srv1, 'ost', 0, self.block1)
     tgt.add_server(self.srv2)
     tgt.add_server(Server('localhost3', ['localhost3@tcp']))
     tgt.full_check(mountdata=False)
     action = Format(tgt)
     self.check_cmd_format(
         action, '--ost --index=0 ' +
         '"--mgsnode=localhost@tcp" "--failnode=localhost2@tcp" ' +
         '"--failnode=localhost3@tcp" %s' % self.block1)
Beispiel #16
0
 def setUp(self):
     CommonTestCase.setUp(self)
     nid = '%s@tcp' % Utils.HOSTNAME
     srv1 = Server(Utils.HOSTNAME, [nid], hdlr=self.eh)
     self.fs.local_server = srv1
     self.disk1 = Utils.make_disk()
     self.disk2 = Utils.make_disk()
     self.disk3 = Utils.make_disk()
     self.mgs = self.fs.new_target(srv1, 'mgt', 0, self.disk1.name)
     self.mdt = self.fs.new_target(srv1, 'mdt', 0, self.disk2.name)
     self.ost = self.fs.new_target(srv1, 'ost', 0, self.disk3.name)
     self.client = self.fs.new_client(srv1, '/mnt/lustre')
Beispiel #17
0
def _get_server(nodename, fs, fs_conf, handler, nodes=None, excluded=None):
    """Instantiate Server and cache them in _SERVERS"""
    if nodename not in _SERVERS:
        server = Server(nodename, fs_conf.get_nid(nodename), handler)

        if (nodes is not None and server.hostname not in nodes) or \
           (excluded is not None and server.hostname in excluded):
            server.action_enabled = False
        _SERVERS[nodename] = server

    if _SERVERS[nodename].is_local():
        fs.local_server = _SERVERS[nodename]

    return _SERVERS[nodename]
Beispiel #18
0
    def setUp(self):
        self.fs = FileSystem('proxy')
        self.srv1 = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME])
        disk = Utils.makeTempFilename()
        self.tgt = self.fs.new_target(self.srv1, 'mgt', 0, disk)

        self.act = self.fs._proxy_action('start', self.srv1.hostname,
                                         self.fs.components)
        self.info = StartTarget(self.tgt).info()

        def fakeprepare(action):
            return [action.fakecmd]

        self.act._prepare_cmd = types.MethodType(fakeprepare, self.act)
Beispiel #19
0
 def test_group_by_all_servers(self):
     """test ComponentGroup.groupbyallservers()"""
     fs = FileSystem('comp')
     grp = ComponentGroup()
     srv1 = Server('foo1', ['foo1@tcp'])
     srv2 = Server('foo2', ['foo2@tcp'])
     comp1 = Target(fs, srv1, 0, '/dev/sda')
     comp1.add_server(srv2)
     grp.add(comp1)
     comp2 = Target(fs, srv2, 1, '/dev/sdb')
     comp2.add_server(srv1)
     grp.add(comp2)
     comp3 = Target(fs, srv1, 2, '/dev/sdc')
     comp3.add_server(srv2)
     grp.add(comp3)
     comp4 = Target(fs, srv2, 3, '/dev/sdd')
     comp4.add_server(srv1)
     grp.add(comp4)
     key = lambda c: c.TYPE
     results = [[srv, sorted(comps, key=key)] for srv, comps in grp.groupbyallservers()]
     self.assertEqual(len(results), 2)
     self.assertTrue([srv1, [comp1, comp2, comp3, comp4]] in results)
     self.assertTrue([srv2, [comp1, comp2, comp3, comp4]] in results)
Beispiel #20
0
 def testGroupByServer(self):
     """test ComponentGroup.groupbyserver()"""
     fs = FileSystem('comp')
     grp = ComponentGroup()
     srv1 = Server('foo1', ['foo1@tcp'])
     srv2 = Server('foo2', ['foo2@tcp'])
     comp1 = Component(fs, srv1)
     comp1.TYPE = 'A'
     grp.add(comp1)
     comp2 = Component(fs, srv2)
     comp2.TYPE = 'B'
     grp.add(comp2)
     comp3 = Component(fs, srv1)
     comp3.TYPE = 'C'
     grp.add(comp3)
     comp4 = Component(fs, srv2)
     comp4.TYPE = 'D'
     grp.add(comp4)
     key = lambda c: c.TYPE
     results = [[srv, sorted(comps, key=key)] for srv, comps in grp.groupbyserver()]
     self.assertEqual(len(results), 2)
     self.assertTrue([srv1, [comp1, comp3]] in results)
     self.assertTrue([srv2, [comp2, comp4]] in results)
Beispiel #21
0
 def test_tunefs_target_network_zero2(self):
     """test command line tunefs network without zero suffix"""
     self.fs.new_target(self.srv1, 'mgt', 0, self.block1)
     ost = self.fs.new_target(self.srv1,
                              'ost',
                              0,
                              self.block1,
                              network='o2ib')
     ost.add_server(self.srv2)
     ost.add_server(Server('localhost3', ['localhost3@o2ib0']))
     action = Tunefs(ost)
     self.check_cmd_tunefs(
         action, '"--mgsnode=localhost@tcp" ' +
         '"--failnode=localhost3@o2ib0" --network=o2ib %s' % self.block1)
Beispiel #22
0
 def test_managed_active(self):
     """test ComponentGroup.managed() with active option"""
     fs = FileSystem('active')
     grp = ComponentGroup()
     srv = Server('foo1', ['foo1@tcp'])
     comp1 = Component(fs, srv)
     comp1.TYPE = 'A'
     grp.add(comp1)
     comp2 = Component(fs, srv, active='no')
     comp2.TYPE = 'B'
     grp.add(comp2)
     comp3 = Component(fs, srv, active='nocreate')
     comp3.TYPE = 'C'
     grp.add(comp3)
     comp4 = Component(fs, srv, active='no', mode='external')
     comp4.TYPE = 'D'
     grp.add(comp4)
     self.assertEqual(str(grp.managed()), 'active-A,active-C')
     self.assertEqual(str(grp.managed(inactive=True)),
                      'active-A,active-B,active-C,active-D')
Beispiel #23
0
 def testNodeSet(self):
     """test ServerGroup.nodeset()"""
     srv1 = Server('foo1', ['foo1@tcp'])
     srv2 = Server('foo2', ['foo2@tcp'])
     grp = ServerGroup([srv1, srv2])
     self.assertEqual(grp.nodeset(), NodeSet('foo[1-2]'))
Beispiel #24
0
 def testIter(self):
     """test ServerGroup.__iter__()"""
     srv1 = Server('foo1', ['foo1@tcp'])
     srv2 = Server('foo2', ['foo2@tcp'])
     grp = ServerGroup([srv1, srv2])
     self.assertEqual(list(iter(grp)), [srv1, srv2])
Beispiel #25
0
 def test_allservers(self):
     """test client.allservers()"""
     fs = FileSystem('foo')
     srv = Server('foo1', ['foo1@tcp'])
     client = fs.new_client(srv, '/foo')
     self.assertEqual(str(client.allservers().nodeset()), 'foo1')
Beispiel #26
0
 def testStringRepr(self):
     """test string representation"""
     srv = Server('localhost', ['localhost@tcp'])
     self.assertEqual(str(srv), 'localhost (localhost@tcp)')
Beispiel #27
0
 def setUp(self):
     CommonTestCase.setUp(self)
     nid = '%s@tcp' % Utils.HOSTNAME
     self.localname = Server(Utils.HOSTNAME, [nid], hdlr=self.eh).hostname
     self.badnames = Server('bad[1-15]', ['bad[1-15]@tcp'],
                            hdlr=self.eh).hostname
Beispiel #28
0
 def setUp(self):
     self.fs = FileSystem('action')
     self.srv1 = Server("localhost", ["localhost@tcp"])
     self.srv2 = Server("localhost2", ["localhost2@tcp"])
Beispiel #29
0
 def setUp(self):
     CommonTestCase.setUp(self)
     self.srv = Server(Utils.HOSTNAME, ["%s@lo" % Utils.HOSTNAME],
                       hdlr=self.eh)
     self._clean_modules()
Beispiel #30
0
 def setUp(self):
     CommonTestCase.setUp(self)
     self.srv1 = Server(Utils.HOSTNAME, ["%s@tcp" % Utils.HOSTNAME])
     self.router = self.fs.new_router(self.srv1)
     self.srv1.unload_modules().launch()
     self.fs._run_actions()