def resource_setup(cls): super(MigrationTest, cls).resource_setup() if cls.protocol not in CONF.share.enable_protocols: message = "%s tests are disabled." % cls.protocol raise cls.skipException(message) if not (CONF.share.run_host_assisted_migration_tests or CONF.share.run_driver_assisted_migration_tests): raise cls.skipException("Share migration tests are disabled.") pools = cls.shares_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise cls.skipException("At least two different pool entries " "are needed to run share migration tests.") cls.share = cls.create_share(cls.protocol) cls.share = cls.shares_client.get_share(cls.share['id']) default_type = cls.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend(cls.share, pools, default_type) if not dest_pool or dest_pool.get('name') is None: raise share_exceptions.ShareMigrationException( "No valid pool entries to run share migration tests.") cls.dest_pool = dest_pool['name'] cls.new_type_invalid = cls.create_share_type( name=data_utils.rand_name('new_invalid_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs(variation='invalid'))
def resource_setup(cls): super(MigrationTest, cls).resource_setup() if cls.protocol not in CONF.share.enable_protocols: message = "%s tests are disabled." % cls.protocol raise cls.skipException(message) if not (CONF.share.run_host_assisted_migration_tests or CONF.share.run_driver_assisted_migration_tests): raise cls.skipException("Share migration tests are disabled.") pools = cls.shares_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise cls.skipException("At least two different pool entries " "are needed to run share migration tests.") cls.share = cls.create_share(cls.protocol) cls.share = cls.shares_client.get_share(cls.share['id']) default_type = cls.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend( cls.share, pools, default_type) if not dest_pool or dest_pool.get('name') is None: raise share_exceptions.ShareMigrationException( "No valid pool entries to run share migration tests.") cls.dest_pool = dest_pool['name'] cls.new_type_invalid = cls.create_share_type( name=data_utils.rand_name( 'new_invalid_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs(variation='invalid'))
def _setup_migration(self, opposite=False): pools = self.shares_v2_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise self.skipException("At least two different pool entries are " "needed to run share migration tests.") share = self.create_share(self.protocol) share = self.shares_v2_client.get_share(share['id']) old_exports = self.shares_v2_client.list_share_export_locations( share['id']) self.assertNotEmpty(old_exports) old_exports = [x['path'] for x in old_exports if x['is_admin_only'] is False] self.assertNotEmpty(old_exports) self.shares_v2_client.create_access_rule( share['id'], access_to="50.50.50.50", access_level="rw") self.shares_v2_client.wait_for_share_status( share['id'], constants.RULE_STATE_ACTIVE, status_attr='access_rules_status') self.shares_v2_client.create_access_rule( share['id'], access_to="51.51.51.51", access_level="ro") self.shares_v2_client.wait_for_share_status( share['id'], constants.RULE_STATE_ACTIVE, status_attr='access_rules_status') if opposite: dest_type = self.new_type_opposite['share_type'] else: dest_type = self.new_type['share_type'] dest_pool = utils.choose_matching_backend(share, pools, dest_type) if opposite: if not dest_pool: raise self.skipException( "This test requires two pools enabled with different " "driver modes.") else: self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) dest_pool = dest_pool['name'] return share, dest_pool
def _setup_migration(self, share, opposite=False): if opposite: dest_type = self.new_type_opposite else: dest_type = self.new_type dest_pool = utils.choose_matching_backend(share, self.pools, dest_type) if opposite: if not dest_pool: raise self.skipException( "This test requires two pools enabled with different " "driver modes.") else: self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) old_exports = self.shares_v2_client.list_share_export_locations( share['id'])['export_locations'] self.assertNotEmpty(old_exports) old_exports = [ x['path'] for x in old_exports if x['is_admin_only'] is False ] self.assertNotEmpty(old_exports) self.shares_v2_client.create_access_rule(share['id'], access_to="50.50.50.50", access_level="rw") waiters.wait_for_resource_status(self.shares_v2_client, share['id'], constants.RULE_STATE_ACTIVE, status_attr='access_rules_status') self.shares_v2_client.create_access_rule(share['id'], access_to="51.51.51.51", access_level="ro") waiters.wait_for_resource_status(self.shares_v2_client, share['id'], constants.RULE_STATE_ACTIVE, status_attr='access_rules_status') dest_pool = dest_pool['name'] share = self.shares_v2_client.get_share(share['id'])['share'] return share, dest_pool
def _validate_share_migration_with_different_snapshot_capability_type( self, force_host_assisted, snapshot_capable): self._check_migration_enabled(force_host_assisted) ss_type, no_ss_type = self._create_share_type_for_snapshot_capability() if snapshot_capable: share_type = ss_type['share_type'] share_type_id = no_ss_type['share_type']['id'] new_share_type_id = ss_type['share_type']['id'] else: share_type = no_ss_type['share_type'] share_type_id = ss_type['share_type']['id'] new_share_type_id = no_ss_type['share_type']['id'] share = self.create_share(self.protocol, share_type_id=share_type_id) share = self.shares_v2_client.get_share(share['id']) if snapshot_capable: self.assertEqual(False, share['snapshot_support']) else: # Verify that share has snapshot support capability self.assertTrue(share['snapshot_support']) dest_pool = utils.choose_matching_backend(share, self.pools, share_type) task_state, new_share_network_id, __ = (self._get_migration_data( share, force_host_assisted)) share = self.migrate_share( share['id'], dest_pool['name'], force_host_assisted_migration=force_host_assisted, wait_for_status=task_state, new_share_type_id=new_share_type_id, new_share_network_id=new_share_network_id) share = self.migration_complete(share['id'], dest_pool) if snapshot_capable: # Verify that migrated share does have snapshot support capability self.assertTrue(share['snapshot_support']) else: # Verify that migrated share don't have snapshot support capability self.assertEqual(False, share['snapshot_support']) self._cleanup_share(share)
def resource_setup(cls): super(MigrationNegativeTest, cls).resource_setup() if cls.protocol not in CONF.share.enable_protocols: message = "%s tests are disabled." % cls.protocol raise cls.skipException(message) if not (CONF.share.run_host_assisted_migration_tests or CONF.share.run_driver_assisted_migration_tests): raise cls.skipException("Share migration tests are disabled.") pools = cls.shares_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise cls.skipException("At least two different pool entries " "are needed to run share migration tests.") # create share type (generic) extra_specs = {} if CONF.share.capability_snapshot_support: extra_specs.update({'snapshot_support': True}) cls.share_type = cls.create_share_type(extra_specs=extra_specs) cls.share_type_id = cls.share_type['id'] # create share cls.share = cls.create_share(cls.protocol, size=CONF.share.share_size + 1, share_type_id=cls.share_type_id) cls.share = cls.shares_client.get_share(cls.share['id'])['share'] dest_pool = utils.choose_matching_backend(cls.share, pools, cls.share_type) if not dest_pool or dest_pool.get('name') is None: raise share_exceptions.ShareMigrationException( "No valid pool entries to run share migration tests.") cls.dest_pool = dest_pool['name'] cls.new_type_invalid = cls.create_share_type( name=data_utils.rand_name('new_invalid_share_type_for_migration'), cleanup_in_class=True, extra_specs=utils.get_configured_extra_specs(variation='invalid'))
def test_migration_files(self): if self.protocol != "NFS": raise self.skipException("Only NFS protocol supported " "at this moment.") pools = self.shares_admin_v2_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise self.skipException("At least two different pool entries are " "needed to run share migration tests.") instance = self.boot_instance(wait_until="BUILD") self.create_share() instance = self.wait_for_active_instance(instance["id"]) self.share = self.shares_client.get_share(self.share['id']) default_type = self.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend(self.share, pools, default_type) self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) dest_pool = dest_pool['name'] self.allow_access_ip(self.share['id'], instance=instance, cleanup=False) ssh_client = self.init_ssh(instance) if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): exports = self.share['export_locations'] else: exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(exports) exports = [x['path'] for x in exports] self.assertNotEmpty(exports) self.mount_share(exports[0], ssh_client) ssh_client.exec_command("mkdir -p /mnt/f1") ssh_client.exec_command("mkdir -p /mnt/f2") ssh_client.exec_command("mkdir -p /mnt/f3") ssh_client.exec_command("mkdir -p /mnt/f4") ssh_client.exec_command("mkdir -p /mnt/f1/ff1") ssh_client.exec_command("sleep 1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f1/1m1.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f2/1m2.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f3/1m3.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f4/1m4.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f1/ff1/1m5.bin bs=1M" " count=1") ssh_client.exec_command("chmod -R 555 /mnt/f3") ssh_client.exec_command("chmod -R 777 /mnt/f4") self.umount_share(ssh_client) task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED, constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE) self.share = self.migrate_share(self.share['id'], dest_pool, task_state) if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): new_exports = self.share['export_locations'] self.assertNotEmpty(new_exports) else: new_exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(new_exports) new_exports = [x['path'] for x in new_exports] self.assertNotEmpty(new_exports) self.assertEqual(dest_pool, self.share['host']) self.assertEqual(constants.TASK_STATE_MIGRATION_SUCCESS, self.share['task_state']) self.mount_share(new_exports[0], ssh_client) output = ssh_client.exec_command("ls -lRA --ignore=lost+found /mnt") self.umount_share(ssh_client) self.assertTrue('1m1.bin' in output) self.assertTrue('1m2.bin' in output) self.assertTrue('1m3.bin' in output) self.assertTrue('1m4.bin' in output) self.assertTrue('1m5.bin' in output)
def test_migration_files(self, force_host_assisted): if (force_host_assisted and not CONF.share.run_host_assisted_migration_tests): raise self.skipException("Host-assisted migration tests are " "disabled.") elif (not force_host_assisted and not CONF.share.run_driver_assisted_migration_tests): raise self.skipException("Driver-assisted migration tests are " "disabled.") if self.protocol != "nfs": raise self.skipException("Only NFS protocol supported " "at this moment.") if self.ipv6_enabled: raise self.skipException("Share Migration using IPv6 is not " "supported at this moment.") pools = self.shares_admin_v2_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise self.skipException("At least two different pool entries are " "needed to run share migration tests.") instance = self.boot_instance(wait_until="BUILD") share = self.create_share() export_location = self.get_user_export_locations(share)[0] instance = self.wait_for_active_instance(instance["id"]) share = self.shares_admin_v2_client.get_share(share['id'])['share'] default_type = self.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend(share, pools, default_type) self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) dest_pool = dest_pool['name'] remote_client = self.init_remote_client(instance) self.allow_access(share=share, instance=instance, remote_client=remote_client, locations=export_location) self.mount_share(export_location, remote_client) remote_client.exec_command("sudo mkdir -p /mnt/f1") remote_client.exec_command("sudo mkdir -p /mnt/f2") remote_client.exec_command("sudo mkdir -p /mnt/f3") remote_client.exec_command("sudo mkdir -p /mnt/f4") remote_client.exec_command("sudo mkdir -p /mnt/f1/ff1") remote_client.exec_command("sleep 1") remote_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f1/1m1.bin bs=1M count=1") remote_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f2/1m2.bin bs=1M count=1") remote_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f3/1m3.bin bs=1M count=1") remote_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f4/1m4.bin bs=1M count=1") remote_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f1/ff1/1m5.bin bs=1M count=1") remote_client.exec_command("sudo chmod -R 555 /mnt/f3") remote_client.exec_command("sudo chmod -R 777 /mnt/f4") task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED if force_host_assisted else constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE) share = self.migrate_share(share['id'], dest_pool, task_state, force_host_assisted) if force_host_assisted: self.assertRaises( exceptions.SSHExecCommandFailed, remote_client.exec_command, "dd if=/dev/zero of=/mnt/f1/1m6.bin bs=1M count=1") self.unmount_share(remote_client) share = self.migration_complete(share['id'], dest_pool) new_exports = self.get_user_export_locations(share) self.assertEqual(dest_pool, share['host']) self.assertEqual(constants.TASK_STATE_MIGRATION_SUCCESS, share['task_state']) self.mount_share(new_exports[0], remote_client) output = remote_client.exec_command("ls -lRA --ignore=lost+found /mnt") self.unmount_share(remote_client) self.assertIn('1m1.bin', output) self.assertIn('1m2.bin', output) self.assertIn('1m3.bin', output) self.assertIn('1m4.bin', output) self.assertIn('1m5.bin', output)
def test_migration_files(self, force_host_assisted): if (force_host_assisted and not CONF.share.run_host_assisted_migration_tests): raise self.skipException("Host-assisted migration tests are " "disabled.") elif (not force_host_assisted and not CONF.share.run_driver_assisted_migration_tests): raise self.skipException("Driver-assisted migration tests are " "disabled.") if self.protocol != "nfs": raise self.skipException("Only NFS protocol supported " "at this moment.") pools = self.shares_admin_v2_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise self.skipException("At least two different pool entries are " "needed to run share migration tests.") instance = self.boot_instance(wait_until="BUILD") self.create_share() instance = self.wait_for_active_instance(instance["id"]) self.share = self.shares_admin_v2_client.get_share(self.share['id']) default_type = self.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend( self.share, pools, default_type) self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) dest_pool = dest_pool['name'] ssh_client = self.init_ssh(instance) self.provide_access_to_auxiliary_instance(instance) exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(exports) exports = [x['path'] for x in exports] self.assertNotEmpty(exports) self.mount_share(exports[0], ssh_client) ssh_client.exec_command("sudo mkdir -p /mnt/f1") ssh_client.exec_command("sudo mkdir -p /mnt/f2") ssh_client.exec_command("sudo mkdir -p /mnt/f3") ssh_client.exec_command("sudo mkdir -p /mnt/f4") ssh_client.exec_command("sudo mkdir -p /mnt/f1/ff1") ssh_client.exec_command("sleep 1") ssh_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f1/1m1.bin bs=1M count=1") ssh_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f2/1m2.bin bs=1M count=1") ssh_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f3/1m3.bin bs=1M count=1") ssh_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f4/1m4.bin bs=1M count=1") ssh_client.exec_command( "sudo dd if=/dev/zero of=/mnt/f1/ff1/1m5.bin bs=1M count=1") ssh_client.exec_command("sudo chmod -R 555 /mnt/f3") ssh_client.exec_command("sudo chmod -R 777 /mnt/f4") task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED if force_host_assisted else constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE) self.share = self.migrate_share( self.share['id'], dest_pool, task_state, force_host_assisted) if force_host_assisted: self.assertRaises( exceptions.SSHExecCommandFailed, ssh_client.exec_command, "dd if=/dev/zero of=/mnt/f1/1m6.bin bs=1M count=1") self.umount_share(ssh_client) self.share = self.migration_complete(self.share['id'], dest_pool) new_exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(new_exports) new_exports = [x['path'] for x in new_exports] self.assertNotEmpty(new_exports) self.assertEqual(dest_pool, self.share['host']) self.assertEqual(constants.TASK_STATE_MIGRATION_SUCCESS, self.share['task_state']) self.mount_share(new_exports[0], ssh_client) output = ssh_client.exec_command("ls -lRA --ignore=lost+found /mnt") self.umount_share(ssh_client) self.assertIn('1m1.bin', output) self.assertIn('1m2.bin', output) self.assertIn('1m3.bin', output) self.assertIn('1m4.bin', output) self.assertIn('1m5.bin', output)
def test_migration_files(self): if self.protocol != "NFS": raise self.skipException("Only NFS protocol supported " "at this moment.") pools = self.shares_admin_v2_client.list_pools(detail=True)['pools'] if len(pools) < 2: raise self.skipException("At least two different pool entries are " "needed to run share migration tests.") instance = self.boot_instance(wait_until="BUILD") self.create_share() instance = self.wait_for_active_instance(instance["id"]) self.share = self.shares_client.get_share(self.share['id']) default_type = self.shares_v2_client.list_share_types( default=True)['share_type'] dest_pool = utils.choose_matching_backend( self.share, pools, default_type) self.assertIsNotNone(dest_pool) self.assertIsNotNone(dest_pool.get('name')) dest_pool = dest_pool['name'] self.allow_access_ip( self.share['id'], instance=instance, cleanup=False) ssh_client = self.init_ssh(instance) if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): exports = self.share['export_locations'] else: exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(exports) exports = [x['path'] for x in exports] self.assertNotEmpty(exports) self.mount_share(exports[0], ssh_client) ssh_client.exec_command("mkdir -p /mnt/f1") ssh_client.exec_command("mkdir -p /mnt/f2") ssh_client.exec_command("mkdir -p /mnt/f3") ssh_client.exec_command("mkdir -p /mnt/f4") ssh_client.exec_command("mkdir -p /mnt/f1/ff1") ssh_client.exec_command("sleep 1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f1/1m1.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f2/1m2.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f3/1m3.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f4/1m4.bin bs=1M" " count=1") ssh_client.exec_command("dd if=/dev/zero of=/mnt/f1/ff1/1m5.bin bs=1M" " count=1") ssh_client.exec_command("chmod -R 555 /mnt/f3") ssh_client.exec_command("chmod -R 777 /mnt/f4") self.umount_share(ssh_client) task_state = (constants.TASK_STATE_DATA_COPYING_COMPLETED, constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE) self.share = self.migrate_share( self.share['id'], dest_pool, task_state) if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): new_exports = self.share['export_locations'] self.assertNotEmpty(new_exports) else: new_exports = self.shares_v2_client.list_share_export_locations( self.share['id']) self.assertNotEmpty(new_exports) new_exports = [x['path'] for x in new_exports] self.assertNotEmpty(new_exports) self.assertEqual(dest_pool, self.share['host']) self.assertEqual(constants.TASK_STATE_MIGRATION_SUCCESS, self.share['task_state']) self.mount_share(new_exports[0], ssh_client) output = ssh_client.exec_command("ls -lRA --ignore=lost+found /mnt") self.umount_share(ssh_client) self.assertTrue('1m1.bin' in output) self.assertTrue('1m2.bin' in output) self.assertTrue('1m3.bin' in output) self.assertTrue('1m4.bin' in output) self.assertTrue('1m5.bin' in output)