Esempio n. 1
0
    def setUp(self):
        super(TestCoraidDriver, self).setUp()
        self.esm_mock = self.mox.CreateMockAnything()
        self.stubs.Set(coraid, 'CoraidRESTClient',
                       lambda *_, **__: self.esm_mock)
        configuration = mox.MockObject(conf.Configuration)
        configuration.append_config_values(mox.IgnoreArg())
        configuration.coraid_esm_address = fake_esm_ipaddress
        configuration.coraid_user = fake_esm_username
        configuration.coraid_group = fake_esm_group
        configuration.coraid_password = fake_esm_password

        self.drv = CoraidDriver(configuration=configuration)
        self.drv.do_setup({})
    def setUp(self):
        super(TestCoraidDriver, self).setUp()
        self.esm_mock = self.mox.CreateMockAnything()
        self.stubs.Set(coraid, "CoraidRESTClient", lambda *_, **__: self.esm_mock)
        configuration = mox.MockObject(conf.Configuration)
        configuration.append_config_values(mox.IgnoreArg())
        configuration.coraid_esm_address = fake_esm_ipaddress
        configuration.coraid_user = fake_esm_username
        configuration.coraid_group = fake_esm_group
        configuration.coraid_password = fake_esm_password

        self.drv = CoraidDriver(configuration=configuration)
        self.drv.do_setup({})
class TestCoraidDriver(test.TestCase):
    def setUp(self):
        super(TestCoraidDriver, self).setUp()
        self.esm_mock = self.mox.CreateMockAnything()
        self.stubs.Set(coraid, "CoraidRESTClient", lambda *_, **__: self.esm_mock)
        configuration = mox.MockObject(conf.Configuration)
        configuration.append_config_values(mox.IgnoreArg())
        configuration.coraid_esm_address = fake_esm_ipaddress
        configuration.coraid_user = fake_esm_username
        configuration.coraid_group = fake_esm_group
        configuration.coraid_password = fake_esm_password

        self.drv = CoraidDriver(configuration=configuration)
        self.drv.do_setup({})

    def test_create_volume(self):
        setattr(self.esm_mock, "create_lun", lambda *_: True)
        self.stubs.Set(CoraidDriver, "_get_repository", lambda *_: fake_repository_name)
        self.drv.create_volume(fake_volume)

    def test_delete_volume(self):
        setattr(self.esm_mock, "delete_lun", lambda *_: True)
        self.drv.delete_volume(fake_volume)

    def test_initialize_connection(self):
        setattr(self.esm_mock, "_get_lun_address", lambda *_: fake_lun_addr)
        self.drv.initialize_connection(fake_volume, "")

    def test_create_snapshot(self):
        setattr(self.esm_mock, "create_snapshot", lambda *_: True)
        self.drv.create_snapshot(fake_snapshot)

    def test_delete_snapshot(self):
        setattr(self.esm_mock, "delete_snapshot", lambda *_: True)
        self.drv.delete_snapshot(fake_snapshot)

    def test_create_volume_from_snapshot(self):
        setattr(self.esm_mock, "create_volume_from_snapshot", lambda *_: True)
        self.stubs.Set(CoraidDriver, "_get_repository", lambda *_: fake_repository_name)
        self.drv.create_volume_from_snapshot(fake_volume, fake_snapshot)
Esempio n. 4
0
class TestCoraidDriver(test.TestCase):
    def setUp(self):
        super(TestCoraidDriver, self).setUp()
        self.esm_mock = self.mox.CreateMockAnything()
        self.stubs.Set(coraid, 'CoraidRESTClient',
                       lambda *_, **__: self.esm_mock)
        configuration = mox.MockObject(conf.Configuration)
        configuration.append_config_values(mox.IgnoreArg())
        configuration.coraid_esm_address = fake_esm_ipaddress
        configuration.coraid_user = fake_esm_username
        configuration.coraid_group = fake_esm_group
        configuration.coraid_password = fake_esm_password
        configuration.volume_name_template = "volume-%s"
        configuration.snapshot_name_template = "snapshot-%s"

        self.drv = CoraidDriver(configuration=configuration)
        self.drv.do_setup({})

    def test_create_volume(self):
        setattr(self.esm_mock, 'create_lun', lambda *_: True)
        self.stubs.Set(CoraidDriver, '_get_repository',
                       lambda *_: fake_repository_name)
        self.drv.create_volume(fake_volume)

    def test_delete_volume(self):
        setattr(self.esm_mock, 'delete_lun',
                lambda *_: True)
        self.drv.delete_volume(fake_volume)

    def test_initialize_connection(self):
        setattr(self.esm_mock, '_get_lun_address',
                lambda *_: fake_lun_addr)
        self.drv.initialize_connection(fake_volume, '')

    def test_create_snapshot(self):
        setattr(self.esm_mock, 'create_snapshot',
                lambda *_: True)
        self.drv.create_snapshot(fake_snapshot)

    def test_delete_snapshot(self):
        setattr(self.esm_mock, 'delete_snapshot',
                lambda *_: True)
        self.drv.delete_snapshot(fake_snapshot)

    def test_create_volume_from_snapshot(self):
        self.esm_mock.create_volume_from_snapshot(
            fake_volume,
            fake_snapshot).AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.create_volume_from_snapshot(fake_volume, fake_snapshot)
        mox.Verify(self.esm_mock)

    def test_create_volume_from_snapshot_bigger(self):
        self.esm_mock.create_volume_from_snapshot(
            fake_volume,
            fake_snapshot).AndReturn(True)
        self.esm_mock.resize_volume(fake_volume_name,
                                    '20').AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.create_volume_from_snapshot(fake_volume, fake_snapshot)
        self.esm_mock.resize_volume(fake_volume_name, '20')
        mox.Verify(self.esm_mock)

    def test_extend_volume(self):
        self.esm_mock.resize_volume(fake_volume_name,
                                    '20').AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.resize_volume(fake_volume_name, '20')
        mox.Verify(self.esm_mock)
Esempio n. 5
0
class TestCoraidDriver(test.TestCase):
    def setUp(self):
        super(TestCoraidDriver, self).setUp()
        self.esm_mock = self.mox.CreateMockAnything()
        self.stubs.Set(coraid, 'CoraidRESTClient',
                       lambda *_, **__: self.esm_mock)
        configuration = mox.MockObject(conf.Configuration)
        configuration.append_config_values(mox.IgnoreArg())
        configuration.coraid_esm_address = fake_esm_ipaddress
        configuration.coraid_user = fake_esm_username
        configuration.coraid_group = fake_esm_group
        configuration.coraid_password = fake_esm_password
        configuration.volume_name_template = "volume-%s"
        configuration.snapshot_name_template = "snapshot-%s"

        self.drv = CoraidDriver(configuration=configuration)
        self.drv.do_setup({})

    def test_create_volume(self):
        setattr(self.esm_mock, 'create_lun', lambda *_: True)
        self.stubs.Set(CoraidDriver, '_get_repository',
                       lambda *_: fake_repository_name)
        self.drv.create_volume(fake_volume)

    def test_delete_volume(self):
        setattr(self.esm_mock, 'delete_lun', lambda *_: True)
        self.drv.delete_volume(fake_volume)

    def test_initialize_connection(self):
        setattr(self.esm_mock, '_get_lun_address', lambda *_: fake_lun_addr)
        self.drv.initialize_connection(fake_volume, '')

    def test_create_snapshot(self):
        setattr(self.esm_mock, 'create_snapshot', lambda *_: True)
        self.drv.create_snapshot(fake_snapshot)

    def test_delete_snapshot(self):
        setattr(self.esm_mock, 'delete_snapshot', lambda *_: True)
        self.drv.delete_snapshot(fake_snapshot)

    def test_create_volume_from_snapshot(self):
        self.esm_mock.create_volume_from_snapshot(
            fake_volume, fake_snapshot).AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.create_volume_from_snapshot(fake_volume, fake_snapshot)
        mox.Verify(self.esm_mock)

    def test_create_volume_from_snapshot_bigger(self):
        self.esm_mock.create_volume_from_snapshot(
            fake_volume, fake_snapshot).AndReturn(True)
        self.esm_mock.resize_volume(fake_volume_name, '20').AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.create_volume_from_snapshot(fake_volume, fake_snapshot)
        self.esm_mock.resize_volume(fake_volume_name, '20')
        mox.Verify(self.esm_mock)

    def test_extend_volume(self):
        self.esm_mock.resize_volume(fake_volume_name, '20').AndReturn(True)
        mox.Replay(self.esm_mock)
        self.esm_mock.resize_volume(fake_volume_name, '20')
        mox.Verify(self.esm_mock)