Exemplo n.º 1
0
 def test_rand_uuid(self):
     actual = data_utils.rand_uuid()
     self.assertIsInstance(actual, str)
     self.assertRegex(actual, "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]"
                      "{4}-[0-9a-f]{4}-[0-9a-f]{12}$")
     actual2 = data_utils.rand_uuid()
     self.assertNotEqual(actual, actual2)
 def test_create_with_nonexistent_volume_type(self):
     # Should not be able to create volume with nonexistent volume_type.
     self.name_field = self.special_fields['name_field']
     params = {self.name_field: data_utils.rand_uuid(),
               'volume_type': data_utils.rand_uuid()}
     self.assertRaises(lib_exc.NotFound,
                       self.volumes_client.create_volume, **params)
 def test_get_nonexistent_extra_spec_id(self):
     # Should not get volume type extra spec for nonexistent extra spec
         # id.
     self.assertRaises(
         lib_exc.NotFound,
         self.admin_volume_types_client.show_volume_type_extra_specs,
         self.volume_type['id'], data_utils.rand_uuid())
Exemplo n.º 4
0
 def test_update_attached_volume_with_nonexistent_volume_in_uri(self):
     volume = self.create_volume()
     nonexistent_volume = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.admin_servers_client.update_attached_volume,
                       self.server['id'], nonexistent_volume,
                       volumeId=volume['id'])
 def test_create_snapshot_with_nonexistent_volume_id(self):
     # Create a snapshot with nonexistent volume id
     s_name = data_utils.rand_name(self.__class__.__name__ + '-snap')
     self.assertRaises(lib_exc.NotFound,
                       self.snapshots_client.create_snapshot,
                       volume_id=data_utils.rand_uuid(),
                       display_name=s_name)
Exemplo n.º 6
0
    def test_compare_console_output(self):
        key_name = data_utils.rand_name('testkey')
        pkey = self.create_key_pair(key_name)
        sec_group_name = self.create_standard_security_group()
        instance_id = self.run_instance(KeyName=key_name,
                                        SecurityGroups=[sec_group_name])

        data_to_check = data_utils.rand_uuid()
        ip_address = self.get_instance_ip(instance_id)
        ssh_client = ssh.Client(ip_address, CONF.aws.image_user, pkey=pkey)
        cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % data_to_check
        ssh_client.exec_command(cmd)

        waiter = base.EC2Waiter(self.client.get_console_output)
        waiter.wait_no_exception(InstanceId=instance_id)

        def _compare_console_output():
            data = self.client.get_console_output(InstanceId=instance_id)
            self.assertEqual(instance_id, data['InstanceId'])
            self.assertIsNotNone(data['Timestamp'])
            self.assertIn('Output', data)
            self.assertIn(data_to_check, data['Output'])

        waiter = base.EC2Waiter(_compare_console_output)
        waiter.wait_no_exception()
Exemplo n.º 7
0
 def test_create_flavor_with_uuid_id(self):
     flavor_id = data_utils.rand_uuid()
     new_flavor_id = self.create_flavor(ram=self.ram,
                                        vcpus=self.vcpus,
                                        disk=self.disk,
                                        id=flavor_id)['id']
     self.assertEqual(new_flavor_id, flavor_id)
Exemplo n.º 8
0
    def test_metadata(self):
        key_name = data_utils.rand_name('testkey')
        self.client.import_key_pair(KeyName=key_name,
                                    PublicKeyMaterial=PUBLIC_KEY_MATERIAL)
        self.addResourceCleanUp(self.client.delete_key_pair, KeyName=key_name)

        sec_group_name = self.create_standard_security_group()
        user_data = six.text_type(data_utils.rand_uuid()) + six.unichr(1071)
        instance_id = self.run_instance(KeyName=key_name, UserData=user_data,
                                        SecurityGroups=[sec_group_name])

        data = self.client.describe_instance_attribute(
            InstanceId=instance_id, Attribute='userData')
        self.assertEqual(
            data['UserData']['Value'],
            base64.b64encode(user_data.encode("utf-8")).decode("utf-8"))

        ip_address = self.get_instance_ip(instance_id)

        ssh_client = ssh.Client(ip_address, CONF.aws.image_user,
                                pkey=PRIVATE_KEY_MATERIAL)

        url = 'http://169.254.169.254'
        data = ssh_client.exec_command('curl %s/latest/user-data' % url)
        if isinstance(data, six.binary_type):
            data = data.decode("utf-8")
        self.assertEqual(user_data, data)

        data = ssh_client.exec_command('curl %s/latest/meta-data/ami-id' % url)
        self.assertEqual(CONF.aws.image_id, data)

        data = ssh_client.exec_command(
            'curl %s/latest/meta-data/public-keys/0/openssh-key' % url)
        # compare only keys. without 'sha-rsa' and owner
        self.assertEqual(PUBLIC_KEY_MATERIAL.split()[1], data.split()[1])
Exemplo n.º 9
0
    def test_show_servers_with_nonexistent_hypervisor(self):
        nonexistent_hypervisor_id = data_utils.rand_uuid()

        self.assertRaises(
            lib_exc.NotFound,
            self.client.list_servers_on_hypervisor,
            nonexistent_hypervisor_id)
 def test_delete_nonexistent_volume_type_id(self):
     # Should not delete volume type extra spec for nonexistent
     # type id.
     self.assertRaises(
         lib_exc.NotFound,
         self.admin_volume_types_client.delete_volume_type_extra_specs,
         data_utils.rand_uuid(), "spec1")
Exemplo n.º 11
0
    def test_update_cluster_template_404(self):
        patch_model = datagen.cluster_template_name_patch_data()

        self.assertRaises(
            exceptions.NotFound,
            self.cluster_template_client.patch_cluster_template,
            data_utils.rand_uuid(), patch_model)
Exemplo n.º 12
0
    def test_get_nonexistent_hypervisor_uptime(self):
        nonexistent_hypervisor_id = data_utils.rand_uuid()

        self.assertRaises(
            lib_exc.NotFound,
            self.client.show_hypervisor_uptime,
            nonexistent_hypervisor_id)
Exemplo n.º 13
0
    def test_update_baymodel_404(self):
        patch_model = datagen.baymodel_name_patch_data()

        self.assertRaises(
            exceptions.NotFound,
            self.baymodel_client.patch_baymodel,
            data_utils.rand_uuid(), patch_model)
Exemplo n.º 14
0
 def test_run_workspace_rename(self):
     new_name = data_utils.rand_uuid()
     cmd = ['tempest', 'workspace', '--workspace-path', self.store_file,
            'rename', "--old-name", self.name, '--new-name', new_name]
     self._run_cmd_gets_return_code(cmd, 0)
     self.assertIsNone(self.workspace_manager.get_workspace(self.name))
     self.assertIsNotNone(self.workspace_manager.get_workspace(new_name))
Exemplo n.º 15
0
def cluster_data(name=data_utils.rand_name('cluster'),
                 cluster_template_id=data_utils.rand_uuid(),
                 node_count=random_int(1, 5), discovery_url=gen_random_ip(),
                 create_timeout=random_int(1, 30),
                 master_count=random_int(1, 5)):
    """Generates random cluster data

    cluster_template_id cannot be random for the cluster to be valid due to
    validations for the presence of clustertemplate prior to clustertemplate
    creation.

    :param name: cluster name (must be unique)
    :param cluster_template_id: clustertemplate unique id (must already exist)
    :param node_count: number of agents for cluster
    :param discovery_url: url provided for node discovery
    :param create_timeout: timeout in minutes for cluster create
    :param master_count: number of master nodes for the cluster
    :returns: ClusterEntity with generated data
    """

    data = {
        "name": name,
        "cluster_template_id": cluster_template_id,
        "keypair": config.Config.keypair_id,
        "node_count": node_count,
        "discovery_url": None,
        "create_timeout": create_timeout,
        "master_count": master_count
    }
    model = cluster_model.ClusterEntity.from_dict(data)

    return model
Exemplo n.º 16
0
def bay_data(name=data_utils.rand_name('bay'),
             baymodel_id=data_utils.rand_uuid(),
             node_count=random_int(1, 5), discovery_url=gen_random_ip(),
             bay_create_timeout=random_int(1, 30),
             master_count=random_int(1, 5)):
    """Generates random bay data

    BayModel_id cannot be random for the bay to be valid due to
    validations for the presence of baymodel prior to baymodel
    creation.

    :param name: bay name (must be unique)
    :param baymodel_id: baymodel unique id (must already exist)
    :param node_count: number of agents for bay
    :param discovery_url: url provided for node discovery
    :param bay_create_timeout: timeout in minutes for bay create
    :param master_count: number of master nodes for the bay
    :returns: BayEntity with generated data
    """

    data = {
        "name": name,
        "baymodel_id": baymodel_id,
        "node_count": node_count,
        "discovery_url": None,
        "bay_create_timeout": bay_create_timeout,
        "master_count": master_count
    }
    model = bay_model.BayEntity.from_dict(data)

    return model
 def test_list_virtual_interfaces_invalid_server_id(self):
     # Negative test: Should not be able to GET virtual interfaces
     # for an invalid server_id
     invalid_server_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.client.list_virtual_interfaces,
                       invalid_server_id)
 def test_delete_metadata_non_existent_server(self):
     # Should not be able to delete metadata item from a non-existent server
     non_existent_server_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.client.delete_server_metadata_item,
                       non_existent_server_id,
                       'd')
 def test_server_metadata_non_existent_server(self):
     # GET on a non-existent server should not succeed
     non_existent_server_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.client.show_server_metadata_item,
                       non_existent_server_id,
                       'test2')
Exemplo n.º 20
0
 def test_rebuild_non_existent_server(self):
     # Rebuild a non existent server
     nonexistent_server = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.client.rebuild_server,
                       nonexistent_server,
                       self.image_ref)
Exemplo n.º 21
0
 def test_path_expansion(self):
     name = data_utils.rand_uuid()
     path = os.path.join("~", name)
     os.makedirs(os.path.expanduser(path))
     self.addCleanup(shutil.rmtree, path, ignore_errors=True)
     self.workspace_manager.register_new_workspace(name, path)
     self.assertIsNotNone(self.workspace_manager.get_workspace(name))
 def test_set_metadata_non_existent_server(self):
     # Set metadata on a non-existent server should not succeed
     non_existent_server_id = data_utils.rand_uuid()
     meta = {'meta1': 'data1'}
     self.assertRaises(lib_exc.NotFound,
                       self.client.set_server_metadata,
                       non_existent_server_id,
                       meta)
 def test_update_nonexistent_extra_spec_id(self):
     # Should not update volume type extra specs with nonexistent id.
     extra_spec = {"spec1": "val2"}
     self.assertRaises(
         lib_exc.BadRequest,
         self.admin_volume_types_client.update_volume_type_extra_specs,
         self.volume_type['id'], data_utils.rand_uuid(),
         extra_spec)
 def test_create_nonexistent_type_id(self):
     # Should not create volume type extra spec for nonexistent volume
     # type id.
     extra_specs = {"spec2": "val1"}
     self.assertRaises(
         lib_exc.NotFound,
         self.admin_volume_types_client.create_volume_type_extra_specs,
         data_utils.rand_uuid(), extra_specs)
 def test_update_metadata_non_existent_server(self):
     # An update should not happen for a non-existent server
     non_existent_server_id = data_utils.rand_uuid()
     meta = {'key1': 'value1', 'key2': 'value2'}
     self.assertRaises(lib_exc.NotFound,
                       self.client.update_server_metadata,
                       non_existent_server_id,
                       meta)
Exemplo n.º 26
0
    def test_create_port_duplicated_port_uuid(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        uuid = data_utils.rand_uuid()

        self.create_port(node_id=node_id, address=address, uuid=uuid)
        self.assertRaises(lib_exc.Conflict, self.create_port, node_id=node_id,
                          address=address, uuid=uuid)
 def test_set_nonexistent_image_metadata_item(self):
     # Negative test: Metadata item should not be set to a
     # nonexistent image
     meta = {'os_distro': 'alt'}
     self.assertRaises(lib_exc.NotFound,
                       self.client.set_image_metadata_item,
                       data_utils.rand_uuid(), 'os_distro',
                       meta)
Exemplo n.º 28
0
    def test_attach_volumes_with_nonexistent_volume_id(self):
        server = self.create_server()

        self.assertRaises(lib_exc.NotFound,
                          self.volumes_client.attach_volume,
                          data_utils.rand_uuid(),
                          instance_uuid=server['id'],
                          mountpoint=self.mountpoint)
Exemplo n.º 29
0
 def test_run_workspace_register(self):
     name = data_utils.rand_uuid()
     path = tempfile.mkdtemp()
     self.addCleanup(shutil.rmtree, path, ignore_errors=True)
     cmd = ['tempest', 'workspace', '--workspace-path', self.store_file,
            'register', '--name', name, '--path', path]
     self._run_cmd_gets_return_code(cmd, 0)
     self.assertIsNotNone(self.workspace_manager.get_workspace(name))
 def test_create_security_group_rule_with_non_existent_security_group(self):
     # Create security group rules with not existing security group.
     non_existent_sg = data_utils.rand_uuid()
     self.assertRaises(
         lib_exc.NotFound,
         self.security_group_rules_client.create_security_group_rule,
         security_group_id=non_existent_sg,
         direction='ingress', ethertype=self.ethertype)
Exemplo n.º 31
0
 def test_delete_baymodel_404(self):
     self.assertRaises(exceptions.NotFound,
                       self.baymodel_client.delete_baymodel,
                       data_utils.rand_uuid())
Exemplo n.º 32
0
 def resource_setup(cls):
     super(ServicesAdminNegativeV253TestJSON, cls).resource_setup()
     cls.fake_service_id = data_utils.rand_uuid()
Exemplo n.º 33
0
 def test_update_tags_for_non_existing_image(self):
     """Update image tag with non existing image"""
     tag = data_utils.rand_name('tag')
     non_exist_image = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.client.add_image_tag,
                       non_exist_image, tag)
 def test_try_delete_replica_by_nonexistent_id(self):
     self.assertRaises(lib_exc.NotFound,
                       self.shares_v2_client.delete_share_replica,
                       data_utils.rand_uuid())
Exemplo n.º 35
0
 def test_list_snapshots_invalid_param_marker(self):
     self.assertRaises(lib_exc.NotFound,
                       self.snapshots_client.list_snapshots,
                       marker=data_utils.rand_uuid())
Exemplo n.º 36
0
 def test_show_invalid_vlan(self):
     non_exist_id = data_utils.rand_uuid()
     self.assertRaises(lib_exec.NotFound,
                       self.admin_client.show_gateway_vlan, non_exist_id)
Exemplo n.º 37
0
 def keypair_create(self, name=data_utils.rand_uuid()):
     """Create keypair and add cleanup."""
     raw_output = self.openstack('keypair create ' + name)
     self.addCleanup(self.keypair_delete, name, True)
     if not raw_output:
         self.fail('Keypair has not been created!')
Exemplo n.º 38
0
 def test_show_non_existent_security_group_rule(self):
     non_exist_id = data_utils.rand_uuid()
     self.assertRaises(
         lib_exc.NotFound,
         self.security_group_rules_client.show_security_group_rule,
         non_exist_id)
 def test_get_nonexistent_volume_type_id(self):
     # Should not get volume type extra spec for nonexistent type id.
     self.assertRaises(
         lib_exc.NotFound,
         self.admin_volume_types_client.show_volume_type_extra_specs,
         data_utils.rand_uuid(), "spec1")
Exemplo n.º 40
0
 def test_delete_non_existent_security_group(self):
     non_exist_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound,
                       self.security_groups_client.delete_security_group,
                       non_exist_id)
Exemplo n.º 41
0
 def test_volume_delete_nonexistent_volume_id(self):
     """Test deleting non existent volume should fail"""
     self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
                       data_utils.rand_uuid())
Exemplo n.º 42
0
 def test_positive(self):
     _id = data_utils.rand_uuid()
     foo = self._test_helper(_id)
     self.assertIn('id-%s' % _id, getattr(foo, '__testtools_attrs'))
     self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
 def test_delete_transfer_request_404(self):
     e = self.assertRaises(lib_exc.NotFound,
                           self.client.delete_transfer_request,
                           data_utils.rand_uuid())
     self.assertTransferRequest404(e.resp, e.resp_body)
Exemplo n.º 44
0
 def test_delete_bay_for_nonexisting_bay(self):
     self.assertRaises(exceptions.NotFound, self.bay_client.delete_bay,
                       data_utils.rand_uuid())
Exemplo n.º 45
0
 def test_workspace_manager_rename(self):
     new_name = data_utils.rand_uuid()
     self.workspace_manager.rename_workspace(self.name, new_name)
     self.assertIsNone(self.workspace_manager.get_workspace(self.name))
     self.assertIsNotNone(self.workspace_manager.get_workspace(new_name))
Exemplo n.º 46
0
 def test_volume_extend_with_nonexistent_volume_id(self):
     """Test extending non existent volume should fail"""
     extend_size = self.volume['size'] + 1
     self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
                       data_utils.rand_uuid(), new_size=extend_size)
Exemplo n.º 47
0
 def generate_random_security_group_id():
     if (CONF.service_available.neutron and
         utils.is_extension_enabled('security-group', 'network')):
         return data_utils.rand_uuid()
     else:
         return data_utils.rand_int_id(start=999)
Exemplo n.º 48
0
 def test_get_non_existent_image(self):
     """Get the non-existent image"""
     non_existent_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.client.show_image,
                       non_existent_id)
Exemplo n.º 49
0
 def test_positive_without_doc(self):
     _id = data_utils.rand_uuid()
     foo = self._test_helper_without_doc(_id)
     self.assertTrue(foo.__doc__.startswith('Test idempotent id: %s' % _id))
Exemplo n.º 50
0
 def test_delete_non_existing_image(self):
     """Delete non-existent image"""
     non_existent_image_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.client.delete_image,
                       non_existent_image_id)
Exemplo n.º 51
0
 def test_delete_cluster_for_nonexisting_cluster(self):
     self.assertRaises(
         exceptions.NotFound,
         self.cluster_client.delete_cluster, data_utils.rand_uuid())
Exemplo n.º 52
0
 def test_migrate_non_existent_server(self):
     # migrate a non existent server
     self.assertRaises(lib_exc.NotFound, self.client.migrate_server,
                       data_utils.rand_uuid())
Exemplo n.º 53
0
 def test_update_tsigkey_404(self):
     e = self.assertRaises(lib_exc.NotFound,
                           self.admin_client.update_tsigkey,
                           data_utils.rand_uuid())
     self.assertTsigkey404(e.resp, e.resp_body)
Exemplo n.º 54
0
 def test_delete_agent_negative(self):
     non_existent_id = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.admin_client.delete_agent,
                       non_existent_id)
Exemplo n.º 55
0
 def test_migrate_non_existent_server(self):
     """Test migrating a non existent server should fail"""
     self.assertRaises(lib_exc.NotFound,
                       self.client.migrate_server,
                       data_utils.rand_uuid())
Exemplo n.º 56
0
 def test_delete_tld_404(self):
     e = self.assertRaises(lib_exc.NotFound, self.admin_client.delete_tld,
                           data_utils.rand_uuid())
     self.assertTld404(e.resp, e.resp_body)
Exemplo n.º 57
0
 def test_create_volume_with_nonexistent_source_volid(self):
     """Test creating volume with non existent source volume should fail"""
     self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
                       size=CONF.volume.volume_size,
                       source_volid=data_utils.rand_uuid())
Exemplo n.º 58
0
 def test_rebuild_non_existent_server(self):
     # Rebuild a non existent server
     nonexistent_server = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.client.rebuild_server,
                       nonexistent_server, self.image_ref)
Exemplo n.º 59
0
 def test_resize_nonexistent_server(self):
     # Resize a non-existent server
     nonexistent_server = data_utils.rand_uuid()
     self.assertRaises(lib_exc.NotFound, self.client.resize_server,
                       nonexistent_server, self.flavor_ref)
Exemplo n.º 60
0
 def test_unreserve_volume_with_nonexistent_volume_id(self):
     """Test unreserving non existent volume should fail"""
     self.assertRaises(lib_exc.NotFound,
                       self.volumes_client.unreserve_volume,
                       data_utils.rand_uuid())