示例#1
0
    def test_delete(self):
        """
        Test the delete of a vDisk
            - Create 2 vDisks with identical names on 2 different vPools
            - Delete 1st vDisk and verify other still remains on correct vPool
            - Delete 2nd vDisk and verify no more volumes left
        """
        structure = Helper.build_service_structure(
            {'vpools': [1, 2],
             'domains': [1],
             'storagerouters': [1],
             'storagedrivers': [(1, 1, 1), (2, 2, 1)],  # (<id>, <vpool_id>, <storagerouter_id>)
             'mds_services': [(1, 1), (2, 2)]}  # (<id>, <storagedriver_id>)
        )
        domains = structure['domains']
        storagedrivers = structure['storagedrivers']

        vdisk1 = VDisk(VDiskController.create_new(volume_name='vdisk_1', volume_size=1024 ** 3, storagedriver_guid=storagedrivers[1].guid))
        vdisk2 = VDisk(VDiskController.create_new(volume_name='vdisk_1', volume_size=1024 ** 3, storagedriver_guid=storagedrivers[2].guid))

        vdisk_domain = VDiskDomain()
        vdisk_domain.domain = domains[1]
        vdisk_domain.vdisk = vdisk1
        vdisk_domain.save()

        # Delete vDisk1 and make some assertions
        VDiskController.delete(vdisk_guid=vdisk1.guid)
        with self.assertRaises(ObjectNotFoundException):
            VDisk(vdisk1.guid)
        self.assertEqual(first=len(VDiskController.list_volumes()),
                         second=1,
                         msg='Expected to find only 1 volume in Storage Driver list_volumes')
        self.assertIn(member=vdisk2,
                      container=VDiskList.get_vdisks(),
                      msg='vDisk2 should still be modeled')

        # Delete vDisk2 and make some assertions
        VDiskController.delete(vdisk_guid=vdisk2.guid)
        with self.assertRaises(ObjectNotFoundException):
            VDisk(vdisk2.guid)
        self.assertEqual(first=len(VDiskController.list_volumes()),
                         second=0,
                         msg='Expected to find no more volumes in Storage Driver list_volumes')
示例#2
0
    def test_delete(self):
        """
        Test the delete of a vDisk
            - Create 2 vDisks with identical names on 2 different vPools
            - Delete 1st vDisk and verify other still remains on correct vPool
            - Delete 2nd vDisk and verify no more volumes left
        """
        structure = DalHelper.build_dal_structure({
            'vpools': [1, 2],
            'domains': [1],
            'storagerouters': [1],
            'storagedrivers':
            [(1, 1, 1), (2, 2, 1)],  # (<id>, <vpool_id>, <storagerouter_id>)
            'mds_services': [(1, 1), (2, 2)]
        }  # (<id>, <storagedriver_id>)
                                                  )
        domains = structure['domains']
        storagedrivers = structure['storagedrivers']

        vdisk1 = VDisk(
            VDiskController.create_new(
                volume_name='vdisk_1',
                volume_size=1024**3,
                storagedriver_guid=storagedrivers[1].guid))
        vdisk2 = VDisk(
            VDiskController.create_new(
                volume_name='vdisk_1',
                volume_size=1024**3,
                storagedriver_guid=storagedrivers[2].guid))

        vdisk_domain = VDiskDomain()
        vdisk_domain.domain = domains[1]
        vdisk_domain.vdisk = vdisk1
        vdisk_domain.save()

        # Delete vDisk1 and make some assertions
        VDiskController.delete(vdisk_guid=vdisk1.guid)
        with self.assertRaises(ObjectNotFoundException):
            VDisk(vdisk1.guid)
        self.assertEqual(
            first=len(VDiskController.list_volumes()),
            second=1,
            msg='Expected to find only 1 volume in Storage Driver list_volumes'
        )
        self.assertIn(member=vdisk2,
                      container=VDiskList.get_vdisks(),
                      msg='vDisk2 should still be modeled')

        # Delete vDisk2 and make some assertions
        VDiskController.delete(vdisk_guid=vdisk2.guid)
        with self.assertRaises(ObjectNotFoundException):
            VDisk(vdisk2.guid)
        self.assertEqual(
            first=len(VDiskController.list_volumes()),
            second=0,
            msg=
            'Expected to find no more volumes in Storage Driver list_volumes')
示例#3
0
    def test_manually_overruled_dtl(self):
        """
        The DTL target of a vDisk can be manually overruled by the customer
        """
        # || StorageRouter || vDisk | Regular Domain || Recovery Domain || DTL Target ||
        #  |      sr 1      |   1   |                 |      domain 1    |             |
        #  |      sr 2      |       |      domain 1   |                  |             |
        #  |      sr 3      |       |      domain 1   |                  |             |
        #  |      sr 4      |       |      domain 2   |                  |             |
        #  |      sr 5      |       |                 |                  |             |
        structure = DalHelper.build_dal_structure(
            {'vpools': [1],
             'vdisks': [(1, 1, 1, 1)],  # (<id>, <storagedriver_id>, <vpool_id>, <mds_service_id>)
             'domains': [1, 2],
             'mds_services': [(1, 1)],  # (<id>, <storagedriver_id>)
             'storagerouters': [1, 2, 3, 4, 5],
             'storagerouter_domains': [(1, 1, 1, True), (2, 2, 1, False), (3, 3, 1, False), (4, 4, 2, False)],  # (<sr_domain_id>, <sr_id>, <domain_id>, <backup>)
             'storagedrivers': [(1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4), (5, 1, 5)]}  # (<id>, <vpool_id>, <sr_id>)
        )
        vpool = structure['vpools'][1]
        vdisk = structure['vdisks'][1]
        domains = structure['domains']
        storagerouters = structure['storagerouters']

        self._roll_out_dtl_services(vpool=vpool, storagerouters=storagerouters)
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': [sr.storagedrivers[0].storage_ip for sr in storagerouters.values()[1:3]]},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.ASYNCHRONOUS}])

        # Set DTL manually to node 2 and add 2 vdisk domains to the vdisk
        vdisk.storagedriver_client.set_manual_dtl_config(volume_id=vdisk.volume_id,
                                                         config=DTLConfig(str(storagerouters[2].storagedrivers[0].storage_ip), 3, DTLMode.SYNCHRONOUS))
        vdomain1 = VDiskDomain()
        vdomain2 = VDiskDomain()
        vdomain1.vdisk = vdisk
        vdomain2.vdisk = vdisk
        vdomain1.domain = domains[1]
        vdomain2.domain = domains[2]
        vdomain1.save()
        vdomain2.save()
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[2].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.SYNCHRONOUS}])
        # Delete the vDiskDomain on which the DTL resides, 1 other vDiskDomain remains, no changes should be made, but OVS_WARNING should be logged
        vdomain1.delete()
        LogHandler._logs = {}
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[2].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.SYNCHRONOUS}])
        warning_logs = []
        for log in LogHandler._logs['lib_vdisk']:
            if 'OVS_WARNING' in log and 'manual DTL configuration is no longer' in log and vdisk.guid in log:
                warning_logs.append(log)
        self.assertEqual(first=1, second=len(warning_logs))

        # Delete the last vDiskDomain --> DTL should not be changed
        vdomain2.delete()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[2].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.SYNCHRONOUS}])
        vdisk.discard()
        self.assertTrue(expr=vdisk.has_manual_dtl)

        # Overrules the DTL manually to None and validate DTL checkup leaves it as it is
        vdisk.storagedriver_client.set_manual_dtl_config(volume_id=vdisk.volume_id, config=None)
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'config', 'value': None}])
示例#4
0
    def test_manually_overruled_dtl(self):
        """
        The DTL target of a vDisk can be manually overruled by the customer
        """
        # || StorageRouter || vDisk | Regular Domain || Recovery Domain || DTL Target ||
        #  |      sr 1      |   1   |                 |      domain 1    |             |
        #  |      sr 2      |       |      domain 1   |                  |             |
        #  |      sr 3      |       |      domain 1   |                  |             |
        #  |      sr 4      |       |      domain 2   |                  |             |
        #  |      sr 5      |       |                 |                  |             |
        structure = Helper.build_service_structure(
            {'vpools': [1],
             'vdisks': [(1, 1, 1, 1)],  # (<id>, <storagedriver_id>, <vpool_id>, <mds_service_id>)
             'domains': [1, 2],
             'mds_services': [(1, 1)],  # (<id>, <storagedriver_id>)
             'storagerouters': [1, 2, 3, 4, 5],
             'storagerouter_domains': [(1, 1, 1, True), (2, 2, 1, False), (3, 3, 1, False), (4, 4, 2, False)],  # (<sr_domain_id>, <sr_id>, <domain_id>, <backup>)
             'storagedrivers': [(1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4), (5, 1, 5)]}  # (<id>, <vpool_id>, <sr_id>)
        )
        vpool = structure['vpools'][1]
        vdisk = structure['vdisks'][1]
        domains = structure['domains']
        storagerouters = structure['storagerouters']

        self._roll_out_dtl_services(vpool=vpool, storagerouters=storagerouters)
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': [sr.storagedrivers[0].storage_ip for sr in storagerouters.values()[1:3]]},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.ASYNCHRONOUS}])

        # Set DTL manually to node 2 and add 2 vdisk domains to the vdisk
        vdisk.storagedriver_client.set_manual_dtl_config(volume_id=vdisk.volume_id,
                                                         config=DTLConfig(str(storagerouters[2].storagedrivers[0].storage_ip), 3, DTLMode.SYNCHRONOUS))
        vdomain1 = VDiskDomain()
        vdomain2 = VDiskDomain()
        vdomain1.vdisk = vdisk
        vdomain2.vdisk = vdisk
        vdomain1.domain = domains[1]
        vdomain2.domain = domains[2]
        vdomain1.save()
        vdomain2.save()
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[2].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.SYNCHRONOUS}])
        # Delete the vDiskDomain on which the DTL resides, 1 other vDiskDomain remains
        vdomain1.delete()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': storagerouters[4].storagedrivers[0].storage_ip},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.SYNCHRONOUS}])

        # Delete the last vDiskDomain --> DTL is no longer manual
        vdomain2.delete()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'host', 'value': [sr.storagedrivers[0].storage_ip for sr in storagerouters.values()[1:3]]},
                                                        {'key': 'port', 'value': 3},
                                                        {'key': 'mode', 'value': DTLMode.ASYNCHRONOUS}])
        vdisk.discard()
        self.assertFalse(expr=vdisk.has_manual_dtl,
                         msg='vDisk "vdisk_1" should have manual_dtl flag set to False')

        # Overrules the DTL manually to None and validate DTL checkup leaves it as it is
        vdisk.storagedriver_client.set_manual_dtl_config(volume_id=vdisk.volume_id, config=None)
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{'key': 'config', 'value': None}])
示例#5
0
    def test_manually_overruled_dtl(self):
        """
        The DTL target of a vDisk can be manually overruled by the customer
        """
        # || StorageRouter || vDisk | Regular Domain || Recovery Domain || DTL Target ||
        #  |      sr 1      |   1   |                 |      domain 1    |             |
        #  |      sr 2      |       |      domain 1   |                  |             |
        #  |      sr 3      |       |      domain 1   |                  |             |
        #  |      sr 4      |       |      domain 2   |                  |             |
        #  |      sr 5      |       |                 |                  |             |
        structure = Helper.build_service_structure({
            'vpools': [1],
            'vdisks': [
                (1, 1, 1, 1)
            ],  # (<id>, <storagedriver_id>, <vpool_id>, <mds_service_id>)
            'domains': [1, 2],
            'mds_services': [(1, 1)],  # (<id>, <storagedriver_id>)
            'storagerouters': [1, 2, 3, 4, 5],
            'storagerouter_domains': [
                (1, 1, 1, True), (2, 2, 1, False), (3, 3, 1, False),
                (4, 4, 2, False)
            ],  # (<sr_domain_id>, <sr_id>, <domain_id>, <backup>)
            'storagedrivers': [(1, 1, 1), (2, 1, 2), (3, 1, 3), (4, 1, 4),
                               (5, 1, 5)]
        }  # (<id>, <vpool_id>, <sr_id>)
                                                   )
        vpool = structure['vpools'][1]
        vdisk = structure['vdisks'][1]
        domains = structure['domains']
        storagerouters = structure['storagerouters']

        self._roll_out_dtl_services(vpool=vpool, storagerouters=storagerouters)
        self._run_and_validate_dtl_checkup(
            vdisk=vdisk,
            validations=[{
                'key':
                'host',
                'value': [
                    sr.storagedrivers[0].storage_ip
                    for sr in storagerouters.values()[1:3]
                ]
            }, {
                'key': 'port',
                'value': 3
            }, {
                'key': 'mode',
                'value': DTLMode.ASYNCHRONOUS
            }])

        # Set DTL manually to node 2 and add 2 vdisk domains to the vdisk
        vdisk.storagedriver_client.set_manual_dtl_config(
            volume_id=vdisk.volume_id,
            config=DTLConfig(
                str(storagerouters[2].storagedrivers[0].storage_ip), 3,
                DTLMode.SYNCHRONOUS))
        vdomain1 = VDiskDomain()
        vdomain2 = VDiskDomain()
        vdomain1.vdisk = vdisk
        vdomain2.vdisk = vdisk
        vdomain1.domain = domains[1]
        vdomain2.domain = domains[2]
        vdomain1.save()
        vdomain2.save()
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(
            vdisk=vdisk,
            validations=[{
                'key':
                'host',
                'value':
                storagerouters[2].storagedrivers[0].storage_ip
            }, {
                'key': 'port',
                'value': 3
            }, {
                'key': 'mode',
                'value': DTLMode.SYNCHRONOUS
            }])
        # Delete the vDiskDomain on which the DTL resides, 1 other vDiskDomain remains
        vdomain1.delete()
        self._run_and_validate_dtl_checkup(
            vdisk=vdisk,
            validations=[{
                'key':
                'host',
                'value':
                storagerouters[4].storagedrivers[0].storage_ip
            }, {
                'key': 'port',
                'value': 3
            }, {
                'key': 'mode',
                'value': DTLMode.SYNCHRONOUS
            }])

        # Delete the last vDiskDomain --> DTL is no longer manual
        vdomain2.delete()
        self._run_and_validate_dtl_checkup(
            vdisk=vdisk,
            validations=[{
                'key':
                'host',
                'value': [
                    sr.storagedrivers[0].storage_ip
                    for sr in storagerouters.values()[1:3]
                ]
            }, {
                'key': 'port',
                'value': 3
            }, {
                'key': 'mode',
                'value': DTLMode.ASYNCHRONOUS
            }])
        vdisk.discard()
        self.assertFalse(
            expr=vdisk.has_manual_dtl,
            msg='vDisk "vdisk_1" should have manual_dtl flag set to False')

        # Overrules the DTL manually to None and validate DTL checkup leaves it as it is
        vdisk.storagedriver_client.set_manual_dtl_config(
            volume_id=vdisk.volume_id, config=None)
        vdisk.has_manual_dtl = True
        vdisk.save()
        self._run_and_validate_dtl_checkup(vdisk=vdisk,
                                           validations=[{
                                               'key': 'config',
                                               'value': None
                                           }])