Esempio n. 1
0
    def test_start_failover(self):
        """start on a failover node"""
        srv2 = Server('fakenode', ['127.0.0.2@tcp'])

        mgt = self.fs.new_target(self.srv1, 'mgt', 0, self.disk1.name)
        mdt = self.fs.new_target(self.srv1, 'mdt', 0, self.disk2.name)
        mdt.add_server(srv2)
        self.assertEqual(self.fs.format(), set([OFFLINE]))

        # For a simpler test environment, simulate local node is the failover
        # node.
        # This could be improved when --servicenode will be supported. Format
        # will be possible directly in failover configuration (no need to
        # reconfig anymore).
        mdt.state = None
        mdt.defaultserver = srv2
        mdt.failservers = ServerGroup()
        mdt.add_server(self.srv1)

        # Fail over this local node (-F HOSTNAME -n HOSTNAME)
        mdt.failover(self.srv1.hostname)
        srv2.action_enabled = False

        # Start should succeed and detect migration
        self.assertEqual(self.fs.start(), set([MIGRATED]))
        self.assertEqual(mgt.state, MOUNTED)
        self.assertEqual(mdt.state, MIGRATED)
Esempio n. 2
0
    def test_start_failover(self):
        """start on a failover node"""
        srv2 = Server('fakenode', ['127.0.0.2@tcp'])

        mgt = self.fs.new_target(self.srv1, 'mgt', 0, self.disk1.name)
        mdt = self.fs.new_target(self.srv1, 'mdt', 0, self.disk2.name)
        mdt.add_server(srv2)
        self.assertEqual(self.fs.format(), OFFLINE)

        # For a simpler test environment, simulate local node is the failover
        # node.
        # This could be improved when --servicenode will be supported. Format
        # will be possible directly in failover configuration (no need to
        # reconfig anymore).
        mdt.state = None
        mdt.defaultserver = srv2
        mdt.failservers = ServerGroup()
        mdt.add_server(self.srv1)

        # Fail over this local node (-F HOSTNAME -n HOSTNAME)
        mdt.failover(self.srv1.hostname)
        srv2.action_enabled = False

        # Start should succeed and detect migration
        self.assertEqual(self.fs.start(), MIGRATED)
        self.assertEqual(mgt.state, MOUNTED)
        self.assertEqual(mdt.state, MIGRATED)
Esempio n. 3
0
 def setUp(self):
     self._fs = FileSystem('complex')
     # Router (foo0)
     self._fs.new_router(Server('foo0', ['foo0@tcp']))
     # MGS (foo1)
     self._fs.new_target(Server('foo1', ['foo1@tcp']), 'mgt', 0, '/dev/mgt')
     # OSTs (foo3)
     srv3 = Server('foo3', ['foo3@tcp'])
     self._fs.new_target(srv3, 'ost', 0, '/dev/ost0')
     self._fs.new_target(srv3, 'ost', 1, '/dev/ost1')
     # MDT (foo2)
     self._fs.new_target(Server('foo2', ['foo2@tcp']), 'mdt', 0, '/dev/mdt')
Esempio n. 4
0
    def test_target_fields(self):
        """fill with target fields"""
        tgt = self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0,
                                  '/dev/foo', '/dev/jfoo', tag='footag',
                                  network="tcp")
        tgt.add_server(Server('foo2', ['foo2@tcp']))
        tgt.journal.dev_size = 123

        fmt = "%device %2flags %hanodes %1index %jdev %3jsize"
        self._fmt_str(fmt, '/dev/foo    foo2 0 /dev/jfoo 123')

        fmt = "%3network %tag %servers"
        self._fmt_str(fmt, 'tcp footag foo,foo2')
Esempio n. 5
0
    def setUp(self):
        self.srv1 = Server(Utils.HOSTNAME, ['%s@tcp' % Utils.HOSTNAME])

        self.disk1 = Utils.make_disk()
        self.disk2 = Utils.make_disk()

        self.fs = FileSystem('testfs')
        self.fs.local_server = self.srv1
Esempio n. 6
0
 def test_install_unreachable(self):
     """install on unreachable nodes raises an error"""
     fs = FileSystem('testfs')
     badsrv1 = Server('badnode1', ['127.0.0.2@tcp'])
     badsrv2 = Server('badnode2', ['127.0.0.3@tcp'])
     fs.new_target(badsrv1, 'mgt', 0, '/dev/fakedev')
     fs.new_client(badsrv2, '/testfs')
     try:
         fs.install(fs_config_file=Utils.makeTempFilename())
     except FSRemoteError, ex:
         self.assertEqual(str(ex.nodes), 'badnode[1-2]')
         self.assertEqual(ex.rc, 1)
         # Partial comparison to support RHEL5 OpenSSH output
         self.assertTrue(str(ex).startswith("badnode[1-2]: Copy failed: "))
         self.assertTrue(
             str(ex).endswith("badnode[1-2]: Name or service not"
                              " known\nlost connection [rc=1]"))
Esempio n. 7
0
 def test_install_nothing(self):
     """install only using local node does nothing"""
     class MyFS(FileSystem):
         def _run_actions(obj):
             self.fail("should not be called")
     fs = MyFS('testfs')
     srv = Server(Utils.HOSTNAME, ['%s@tcp' % Utils.HOSTNAME])
     fs.local_server = srv
     fs.new_target(srv, 'mgt', 0, '/dev/fakedev')
     fs.install(fs_config_file=Utils.makeTempFilename())
Esempio n. 8
0
 def test_size_field(self):
     """fill with different dev size"""
     tgt = self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0,
                               '/dev/foo')
     tgt.dev_size = 123
     self._fmt_str('%size', '123')
     # KB
     tgt.dev_size = 123456
     self._fmt_str('%size', '120.6KB')
     # MB
     tgt.dev_size = 123456789
     self._fmt_str('%size', '117.7MB')
     # GB
     tgt.dev_size = 12345678901
     self._fmt_str('%size', '11.5GB')
     # TB
     tgt.dev_size = 1024**4
     self._fmt_str('%size', '1.0TB')
Esempio n. 9
0
 def test_simple_fs(self):
     """fill with a MGT only filesystem"""
     self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0, '/dev/foo')
     self._fmt_str("%fsname %node", 'foofs foo')
Esempio n. 10
0
 def setUp(self):
     self.fs = FileSystem('prepare')
     self.remotesrv = Server('remote', ['remote@tcp'])
     self.localsrv = Server(Utils.HOSTNAME, ['%s@tcp' % Utils.HOSTNAME])
     self.fs.local_server = self.localsrv
Esempio n. 11
0
 def test_client_fields(self):
     """fill with client fields"""
     self._fs.new_client(Server('foo', ['foo@tcp']), '/mnt/foo', 'ro')
     self._fmt_str("%mntpath %mntopts", '/mnt/foo ro')
Esempio n. 12
0
 def test_journal_fields(self):
     """fill using journal fields with no journal"""
     self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0, '/dev/foo')
     self._fmt_str("%jdev %jsize", '')
Esempio n. 13
0
 def test_status_evicted(self):
     """fill with status/statusonly field with different values"""
     client = self._fs.new_client(Server('foo', ['foo@tcp']), '/foo')
     client.proc_states['evicted'] = 1
     client.state = MOUNTED
     self._fmt_str("%status | %statusonly", "mounted (evicted=1) | mounted")
Esempio n. 14
0
 def test_common_fields(self):
     """fill with component common fields"""
     self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0, '/dev/foo')
     self._fmt_str(
         "%fsname %label %node %status %statusonly %type %servers",
         'foofs MGS foo unknown unknown MGT foo')
Esempio n. 15
0
 def test_simple_fs_group_fields(self):
     """fill with a MGT only filesystem with group fields"""
     self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0, '/dev/foo')
     self._fmt_str("%fsname %node %count %labels %nodes",
                   'foofs foo 1 MGS foo')
Esempio n. 16
0
 def test_bad_field(self):
     """fill with bad field name"""
     self._fs.new_target(Server('foo', ['foo@tcp']), 'mgt', 0, '/dev/foo')
     tbl = TextTable('%badname')
     self.assertRaises(DisplayError, table_fill, tbl, self._fs)
Esempio n. 17
0
 def test_missing_field(self):
     """fill with an irrelevant field"""
     self._fs.new_router(Server('foo', ['foo@tcp']))
     self._fmt_str('%index', '-')