Merge "Make testing neutron agents optional"
diff --git a/.testr.conf b/.testr.conf
index c25ebec..abaf14a 100644
--- a/.testr.conf
+++ b/.testr.conf
@@ -2,8 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-500} \
- OS_TEST_PATH=${OS_TEST_PATH:-./tempest} \
- ${PYTHON:-python} -m subunit.run discover -t ./ $OS_TEST_PATH $LISTOPT $IDOPTION
+ ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tempest/test_discover} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^\.]*\.)*
diff --git a/README.rst b/README.rst
index 96f6e4c..4098e32 100644
--- a/README.rst
+++ b/README.rst
@@ -67,7 +67,7 @@
To run one single test ::
- $> testr run --parallel tempest.api.compute.servers.test_server_actions.ServerActionsTestJSON.test_rebuild_nonexistent_server
+ $> testr run --parallel tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Alternatively, you can use the run_tests.sh script which will create a venv
and run the tests or use tox to do the same.
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 607ba8b..f306d8e 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -28,7 +28,7 @@
# format string to use for log messages with context (string
# value)
-#logging_context_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user)s %(tenant)s] %(instance)s%(message)s
+#logging_context_format_string=%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
# format string to use for log messages without context
# (string value)
@@ -43,7 +43,7 @@
#logging_exception_prefix=%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s
# list of logger=LEVEL pairs (list value)
-#default_log_levels=amqplib=WARN,sqlalchemy=WARN,boto=WARN,suds=INFO,keystone=INFO,paramiko=INFO
+#default_log_levels=amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,iso8601=WARN
# publish error events (boolean value)
#publish_errors=false
@@ -59,12 +59,13 @@
# it like this (string value)
#instance_uuid_format="[instance: %(uuid)s] "
-# If this option is specified, the logging configuration file
-# specified is used and overrides any other logging options
-# specified. Please see the Python logging module
-# documentation for details on logging configuration files.
-# (string value)
-#log_config=<None>
+# The name of logging configuration file. It does not disable
+# existing loggers, but just appends specified logging
+# configuration to any other existing logging options. Please
+# see the Python logging module documentation for details on
+# logging configuration files. (string value)
+# Deprecated group/name - [DEFAULT]/log_config
+#log_config_append=<None>
# DEPRECATED. A logging.Formatter log message format string
# which may use any of the available logging.LogRecord
@@ -94,326 +95,50 @@
#syslog_log_facility=LOG_USER
-[image]
+[boto]
#
# Options defined in tempest.config
#
-# Catalog type of the Image service. (string value)
-#catalog_type=image
+# EC2 URL (string value)
+#ec2_url=http://localhost:8773/services/Cloud
-# The image region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
+# S3 URL (string value)
+#s3_url=http://localhost:8080
-# http accessible image (string value)
-#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
+# AWS Secret Key (string value)
+#aws_secret=<None>
+# AWS Access Key (string value)
+#aws_access=<None>
-[object-storage]
+# S3 Materials Path (string value)
+#s3_materials_path=/opt/stack/devstack/files/images/s3-materials/cirros-0.3.0
-#
-# Options defined in tempest.config
-#
+# ARI Ramdisk Image manifest (string value)
+#ari_manifest=cirros-0.3.0-x86_64-initrd.manifest.xml
-# Catalog type of the Object-Storage service. (string value)
-#catalog_type=object-store
+# AMI Machine Image manifest (string value)
+#ami_manifest=cirros-0.3.0-x86_64-blank.img.manifest.xml
-# The object-storage region name to use. If empty, the value
-# of identity.region is used instead. If no such region is
-# found in the service catalog, the first found one is used.
-# (string value)
-#region=
+# AKI Kernel Image manifest (string value)
+#aki_manifest=cirros-0.3.0-x86_64-vmlinuz.manifest.xml
-# Number of seconds to time on waiting for a containerto
-# container synchronization complete. (integer value)
-#container_sync_timeout=120
+# Instance type (string value)
+#instance_type=m1.tiny
-# Number of seconds to wait while looping to check thestatus
-# of a container to container synchronization (integer value)
-#container_sync_interval=5
+# boto Http socket timeout (integer value)
+#http_socket_timeout=3
-# Role to add to users created for swift tests to enable
-# creating containers (string value)
-#operator_role=Member
+# boto num_retries on error (integer value)
+#num_retries=1
+# Status Change Timeout (integer value)
+#build_timeout=60
-[network]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the Neutron service. (string value)
-#catalog_type=network
-
-# The network region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
-
-# The cidr block to allocate tenant networks from (string
-# value)
-#tenant_network_cidr=10.100.0.0/16
-
-# The mask bits for tenant networks (integer value)
-#tenant_network_mask_bits=28
-
-# Whether tenant network connectivity should be evaluated
-# directly (boolean value)
-#tenant_networks_reachable=false
-
-# Id of the public network that provides external connectivity
-# (string value)
-#public_network_id=
-
-# Id of the public router that provides external connectivity
-# (string value)
-#public_router_id=
-
-
-[data_processing]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the data processing service. (string value)
-#catalog_type=data_processing
-
-
-[object-storage-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Set to True if the Container Quota middleware is enabled
-# (boolean value)
-#container_quotas=true
-
-# Set to True if the Account Quota middleware is enabled
-# (boolean value)
-#accounts_quotas=true
-
-# Set to True if the Crossdomain middleware is enabled
-# (boolean value)
-#crossdomain=true
-
-# Set to True if the TempURL middleware is enabled (boolean
-# value)
-#tempurl=true
-
-
-[network-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
-
-
-[volume-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Runs Cinder multi-backend test (requires 2 backends)
-# (boolean value)
-#multi_backend=false
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
-
-
-[image-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# Is the v2 image API enabled (boolean value)
-#api_v2=true
-
-# Is the v1 image API enabled (boolean value)
-#api_v1=true
-
-
-[compute-admin]
-
-#
-# Options defined in tempest.config
-#
-
-# Administrative Username to use for Nova API requests.
-# (string value)
-#username=admin
-
-# Administrative Tenant name to use for Nova API requests.
-# (string value)
-#tenant_name=admin
-
-# API key to use when authenticating as admin. (string value)
-#password=pass
-
-
-[volume]
-
-#
-# Options defined in tempest.config
-#
-
-# Time in seconds between volume availability checks. (integer
-# value)
-#build_interval=10
-
-# Timeout in seconds to wait for a volume to becomeavailable.
-# (integer value)
-#build_timeout=300
-
-# Catalog type of the Volume Service (string value)
-#catalog_type=volume
-
-# The volume region name to use. If empty, the value of
-# identity.region is used instead. If no such region is found
-# in the service catalog, the first found one is used. (string
-# value)
-#region=
-
-# Name of the backend1 (must be declared in cinder.conf)
-# (string value)
-#backend1_name=BACKEND_1
-
-# Name of the backend2 (must be declared in cinder.conf)
-# (string value)
-#backend2_name=BACKEND_2
-
-# Backend protocol to target when creating volume types
-# (string value)
-#storage_protocol=iSCSI
-
-# Backend vendor to target when creating volume types (string
-# value)
-#vendor_name=Open Source
-
-# Disk format to use when copying a volume to image (string
-# value)
-#disk_format=raw
-
-
-[compute-feature-enabled]
-
-#
-# Options defined in tempest.config
-#
-
-# If false, skip all nova v3 tests. (boolean value)
-#api_v3=true
-
-# If false, skip disk config tests (boolean value)
-#disk_config=true
-
-# A list of enabled extensions with a special entry all which
-# indicates every extension is enabled (list value)
-#api_extensions=all
-
-# A list of enabled v3 extensions with a special entry all
-# which indicates every extension is enabled (list value)
-#api_v3_extensions=all
-
-# Does the test environment support changing the admin
-# password? (boolean value)
-#change_password=false
-
-# Does the test environment support snapshots? (boolean value)
-#create_image=false
-
-# Does the test environment support resizing? (boolean value)
-#resize=false
-
-# Does the test environment support live migration available?
-# (boolean value)
-#live_migration=false
-
-# Does the test environment use block devices for live
-# migration (boolean value)
-#block_migration_for_live_migration=false
-
-# Does the test environment block migration support cinder
-# iSCSI volumes (boolean value)
-#block_migrate_cinder_iscsi=false
-
-
-[identity]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the Identity service. (string value)
-#catalog_type=identity
-
-# Set to True if using self-signed SSL certificates. (boolean
-# value)
-#disable_ssl_certificate_validation=false
-
-# Full URI of the OpenStack Identity API (Keystone), v2
-# (string value)
-#uri=<None>
-
-# Full URI of the OpenStack Identity API (Keystone), v3
-# (string value)
-#uri_v3=<None>
-
-# The identity region name to use. Also used as the other
-# services' region name unless they are set explicitly. If no
-# such region is found in the service catalog, the first found
-# one is used. (string value)
-#region=RegionOne
-
-# Username to use for Nova API requests. (string value)
-#username=demo
-
-# Tenant name to use for Nova API requests. (string value)
-#tenant_name=demo
-
-# Role required to administrate keystone. (string value)
-#admin_role=admin
-
-# API key to use when authenticating. (string value)
-#password=pass
-
-# Username of alternate user to use for Nova API requests.
-# (string value)
-#alt_username=<None>
-
-# Alternate user's Tenant name to use for Nova API requests.
-# (string value)
-#alt_tenant_name=<None>
-
-# API key to use when authenticating as alternate user.
-# (string value)
-#alt_password=<None>
-
-# Administrative Username to use forKeystone API requests.
-# (string value)
-#admin_username=admin
-
-# Administrative Tenant name to use for Keystone API requests.
-# (string value)
-#admin_tenant_name=admin
-
-# API key to use when authenticating as admin. (string value)
-#admin_password=pass
+# Status Change Test Interval (integer value)
+#build_interval=1
[cli]
@@ -433,44 +158,6 @@
#timeout=15
-[stress]
-
-#
-# Options defined in tempest.config
-#
-
-# Directory containing log files on the compute nodes (string
-# value)
-#nova_logdir=<None>
-
-# Maximum number of instances to create during test. (integer
-# value)
-#max_instances=16
-
-# Controller host. (string value)
-#controller=<None>
-
-# Controller host. (string value)
-#target_controller=<None>
-
-# ssh user. (string value)
-#target_ssh_user=<None>
-
-# Path to private key. (string value)
-#target_private_key_path=<None>
-
-# regexp for list of log files. (string value)
-#target_logfiles=<None>
-
-# time (in seconds) between log file error checks. (integer
-# value)
-#log_check_interval=60
-
-# The number of threads created while stress test. (integer
-# value)
-#default_thread_number_per_action=4
-
-
[compute]
#
@@ -581,77 +268,68 @@
# (integer value)
#shelved_offload_time=0
+# Allows test cases to create/destroy tenants and users. This
+# option enables isolated test cases and better parallel
+# execution, but also requires that OpenStack Identity API
+# admin credentials are known. (boolean value)
+#allow_tenant_isolation=false
-[scenario]
+
+[compute-admin]
#
# Options defined in tempest.config
#
-# Directory containing image files (string value)
-#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
+# Administrative Username to use for Nova API requests.
+# (string value)
+#username=admin
-# AMI image file name (string value)
-#ami_img_file=cirros-0.3.1-x86_64-blank.img
+# Administrative Tenant name to use for Nova API requests.
+# (string value)
+#tenant_name=admin
-# ARI image file name (string value)
-#ari_img_file=cirros-0.3.1-x86_64-initrd
-
-# AKI image file name (string value)
-#aki_img_file=cirros-0.3.1-x86_64-vmlinuz
-
-# ssh username for the image file (string value)
-#ssh_user=cirros
-
-# specifies how many resources to request at once. Used for
-# large operations testing. (integer value)
-#large_ops_number=0
+# API key to use when authenticating as admin. (string value)
+#password=pass
-[boto]
+[compute-feature-enabled]
#
# Options defined in tempest.config
#
-# EC2 URL (string value)
-#ec2_url=http://localhost:8773/services/Cloud
+# If false, skip all nova v3 tests. (boolean value)
+#api_v3=true
-# S3 URL (string value)
-#s3_url=http://localhost:8080
+# If false, skip disk config tests (boolean value)
+#disk_config=true
-# AWS Secret Key (string value)
-#aws_secret=<None>
+# A list of enabled v3 extensions with a special entry all
+# which indicates every extension is enabled (list value)
+#api_v3_extensions=all
-# AWS Access Key (string value)
-#aws_access=<None>
+# Does the test environment support changing the admin
+# password? (boolean value)
+#change_password=false
-# S3 Materials Path (string value)
-#s3_materials_path=/opt/stack/devstack/files/images/s3-materials/cirros-0.3.0
+# Does the test environment support snapshots? (boolean value)
+#create_image=false
-# ARI Ramdisk Image manifest (string value)
-#ari_manifest=cirros-0.3.0-x86_64-initrd.manifest.xml
+# Does the test environment support resizing? (boolean value)
+#resize=false
-# AMI Machine Image manifest (string value)
-#ami_manifest=cirros-0.3.0-x86_64-blank.img.manifest.xml
+# Does the test environment support live migration available?
+# (boolean value)
+#live_migration=false
-# AKI Kernel Image manifest (string value)
-#aki_manifest=cirros-0.3.0-x86_64-vmlinuz.manifest.xml
+# Does the test environment use block devices for live
+# migration (boolean value)
+#block_migration_for_live_migration=false
-# Instance type (string value)
-#instance_type=m1.tiny
-
-# boto Http socket timeout (integer value)
-#http_socket_timeout=3
-
-# boto num_retries on error (integer value)
-#num_retries=1
-
-# Status Change Timeout (integer value)
-#build_timeout=60
-
-# Status Change Test Interval (integer value)
-#build_interval=1
+# Does the test environment block migration support cinder
+# iSCSI volumes (boolean value)
+#block_migrate_cinder_iscsi=false
[dashboard]
@@ -667,6 +345,226 @@
#login_url=http://localhost/auth/login/
+[data_processing]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the data processing service. (string value)
+#catalog_type=data_processing
+
+
+[debug]
+
+#
+# Options defined in tempest.config
+#
+
+# Enable diagnostic commands (boolean value)
+#enable=true
+
+
+[identity]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Identity service. (string value)
+#catalog_type=identity
+
+# Set to True if using self-signed SSL certificates. (boolean
+# value)
+#disable_ssl_certificate_validation=false
+
+# Full URI of the OpenStack Identity API (Keystone), v2
+# (string value)
+#uri=<None>
+
+# Full URI of the OpenStack Identity API (Keystone), v3
+# (string value)
+#uri_v3=<None>
+
+# The identity region name to use. Also used as the other
+# services' region name unless they are set explicitly. If no
+# such region is found in the service catalog, the first found
+# one is used. (string value)
+#region=RegionOne
+
+# Username to use for Nova API requests. (string value)
+#username=demo
+
+# Tenant name to use for Nova API requests. (string value)
+#tenant_name=demo
+
+# Role required to administrate keystone. (string value)
+#admin_role=admin
+
+# API key to use when authenticating. (string value)
+#password=pass
+
+# Username of alternate user to use for Nova API requests.
+# (string value)
+#alt_username=<None>
+
+# Alternate user's Tenant name to use for Nova API requests.
+# (string value)
+#alt_tenant_name=<None>
+
+# API key to use when authenticating as alternate user.
+# (string value)
+#alt_password=<None>
+
+# Administrative Username to use forKeystone API requests.
+# (string value)
+#admin_username=admin
+
+# Administrative Tenant name to use for Keystone API requests.
+# (string value)
+#admin_tenant_name=admin
+
+# API key to use when authenticating as admin. (string value)
+#admin_password=pass
+
+
+[image]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Image service. (string value)
+#catalog_type=image
+
+# The image region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# http accessible image (string value)
+#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
+
+
+[image-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Is the v2 image API enabled (boolean value)
+#api_v2=true
+
+# Is the v1 image API enabled (boolean value)
+#api_v1=true
+
+
+[network]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Neutron service. (string value)
+#catalog_type=network
+
+# The network region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# The cidr block to allocate tenant networks from (string
+# value)
+#tenant_network_cidr=10.100.0.0/16
+
+# The mask bits for tenant networks (integer value)
+#tenant_network_mask_bits=28
+
+# Whether tenant network connectivity should be evaluated
+# directly (boolean value)
+#tenant_networks_reachable=false
+
+# Id of the public network that provides external connectivity
+# (string value)
+#public_network_id=
+
+# Id of the public router that provides external connectivity
+# (string value)
+#public_router_id=
+
+
+[network-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
+
+
+[object-storage]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Object-Storage service. (string value)
+#catalog_type=object-store
+
+# The object-storage region name to use. If empty, the value
+# of identity.region is used instead. If no such region is
+# found in the service catalog, the first found one is used.
+# (string value)
+#region=
+
+# Number of seconds to time on waiting for a containerto
+# container synchronization complete. (integer value)
+#container_sync_timeout=120
+
+# Number of seconds to wait while looping to check thestatus
+# of a container to container synchronization (integer value)
+#container_sync_interval=5
+
+# Role to add to users created for swift tests to enable
+# creating containers (string value)
+#operator_role=Member
+
+
+[object-storage-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Set to True if the Container Quota middleware is enabled
+# (boolean value)
+#container_quotas=true
+
+# Set to True if the Account Quota middleware is enabled
+# (boolean value)
+#accounts_quotas=true
+
+# Set to True if the Crossdomain middleware is enabled
+# (boolean value)
+#crossdomain=true
+
+# Set to True if the TempURL middleware is enabled (boolean
+# value)
+#tempurl=true
+
+
[orchestration]
#
@@ -682,12 +580,6 @@
# value)
#region=
-# Allows test cases to create/destroy tenants and users. This
-# option enables isolated test cases and better parallel
-# execution, but also requires that OpenStack Identity API
-# admin credentials are known. (boolean value)
-#allow_tenant_isolation=false
-
# Time in seconds between build status checks. (integer value)
#build_interval=1
@@ -712,14 +604,30 @@
#max_template_size=524288
-[debug]
+[scenario]
#
# Options defined in tempest.config
#
-# Enable diagnostic commands (boolean value)
-#enable=true
+# Directory containing image files (string value)
+#img_dir=/opt/stack/new/devstack/files/images/cirros-0.3.1-x86_64-uec
+
+# AMI image file name (string value)
+#ami_img_file=cirros-0.3.1-x86_64-blank.img
+
+# ARI image file name (string value)
+#ari_img_file=cirros-0.3.1-x86_64-initrd
+
+# AKI image file name (string value)
+#aki_img_file=cirros-0.3.1-x86_64-vmlinuz
+
+# ssh username for the image file (string value)
+#ssh_user=cirros
+
+# specifies how many resources to request at once. Used for
+# large operations testing. (integer value)
+#large_ops_number=0
[service_available]
@@ -765,3 +673,109 @@
#savanna=false
+[stress]
+
+#
+# Options defined in tempest.config
+#
+
+# Directory containing log files on the compute nodes (string
+# value)
+#nova_logdir=<None>
+
+# Maximum number of instances to create during test. (integer
+# value)
+#max_instances=16
+
+# Controller host. (string value)
+#controller=<None>
+
+# Controller host. (string value)
+#target_controller=<None>
+
+# ssh user. (string value)
+#target_ssh_user=<None>
+
+# Path to private key. (string value)
+#target_private_key_path=<None>
+
+# regexp for list of log files. (string value)
+#target_logfiles=<None>
+
+# time (in seconds) between log file error checks. (integer
+# value)
+#log_check_interval=60
+
+# The number of threads created while stress test. (integer
+# value)
+#default_thread_number_per_action=4
+
+
+[telemetry]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Telemetry service. (string value)
+#catalog_type=metering
+
+
+[volume]
+
+#
+# Options defined in tempest.config
+#
+
+# Time in seconds between volume availability checks. (integer
+# value)
+#build_interval=10
+
+# Timeout in seconds to wait for a volume to becomeavailable.
+# (integer value)
+#build_timeout=300
+
+# Catalog type of the Volume Service (string value)
+#catalog_type=volume
+
+# The volume region name to use. If empty, the value of
+# identity.region is used instead. If no such region is found
+# in the service catalog, the first found one is used. (string
+# value)
+#region=
+
+# Name of the backend1 (must be declared in cinder.conf)
+# (string value)
+#backend1_name=BACKEND_1
+
+# Name of the backend2 (must be declared in cinder.conf)
+# (string value)
+#backend2_name=BACKEND_2
+
+# Backend protocol to target when creating volume types
+# (string value)
+#storage_protocol=iSCSI
+
+# Backend vendor to target when creating volume types (string
+# value)
+#vendor_name=Open Source
+
+# Disk format to use when copying a volume to image (string
+# value)
+#disk_format=raw
+
+
+[volume-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Runs Cinder multi-backend test (requires 2 backends)
+# (boolean value)
+#multi_backend=false
+
+# Is the v1 volume API enabled (boolean value)
+#api_v1=true
+
+
diff --git a/requirements.txt b/requirements.txt
index cd11aa7..e070549 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,7 +18,6 @@
keyring>=1.6.1,<2.0
testrepository>=0.0.17
oslo.config>=1.2.0
-eventlet>=0.13.0
six>=1.4.1
iso8601>=0.1.8
fixtures>=0.3.14
diff --git a/tempest/api/compute/__init__.py b/tempest/api/compute/__init__.py
index a385f83..e69de29 100644
--- a/tempest/api/compute/__init__.py
+++ b/tempest/api/compute/__init__.py
@@ -1,27 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2012 OpenStack Foundation
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-# from tempest import config
-from tempest.openstack.common import log as logging
-
-LOG = logging.getLogger(__name__)
-
-# CONFIG = config.CONF
-# CREATE_IMAGE_ENABLED = CONFIG.compute_feature_enabled.create_image
-# RESIZE_AVAILABLE = CONFIG.compute_feature_enabled.resize
-# CHANGE_PASSWORD_AVAILABLE = CONFIG.compute_feature_enabled.change_password
-# DISK_CONFIG_ENABLED = CONFIG.compute_feature_enabled.disk_config
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 6b24e72..dbf7967 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -17,7 +17,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
@@ -41,18 +41,18 @@
hostname = hosts[0]['host_name']
return hostname
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_list_hosts_with_non_admin_user(self):
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.list_hosts)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_nonexistent_hostname(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
self.assertRaises(exceptions.NotFound,
self.client.show_host_detail, nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_show_host_detail_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -60,7 +60,7 @@
self.non_admin_client.show_host_detail,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -68,7 +68,8 @@
self.non_admin_client.update_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.skip_because(bug="1261964", interface="xml")
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_extra_param(self):
# only 'status' and 'maintenance_mode' are the valid params.
hostname = self._get_host_name()
@@ -80,7 +81,7 @@
maintenance_mode='enable',
param='XXX')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_invalid_status(self):
# 'status' can only be 'enable' or 'disable'
hostname = self._get_host_name()
@@ -91,7 +92,7 @@
status='invalid',
maintenance_mode='enable')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_with_invalid_maintenance_mode(self):
# 'maintenance_mode' can only be 'enable' or 'disable'
hostname = self._get_host_name()
@@ -102,7 +103,7 @@
status='enable',
maintenance_mode='invalid')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_host_without_param(self):
# 'status' or 'maintenance_mode' needed for host update
hostname = self._get_host_name()
@@ -111,7 +112,7 @@
self.client.update_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -121,7 +122,7 @@
status='enable',
maintenance_mode='enable')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_startup_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -129,7 +130,7 @@
self.client.startup_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_startup_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -137,7 +138,7 @@
self.non_admin_client.startup_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shutdown_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -145,7 +146,7 @@
self.client.shutdown_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shutdown_host_with_non_admin_user(self):
hostname = self._get_host_name()
@@ -153,7 +154,7 @@
self.non_admin_client.shutdown_host,
hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_nonexistent_host(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
@@ -161,7 +162,7 @@
self.client.reboot_host,
nonexitent_hostname)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_host_with_non_admin_user(self):
hostname = self._get_host_name()
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index ef4f51f..bd431d4 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -38,24 +38,27 @@
self.assertEqual(200, resp.status)
return hypers
+ def assertHypervisors(self, hypers):
+ self.assertTrue(len(hypers) > 0, "No hypervisors found: %s" % hypers)
+
@attr(type='gate')
def test_get_hypervisor_list(self):
# List of hypervisor and available hypervisors hostname
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
@attr(type='gate')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
resp, hypers = self.client.get_hypervisor_list_details()
self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
@attr(type='gate')
def test_get_hypervisor_show_details(self):
# Display the details of the specified hypervisor
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
resp, details = (self.client.
get_hypervisor_show_details(hypers[0]['id']))
@@ -68,7 +71,7 @@
def test_get_hypervisor_show_servers(self):
# Show instances about the specific hypervisors
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
hostname = hypers[0]['hypervisor_hostname']
resp, hypervisors = self.client.get_hypervisor_servers(hostname)
@@ -87,18 +90,29 @@
# Verify that GET shows the specified hypervisor uptime
hypers = self._list_hypervisors()
- resp, uptime = self.client.get_hypervisor_uptime(hypers[0]['id'])
- self.assertEqual(200, resp.status)
- self.assertTrue(len(uptime) > 0)
+ has_valid_uptime = False
+ for hyper in hypers:
+ # because hypervisors might be disabled, this loops looking
+ # for any good hit.
+ try:
+ resp, uptime = self.client.get_hypervisor_uptime(hyper['id'])
+ if (resp.status == 200) and (len(uptime) > 0):
+ has_valid_uptime = True
+ break
+ except Exception:
+ pass
+ self.assertTrue(
+ has_valid_uptime,
+ "None of the hypervisors had a valid uptime: %s" % hypers)
@attr(type='gate')
def test_search_hypervisor(self):
hypers = self._list_hypervisors()
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
resp, hypers = self.client.search_hypervisor(
hypers[0]['hypervisor_hostname'])
self.assertEqual(200, resp.status)
- self.assertTrue(len(hypers) > 0)
+ self.assertHypervisors(hypers)
class HypervisorAdminTestXML(HypervisorAdminTestJSON):
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index a599f06..c416ad2 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -18,7 +18,6 @@
import datetime
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
import time
@@ -83,33 +82,6 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
- @attr(type=['negative', 'gate'])
- def test_get_usage_tenant_with_empty_tenant_id(self):
- # Get usage for a specific tenant empty
- params = {'start': self.start,
- 'end': self.end}
- self.assertRaises(exceptions.NotFound,
- self.adm_client.get_tenant_usage,
- '', params)
-
- @attr(type=['negative', 'gate'])
- def test_get_usage_tenant_with_invalid_date(self):
- # Get usage for tenant with invalid date
- params = {'start': self.end,
- 'end': self.start}
- self.assertRaises(exceptions.BadRequest,
- self.adm_client.get_tenant_usage,
- self.tenant_id, params)
-
- @attr(type=['negative', 'gate'])
- def test_list_usage_all_tenants_with_non_admin_user(self):
- # Get usage for all tenants with non admin user
- params = {'start': self.start,
- 'end': self.end,
- 'detailed': int(bool(True))}
- self.assertRaises(exceptions.Unauthorized,
- self.client.list_tenant_usages, params)
-
class TenantUsagesTestXML(TenantUsagesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
new file mode 100644
index 0000000..7e5168e
--- /dev/null
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -0,0 +1,76 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import datetime
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(TenantUsagesNegativeTestJSON, cls).setUpClass()
+ cls.adm_client = cls.os_adm.tenant_usages_client
+ cls.client = cls.os.tenant_usages_client
+ cls.identity_client = cls._get_identity_admin_client()
+ now = datetime.datetime.now()
+ cls.start = cls._parse_strtime(now - datetime.timedelta(days=1))
+ cls.end = cls._parse_strtime(now + datetime.timedelta(days=1))
+
+ @classmethod
+ def _parse_strtime(cls, at):
+ # Returns formatted datetime
+ return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
+
+ @attr(type=['negative', 'gate'])
+ def test_get_usage_tenant_with_empty_tenant_id(self):
+ # Get usage for a specific tenant empty
+ params = {'start': self.start,
+ 'end': self.end}
+ self.assertRaises(exceptions.NotFound,
+ self.adm_client.get_tenant_usage,
+ '', params)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_usage_tenant_with_invalid_date(self):
+ # Get usage for tenant with invalid date
+ params = {'start': self.end,
+ 'end': self.start}
+ resp, tenants = self.identity_client.list_tenants()
+ tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
+ self.client.tenant_name][0]
+ self.assertRaises(exceptions.BadRequest,
+ self.adm_client.get_tenant_usage,
+ tenant_id, params)
+
+ @attr(type=['negative', 'gate'])
+ def test_list_usage_all_tenants_with_non_admin_user(self):
+ # Get usage for all tenants with non admin user
+ params = {'start': self.start,
+ 'end': self.end,
+ 'detailed': int(bool(True))}
+ self.assertRaises(exceptions.Unauthorized,
+ self.client.list_tenant_usages, params)
+
+
+class TenantUsagesNegativeTestXML(TenantUsagesNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 9cb425a..b060f15 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -100,9 +100,8 @@
except exceptions.NotFound:
# The image may have already been deleted which is OK.
pass
- except Exception as exc:
- LOG.info('Exception raised deleting image %s', image_id)
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Exception raised deleting image %s' % image_id)
pass
@classmethod
@@ -214,8 +213,8 @@
try:
cls.servers_client.delete_server(server_id)
cls.servers_client.wait_for_server_termination(server_id)
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Failed to delete server %s' % server_id)
pass
resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
cls.password = server['adminPass']
@@ -260,14 +259,20 @@
cls.servers_client = cls.os.servers_v3_client
cls.images_client = cls.os.image_client
+ cls.flavors_client = cls.os.flavors_v3_client
cls.services_client = cls.os.services_v3_client
cls.extensions_client = cls.os.extensions_v3_client
cls.availability_zone_client = cls.os.availability_zone_v3_client
cls.interfaces_client = cls.os.interfaces_v3_client
cls.hypervisor_client = cls.os.hypervisor_v3_client
+ cls.keypairs_client = cls.os.keypairs_v3_client
cls.tenant_usages_client = cls.os.tenant_usages_v3_client
cls.volumes_client = cls.os.volumes_client
cls.certificates_client = cls.os.certificates_v3_client
+ cls.keypairs_client = cls.os.keypairs_v3_client
+ cls.aggregates_client = cls.os.aggregates_v3_client
+ cls.hosts_client = cls.os.hosts_v3_client
+ cls.quotas_client = cls.os.quotas_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
@@ -294,8 +299,8 @@
try:
cls.servers_client.delete_server(server_id)
cls.servers_client.wait_for_server_termination(server_id)
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Failed to delete server %s' % server_id)
pass
resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs)
cls.password = server['admin_password']
@@ -326,9 +331,13 @@
os_adm = clients.ComputeAdminManager(interface=cls._interface)
cls.os_adm = os_adm
- cls.severs_admin_client = cls.os_adm.servers_v3_client
+ cls.servers_admin_client = cls.os_adm.servers_v3_client
cls.services_admin_client = cls.os_adm.services_v3_client
cls.availability_zone_admin_client = \
cls.os_adm.availability_zone_v3_client
cls.hypervisor_admin_client = cls.os_adm.hypervisor_v3_client
cls.tenant_usages_admin_client = cls.os_adm.tenant_usages_v3_client
+ cls.flavors_admin_client = cls.os_adm.flavors_v3_client
+ cls.aggregates_admin_client = cls.os_adm.aggregates_v3_client
+ cls.hosts_admin_client = cls.os_adm.hosts_v3_client
+ cls.quotas_admin_client = cls.os_adm.quotas_v3_client
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index f4ad449..32e7b39 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -51,17 +51,15 @@
# Positive test:Allocation of a new floating IP to a project
# should be successful
resp, body = self.client.create_floating_ip()
- self.assertEqual(200, resp.status)
floating_ip_id_allocated = body['id']
- try:
- resp, floating_ip_details = \
- self.client.get_floating_ip_details(floating_ip_id_allocated)
- # Checking if the details of allocated IP is in list of floating IP
- resp, body = self.client.list_floating_ips()
- self.assertIn(floating_ip_details, body)
- finally:
- # Deleting the floating IP which is created in this method
- self.client.delete_floating_ip(floating_ip_id_allocated)
+ self.addCleanup(self.client.delete_floating_ip,
+ floating_ip_id_allocated)
+ self.assertEqual(200, resp.status)
+ resp, floating_ip_details = \
+ self.client.get_floating_ip_details(floating_ip_id_allocated)
+ # Checking if the details of allocated IP is in list of floating IP
+ resp, body = self.client.list_floating_ips()
+ self.assertIn(floating_ip_details, body)
@attr(type='gate')
def test_delete_floating_ip(self):
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index e4d03ae..9238994 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -54,25 +54,23 @@
def test_get_floating_ip_details(self):
# Positive test:Should be able to GET the details of floatingIP
# Creating a floating IP for which details are to be checked
- try:
- resp, body = self.client.create_floating_ip()
- floating_ip_instance_id = body['instance_id']
- floating_ip_ip = body['ip']
- floating_ip_fixed_ip = body['fixed_ip']
- floating_ip_id = body['id']
- resp, body = \
- self.client.get_floating_ip_details(floating_ip_id)
- self.assertEqual(200, resp.status)
- # Comparing the details of floating IP
- self.assertEqual(floating_ip_instance_id,
- body['instance_id'])
- self.assertEqual(floating_ip_ip, body['ip'])
- self.assertEqual(floating_ip_fixed_ip,
- body['fixed_ip'])
- self.assertEqual(floating_ip_id, body['id'])
- # Deleting the floating IP created in this method
- finally:
- self.client.delete_floating_ip(floating_ip_id)
+ resp, body = self.client.create_floating_ip()
+ floating_ip_id = body['id']
+ self.addCleanup(self.client.delete_floating_ip,
+ floating_ip_id)
+ floating_ip_instance_id = body['instance_id']
+ floating_ip_ip = body['ip']
+ floating_ip_fixed_ip = body['fixed_ip']
+ resp, body = \
+ self.client.get_floating_ip_details(floating_ip_id)
+ self.assertEqual(200, resp.status)
+ # Comparing the details of floating IP
+ self.assertEqual(floating_ip_instance_id,
+ body['instance_id'])
+ self.assertEqual(floating_ip_ip, body['ip'])
+ self.assertEqual(floating_ip_fixed_ip,
+ body['fixed_ip'])
+ self.assertEqual(floating_ip_id, body['id'])
@attr(type='gate')
def test_list_floating_ip_pools(self):
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 618abe2..76e0cae 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -17,7 +17,6 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
from tempest.test import attr
@@ -110,49 +109,6 @@
expected = {'key2': 'value2'}
self.assertEqual(expected, resp_metadata)
- @attr(type=['negative', 'gate'])
- def test_list_nonexistant_image_metadata(self):
- # Negative test: List on nonexistant image
- # metadata should not happen
- self.assertRaises(exceptions.NotFound, self.client.list_image_metadata,
- 999)
-
- @attr(type=['negative', 'gate'])
- def test_update_nonexistant_image_metadata(self):
- # Negative test:An update should not happen for a non-existent image
- meta = {'key1': 'alt1', 'key2': 'alt2'}
- self.assertRaises(exceptions.NotFound,
- self.client.update_image_metadata, 999, meta)
-
- @attr(type=['negative', 'gate'])
- def test_get_nonexistant_image_metadata_item(self):
- # Negative test: Get on non-existent image should not happen
- self.assertRaises(exceptions.NotFound,
- self.client.get_image_metadata_item, 999, 'key2')
-
- @attr(type=['negative', 'gate'])
- def test_set_nonexistant_image_metadata(self):
- # Negative test: Metadata should not be set to a non-existent image
- meta = {'key1': 'alt1', 'key2': 'alt2'}
- self.assertRaises(exceptions.NotFound, self.client.set_image_metadata,
- 999, meta)
-
- @attr(type=['negative', 'gate'])
- def test_set_nonexistant_image_metadata_item(self):
- # Negative test: Metadata item should not be set to a
- # nonexistant image
- meta = {'key1': 'alt'}
- self.assertRaises(exceptions.NotFound,
- self.client.set_image_metadata_item, 999, 'key1',
- meta)
-
- @attr(type=['negative', 'gate'])
- def test_delete_nonexistant_image_metadata_item(self):
- # Negative test: Shouldn't be able to delete metadata
- # item from non-existent image
- self.assertRaises(exceptions.NotFound,
- self.client.delete_image_metadata_item, 999, 'key1')
-
class ImagesMetadataTestXML(ImagesMetadataTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
new file mode 100644
index 0000000..1767e5d
--- /dev/null
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -0,0 +1,81 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesMetadataTestJSON, cls).setUpClass()
+ cls.client = cls.images_client
+
+ @attr(type=['negative', 'gate'])
+ def test_list_nonexistent_image_metadata(self):
+ # Negative test: List on nonexistent image
+ # metadata should not happen
+ self.assertRaises(exceptions.NotFound, self.client.list_image_metadata,
+ data_utils.rand_uuid())
+
+ @attr(type=['negative', 'gate'])
+ def test_update_nonexistent_image_metadata(self):
+ # Negative test:An update should not happen for a non-existent image
+ meta = {'key1': 'alt1', 'key2': 'alt2'}
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_image_metadata,
+ data_utils.rand_uuid(), meta)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_nonexistent_image_metadata_item(self):
+ # Negative test: Get on non-existent image should not happen
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_image_metadata_item,
+ data_utils.rand_uuid(), 'key2')
+
+ @attr(type=['negative', 'gate'])
+ def test_set_nonexistent_image_metadata(self):
+ # Negative test: Metadata should not be set to a non-existent image
+ meta = {'key1': 'alt1', 'key2': 'alt2'}
+ self.assertRaises(exceptions.NotFound, self.client.set_image_metadata,
+ data_utils.rand_uuid(), meta)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_nonexistent_image_metadata_item(self):
+ # Negative test: Metadata item should not be set to a
+ # nonexistent image
+ meta = {'key1': 'alt'}
+ self.assertRaises(exceptions.NotFound,
+ self.client.set_image_metadata_item,
+ data_utils.rand_uuid(), 'key1',
+ meta)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_nonexistent_image_metadata_item(self):
+ # Negative test: Shouldn't be able to delete metadata
+ # item from non-existent image
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_image_metadata_item,
+ data_utils.rand_uuid(), 'key1')
+
+
+class ImagesMetadataTestXML(ImagesMetadataTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index c711bd5..26cc3f6 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -46,10 +46,11 @@
try:
self.servers_client.wait_for_server_status(self.server_id,
'ACTIVE')
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('server %s timed out to become ACTIVE. rebuilding'
+ % self.server_id)
# Rebuild server if cannot reach the ACTIVE state
- # Usually it means the server had a serius accident
+ # Usually it means the server had a serious accident
self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index b8a4304..5e235d1 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -45,10 +45,11 @@
try:
self.servers_client.wait_for_server_status(self.server_id,
'ACTIVE')
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('server %s timed out to become ACTIVE. rebuilding'
+ % self.server_id)
# Rebuild server if cannot reach the ACTIVE state
- # Usually it means the server had a serius accident
+ # Usually it means the server had a serious accident
self._reset_server()
def _reset_server(self):
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index ac2ecba..bfdd8b2 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -59,8 +59,8 @@
resp, cls.image2 = cls.create_image_from_server(
cls.server1['id'], wait_until='ACTIVE')
cls.image2_id = cls.image2['id']
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('setUpClass failed')
cls.tearDownClass()
raise
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index 2809244..908d537 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -16,8 +16,7 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
@@ -27,9 +26,8 @@
def setUpClass(cls):
super(AbsoluteLimitsTestJSON, cls).setUpClass()
cls.client = cls.limits_client
- cls.server_client = cls.servers_client
- @attr(type='gate')
+ @test.attr(type='gate')
def test_absLimits_get(self):
# To check if all limits are present in the response
resp, absolute_limits = self.client.get_absolute_limits()
@@ -49,25 +47,6 @@
"Failed to find element %s in absolute limits list"
% ', '.join(ele for ele in missing_elements))
- @attr(type=['negative', 'gate'])
- def test_max_image_meta_exceed_limit(self):
- # We should not create vm with image meta over maxImageMeta limit
- # Get max limit value
- max_meta = self.client.get_specific_absolute_limit('maxImageMeta')
-
- # Create server should fail, since we are passing > metadata Limit!
- max_meta_data = int(max_meta) + 1
-
- meta_data = {}
- for xx in range(max_meta_data):
- meta_data[str(xx)] = str(xx)
-
- self.assertRaises(exceptions.OverLimit,
- self.server_client.create_server,
- name='test', meta=meta_data,
- flavor_ref=self.flavor_ref,
- image_ref=self.image_ref)
-
class AbsoluteLimitsTestXML(AbsoluteLimitsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py
new file mode 100644
index 0000000..8547403
--- /dev/null
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -0,0 +1,53 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest import test
+
+
+class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AbsoluteLimitsNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.limits_client
+ cls.server_client = cls.servers_client
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_image_meta_exceed_limit(self):
+ # We should not create vm with image meta over maxImageMeta limit
+ # Get max limit value
+ max_meta = self.client.get_specific_absolute_limit('maxImageMeta')
+
+ # Create server should fail, since we are passing > metadata Limit!
+ max_meta_data = int(max_meta) + 1
+
+ meta_data = {}
+ for xx in range(max_meta_data):
+ meta_data[str(xx)] = str(xx)
+
+ self.assertRaises(exceptions.OverLimit,
+ self.server_client.create_server,
+ name='test', meta=meta_data,
+ flavor_ref=self.flavor_ref,
+ image_ref=self.image_ref)
+
+
+class AbsoluteLimitsNegativeTestXML(AbsoluteLimitsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 95e9171..4ae65be 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -15,17 +15,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-import uuid
-
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
-
-CONF = config.CONF
+from tempest import test
class SecurityGroupsTestJSON(base.BaseV2ComputeTest):
@@ -35,13 +28,12 @@
def setUpClass(cls):
super(SecurityGroupsTestJSON, cls).setUpClass()
cls.client = cls.security_groups_client
- cls.neutron_available = cls.config.service_available.neutron
def _delete_security_group(self, securitygroup_id):
resp, _ = self.client.delete_security_group(securitygroup_id)
self.assertEqual(202, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_security_groups_create_list_delete(self):
# Positive test:Should return the list of Security Groups
# Create 3 Security Groups
@@ -69,7 +61,7 @@
# TODO(afazekas): scheduled for delete,
# test_security_group_create_get_delete covers it
- @attr(type='gate')
+ @test.attr(type='gate')
def test_security_group_create_delete(self):
# Security Group should be created, verified and deleted
s_name = data_utils.rand_name('securitygroup-')
@@ -88,7 +80,7 @@
"The created Security Group name is "
"not equal to the requested name")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_security_group_create_get_delete(self):
# Security Group should be created, fetched and deleted
s_name = data_utils.rand_name('securitygroup-')
@@ -112,121 +104,7 @@
"The fetched Security Group is different "
"from the created Group")
- @attr(type=['negative', 'smoke'])
- def test_security_group_get_nonexistant_group(self):
- # Negative test:Should not be able to GET the details
- # of non-existent Security Group
- security_group_id = []
- resp, body = self.client.list_security_groups()
- for i in range(len(body)):
- security_group_id.append(body[i]['id'])
- # Creating a non-existent Security Group id
- while True:
- non_exist_id = data_utils.rand_int_id(start=999)
- if self.neutron_available:
- non_exist_id = str(uuid.uuid4())
- if non_exist_id not in security_group_id:
- break
- self.assertRaises(exceptions.NotFound, self.client.get_security_group,
- non_exist_id)
-
- @skip_because(bug="1161411",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_group_create_with_invalid_group_name(self):
- # Negative test: Security Group should not be created with group name
- # as an empty string/with white spaces/chars more than 255
- s_description = data_utils.rand_name('description-')
- # Create Security Group with empty string as group name
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, "", s_description)
- # Create Security Group with white space in group name
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, " ",
- s_description)
- # Create Security Group with group name longer than 255 chars
- s_name = 'securitygroup-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, s_name,
- s_description)
-
- @skip_because(bug="1161411",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_group_create_with_invalid_group_description(self):
- # Negative test:Security Group should not be created with description
- # as an empty string/with white spaces/chars more than 255
- s_name = data_utils.rand_name('securitygroup-')
- # Create Security Group with empty string as description
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, s_name, "")
- # Create Security Group with white space in description
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, s_name, " ")
- # Create Security Group with group description longer than 255 chars
- s_description = 'description-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, s_name,
- s_description)
-
- @testtools.skipIf(CONF.service_available.neutron,
- "Neutron allows duplicate names for security groups")
- @attr(type=['negative', 'gate'])
- def test_security_group_create_with_duplicate_name(self):
- # Negative test:Security Group with duplicate name should not
- # be created
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, security_group =\
- self.client.create_security_group(s_name, s_description)
- self.assertEqual(200, resp.status)
-
- self.addCleanup(self.client.delete_security_group,
- security_group['id'])
- # Now try the Security Group with the same 'Name'
- self.assertRaises(exceptions.BadRequest,
- self.client.create_security_group, s_name,
- s_description)
-
- @attr(type=['negative', 'gate'])
- def test_delete_the_default_security_group(self):
- # Negative test:Deletion of the "default" Security Group should Fail
- default_security_group_id = None
- resp, body = self.client.list_security_groups()
- for i in range(len(body)):
- if body[i]['name'] == 'default':
- default_security_group_id = body[i]['id']
- break
- # Deleting the "default" Security Group
- self.assertRaises(exceptions.BadRequest,
- self.client.delete_security_group,
- default_security_group_id)
-
- @attr(type=['negative', 'smoke'])
- def test_delete_nonexistant_security_group(self):
- # Negative test:Deletion of a non-existent Security Group should Fail
- security_group_id = []
- resp, body = self.client.list_security_groups()
- for i in range(len(body)):
- security_group_id.append(body[i]['id'])
- # Creating non-existent Security Group
- while True:
- non_exist_id = data_utils.rand_int_id(start=999)
- if self.neutron_available:
- non_exist_id = str(uuid.uuid4())
- if non_exist_id not in security_group_id:
- break
- self.assertRaises(exceptions.NotFound,
- self.client.delete_security_group, non_exist_id)
-
- @attr(type=['negative', 'gate'])
- def test_delete_security_group_without_passing_id(self):
- # Negative test:Deletion of a Security Group with out passing ID
- # should Fail
- self.assertRaises(exceptions.NotFound,
- self.client.delete_security_group, '')
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_server_security_groups(self):
# Checks that security groups may be added and linked to a server
# and not deleted if the server is active.
@@ -282,6 +160,33 @@
self.client.delete_security_group(sg2_id)
self.assertEqual(202, resp.status)
+ @test.attr(type='gate')
+ def test_update_security_groups(self):
+ # Update security group name and description
+ # Create a security group
+ s_name = data_utils.rand_name('sg-')
+ s_description = data_utils.rand_name('description-')
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
+ self.assertEqual(200, resp.status)
+ self.assertIn('id', securitygroup)
+ securitygroup_id = securitygroup['id']
+ self.addCleanup(self._delete_security_group,
+ securitygroup_id)
+ # Update the name and description
+ s_new_name = data_utils.rand_name('sg-hth-')
+ s_new_des = data_utils.rand_name('description-hth-')
+ resp, sg_new = \
+ self.client.update_security_group(securitygroup_id,
+ name=s_new_name,
+ description=s_new_des)
+ self.assertEqual(200, resp.status)
+ # get the security group
+ resp, fetched_group = \
+ self.client.get_security_group(securitygroup_id)
+ self.assertEqual(s_new_name, fetched_group['name'])
+ self.assertEqual(s_new_des, fetched_group['description'])
+
class SecurityGroupsTestXML(SecurityGroupsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
new file mode 100644
index 0000000..6a8e604
--- /dev/null
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -0,0 +1,216 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import testtools
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest import exceptions
+from tempest import test
+
+CONF = config.CONF
+
+
+class SecurityGroupsNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(SecurityGroupsNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.security_groups_client
+ cls.neutron_available = cls.config.service_available.neutron
+
+ def _delete_security_group(self, securitygroup_id):
+ resp, _ = self.client.delete_security_group(securitygroup_id)
+ self.assertEqual(202, resp.status)
+
+ def _generate_a_non_existent_security_group_id(self):
+ security_group_id = []
+ resp, body = self.client.list_security_groups()
+ for i in range(len(body)):
+ security_group_id.append(body[i]['id'])
+ # Generate a non-existent security group id
+ while True:
+ non_exist_id = data_utils.rand_int_id(start=999)
+ if self.neutron_available:
+ non_exist_id = data_utils.rand_uuid()
+ if non_exist_id not in security_group_id:
+ break
+ return non_exist_id
+
+ @test.attr(type=['negative', 'smoke'])
+ def test_security_group_get_nonexistent_group(self):
+ # Negative test:Should not be able to GET the details
+ # of non-existent Security Group
+ non_exist_id = self._generate_a_non_existent_security_group_id()
+ self.assertRaises(exceptions.NotFound, self.client.get_security_group,
+ non_exist_id)
+
+ @test.skip_because(bug="1161411",
+ condition=CONF.service_available.neutron)
+ @test.attr(type=['negative', 'gate'])
+ def test_security_group_create_with_invalid_group_name(self):
+ # Negative test: Security Group should not be created with group name
+ # as an empty string/with white spaces/chars more than 255
+ s_description = data_utils.rand_name('description-')
+ # Create Security Group with empty string as group name
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, "", s_description)
+ # Create Security Group with white space in group name
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, " ",
+ s_description)
+ # Create Security Group with group name longer than 255 chars
+ s_name = 'securitygroup-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
+
+ @test.skip_because(bug="1161411",
+ condition=CONF.service_available.neutron)
+ @test.attr(type=['negative', 'gate'])
+ def test_security_group_create_with_invalid_group_description(self):
+ # Negative test:Security Group should not be created with description
+ # as an empty string/with white spaces/chars more than 255
+ s_name = data_utils.rand_name('securitygroup-')
+ # Create Security Group with empty string as description
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name, "")
+ # Create Security Group with white space in description
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name, " ")
+ # Create Security Group with group description longer than 255 chars
+ s_description = 'description-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
+
+ @testtools.skipIf(CONF.service_available.neutron,
+ "Neutron allows duplicate names for security groups")
+ @test.attr(type=['negative', 'gate'])
+ def test_security_group_create_with_duplicate_name(self):
+ # Negative test:Security Group with duplicate name should not
+ # be created
+ s_name = data_utils.rand_name('securitygroup-')
+ s_description = data_utils.rand_name('description-')
+ resp, security_group =\
+ self.client.create_security_group(s_name, s_description)
+ self.assertEqual(200, resp.status)
+
+ self.addCleanup(self.client.delete_security_group,
+ security_group['id'])
+ # Now try the Security Group with the same 'Name'
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_security_group, s_name,
+ s_description)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_the_default_security_group(self):
+ # Negative test:Deletion of the "default" Security Group should Fail
+ default_security_group_id = None
+ resp, body = self.client.list_security_groups()
+ for i in range(len(body)):
+ if body[i]['name'] == 'default':
+ default_security_group_id = body[i]['id']
+ break
+ # Deleting the "default" Security Group
+ self.assertRaises(exceptions.BadRequest,
+ self.client.delete_security_group,
+ default_security_group_id)
+
+ @test.attr(type=['negative', 'smoke'])
+ def test_delete_nonexistent_security_group(self):
+ # Negative test:Deletion of a non-existent Security Group should fail
+ non_exist_id = self._generate_a_non_existent_security_group_id()
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_security_group, non_exist_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_security_group_without_passing_id(self):
+ # Negative test:Deletion of a Security Group with out passing ID
+ # should Fail
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_security_group, '')
+
+ @testtools.skipIf(CONF.service_available.neutron,
+ "Neutron not check the security_group_id")
+ @test.attr(type=['negative', 'gate'])
+ def test_update_security_group_with_invalid_sg_id(self):
+ # Update security_group with invalid sg_id should fail
+ s_name = data_utils.rand_name('sg-')
+ s_description = data_utils.rand_name('description-')
+ # Create a non int sg_id
+ sg_id_invalid = data_utils.rand_name('sg-')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_security_group, sg_id_invalid,
+ name=s_name, description=s_description)
+
+ @testtools.skipIf(CONF.service_available.neutron,
+ "Neutron not check the security_group_name")
+ @test.attr(type=['negative', 'gate'])
+ def test_update_security_group_with_invalid_sg_name(self):
+ # Update security_group with invalid sg_name should fail
+ s_name = data_utils.rand_name('sg-')
+ s_description = data_utils.rand_name('description-')
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
+ self.assertEqual(200, resp.status)
+ self.assertIn('id', securitygroup)
+ securitygroup_id = securitygroup['id']
+ self.addCleanup(self._delete_security_group,
+ securitygroup_id)
+ # Update Security Group with group name longer than 255 chars
+ s_new_name = 'securitygroup-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_security_group,
+ securitygroup_id, name=s_new_name)
+
+ @testtools.skipIf(CONF.service_available.neutron,
+ "Neutron not check the security_group_description")
+ @test.attr(type=['negative', 'gate'])
+ def test_update_security_group_with_invalid_sg_des(self):
+ # Update security_group with invalid sg_des should fail
+ s_name = data_utils.rand_name('sg-')
+ s_description = data_utils.rand_name('description-')
+ resp, securitygroup = \
+ self.client.create_security_group(s_name, s_description)
+ self.assertEqual(200, resp.status)
+ self.assertIn('id', securitygroup)
+ securitygroup_id = securitygroup['id']
+ self.addCleanup(self._delete_security_group,
+ securitygroup_id)
+ # Update Security Group with group description longer than 255 chars
+ s_new_des = 'des-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_security_group,
+ securitygroup_id, description=s_new_des)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_non_existent_security_group(self):
+ # Update a non-existent Security Group should Fail
+ non_exist_id = self._generate_a_non_existent_security_group_id()
+ s_name = data_utils.rand_name('sg-')
+ s_description = data_utils.rand_name('description-')
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_security_group,
+ non_exist_id, name=s_name,
+ description=s_description)
+
+
+class SecurityGroupsNegativeTestXML(SecurityGroupsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index 080bd1a..91c350e 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -17,8 +17,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class MultipleCreateTestJSON(base.BaseV2ComputeTest):
@@ -38,7 +37,7 @@
return resp, body
- @attr(type='gate')
+ @test.attr(type='gate')
def test_multiple_create(self):
resp, body = self._create_multiple_servers(wait_until='ACTIVE',
min_count=1,
@@ -49,39 +48,7 @@
self.assertEqual('202', resp['status'])
self.assertNotIn('reservation_id', body)
- @attr(type=['negative', 'gate'])
- def test_min_count_less_than_one(self):
- invalid_min_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @attr(type=['negative', 'gate'])
- def test_min_count_non_integer(self):
- invalid_min_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=invalid_min_count)
-
- @attr(type=['negative', 'gate'])
- def test_max_count_less_than_one(self):
- invalid_max_count = 0
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @attr(type=['negative', 'gate'])
- def test_max_count_non_integer(self):
- invalid_max_count = 2.5
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- max_count=invalid_max_count)
-
- @attr(type=['negative', 'gate'])
- def test_max_count_less_than_min_count(self):
- min_count = 3
- max_count = 2
- self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
- min_count=min_count,
- max_count=max_count)
-
- @attr(type='gate')
+ @test.attr(type='gate')
def test_multiple_create_with_reservation_return(self):
resp, body = self._create_multiple_servers(wait_until='ACTIVE',
min_count=1,
diff --git a/tempest/api/compute/servers/test_multiple_create_negative.py b/tempest/api/compute/servers/test_multiple_create_negative.py
new file mode 100644
index 0000000..a9d9945
--- /dev/null
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -0,0 +1,75 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class MultipleCreateNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+ _name = 'multiple-create-test'
+
+ def _generate_name(self):
+ return data_utils.rand_name(self._name)
+
+ def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
+ """
+ This is the right way to create_multiple servers and manage to get the
+ created servers into the servers list to be cleaned up after all.
+ """
+ kwargs['name'] = kwargs.get('name', self._generate_name())
+ resp, body = self.create_test_server(**kwargs)
+
+ return resp, body
+
+ @test.attr(type=['negative', 'gate'])
+ def test_min_count_less_than_one(self):
+ invalid_min_count = 0
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=invalid_min_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_min_count_non_integer(self):
+ invalid_min_count = 2.5
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=invalid_min_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_less_than_one(self):
+ invalid_max_count = 0
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ max_count=invalid_max_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_non_integer(self):
+ invalid_max_count = 2.5
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ max_count=invalid_max_count)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_max_count_less_than_min_count(self):
+ min_count = 3
+ max_count = 2
+ self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
+ min_count=min_count,
+ max_count=max_count)
+
+
+class MultipleCreateNegativeTestXML(MultipleCreateNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 7ca8a52..1e55afb 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -16,34 +16,20 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
-class ServerAddressesTest(base.BaseV2ComputeTest):
+class ServerAddressesTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(ServerAddressesTest, cls).setUpClass()
+ super(ServerAddressesTestJSON, cls).setUpClass()
cls.client = cls.servers_client
resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
- @attr(type=['negative', 'gate'])
- def test_list_server_addresses_invalid_server_id(self):
- # List addresses request should fail if server id not in system
- self.assertRaises(exceptions.NotFound, self.client.list_addresses,
- '999')
-
- @attr(type=['negative', 'gate'])
- def test_list_server_addresses_by_network_neg(self):
- # List addresses by network should fail if network name not valid
- self.assertRaises(exceptions.NotFound,
- self.client.list_addresses_by_network,
- self.server['id'], 'invalid')
-
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_server_addresses(self):
# All public and private addresses for
# a server should be returned
@@ -60,7 +46,7 @@
self.assertTrue(address['addr'])
self.assertTrue(address['version'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_server_addresses_by_network(self):
# Providing a network type should filter
# the addresses return by that type
@@ -80,5 +66,5 @@
self.assertTrue(any([a for a in addr if a == address]))
-class ServerAddressesTestXML(ServerAddressesTest):
+class ServerAddressesTestXML(ServerAddressesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_server_addresses_negative.py b/tempest/api/compute/servers/test_server_addresses_negative.py
new file mode 100644
index 0000000..30aa7d1
--- /dev/null
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -0,0 +1,48 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest import test
+
+
+class ServerAddressesNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServerAddressesNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ resp, cls.server = cls.create_test_server(wait_until='ACTIVE')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_server_addresses_invalid_server_id(self):
+ # List addresses request should fail if server id not in system
+ self.assertRaises(exceptions.NotFound, self.client.list_addresses,
+ '999')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_server_addresses_by_network_neg(self):
+ # List addresses by network should fail if network name not valid
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_addresses_by_network,
+ self.server['id'], 'invalid')
+
+
+class ServerAddressesNegativeTestXML(ServerAddressesNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 164c6df..968ae47 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -18,11 +18,8 @@
import netaddr
from tempest.api.compute import base
-from tempest.common.utils import data_utils
from tempest import config
-from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
+from tempest import test
class VirtualInterfacesTestJSON(base.BaseV2ComputeTest):
@@ -37,9 +34,9 @@
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @skip_because(bug="1183436",
- condition=CONF.service_available.neutron)
- @attr(type='gate')
+ @test.skip_because(bug="1183436",
+ condition=CONF.service_available.neutron)
+ @test.attr(type='gate')
def test_list_virtual_interfaces(self):
# Positive test:Should be able to GET the virtual interfaces list
# for a given server_id
@@ -54,15 +51,6 @@
self.assertTrue(netaddr.valid_mac(mac_address),
"Invalid mac address detected.")
- @attr(type=['negative', 'gate'])
- 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_name('!@#$%^&*()')
- self.assertRaises(exceptions.NotFound,
- self.client.list_virtual_interfaces,
- invalid_server_id)
-
class VirtualInterfacesTestXML(VirtualInterfacesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_virtual_interfaces_negative.py b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
new file mode 100644
index 0000000..a2a6c11
--- /dev/null
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -0,0 +1,44 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import uuid
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest import test
+
+
+class VirtualInterfacesNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(VirtualInterfacesNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+
+ @test.attr(type=['negative', 'gate'])
+ 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 = str(uuid.uuid4())
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_virtual_interfaces,
+ invalid_server_id)
+
+
+class VirtualInterfacesNegativeTestXML(VirtualInterfacesNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/test_auth_token.py b/tempest/api/compute/test_auth_token.py
deleted file mode 100644
index e52c415..0000000
--- a/tempest/api/compute/test_auth_token.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright 2013 IBM Corp
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-import testtools
-
-from tempest.api.compute import base
-import tempest.config as config
-
-CONF = config.CONF
-
-
-class AuthTokenTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(AuthTokenTestJSON, cls).setUpClass()
-
- cls.servers_v2 = cls.os.servers_client
- cls.servers_v3 = cls.os.servers_client_v3_auth
-
- def test_v2_token(self):
- # Can get a token using v2 of the identity API and use that to perform
- # an operation on the compute service.
-
- # Doesn't matter which compute API is used,
- # picking list_servers because it's easy.
- self.servers_v2.list_servers()
-
- @testtools.skipIf(not CONF.identity.uri_v3,
- 'v3 auth client not configured')
- def test_v3_token(self):
- # Can get a token using v3 of the identity API and use that to perform
- # an operation on the compute service.
-
- # Doesn't matter which compute API is used,
- # picking list_servers because it's easy.
- self.servers_v3.list_servers()
-
-
-class AuthTokenTestXML(AuthTokenTestJSON):
- _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_aggregates.py b/tempest/api/compute/v3/admin/test_aggregates.py
new file mode 100644
index 0000000..144dc44
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -0,0 +1,221 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class AggregatesAdminV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Aggregates API that require admin privileges
+ """
+
+ _host_key = 'os-extended-server-attributes:host'
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AggregatesAdminV3TestJSON, cls).setUpClass()
+ cls.client = cls.aggregates_admin_client
+ cls.user_client = cls.aggregates_client
+ cls.aggregate_name_prefix = 'test_aggregate_'
+ cls.az_name_prefix = 'test_az_'
+
+ resp, hosts_all = cls.hosts_admin_client.list_hosts()
+ hosts = map(lambda x: x['host_name'],
+ filter(lambda y: y['service'] == 'compute', hosts_all))
+ cls.host = hosts[0]
+
+ @test.attr(type='gate')
+ def test_aggregate_create_delete(self):
+ # Create and delete an aggregate.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.assertEqual(aggregate_name, aggregate['name'])
+ self.assertEqual(None, aggregate['availability_zone'])
+
+ resp, _ = self.client.delete_aggregate(aggregate['id'])
+ self.assertEqual(204, resp.status)
+ self.client.wait_for_resource_deletion(aggregate['id'])
+
+ @test.attr(type='gate')
+ def test_aggregate_create_delete_with_az(self):
+ # Create and delete an aggregate.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ az_name = data_utils.rand_name(self.az_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)
+ self.assertEqual(201, resp.status)
+ self.assertEqual(aggregate_name, aggregate['name'])
+ self.assertEqual(az_name, aggregate['availability_zone'])
+
+ resp, _ = self.client.delete_aggregate(aggregate['id'])
+ self.assertEqual(204, resp.status)
+ self.client.wait_for_resource_deletion(aggregate['id'])
+
+ @test.attr(type='gate')
+ def test_aggregate_create_verify_entry_in_list(self):
+ # Create an aggregate and ensure it is listed.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ resp, aggregates = self.client.list_aggregates()
+ self.assertEqual(200, resp.status)
+ self.assertIn((aggregate['id'], aggregate['availability_zone']),
+ map(lambda x: (x['id'], x['availability_zone']),
+ aggregates))
+
+ @test.attr(type='gate')
+ def test_aggregate_create_update_metadata_get_details(self):
+ # Create an aggregate and ensure its details are returned.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ resp, body = self.client.get_aggregate(aggregate['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(aggregate['name'], body['name'])
+ self.assertEqual(aggregate['availability_zone'],
+ body['availability_zone'])
+ self.assertEqual({}, body["metadata"])
+
+ # set the metadata of the aggregate
+ meta = {"key": "value"}
+ resp, body = self.client.set_metadata(aggregate['id'], meta)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(meta, body["metadata"])
+
+ # verify the metadata has been set
+ resp, body = self.client.get_aggregate(aggregate['id'])
+ self.assertEqual(200, resp.status)
+ self.assertEqual(meta, body["metadata"])
+
+ @test.attr(type='gate')
+ def test_aggregate_create_update_with_az(self):
+ # Update an aggregate and ensure properties are updated correctly
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ az_name = data_utils.rand_name(self.az_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertEqual(201, resp.status)
+ self.assertEqual(aggregate_name, aggregate['name'])
+ self.assertEqual(az_name, aggregate['availability_zone'])
+ self.assertIsNotNone(aggregate['id'])
+
+ aggregate_id = aggregate['id']
+ new_aggregate_name = aggregate_name + '_new'
+ new_az_name = az_name + '_new'
+
+ resp, resp_aggregate = self.client.update_aggregate(aggregate_id,
+ new_aggregate_name,
+ new_az_name)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(new_aggregate_name, resp_aggregate['name'])
+ self.assertEqual(new_az_name, resp_aggregate['availability_zone'])
+
+ resp, aggregates = self.client.list_aggregates()
+ self.assertEqual(200, resp.status)
+ self.assertIn((aggregate_id, new_aggregate_name, new_az_name),
+ map(lambda x:
+ (x['id'], x['name'], x['availability_zone']),
+ aggregates))
+
+ @test.attr(type='gate')
+ def test_aggregate_add_remove_host(self):
+ # Add an host to the given aggregate and remove.
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ resp, body = self.client.add_host(aggregate['id'], self.host)
+ self.assertEqual(202, resp.status)
+ self.assertEqual(aggregate_name, body['name'])
+ self.assertEqual(aggregate['availability_zone'],
+ body['availability_zone'])
+ self.assertIn(self.host, body['hosts'])
+
+ resp, body = self.client.remove_host(aggregate['id'], self.host)
+ self.assertEqual(202, resp.status)
+ self.assertEqual(aggregate_name, body['name'])
+ self.assertEqual(aggregate['availability_zone'],
+ body['availability_zone'])
+ self.assertNotIn(self.host, body['hosts'])
+
+ @test.attr(type='gate')
+ def test_aggregate_add_host_list(self):
+ # Add an host to the given aggregate and list.
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+ self.client.add_host(aggregate['id'], self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+
+ resp, aggregates = self.client.list_aggregates()
+ aggs = filter(lambda x: x['id'] == aggregate['id'], aggregates)
+ self.assertEqual(1, len(aggs))
+ agg = aggs[0]
+ self.assertEqual(aggregate_name, agg['name'])
+ self.assertEqual(None, agg['availability_zone'])
+ self.assertIn(self.host, agg['hosts'])
+
+ @test.attr(type='gate')
+ def test_aggregate_add_host_get_details(self):
+ # Add an host to the given aggregate and get details.
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+ self.client.add_host(aggregate['id'], self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+
+ resp, body = self.client.get_aggregate(aggregate['id'])
+ self.assertEqual(aggregate_name, body['name'])
+ self.assertEqual(None, body['availability_zone'])
+ self.assertIn(self.host, body['hosts'])
+
+ @test.attr(type='gate')
+ def test_aggregate_add_host_create_server_with_az(self):
+ # Add an host to the given aggregate and create a server.
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ az_name = data_utils.rand_name(self.az_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+ self.client.add_host(aggregate['id'], self.host)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+ server_name = data_utils.rand_name('test_server_')
+ admin_servers_client = self.servers_admin_client
+ resp, server = self.create_test_server(name=server_name,
+ availability_zone=az_name,
+ wait_until='ACTIVE')
+ resp, body = admin_servers_client.get_server(server['id'])
+ self.assertEqual(self.host, body[self._host_key])
+
+
+class AggregatesAdminV3TestXML(AggregatesAdminV3TestJSON):
+ _host_key = (
+ '{http://docs.openstack.org/compute/ext/'
+ 'extended_server_attributes/api/v3}host')
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_aggregates_negative.py b/tempest/api/compute/v3/admin/test_aggregates_negative.py
new file mode 100644
index 0000000..87eadce
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -0,0 +1,196 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Huawei Technologies Co.,LTD.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class AggregatesAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Aggregates API that require admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AggregatesAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.aggregates_admin_client
+ cls.user_client = cls.aggregates_client
+ cls.aggregate_name_prefix = 'test_aggregate_'
+ cls.az_name_prefix = 'test_az_'
+
+ resp, hosts_all = cls.hosts_admin_client.list_hosts()
+ hosts = map(lambda x: x['host_name'],
+ filter(lambda y: y['service'] == 'compute', hosts_all))
+ cls.host = hosts[0]
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_create_as_user(self):
+ # Regular user is not allowed to create an aggregate.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.create_aggregate,
+ aggregate_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_create_aggregate_name_length_less_than_1(self):
+ # the length of aggregate name should >= 1 and <=255
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_aggregate,
+ '')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_create_aggregate_name_length_exceeds_255(self):
+ # the length of aggregate name should >= 1 and <=255
+ aggregate_name = 'a' * 256
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_aggregate,
+ aggregate_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_create_with_existent_aggregate_name(self):
+ # creating an aggregate with existent aggregate name is forbidden
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Conflict,
+ self.client.create_aggregate,
+ aggregate_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_delete_as_user(self):
+ # Regular user is not allowed to delete an aggregate.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.delete_aggregate,
+ aggregate['id'])
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_list_as_user(self):
+ # Regular user is not allowed to list aggregates.
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.list_aggregates)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_get_details_as_user(self):
+ # Regular user is not allowed to get aggregate details.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.get_aggregate,
+ aggregate['id'])
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_delete_with_invalid_id(self):
+ # Delete an aggregate with invalid id should raise exceptions.
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_aggregate, -1)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_get_details_with_invalid_id(self):
+ # Get aggregate details with invalid id should raise exceptions.
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_aggregate, -1)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_add_non_exist_host(self):
+ # Adding a non-exist host to an aggregate should raise exceptions.
+ resp, hosts_all = self.hosts_admin_client.list_hosts()
+ hosts = map(lambda x: x['host_name'], hosts_all)
+ while True:
+ non_exist_host = data_utils.rand_name('nonexist_host_')
+ if non_exist_host not in hosts:
+ break
+
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.NotFound, self.client.add_host,
+ aggregate['id'], non_exist_host)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_add_host_as_user(self):
+ # Regular user is not allowed to add a host to an aggregate.
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.add_host,
+ aggregate['id'], self.host)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_add_existent_host(self):
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ resp, body = self.client.add_host(aggregate['id'], self.host)
+ self.assertEqual(202, resp.status)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+
+ self.assertRaises(exceptions.Conflict, self.client.add_host,
+ aggregate['id'], self.host)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_remove_host_as_user(self):
+ # Regular user is not allowed to remove a host from an aggregate.
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+ resp, body = self.client.add_host(aggregate['id'], self.host)
+ self.assertEqual(202, resp.status)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.remove_host,
+ aggregate['id'], self.host)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_aggregate_remove_nonexistent_host(self):
+ non_exist_host = data_utils.rand_name('nonexist_host_')
+ aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)
+ resp, aggregate = self.client.create_aggregate(aggregate_name)
+ self.assertEqual(201, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.NotFound, self.client.remove_host,
+ aggregate['id'], non_exist_host)
+
+
+class AggregatesAdminNegativeV3TestXML(AggregatesAdminNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access.py b/tempest/api/compute/v3/admin/test_flavors_access.py
index 048312b..86194af 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -20,7 +20,7 @@
from tempest import test
-class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -31,19 +31,15 @@
@classmethod
def setUpClass(cls):
- super(FlavorsAccessTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsAccessV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
admin_client = cls._get_identity_admin_client()
cls.tenant = admin_client.get_tenant_by_name(cls.flavors_client.
tenant_name)
cls.tenant_id = cls.tenant['id']
- cls.adm_tenant = admin_client.get_tenant_by_name(cls.os_adm.
- flavors_client.
- tenant_name)
+ cls.adm_tenant = admin_client.get_tenant_by_name(
+ cls.flavors_admin_client.tenant_name)
cls.adm_tenant_id = cls.adm_tenant['id']
cls.flavor_name_prefix = 'test_flavor_access_'
cls.ram = 512
@@ -61,7 +57,7 @@
new_flavor_id,
is_public='False')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
resp, flavor_access = self.client.list_flavor_access(new_flavor_id)
self.assertEqual(resp.status, 200)
self.assertEqual(len(flavor_access), 1, str(flavor_access))
@@ -107,5 +103,5 @@
self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
-class FlavorsAdminTestXML(FlavorsAccessTestJSON):
+class FlavorsAdminV3TestXML(FlavorsAccessV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_access_negative.py b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
index 976124e..df6557e 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -23,7 +23,7 @@
from tempest import test
-class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -34,19 +34,15 @@
@classmethod
def setUpClass(cls):
- super(FlavorsAccessNegativeTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsAccessNegativeV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
admin_client = cls._get_identity_admin_client()
cls.tenant = admin_client.get_tenant_by_name(cls.flavors_client.
tenant_name)
cls.tenant_id = cls.tenant['id']
- cls.adm_tenant = admin_client.get_tenant_by_name(cls.os_adm.
- flavors_client.
- tenant_name)
+ cls.adm_tenant = admin_client.get_tenant_by_name(
+ cls.flavors_admin_client.tenant_name)
cls.adm_tenant_id = cls.adm_tenant['id']
cls.flavor_name_prefix = 'test_flavor_access_'
cls.ram = 512
@@ -64,7 +60,7 @@
new_flavor_id,
is_public='True')
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertRaises(exceptions.NotFound,
self.client.list_flavor_access,
new_flavor_id)
@@ -148,5 +144,5 @@
str(uuid.uuid4()))
-class FlavorsAdminNegativeTestXML(FlavorsAccessNegativeTestJSON):
+class FlavorsAdminNegativeV3TestXML(FlavorsAccessNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
index 875f742..d745829 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -20,7 +20,7 @@
from tempest import test
-class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Extra Spec API extension.
@@ -32,12 +32,9 @@
@classmethod
def setUpClass(cls):
- super(FlavorsExtraSpecsTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsExtraSpecsV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
ram = 512
vcpus = 1
@@ -58,7 +55,7 @@
def tearDownClass(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsV3TestJSON, cls).tearDownClass()
@test.attr(type='gate')
def test_flavor_set_get_update_show_unset_keys(self):
@@ -69,7 +66,7 @@
# SET extra specs to the flavor created in setUp
set_resp, set_body = \
self.client.set_flavor_extra_spec(self.flavor['id'], specs)
- self.assertEqual(set_resp.status, 200)
+ self.assertEqual(set_resp.status, 201)
self.assertEqual(set_body, specs)
# GET extra specs and verify
get_resp, get_body = \
@@ -95,10 +92,10 @@
# UNSET extra specs that were set in this test
unset_resp, _ = \
self.client.unset_flavor_extra_spec(self.flavor['id'], "key1")
- self.assertEqual(unset_resp.status, 200)
+ self.assertEqual(unset_resp.status, 204)
unset_resp, _ = \
self.client.unset_flavor_extra_spec(self.flavor['id'], "key2")
- self.assertEqual(unset_resp.status, 200)
+ self.assertEqual(unset_resp.status, 204)
@test.attr(type='gate')
def test_flavor_non_admin_get_all_keys(self):
@@ -117,7 +114,7 @@
specs = {"key1": "value1", "key2": "value2"}
resp, body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertEqual(body['key1'], 'value1')
self.assertIn('key2', body)
resp, body = self.flavors_client.get_flavor_extra_spec_with_key(
@@ -127,5 +124,5 @@
self.assertNotIn('key2', body)
-class FlavorsExtraSpecsTestXML(FlavorsExtraSpecsTestJSON):
+class FlavorsExtraSpecsV3TestXML(FlavorsExtraSpecsV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
index fb09a63..1d5e447 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs_negative.py
@@ -22,7 +22,7 @@
from tempest import test
-class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Negative Tests Flavor Extra Spec API extension.
@@ -33,12 +33,9 @@
@classmethod
def setUpClass(cls):
- super(FlavorsExtraSpecsNegativeTestJSON, cls).setUpClass()
- if not test.is_extension_enabled('FlavorExtraData', 'compute'):
- msg = "FlavorExtraData extension not enabled."
- raise cls.skipException(msg)
+ super(FlavorsExtraSpecsNegativeV3TestJSON, cls).setUpClass()
- cls.client = cls.os_adm.flavors_client
+ cls.client = cls.flavors_admin_client
flavor_name = data_utils.rand_name('test_flavor')
ram = 512
vcpus = 1
@@ -59,7 +56,7 @@
def tearDownClass(cls):
resp, body = cls.client.delete_flavor(cls.flavor['id'])
cls.client.wait_for_resource_deletion(cls.flavor['id'])
- super(FlavorsExtraSpecsNegativeTestJSON, cls).tearDownClass()
+ super(FlavorsExtraSpecsNegativeV3TestJSON, cls).tearDownClass()
@test.attr(type=['negative', 'gate'])
def test_flavor_non_admin_set_keys(self):
@@ -76,7 +73,7 @@
specs = {"key1": "value1", "key2": "value2"}
resp, body = self.client.set_flavor_extra_spec(
self.flavor['id'], specs)
- self.assertEqual(resp.status, 200)
+ self.assertEqual(resp.status, 201)
self.assertEqual(body['key1'], 'value1')
self.assertRaises(exceptions.Unauthorized,
self.flavors_client.
@@ -131,5 +128,5 @@
key2="value")
-class FlavorsExtraSpecsNegativeTestXML(FlavorsExtraSpecsNegativeTestJSON):
+class FlavorsExtraSpecsNegativeV3TestXML(FlavorsExtraSpecsNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts.py b/tempest/api/compute/v3/admin/test_hosts.py
new file mode 100644
index 0000000..896d6a7
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -0,0 +1,94 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
+from tempest import test
+
+
+class HostsAdminV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests hosts API using admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(HostsAdminV3TestJSON, cls).setUpClass()
+ cls.client = cls.hosts_admin_client
+
+ @test.attr(type='gate')
+ def test_list_hosts(self):
+ resp, hosts = self.client.list_hosts()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(hosts) >= 2, str(hosts))
+
+ @test.attr(type='gate')
+ def test_list_hosts_with_zone(self):
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ resp, hosts = self.client.list_hosts()
+ host = hosts[0]
+ zone_name = host['zone']
+ params = {'zone': zone_name}
+ resp, hosts = self.client.list_hosts(params)
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(hosts) >= 1)
+ self.assertIn(host, hosts)
+
+ @test.attr(type='gate')
+ def test_list_hosts_with_a_blank_zone(self):
+ # If send the request with a blank zone, the request will be successful
+ # and it will return all the hosts list
+ params = {'zone': ''}
+ resp, hosts = self.client.list_hosts(params)
+ self.assertNotEqual(0, len(hosts))
+ self.assertEqual(200, resp.status)
+
+ @test.attr(type='gate')
+ def test_list_hosts_with_nonexistent_zone(self):
+ # If send the request with a nonexistent zone, the request will be
+ # successful and no hosts will be retured
+ params = {'zone': 'xxx'}
+ resp, hosts = self.client.list_hosts(params)
+ self.assertEqual(0, len(hosts))
+ self.assertEqual(200, resp.status)
+
+ @test.attr(type='gate')
+ def test_show_host_detail(self):
+ resp, hosts = self.client.list_hosts()
+ self.assertEqual(200, resp.status)
+
+ hosts = [host for host in hosts if host['service'] == 'compute']
+ self.assertTrue(len(hosts) >= 1)
+
+ for host in hosts:
+ hostname = host['host_name']
+ resp, resources = self.client.show_host_detail(hostname)
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(resources) >= 1)
+ host_resource = resources[0]['resource']
+ self.assertIsNotNone(host_resource)
+ self.assertIsNotNone(host_resource['cpu'])
+ self.assertIsNotNone(host_resource['disk_gb'])
+ self.assertIsNotNone(host_resource['memory_mb'])
+ self.assertIsNotNone(host_resource['project'])
+ self.assertEqual(hostname, host_resource['host'])
+
+
+class HostsAdminV3TestXML(HostsAdminV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_hosts_negative.py b/tempest/api/compute/v3/admin/test_hosts_negative.py
new file mode 100644
index 0000000..755fa2b
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -0,0 +1,174 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Huawei Technologies Co.,LTD.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class HostsAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests hosts API using admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(HostsAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.hosts_admin_client
+ cls.non_admin_client = cls.hosts_client
+
+ def _get_host_name(self):
+ resp, hosts = self.client.list_hosts()
+ self.assertEqual(200, resp.status)
+ self.assertTrue(len(hosts) >= 1)
+ hostname = hosts[0]['host_name']
+ return hostname
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_hosts_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.list_hosts)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_show_host_detail_with_nonexistent_hostname(self):
+ nonexitent_hostname = data_utils.rand_name('rand_hostname')
+ self.assertRaises(exceptions.NotFound,
+ self.client.show_host_detail, nonexitent_hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_show_host_detail_with_non_admin_user(self):
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.show_host_detail,
+ hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_host_with_non_admin_user(self):
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.update_host,
+ hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_host_with_extra_param(self):
+ # only 'status' and 'maintenance_mode' are the valid params.
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_host,
+ hostname,
+ status='enable',
+ maintenance_mode='enable',
+ param='XXX')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_host_with_invalid_status(self):
+ # 'status' can only be 'enable' or 'disable'
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_host,
+ hostname,
+ status='invalid',
+ maintenance_mode='enable')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_host_with_invalid_maintenance_mode(self):
+ # 'maintenance_mode' can only be 'enable' or 'disable'
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_host,
+ hostname,
+ status='enable',
+ maintenance_mode='invalid')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_host_without_param(self):
+ # 'status' or 'maintenance_mode' needed for host update
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_host,
+ hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_update_nonexistent_host(self):
+ nonexitent_hostname = data_utils.rand_name('rand_hostname')
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_host,
+ nonexitent_hostname,
+ status='enable',
+ maintenance_mode='enable')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_startup_nonexistent_host(self):
+ nonexitent_hostname = data_utils.rand_name('rand_hostname')
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.startup_host,
+ nonexitent_hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_startup_host_with_non_admin_user(self):
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.startup_host,
+ hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_shutdown_nonexistent_host(self):
+ nonexitent_hostname = data_utils.rand_name('rand_hostname')
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.shutdown_host,
+ nonexitent_hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_shutdown_host_with_non_admin_user(self):
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.shutdown_host,
+ hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_reboot_nonexistent_host(self):
+ nonexitent_hostname = data_utils.rand_name('rand_hostname')
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.reboot_host,
+ nonexitent_hostname)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_reboot_host_with_non_admin_user(self):
+ hostname = self._get_host_name()
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.reboot_host,
+ hostname)
+
+
+class HostsAdminNegativeV3TestXML(HostsAdminNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index 66d41b8..e67ed8f 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
-# Copyright 2012 OpenStack Foundation
+# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -17,41 +17,34 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import skip_because
-
-CONF = config.CONF
+from tempest import test
-class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
+class QuotasAdminV3TestJSON(base.BaseV3ComputeAdminTest):
_interface = 'json'
force_tenant_isolation = True
@classmethod
def setUpClass(cls):
- super(QuotasAdminTestJSON, cls).setUpClass()
+ super(QuotasAdminV3TestJSON, cls).setUpClass()
cls.auth_url = cls.config.identity.uri
- cls.client = cls.os.quotas_client
- cls.adm_client = cls.os_adm.quotas_client
+ cls.client = cls.quotas_client
+ cls.adm_client = cls.quotas_admin_client
cls.identity_admin_client = cls._get_identity_admin_client()
- cls.sg_client = cls.security_groups_client
# NOTE(afazekas): these test cases should always create and use a new
# tenant most of them should be skipped if we can't do that
cls.demo_tenant_id = cls.isolated_creds.get_primary_user().get(
'tenantId')
- cls.default_quota_set = set(('injected_file_content_bytes',
- 'metadata_items', 'injected_files',
+ cls.default_quota_set = set(('metadata_items',
'ram', 'floating_ips',
'fixed_ips', 'key_pairs',
- 'injected_file_path_bytes',
'instances', 'security_group_rules',
'cores', 'security_groups'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_default_quotas(self):
# Admin can get the default resource quota set for a tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -62,15 +55,14 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.demo_tenant_id)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_all_quota_resources_for_tenant(self):
# Admin can update all the resource quota limits for a tenant
resp, default_quota_set = self.client.get_default_quota_set(
self.demo_tenant_id)
- new_quota_set = {'injected_file_content_bytes': 20480,
- 'metadata_items': 256, 'injected_files': 10,
+ new_quota_set = {'metadata_items': 256,
'ram': 10240, 'floating_ips': 20, 'fixed_ips': 10,
- 'key_pairs': 200, 'injected_file_path_bytes': 512,
+ 'key_pairs': 200,
'instances': 20, 'security_group_rules': 20,
'cores': 2, 'security_groups': 20}
# Update limits for all quota resources
@@ -83,10 +75,11 @@
self.addCleanup(self.adm_client.update_quota_set,
self.demo_tenant_id, **default_quota_set)
self.assertEqual(200, resp.status)
+ quota_set.pop('id')
self.assertEqual(new_quota_set, quota_set)
# TODO(afazekas): merge these test cases
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_updated_quotas(self):
# Verify that GET shows the updated quota set
tenant_name = data_utils.rand_name('cpu_quota_tenant_')
@@ -106,7 +99,7 @@
# TODO(afazekas): Add dedicated tenant to the skiped quota tests
# it can be moved into the setUpClass as well
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_when_cpu_quota_is_full(self):
# Disallow server creation when tenant's vcpu quota is full
resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
@@ -121,7 +114,7 @@
cores=default_vcpu_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_when_memory_quota_is_full(self):
# Disallow server creation when tenant's memory quota is full
resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
@@ -136,14 +129,14 @@
ram=default_mem_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_quota_normal_user(self):
self.assertRaises(exceptions.Unauthorized,
self.client.update_quota_set,
self.demo_tenant_id,
ram=0)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_when_instances_quota_is_full(self):
# Once instances quota limit is reached, disallow server creation
resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
@@ -157,66 +150,6 @@
instances=default_instances_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_exceed_limit(self):
- # Negative test: Creation Security Groups over limit should FAIL
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_quota = quota_set['security_groups']
- sg_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(self.demo_tenant_id,
- force=True,
- security_groups=sg_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_groups=default_sg_quota)
-
- # Check we cannot create anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group,
- "sg-overlimit", "sg-desc")
-
- @skip_because(bug="1186354",
- condition=CONF.service_available.neutron)
- @attr(type=['negative', 'gate'])
- def test_security_groups_rules_exceed_limit(self):
- # Negative test: Creation of Security Group Rules should FAIL
- # when we reach limit maxSecurityGroupRules
-
- resp, quota_set = self.client.get_quota_set(self.demo_tenant_id)
- default_sg_rules_quota = quota_set['security_group_rules']
- sg_rules_quota = 0 # Set the quota to zero to conserve resources
-
- resp, quota_set =\
- self.adm_client.update_quota_set(
- self.demo_tenant_id,
- force=True,
- security_group_rules=sg_rules_quota)
-
- self.addCleanup(self.adm_client.update_quota_set,
- self.demo_tenant_id,
- security_group_rules=default_sg_rules_quota)
-
- s_name = data_utils.rand_name('securitygroup-')
- s_description = data_utils.rand_name('description-')
- resp, securitygroup =\
- self.sg_client.create_security_group(s_name, s_description)
- self.addCleanup(self.sg_client.delete_security_group,
- securitygroup['id'])
-
- secgroup_id = securitygroup['id']
- ip_protocol = 'tcp'
-
- # Check we cannot create SG rule anymore
- self.assertRaises(exceptions.OverLimit,
- self.sg_client.create_security_group_rule,
- secgroup_id, ip_protocol, 1025, 1025)
-
-
-class QuotasAdminTestXML(QuotasAdminTestJSON):
+class QuotasAdminV3TestXML(QuotasAdminV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers.py b/tempest/api/compute/v3/admin/test_servers.py
new file mode 100644
index 0000000..6fe3186
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -0,0 +1,146 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+from tempest.test import skip_because
+
+
+class ServersAdminTestJSON(base.BaseV2ComputeAdminTest):
+
+ """
+ Tests Servers API using admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersAdminTestJSON, cls).setUpClass()
+ cls.client = cls.os_adm.servers_client
+ cls.non_admin_client = cls.servers_client
+ cls.flavors_client = cls.os_adm.flavors_client
+
+ cls.s1_name = data_utils.rand_name('server')
+ resp, server = cls.create_test_server(name=cls.s1_name,
+ wait_until='ACTIVE')
+ cls.s1_id = server['id']
+
+ cls.s2_name = data_utils.rand_name('server')
+ resp, server = cls.create_test_server(name=cls.s2_name,
+ wait_until='ACTIVE')
+
+ def _get_unused_flavor_id(self):
+ flavor_id = data_utils.rand_int_id(start=1000)
+ while True:
+ try:
+ resp, body = self.flavors_client.get_flavor_details(flavor_id)
+ except exceptions.NotFound:
+ break
+ flavor_id = data_utils.rand_int_id(start=1000)
+ return flavor_id
+
+ @attr(type='gate')
+ def test_list_servers_by_admin(self):
+ # Listing servers by admin user returns empty list by default
+ resp, body = self.client.list_servers_with_detail()
+ servers = body['servers']
+ self.assertEqual('200', resp['status'])
+ self.assertEqual([], servers)
+
+ @attr(type='gate')
+ def test_list_servers_by_admin_with_all_tenants(self):
+ # Listing servers by admin user with all tenants parameter
+ # Here should be listed all servers
+ params = {'all_tenants': ''}
+ resp, body = self.client.list_servers_with_detail(params)
+ servers = body['servers']
+ servers_name = map(lambda x: x['name'], servers)
+
+ self.assertIn(self.s1_name, servers_name)
+ self.assertIn(self.s2_name, servers_name)
+
+ @attr(type='gate')
+ def test_admin_delete_servers_of_others(self):
+ # Administrator can delete servers of others
+ _, server = self.create_test_server()
+ resp, _ = self.client.delete_server(server['id'])
+ self.assertEqual('204', resp['status'])
+ self.servers_client.wait_for_server_termination(server['id'])
+
+ @attr(type='gate')
+ def test_reset_state_server(self):
+ # Reset server's state to 'error'
+ resp, server = self.client.reset_state(self.s1_id)
+ self.assertEqual(202, resp.status)
+
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ERROR')
+
+ # Reset server's state to 'active'
+ resp, server = self.client.reset_state(self.s1_id, state='active')
+ self.assertEqual(202, resp.status)
+
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ACTIVE')
+
+ @attr(type='gate')
+ @skip_because(bug="1240043")
+ def test_get_server_diagnostics_by_admin(self):
+ # Retrieve server diagnostics by admin user
+ resp, diagnostic = self.client.get_server_diagnostics(self.s1_id)
+ self.assertEqual(200, resp.status)
+ basic_attrs = ['rx_packets', 'rx_errors', 'rx_drop',
+ 'tx_packets', 'tx_errors', 'tx_drop',
+ 'read_req', 'write_req', 'cpu', 'memory']
+ for key in basic_attrs:
+ self.assertIn(key, str(diagnostic.keys()))
+
+ @attr(type='gate')
+ def test_rebuild_server_in_error_state(self):
+ # The server in error state should be rebuilt using the provided
+ # image and changed to ACTIVE state
+
+ # resetting vm state require admin priviledge
+ resp, server = self.client.reset_state(self.s1_id, state='error')
+ self.assertEqual(202, resp.status)
+ resp, rebuilt_server = self.non_admin_client.rebuild(
+ self.s1_id, self.image_ref_alt)
+ self.addCleanup(self.non_admin_client.wait_for_server_status,
+ self.s1_id, 'ACTIVE')
+ self.addCleanup(self.non_admin_client.rebuild, self.s1_id,
+ self.image_ref)
+
+ # Verify the properties in the initial response are correct
+ self.assertEqual(self.s1_id, rebuilt_server['id'])
+ rebuilt_image_id = rebuilt_server['image']['id']
+ self.assertEqual(self.image_ref_alt, rebuilt_image_id)
+ self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
+ self.non_admin_client.wait_for_server_status(rebuilt_server['id'],
+ 'ACTIVE',
+ raise_on_error=False)
+ # Verify the server properties after rebuilding
+ resp, server = self.non_admin_client.get_server(rebuilt_server['id'])
+ rebuilt_image_id = server['image']['id']
+ self.assertEqual(self.image_ref_alt, rebuilt_image_id)
+
+
+class ServersAdminTestXML(ServersAdminTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_servers_negative.py b/tempest/api/compute/v3/admin/test_servers_negative.py
new file mode 100644
index 0000000..77d873b
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -0,0 +1,143 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 Huawei Technologies Co.,LTD.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import uuid
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ """
+ Tests Servers API using admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersAdminNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.os_adm.servers_client
+ cls.non_adm_client = cls.servers_client
+ cls.flavors_client = cls.os_adm.flavors_client
+ cls.identity_client = cls._get_identity_admin_client()
+ tenant = cls.identity_client.get_tenant_by_name(
+ cls.client.tenant_name)
+ cls.tenant_id = tenant['id']
+
+ cls.s1_name = data_utils.rand_name('server')
+ resp, server = cls.create_test_server(name=cls.s1_name,
+ wait_until='ACTIVE')
+ cls.s1_id = server['id']
+
+ def _get_unused_flavor_id(self):
+ flavor_id = data_utils.rand_int_id(start=1000)
+ while True:
+ try:
+ resp, body = self.flavors_client.get_flavor_details(flavor_id)
+ except exceptions.NotFound:
+ break
+ flavor_id = data_utils.rand_int_id(start=1000)
+ return flavor_id
+
+ @attr(type=['negative', 'gate'])
+ def test_resize_server_using_overlimit_ram(self):
+ flavor_name = data_utils.rand_name("flavor-")
+ flavor_id = self._get_unused_flavor_id()
+ resp, quota_set = self.quotas_client.get_default_quota_set(
+ self.tenant_id)
+ ram = int(quota_set['ram']) + 1
+ vcpus = 8
+ disk = 10
+ resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
+ ram, vcpus, disk,
+ flavor_id)
+ self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
+ self.assertRaises(exceptions.OverLimit,
+ self.client.resize,
+ self.servers[0]['id'],
+ flavor_ref['id'])
+
+ @attr(type=['negative', 'gate'])
+ def test_resize_server_using_overlimit_vcpus(self):
+ flavor_name = data_utils.rand_name("flavor-")
+ flavor_id = self._get_unused_flavor_id()
+ ram = 512
+ resp, quota_set = self.quotas_client.get_default_quota_set(
+ self.tenant_id)
+ vcpus = int(quota_set['cores']) + 1
+ disk = 10
+ resp, flavor_ref = self.flavors_client.create_flavor(flavor_name,
+ ram, vcpus, disk,
+ flavor_id)
+ self.addCleanup(self.flavors_client.delete_flavor, flavor_id)
+ self.assertRaises(exceptions.OverLimit,
+ self.client.resize,
+ self.servers[0]['id'],
+ flavor_ref['id'])
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_invalid_state(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reset_state, self.s1_id,
+ state='invalid')
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_invalid_type(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reset_state, self.s1_id,
+ state=1)
+
+ @attr(type=['negative', 'gate'])
+ def test_reset_state_server_nonexistent_server(self):
+ self.assertRaises(exceptions.NotFound,
+ self.client.reset_state, '999')
+
+ @attr(type=['negative', 'gate'])
+ def test_get_server_diagnostics_by_non_admin(self):
+ # Non-admin user can not view server diagnostics according to policy
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_adm_client.get_server_diagnostics,
+ self.s1_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_migrate_non_existent_server(self):
+ # migrate a non existent server
+ self.assertRaises(exceptions.NotFound,
+ self.client.migrate_server,
+ str(uuid.uuid4()))
+
+ @attr(type=['negative', 'gate'])
+ def test_migrate_server_invalid_state(self):
+ # create server.
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ self.assertEqual(202, resp.status)
+ server_id = server['id']
+ # suspend the server.
+ resp, _ = self.client.suspend_server(server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(server_id, 'SUSPENDED')
+ # migrate an suspended server should fail
+ self.assertRaises(exceptions.Conflict,
+ self.client.migrate_server,
+ server_id)
+
+
+class ServersAdminNegativeTestXML(ServersAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
index 3fc58eb..99f2c52 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
@@ -18,7 +18,6 @@
import datetime
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
import time
@@ -83,33 +82,6 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
- @attr(type=['negative', 'gate'])
- def test_get_usage_tenant_with_empty_tenant_id(self):
- # Get usage for a specific tenant empty
- params = {'start': self.start,
- 'end': self.end}
- self.assertRaises(exceptions.NotFound,
- self.adm_client.get_tenant_usage,
- '', params)
-
- @attr(type=['negative', 'gate'])
- def test_get_usage_tenant_with_invalid_date(self):
- # Get usage for tenant with invalid date
- params = {'start': self.end,
- 'end': self.start}
- self.assertRaises(exceptions.BadRequest,
- self.adm_client.get_tenant_usage,
- self.tenant_id, params)
-
- @attr(type=['negative', 'gate'])
- def test_list_usage_all_tenants_with_non_admin_user(self):
- # Get usage for all tenants with non admin user
- params = {'start': self.start,
- 'end': self.end,
- 'detailed': int(bool(True))}
- self.assertRaises(exceptions.Unauthorized,
- self.client.list_tenant_usages, params)
-
class TenantUsagesV3TestXML(TenantUsagesV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
new file mode 100644
index 0000000..ef49ed7
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
@@ -0,0 +1,76 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import datetime
+
+from tempest.api.compute import base
+from tempest import exceptions
+from tempest.test import attr
+
+
+class TenantUsagesNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(TenantUsagesNegativeV3TestJSON, cls).setUpClass()
+ cls.adm_client = cls.os_adm.tenant_usages_client
+ cls.client = cls.os.tenant_usages_client
+ cls.identity_client = cls._get_identity_admin_client()
+ now = datetime.datetime.now()
+ cls.start = cls._parse_strtime(now - datetime.timedelta(days=1))
+ cls.end = cls._parse_strtime(now + datetime.timedelta(days=1))
+
+ @classmethod
+ def _parse_strtime(cls, at):
+ # Returns formatted datetime
+ return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
+
+ @attr(type=['negative', 'gate'])
+ def test_get_usage_tenant_with_empty_tenant_id(self):
+ # Get usage for a specific tenant empty
+ params = {'start': self.start,
+ 'end': self.end}
+ self.assertRaises(exceptions.NotFound,
+ self.adm_client.get_tenant_usage,
+ '', params)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_usage_tenant_with_invalid_date(self):
+ # Get usage for tenant with invalid date
+ params = {'start': self.end,
+ 'end': self.start}
+ resp, tenants = self.identity_client.list_tenants()
+ tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
+ self.client.tenant_name][0]
+ self.assertRaises(exceptions.BadRequest,
+ self.adm_client.get_tenant_usage,
+ tenant_id, params)
+
+ @attr(type=['negative', 'gate'])
+ def test_list_usage_all_tenants_with_non_admin_user(self):
+ # Get usage for all tenants with non admin user
+ params = {'start': self.start,
+ 'end': self.end,
+ 'detailed': int(bool(True))}
+ self.assertRaises(exceptions.Unauthorized,
+ self.client.list_tenant_usages, params)
+
+
+class TenantUsagesNegativeV3TestXML(TenantUsagesNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
index b36595c..029633f 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -20,17 +20,17 @@
from tempest import test
-class KeyPairsTestJSON(base.BaseV2ComputeTest):
+class KeyPairsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(KeyPairsTestJSON, cls).setUpClass()
+ super(KeyPairsV3TestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
def _delete_keypair(self, keypair_name):
resp, _ = self.client.delete_keypair(keypair_name)
- self.assertEqual(202, resp.status)
+ self.assertEqual(204, resp.status)
def _create_keypair(self, keypair_name, pub_key=None):
resp, body = self.client.create_keypair(keypair_name, pub_key)
@@ -49,7 +49,7 @@
# as the keypair dicts from list API doesn't have them.
keypair.pop('private_key')
keypair.pop('user_id')
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
key_list.append(keypair)
# Fetch all keypairs and verify the list
# has all created keypairs
@@ -72,7 +72,7 @@
# Keypair should be created, verified and deleted
k_name = data_utils.rand_name('keypair-')
resp, keypair = self._create_keypair(k_name)
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
private_key = keypair['private_key']
key_name = keypair['name']
self.assertEqual(key_name, k_name,
@@ -111,7 +111,7 @@
"XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
"snSA8wzBx3A/8y9Pp1B nova@ubuntu")
resp, keypair = self._create_keypair(k_name, pub_key)
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
self.assertFalse('private_key' in keypair,
"Field private_key is not empty!")
key_name = keypair['name']
@@ -120,5 +120,5 @@
"to the requested name!")
-class KeyPairsTestXML(KeyPairsTestJSON):
+class KeyPairsV3TestXML(KeyPairsV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
index 621487c..edc0c26 100644
--- a/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -22,12 +22,12 @@
from tempest import test
-class KeyPairsNegativeTestJSON(base.BaseV2ComputeTest):
+class KeyPairsNegativeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(KeyPairsNegativeTestJSON, cls).setUpClass()
+ super(KeyPairsNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
def _create_keypair(self, keypair_name, pub_key=None):
@@ -70,12 +70,11 @@
# Keypairs with duplicate names should not be created
k_name = data_utils.rand_name('keypair-')
resp, _ = self.client.create_keypair(k_name)
- self.assertEqual(200, resp.status)
+ self.addCleanup(self.client.delete_keypair, k_name)
+ self.assertEqual(201, resp.status)
# Now try the same keyname to create another key
self.assertRaises(exceptions.Conflict, self._create_keypair,
k_name)
- resp, _ = self.client.delete_keypair(k_name)
- self.assertEqual(202, resp.status)
@test.attr(type=['negative', 'gate'])
def test_create_keypair_with_empty_name_string(self):
@@ -98,5 +97,5 @@
k_name)
-class KeyPairsNegativeTestXML(KeyPairsNegativeTestJSON):
+class KeyPairsNegativeV3TestXML(KeyPairsNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
index 4da527c..a030584 100644
--- a/tempest/api/compute/v3/servers/test_attach_volume.py
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -19,13 +19,15 @@
from tempest.api.compute import base
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class AttachVolumeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
super(AttachVolumeV3TestJSON, self).__init__(*args, **kwargs)
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 94175ab..e1bb160 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -24,19 +24,19 @@
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
from tempest import config
-from tempest.test import attr
+from tempest import test
CONF = config.CONF
-class ServersTestJSON(base.BaseV2ComputeTest):
+class ServersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
def setUpClass(cls):
- super(ServersTestJSON, cls).setUpClass()
+ super(ServersV3TestJSON, cls).setUpClass()
cls.meta = {'hello': 'world'}
cls.accessIPv4 = '1.1.1.1'
cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
@@ -47,36 +47,37 @@
cls.client = cls.servers_client
cli_resp = cls.create_test_server(name=cls.name,
meta=cls.meta,
- accessIPv4=cls.accessIPv4,
- accessIPv6=cls.accessIPv6,
+ access_ip_v4=cls.accessIPv4,
+ access_ip_v6=cls.accessIPv6,
personality=personality,
disk_config=cls.disk_config)
cls.resp, cls.server_initial = cli_resp
- cls.password = cls.server_initial['adminPass']
+ cls.password = cls.server_initial['admin_password']
cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
resp, cls.server = cls.client.get_server(cls.server_initial['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_server_response(self):
# Check that the required fields are returned with values
self.assertEqual(202, self.resp.status)
self.assertTrue(self.server_initial['id'] is not None)
- self.assertTrue(self.server_initial['adminPass'] is not None)
+ self.assertTrue(self.server_initial['admin_password'] is not None)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_verify_server_details(self):
# Verify the specified server attributes are set correctly
- self.assertEqual(self.accessIPv4, self.server['accessIPv4'])
+ self.assertEqual(self.accessIPv4,
+ self.server['os-access-ips:access_ip_v4'])
# NOTE(maurosr): See http://tools.ietf.org/html/rfc5952 (section 4)
# Here we compare directly with the canonicalized format.
- self.assertEqual(self.server['accessIPv6'],
+ self.assertEqual(self.server['os-access-ips:access_ip_v6'],
str(netaddr.IPAddress(self.accessIPv6)))
self.assertEqual(self.name, self.server['name'])
self.assertEqual(self.image_ref, self.server['image']['id'])
self.assertEqual(self.flavor_ref, self.server['flavor']['id'])
self.assertEqual(self.meta, self.server['metadata'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_servers(self):
# The created server should be in the list of all servers
resp, body = self.client.list_servers()
@@ -84,7 +85,7 @@
found = any([i for i in servers if i['id'] == self.server['id']])
self.assertTrue(found)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_servers_with_detail(self):
# The created server should be in the detailed list of all servers
resp, body = self.client.list_servers_with_detail()
@@ -93,14 +94,14 @@
self.assertTrue(found)
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_can_log_into_created_server(self):
# Check that the user can authenticate with the generated password
linux_client = RemoteClient(self.server, self.ssh_user, self.password)
self.assertTrue(linux_client.can_authenticate())
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
@@ -109,14 +110,14 @@
self.assertEqual(flavor['vcpus'], linux_client.get_number_of_vcpus())
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
- @attr(type='gate')
+ @test.attr(type='gate')
def test_host_name_is_same_as_server_name(self):
# Verify the instance host name is the same as the server name
linux_client = RemoteClient(self.server, self.ssh_user, self.password)
self.assertTrue(linux_client.hostname_equals_servername(self.name))
-class ServersTestManualDisk(ServersTestJSON):
+class ServersV3TestManualDisk(ServersV3TestJSON):
disk_config = 'MANUAL'
@classmethod
@@ -124,8 +125,8 @@
if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
- super(ServersTestManualDisk, cls).setUpClass()
+ super(ServersV3TestManualDisk, cls).setUpClass()
-class ServersTestXML(ServersTestJSON):
+class ServersV3TestXML(ServersV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
index 080bd1a..3ee46ad 100644
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ b/tempest/api/compute/v3/servers/test_multiple_create.py
@@ -18,10 +18,10 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
-class MultipleCreateTestJSON(base.BaseV2ComputeTest):
+class MultipleCreateV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
_name = 'multiple-create-test'
@@ -38,7 +38,7 @@
return resp, body
- @attr(type='gate')
+ @test.attr(type='gate')
def test_multiple_create(self):
resp, body = self._create_multiple_servers(wait_until='ACTIVE',
min_count=1,
@@ -49,31 +49,31 @@
self.assertEqual('202', resp['status'])
self.assertNotIn('reservation_id', body)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_min_count_less_than_one(self):
invalid_min_count = 0
self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
min_count=invalid_min_count)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_min_count_non_integer(self):
invalid_min_count = 2.5
self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
min_count=invalid_min_count)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_max_count_less_than_one(self):
invalid_max_count = 0
self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
max_count=invalid_max_count)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_max_count_non_integer(self):
invalid_max_count = 2.5
self.assertRaises(exceptions.BadRequest, self._create_multiple_servers,
max_count=invalid_max_count)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_max_count_less_than_min_count(self):
min_count = 3
max_count = 2
@@ -81,7 +81,7 @@
min_count=min_count,
max_count=max_count)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_multiple_create_with_reservation_return(self):
resp, body = self._create_multiple_servers(wait_until='ACTIVE',
min_count=1,
@@ -91,5 +91,5 @@
self.assertIn('reservation_id', body)
-class MultipleCreateTestXML(MultipleCreateTestJSON):
+class MultipleCreateV3TestXML(MultipleCreateV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_actions.py b/tempest/api/compute/v3/servers/test_server_actions.py
index 8cd6c11..602bd5b 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -123,6 +123,7 @@
metadata=meta,
personality=personality,
admin_password=password)
+ self.addCleanup(self.client.rebuild, self.server_id, self.image_ref)
# Verify the properties in the initial response are correct
self.assertEqual(self.server_id, rebuilt_server['id'])
@@ -142,6 +143,35 @@
linux_client = RemoteClient(server, self.ssh_user, password)
linux_client.validate_authentication()
+ @attr(type='gate')
+ def test_rebuild_server_in_stop_state(self):
+ # The server in stop state should be rebuilt using the provided
+ # image and remain in SHUTOFF state
+ resp, server = self.client.get_server(self.server_id)
+ old_image = server['image']['id']
+ new_image = self.image_ref_alt \
+ if old_image == self.image_ref else self.image_ref
+ resp, server = self.client.stop(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id, 'SHUTOFF')
+ self.addCleanup(self.client.start, self.server_id)
+ resp, rebuilt_server = self.client.rebuild(self.server_id, new_image)
+ self.addCleanup(self.client.wait_for_server_status, self.server_id,
+ 'SHUTOFF')
+ self.addCleanup(self.client.rebuild, self.server_id, old_image)
+
+ # Verify the properties in the initial response are correct
+ self.assertEqual(self.server_id, rebuilt_server['id'])
+ rebuilt_image_id = rebuilt_server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+ self.assertEqual(self.flavor_ref, rebuilt_server['flavor']['id'])
+
+ # Verify the server properties after the rebuild completes
+ self.client.wait_for_server_status(rebuilt_server['id'], 'SHUTOFF')
+ resp, server = self.client.get_server(rebuilt_server['id'])
+ rebuilt_image_id = server['image']['id']
+ self.assertEqual(new_image, rebuilt_image_id)
+
def _detect_server_image_flavor(self, server_id):
# Detects the current server image flavor ref.
resp, server = self.client.get_server(self.server_id)
@@ -199,32 +229,115 @@
raise exceptions.TimeoutException(message)
@attr(type='gate')
+ def test_create_backup(self):
+ # Positive test:create backup successfully and rotate backups correctly
+ # create the first and the second backup
+ backup1 = data_utils.rand_name('backup')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup1)
+ oldest_backup_exist = True
+
+ # the oldest one should be deleted automatically in this test
+ def _clean_oldest_backup(oldest_backup):
+ if oldest_backup_exist:
+ self.images_client.delete_image(oldest_backup)
+
+ image1_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(_clean_oldest_backup, image1_id)
+ self.assertEqual(202, resp.status)
+ self.images_client.wait_for_image_status(image1_id, 'active')
+
+ backup2 = data_utils.rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup2)
+ image2_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.images_client.delete_image, image2_id)
+ self.assertEqual(202, resp.status)
+ self.images_client.wait_for_image_status(image2_id, 'active')
+
+ # verify they have been created
+ properties = {
+ 'image_type': 'backup',
+ 'backup_type': "daily",
+ 'instance_uuid': self.server_id,
+ }
+ resp, image_list = self.images_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup1, backup2),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ # create the third one, due to the rotation is 2,
+ # the first one will be deleted
+ backup3 = data_utils.rand_name('backup')
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+ resp, _ = self.servers_client.create_backup(self.server_id,
+ 'daily',
+ 2,
+ backup3)
+ image3_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.images_client.delete_image, image3_id)
+ self.assertEqual(202, resp.status)
+ # the first back up should be deleted
+ self.images_client.wait_for_resource_deletion(image1_id)
+ oldest_backup_exist = False
+ resp, image_list = self.images_client.image_list_detail(
+ properties,
+ sort_key='created_at',
+ sort_dir='asc')
+ self.assertEqual(200, resp.status)
+ self.assertEqual(2, len(image_list))
+ self.assertEqual((backup2, backup3),
+ (image_list[0]['name'], image_list[1]['name']))
+
+ def _get_output(self):
+ resp, output = self.servers_client.get_console_output(
+ self.server_id, 10)
+ self.assertEqual(200, resp.status)
+ self.assertTrue(output, "Console output was empty.")
+ lines = len(output.split('\n'))
+ self.assertEqual(lines, 10)
+
+ @attr(type='gate')
def test_get_console_output(self):
# Positive test:Should be able to GET the console output
# for a given server_id and number of lines
- def get_output():
- resp, output = self.servers_client.get_console_output(
- self.server_id, 10)
- self.assertEqual(200, resp.status)
- self.assertTrue(output, "Console output was empty.")
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
- self.wait_for(get_output)
- @skip_because(bug="1014683")
+ # This reboot is necessary for outputting some console log after
+ # creating a instance backup. If a instance backup, the console
+ # log file is truncated and we cannot get any console log through
+ # "console-log" API.
+ # The detail is https://bugs.launchpad.net/nova/+bug/1251920
+ resp, body = self.servers_client.reboot(self.server_id, 'HARD')
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ self.wait_for(self._get_output)
+
@attr(type='gate')
- def test_get_console_output_server_id_in_reboot_status(self):
+ def test_get_console_output_server_id_in_shutoff_status(self):
# Positive test:Should be able to GET the console output
- # for a given server_id in reboot status
- resp, output = self.servers_client.reboot(self.server_id, 'SOFT')
- self.servers_client.wait_for_server_status(self.server_id,
- 'REBOOT')
- resp, output = self.servers_client.get_console_output(self.server_id,
- 10)
- self.assertEqual(200, resp.status)
- self.assertIsNotNone(output)
- lines = len(output.split('\n'))
- self.assertEqual(lines, 10)
+ # for a given server_id in SHUTOFF status
+
+ # NOTE: SHUTOFF is irregular status. To avoid test instability,
+ # one server is created only for this test without using
+ # the server that was created in setupClass.
+ resp, server = self.create_test_server(wait_until='ACTIVE')
+ temp_server_id = server['id']
+
+ resp, server = self.servers_client.stop(temp_server_id)
+ self.assertEqual(202, resp.status)
+ self.servers_client.wait_for_server_status(temp_server_id, 'SHUTOFF')
+
+ self.wait_for(self._get_output)
@attr(type='gate')
def test_pause_unpause_server(self):
@@ -245,6 +358,30 @@
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
@attr(type='gate')
+ def test_shelve_unshelve_server(self):
+ resp, server = self.client.shelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+
+ offload_time = self.config.compute.shelved_offload_time
+ if offload_time >= 0:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED_OFFLOADED',
+ extra_timeout=offload_time)
+ else:
+ self.client.wait_for_server_status(self.server_id,
+ 'SHELVED')
+
+ resp, server = self.client.get_server(self.server_id)
+ image_name = server['name'] + '-shelved'
+ resp, images = self.images_client.image_list(name=image_name)
+ self.assertEqual(1, len(images))
+ self.assertEqual(image_name, images[0]['name'])
+
+ resp, server = self.client.unshelve_server(self.server_id)
+ self.assertEqual(202, resp.status)
+ self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+
+ @attr(type='gate')
def test_stop_start_server(self):
resp, server = self.servers_client.stop(self.server_id)
self.assertEqual(202, resp.status)
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index d72476d..9eff462 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -17,31 +17,31 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
-class ServersTestJSON(base.BaseV2ComputeTest):
+class ServersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(ServersTestJSON, cls).setUpClass()
+ super(ServersV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
def tearDown(self):
self.clear_servers()
- super(ServersTestJSON, self).tearDown()
+ super(ServersV3TestJSON, self).tearDown()
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_with_admin_password(self):
# If an admin password is provided on server creation, the server's
# root password should be set to that password.
- resp, server = self.create_test_server(adminPass='testpassword')
+ resp, server = self.create_test_server(admin_password='testpassword')
# Verify the password is set correctly in the response
- self.assertEqual('testpassword', server['adminPass'])
+ self.assertEqual('testpassword', server['admin_password'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_with_existing_server_name(self):
# Creating a server with a name that already exists is allowed
@@ -60,7 +60,7 @@
name2 = server['name']
self.assertEqual(name1, name2)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_specify_keypair(self):
# Specify a keypair while creating a server
@@ -73,7 +73,7 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual(key_name, server['key_name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_server_name(self):
# The server name should be changed to the the provided value
resp, server = self.create_test_server(wait_until='ACTIVE')
@@ -88,46 +88,47 @@
resp, server = self.client.get_server(server['id'])
self.assertEqual('newname', server['name'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_update_access_server_address(self):
# The server's access addresses should reflect the provided values
resp, server = self.create_test_server(wait_until='ACTIVE')
# Update the IPv4 and IPv6 access addresses
resp, body = self.client.update_server(server['id'],
- accessIPv4='1.1.1.1',
- accessIPv6='::babe:202:202')
+ access_ip_v4='1.1.1.1',
+ access_ip_v6='::babe:202:202')
self.assertEqual(200, resp.status)
self.client.wait_for_server_status(server['id'], 'ACTIVE')
# Verify the access addresses have been updated
resp, server = self.client.get_server(server['id'])
- self.assertEqual('1.1.1.1', server['accessIPv4'])
- self.assertEqual('::babe:202:202', server['accessIPv6'])
+ self.assertEqual('1.1.1.1', server['os-access-ips:access_ip_v4'])
+ self.assertEqual('::babe:202:202',
+ server['os-access-ips:access_ip_v6'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_server_while_in_building_state(self):
# Delete a server while it's VM state is Building
resp, server = self.create_test_server(wait_until='BUILD')
resp, _ = self.client.delete_server(server['id'])
self.assertEqual('204', resp['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_delete_active_server(self):
# Delete a server while it's VM state is Active
resp, server = self.create_test_server(wait_until='ACTIVE')
resp, _ = self.client.delete_server(server['id'])
self.assertEqual('204', resp['status'])
- @attr(type='gate')
+ @test.attr(type='gate')
def test_create_server_with_ipv6_addr_only(self):
# Create a server without an IPv4 address(only IPv6 address).
- resp, server = self.create_test_server(accessIPv6='2001:2001::3')
+ resp, server = self.create_test_server(access_ip_v6='2001:2001::3')
self.assertEqual('202', resp['status'])
self.client.wait_for_server_status(server['id'], 'ACTIVE')
resp, server = self.client.get_server(server['id'])
- self.assertEqual('2001:2001::3', server['accessIPv6'])
+ self.assertEqual('2001:2001::3', server['os-access-ips:access_ip_v6'])
-class ServersTestXML(ServersTestJSON):
+class ServersV3TestXML(ServersV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_servers_negative.py b/tempest/api/compute/v3/servers/test_servers_negative.py
index 6532032..85fe47c 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -25,11 +25,11 @@
from tempest import test
-class ServersNegativeTestJSON(base.BaseV2ComputeTest):
+class ServersNegativeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
def setUp(self):
- super(ServersNegativeTestJSON, self).setUp()
+ super(ServersNegativeV3TestJSON, self).setUp()
try:
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
except Exception:
@@ -37,10 +37,10 @@
@classmethod
def setUpClass(cls):
- super(ServersNegativeTestJSON, cls).setUpClass()
+ super(ServersNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
cls.alt_os = clients.AltManager()
- cls.alt_client = cls.alt_os.servers_client
+ cls.alt_client = cls.alt_os.servers_v3_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
@@ -53,18 +53,6 @@
name='')
@test.attr(type=['negative', 'gate'])
- def test_personality_file_contents_not_encoded(self):
- # Use an unencoded file when creating a server with personality
-
- file_contents = 'This is a test file.'
- person = [{'path': '/etc/testfile.txt',
- 'contents': file_contents}]
-
- self.assertRaises(exceptions.BadRequest,
- self.create_test_server,
- personality=person)
-
- @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -86,7 +74,7 @@
IPv4 = '1.1.1.1.1.1'
self.assertRaises(exceptions.BadRequest,
- self.create_test_server, accessIPv4=IPv4)
+ self.create_test_server, access_ip_v4=IPv4)
@test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
@@ -95,7 +83,7 @@
IPv6 = 'notvalid'
self.assertRaises(exceptions.BadRequest,
- self.create_test_server, accessIPv6=IPv6)
+ self.create_test_server, access_ip_v6=IPv6)
@test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
@@ -186,12 +174,12 @@
self.create_test_server,
name=server_name)
+ @test.skip_because(bug="1208743")
@test.attr(type=['negative', 'gate'])
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}]
-
self.assertRaises(exceptions.BadRequest,
self.create_test_server,
networks=networks)
@@ -421,8 +409,7 @@
resp, server = self.client.get_server(self.server_id)
image_name = server['name'] + '-shelved'
- params = {'name': image_name}
- resp, images = self.images_client.list_images(params)
+ resp, images = self.images_client.image_list(name=image_name)
self.assertEqual(1, len(images))
self.assertEqual(image_name, images[0]['name'])
@@ -445,5 +432,5 @@
self.server_id)
-class ServersNegativeTestXML(ServersNegativeTestJSON):
+class ServersNegativeV3TestXML(ServersNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/test_live_block_migration.py b/tempest/api/compute/v3/test_live_block_migration.py
new file mode 100644
index 0000000..3de50c8
--- /dev/null
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -0,0 +1,173 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2012 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import random
+import string
+
+import testtools
+
+from tempest.api.compute import base
+from tempest import config
+from tempest import exceptions
+from tempest.test import attr
+
+
+class LiveBlockMigrationV3TestJSON(base.BaseV3ComputeAdminTest):
+ _host_key = 'os-extended-server-attributes:host'
+ _interface = 'json'
+
+ CONF = config.CONF
+
+ @classmethod
+ def setUpClass(cls):
+ super(LiveBlockMigrationV3TestJSON, cls).setUpClass()
+
+ cls.admin_hosts_client = cls.hosts_admin_client
+ cls.admin_servers_client = cls.servers_admin_client
+
+ cls.created_server_ids = []
+
+ def _get_compute_hostnames(self):
+ _resp, body = self.admin_hosts_client.list_hosts()
+ return [
+ host_record['host_name']
+ for host_record in body
+ if host_record['service'] == 'compute'
+ ]
+
+ def _get_server_details(self, server_id):
+ _resp, body = self.admin_servers_client.get_server(server_id)
+ return body
+
+ def _get_host_for_server(self, server_id):
+ return self._get_server_details(server_id)[self._host_key]
+
+ def _migrate_server_to(self, server_id, dest_host):
+ _resp, body = self.admin_servers_client.live_migrate_server(
+ server_id, dest_host,
+ self.config.compute_feature_enabled.
+ block_migration_for_live_migration)
+ return body
+
+ def _get_host_other_than(self, host):
+ for target_host in self._get_compute_hostnames():
+ if host != target_host:
+ return target_host
+
+ def _get_non_existing_host_name(self):
+ random_name = ''.join(
+ random.choice(string.ascii_uppercase) for x in range(20))
+
+ self.assertNotIn(random_name, self._get_compute_hostnames())
+
+ return random_name
+
+ def _get_server_status(self, server_id):
+ return self._get_server_details(server_id)['status']
+
+ def _get_an_active_server(self):
+ for server_id in self.created_server_ids:
+ if 'ACTIVE' == self._get_server_status(server_id):
+ return server_id
+ else:
+ _, server = self.create_test_server(wait_until="ACTIVE")
+ server_id = server['id']
+ self.password = server['admin_password']
+ self.password = 'password'
+ self.created_server_ids.append(server_id)
+ return server_id
+
+ def _volume_clean_up(self, server_id, volume_id):
+ resp, body = self.volumes_client.get_volume(volume_id)
+ if body['status'] == 'in-use':
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id, 'available')
+ self.volumes_client.delete_volume(volume_id)
+
+ @testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
+ 'Live migration not available')
+ @attr(type='gate')
+ def test_live_block_migration(self):
+ # Live block migrate an instance to another host
+ if len(self._get_compute_hostnames()) < 2:
+ raise self.skipTest(
+ "Less than 2 compute nodes, skipping migration test.")
+ server_id = self._get_an_active_server()
+ actual_host = self._get_host_for_server(server_id)
+ target_host = self._get_host_other_than(actual_host)
+ self._migrate_server_to(server_id, target_host)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ self.assertEqual(target_host, self._get_host_for_server(server_id))
+
+ @testtools.skipIf(not CONF.compute_feature_enabled.live_migration,
+ 'Live migration not available')
+ @attr(type='gate')
+ def test_invalid_host_for_migration(self):
+ # Migrating to an invalid host should not change the status
+ server_id = self._get_an_active_server()
+ target_host = self._get_non_existing_host_name()
+
+ self.assertRaises(exceptions.BadRequest, self._migrate_server_to,
+ server_id, target_host)
+ self.assertEqual('ACTIVE', self._get_server_status(server_id))
+
+ @testtools.skipIf(not CONF.compute_feature_enabled.live_migration or not
+ CONF.compute_feature_enabled.
+ block_migration_for_live_migration,
+ 'Block Live migration not available')
+ @testtools.skipIf(not CONF.compute_feature_enabled.
+ block_migrate_cinder_iscsi,
+ 'Block Live migration not configured for iSCSI')
+ @attr(type='gate')
+ def test_iscsi_volume(self):
+ # Live block migrate an instance to another host
+ if len(self._get_compute_hostnames()) < 2:
+ raise self.skipTest(
+ "Less than 2 compute nodes, skipping migration test.")
+ server_id = self._get_an_active_server()
+ actual_host = self._get_host_for_server(server_id)
+ target_host = self._get_host_other_than(actual_host)
+
+ resp, volume = self.volumes_client.create_volume(1,
+ display_name='test')
+
+ self.volumes_client.wait_for_volume_status(volume['id'],
+ 'available')
+ self.addCleanup(self._volume_clean_up, server_id, volume['id'])
+
+ # Attach the volume to the server
+ self.servers_client.attach_volume(server_id, volume['id'],
+ device='/dev/xvdb')
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+
+ self._migrate_server_to(server_id, target_host)
+ self.servers_client.wait_for_server_status(server_id, 'ACTIVE')
+ self.assertEqual(target_host, self._get_host_for_server(server_id))
+
+ @classmethod
+ def tearDownClass(cls):
+ for server_id in cls.created_server_ids:
+ cls.servers_client.delete_server(server_id)
+
+ super(LiveBlockMigrationV3TestJSON, cls).tearDownClass()
+
+
+class LiveBlockMigrationV3TestXML(LiveBlockMigrationV3TestJSON):
+ _host_key = (
+ '{http://docs.openstack.org/compute/ext/'
+ 'extended_server_attributes/api/v3}host')
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/test_quotas.py b/tempest/api/compute/v3/test_quotas.py
index 475d055..d2f80a5 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -16,29 +16,27 @@
# under the License.
from tempest.api.compute import base
-from tempest.test import attr
+from tempest import test
-class QuotasTestJSON(base.BaseV2ComputeTest):
+class QuotasV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(QuotasTestJSON, cls).setUpClass()
+ super(QuotasV3TestJSON, cls).setUpClass()
cls.client = cls.quotas_client
cls.admin_client = cls._get_identity_admin_client()
resp, tenants = cls.admin_client.list_tenants()
cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
cls.client.tenant_name][0]
- cls.default_quota_set = set(('injected_file_content_bytes',
- 'metadata_items', 'injected_files',
+ cls.default_quota_set = set(('metadata_items',
'ram', 'floating_ips',
'fixed_ips', 'key_pairs',
- 'injected_file_path_bytes',
'instances', 'security_group_rules',
'cores', 'security_groups'))
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_quotas(self):
# User can get the quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -48,7 +46,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_get_default_quotas(self):
# User can get the default quota set for it's tenant
expected_quota_set = self.default_quota_set | set(['id'])
@@ -58,7 +56,7 @@
sorted(quota_set.keys()))
self.assertEqual(quota_set['id'], self.tenant_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_compare_tenant_quotas_with_default_quotas(self):
# Tenants are created with the default quota values
resp, defualt_quota_set = \
@@ -69,5 +67,5 @@
self.assertEqual(defualt_quota_set, tenant_quota_set)
-class QuotasTestXML(QuotasTestJSON):
+class QuotasV3TestXML(QuotasV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/identity/admin/test_services.py b/tempest/api/identity/admin/test_services.py
index 7fe5171..872adb8 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -25,47 +25,47 @@
class ServicesTestJSON(base.BaseIdentityAdminTest):
_interface = 'json'
+ def _del_service(self, service_id):
+ # Deleting the service created in this method
+ resp, _ = self.client.delete_service(service_id)
+ self.assertEqual(resp['status'], '204')
+ # Checking whether service is deleted successfully
+ self.assertRaises(exceptions.NotFound, self.client.get_service,
+ service_id)
+
@attr(type='smoke')
def test_create_get_delete_service(self):
# GET Service
- try:
- # Creating a Service
- name = data_utils.rand_name('service-')
- type = data_utils.rand_name('type--')
- description = data_utils.rand_name('description-')
- resp, service_data = self.client.create_service(
- name, type, description=description)
- self.assertTrue(resp['status'].startswith('2'))
- # Verifying response body of create service
- self.assertIn('id', service_data)
- self.assertFalse(service_data['id'] is None)
- self.assertIn('name', service_data)
- self.assertEqual(name, service_data['name'])
- self.assertIn('type', service_data)
- self.assertEqual(type, service_data['type'])
- self.assertIn('description', service_data)
- self.assertEqual(description, service_data['description'])
- # Get service
- resp, fetched_service = self.client.get_service(service_data['id'])
- self.assertTrue(resp['status'].startswith('2'))
- # verifying the existence of service created
- self.assertIn('id', fetched_service)
- self.assertEqual(fetched_service['id'], service_data['id'])
- self.assertIn('name', fetched_service)
- self.assertEqual(fetched_service['name'], service_data['name'])
- self.assertIn('type', fetched_service)
- self.assertEqual(fetched_service['type'], service_data['type'])
- self.assertIn('description', fetched_service)
- self.assertEqual(fetched_service['description'],
- service_data['description'])
- finally:
- if 'service_data' in locals():
- # Deleting the service created in this method
- resp, _ = self.client.delete_service(service_data['id'])
- self.assertEqual(resp['status'], '204')
- # Checking whether service is deleted successfully
- self.assertRaises(exceptions.NotFound, self.client.get_service,
- service_data['id'])
+ # Creating a Service
+ name = data_utils.rand_name('service-')
+ type = data_utils.rand_name('type--')
+ description = data_utils.rand_name('description-')
+ resp, service_data = self.client.create_service(
+ name, type, description=description)
+ self.assertFalse(service_data['id'] is None)
+ self.addCleanup(self._del_service, service_data['id'])
+ self.assertTrue(resp['status'].startswith('2'))
+ # Verifying response body of create service
+ self.assertIn('id', service_data)
+ self.assertIn('name', service_data)
+ self.assertEqual(name, service_data['name'])
+ self.assertIn('type', service_data)
+ self.assertEqual(type, service_data['type'])
+ self.assertIn('description', service_data)
+ self.assertEqual(description, service_data['description'])
+ # Get service
+ resp, fetched_service = self.client.get_service(service_data['id'])
+ self.assertTrue(resp['status'].startswith('2'))
+ # verifying the existence of service created
+ self.assertIn('id', fetched_service)
+ self.assertEqual(fetched_service['id'], service_data['id'])
+ self.assertIn('name', fetched_service)
+ self.assertEqual(fetched_service['name'], service_data['name'])
+ self.assertIn('type', fetched_service)
+ self.assertEqual(fetched_service['type'], service_data['type'])
+ self.assertIn('description', fetched_service)
+ self.assertEqual(fetched_service['description'],
+ service_data['description'])
@attr(type='smoke')
def test_list_services(self):
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
index 5e13a5a..1ecc90c 100644
--- a/tempest/api/identity/admin/v3/test_trusts.py
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -12,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+import datetime
+import re
from tempest.api.identity import base
from tempest import clients
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
+from tempest.openstack.common import timeutils
from tempest.test import attr
@@ -28,7 +31,14 @@
self.trust_id = None
self.create_trustor_and_roles()
- self.addCleanup(self.cleanup_trust_user_and_roles)
+ self.addCleanup(self.cleanup_user_and_roles)
+
+ def tearDown(self):
+ if self.trust_id:
+ # Do the delete in tearDown not addCleanup - we want the test to
+ # fail in the event there is a bug which causes undeletable trusts
+ self.delete_trust()
+ super(BaseTrustsV3Test, self).tearDown()
def create_trustor_and_roles(self):
# Get trustor project ID, use the admin project
@@ -83,14 +93,7 @@
interface=self._interface)
self.trustor_v3_client = os.identity_v3_client
- def cleanup_trust_user_and_roles(self):
- if self.trust_id:
- try:
- self.trustor_v3_client.delete_trust(self.trust_id)
- except exceptions.NotFound:
- pass
- self.trust_id = None
-
+ def cleanup_user_and_roles(self):
if self.trustor_user_id:
self.v3_client.delete_user(self.trustor_user_id)
if self.delegated_role_id:
@@ -115,7 +118,15 @@
summary=False):
self.assertIsNotNone(trust['id'])
self.assertEqual(impersonate, trust['impersonation'])
- self.assertEqual(expires, trust['expires_at'])
+ # FIXME(shardy): ref bug #1246383 we can't check the
+ # microsecond component of the expiry time, because mysql
+ # <5.6.4 doesn't support microseconds.
+ # expected format 2013-12-20T16:08:36.036987Z
+ if expires is not None:
+ expires_nousec = re.sub(r'\.([0-9]){6}Z', '', expires)
+ self.assertTrue(trust['expires_at'].startswith(expires_nousec))
+ else:
+ self.assertIsNone(trust['expires_at'])
self.assertEqual(self.trustor_user_id, trust['trustor_user_id'])
self.assertEqual(self.trustee_user_id, trust['trustee_user_id'])
self.assertIn('v3/OS-TRUST/trusts', trust['links']['self'])
@@ -195,8 +206,6 @@
self.check_trust_roles()
- self.delete_trust()
-
@attr(type='smoke')
def test_trust_noimpersonate(self):
# Test case to check we can create, get and delete a trust
@@ -209,7 +218,21 @@
self.check_trust_roles()
- self.delete_trust()
+ @attr(type='smoke')
+ def test_trust_expire(self):
+ # Test case to check we can create, get and delete a trust
+ # with an expiry specified
+ expires_at = timeutils.utcnow() + datetime.timedelta(hours=1)
+ expires_str = timeutils.isotime(at=expires_at, subsecond=True)
+
+ trust = self.create_trust(expires=expires_str)
+ self.validate_trust(trust, expires=expires_str)
+
+ trust_get = self.get_trust()
+
+ self.validate_trust(trust_get, expires=expires_str)
+
+ self.check_trust_roles()
@attr(type='smoke')
def test_trust_expire_invalid(self):
@@ -220,3 +243,22 @@
self.assertRaises(exceptions.BadRequest,
self.create_trust,
expires=expires_str)
+
+ @attr(type='smoke')
+ def test_get_trusts_query(self):
+ self.create_trust()
+ resp, trusts_get = self.trustor_v3_client.get_trusts(
+ trustor_user_id=self.trustor_user_id)
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(1, len(trusts_get))
+ self.validate_trust(trusts_get[0], summary=True)
+
+ @attr(type='smoke')
+ def test_get_trusts_all(self):
+ self.create_trust()
+ resp, trusts_get = self.v3_client.get_trusts()
+ self.assertEqual('200', resp['status'])
+ trusts = [t for t in trusts_get
+ if t['id'] == self.trust_id]
+ self.assertEqual(1, len(trusts))
+ self.validate_trust(trusts[0], summary=True)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 064eaff..dcad101 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -66,6 +66,7 @@
cls.health_monitors = []
cls.vpnservices = []
cls.ikepolicies = []
+ cls.floating_ips = []
@classmethod
def tearDownClass(cls):
@@ -75,6 +76,9 @@
# Clean up vpn services
for vpnservice in cls.vpnservices:
cls.client.delete_vpnservice(vpnservice['id'])
+ # Clean up floating IPs
+ for floating_ip in cls.floating_ips:
+ cls.client.delete_floating_ip(floating_ip['id'])
# Clean up routers
for router in cls.routers:
resp, body = cls.client.list_router_interfaces(router['id'])
@@ -167,15 +171,35 @@
return router
@classmethod
+ def create_floating_ip(cls, external_network_id, **kwargs):
+ """Wrapper utility that returns a test floating IP."""
+ resp, body = cls.client.create_floating_ip(
+ external_network_id,
+ **kwargs)
+ fip = body['floatingip']
+ cls.floating_ips.append(fip)
+ return fip
+
+ @classmethod
def create_pool(cls, name, lb_method, protocol, subnet):
"""Wrapper utility that returns a test pool."""
- resp, body = cls.client.create_pool(name, lb_method, protocol,
- subnet['id'])
+ resp, body = cls.client.create_pool(
+ name=name,
+ lb_method=lb_method,
+ protocol=protocol,
+ subnet_id=subnet['id'])
pool = body['pool']
cls.pools.append(pool)
return pool
@classmethod
+ def update_pool(cls, name):
+ """Wrapper utility that returns a test pool."""
+ resp, body = cls.client.update_pool(name=name)
+ pool = body['pool']
+ return pool
+
+ @classmethod
def create_vip(cls, name, protocol, protocol_port, subnet, pool):
"""Wrapper utility that returns a test vip."""
resp, body = cls.client.create_vip(name, protocol, protocol_port,
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
new file mode 100644
index 0000000..9baef04
--- /dev/null
+++ b/tempest/api/network/base_routers.py
@@ -0,0 +1,50 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.network import base
+
+
+class BaseRouterTest(base.BaseAdminNetworkTest):
+ # NOTE(salv-orlando): This class inherits from BaseAdminNetworkTest
+ # as some router operations, such as enabling or disabling SNAT
+ # require admin credentials by default
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseRouterTest, cls).setUpClass()
+
+ def _delete_router(self, router_id):
+ resp, _ = self.client.delete_router(router_id)
+ self.assertEqual(204, resp.status)
+ # Asserting that the router is not found in the list
+ # after deletion
+ resp, list_body = self.client.list_routers()
+ self.assertEqual('200', resp['status'])
+ routers_list = list()
+ for router in list_body['routers']:
+ routers_list.append(router['id'])
+ self.assertNotIn(router_id, routers_list)
+
+ def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
+ resp, _ = self.client.remove_router_interface_with_subnet_id(
+ router_id, subnet_id)
+ self.assertEqual('200', resp['status'])
+
+ def _remove_router_interface_with_port_id(self, router_id, port_id):
+ resp, _ = self.client.remove_router_interface_with_port_id(
+ router_id, port_id)
+ self.assertEqual('200', resp['status'])
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 3a41f4f..6f3fa4b 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -25,15 +25,18 @@
"""
Tests the following operations in the Quantum API using the REST client for
- Quantum:
+ Neutron:
Create a Floating IP
Update a Floating IP
Delete a Floating IP
List all Floating IPs
Show Floating IP details
+ Associate a Floating IP with a port and then delete that port
+ Associate a Floating IP with a port and then with a port on another
+ router
- v2.0 of the Quantum API is assumed. It is also assumed that the following
+ v2.0 of the Neutron API is assumed. It is also assumed that the following
options are defined in the [network] section of etc/tempest.conf:
public_network_id which is the id for the external network present
@@ -47,63 +50,38 @@
# Create network, subnet, router and add interface
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
- cls.router = cls.create_router(
- data_utils.rand_name('router-'),
- external_network_id=cls.network_cfg.public_network_id)
- resp, _ = cls.client.add_router_interface_with_subnet_id(
- cls.router['id'], cls.subnet['id'])
+ cls.router = cls.create_router(data_utils.rand_name('router-'),
+ external_network_id=cls.ext_net_id)
+ cls.create_router_interface(cls.router['id'], cls.subnet['id'])
cls.port = list()
# Create two ports one each for Creation and Updating of floatingIP
for i in range(2):
- resp, port = cls.client.create_port(cls.network['id'])
- cls.port.append(port['port'])
-
- @classmethod
- def tearDownClass(cls):
- cls.client.remove_router_interface_with_subnet_id(cls.router['id'],
- cls.subnet['id'])
- for i in range(2):
- cls.client.delete_port(cls.port[i]['id'])
- super(FloatingIPTestJSON, cls).tearDownClass()
-
- def _delete_floating_ip(self, floating_ip_id):
- # Deletes a floating IP and verifies if it is deleted or not
- resp, _ = self.client.delete_floatingip(floating_ip_id)
- self.assertEqual(204, resp.status)
- # Asserting that the floating_ip is not found in list after deletion
- resp, floating_ips = self.client.list_floatingips()
- floatingip_id_list = list()
- for f in floating_ips['floatingips']:
- floatingip_id_list.append(f['id'])
- self.assertNotIn(floating_ip_id, floatingip_id_list)
+ cls.create_port(cls.network)
@attr(type='smoke')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
- resp, floating_ip = self.client.create_floating_ip(
- self.ext_net_id, port_id=self.port[0]['id'])
- self.assertEqual('201', resp['status'])
- create_floating_ip = floating_ip['floatingip']
- self.assertIsNotNone(create_floating_ip['id'])
- self.assertIsNotNone(create_floating_ip['tenant_id'])
- self.assertIsNotNone(create_floating_ip['floating_ip_address'])
- self.assertEqual(create_floating_ip['port_id'], self.port[0]['id'])
- self.assertEqual(create_floating_ip['floating_network_id'],
+ created_floating_ip = self.create_floating_ip(
+ self.ext_net_id, port_id=self.ports[0]['id'])
+ self.assertIsNotNone(created_floating_ip['id'])
+ self.assertIsNotNone(created_floating_ip['tenant_id'])
+ self.assertIsNotNone(created_floating_ip['floating_ip_address'])
+ self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id'])
+ self.assertEqual(created_floating_ip['floating_network_id'],
self.ext_net_id)
- self.addCleanup(self._delete_floating_ip, create_floating_ip['id'])
# Verifies the details of a floating_ip
resp, floating_ip = self.client.show_floating_ip(
- create_floating_ip['id'])
+ created_floating_ip['id'])
self.assertEqual('200', resp['status'])
- show_floating_ip = floating_ip['floatingip']
- self.assertEqual(show_floating_ip['id'], create_floating_ip['id'])
- self.assertEqual(show_floating_ip['floating_network_id'],
+ shown_floating_ip = floating_ip['floatingip']
+ self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
+ self.assertEqual(shown_floating_ip['floating_network_id'],
self.ext_net_id)
- self.assertEqual(show_floating_ip['tenant_id'],
- create_floating_ip['tenant_id'])
- self.assertEqual(show_floating_ip['floating_ip_address'],
- create_floating_ip['floating_ip_address'])
- self.assertEqual(show_floating_ip['port_id'], self.port[0]['id'])
+ self.assertEqual(shown_floating_ip['tenant_id'],
+ created_floating_ip['tenant_id'])
+ self.assertEqual(shown_floating_ip['floating_ip_address'],
+ created_floating_ip['floating_ip_address'])
+ self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
resp, floating_ips = self.client.list_floatingips()
@@ -111,25 +89,70 @@
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
- self.assertIn(create_floating_ip['id'], floatingip_id_list)
-
+ self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=self.port[1]['id'])
+ created_floating_ip['id'], port_id=self.ports[1]['id'])
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertEqual(update_floating_ip['port_id'], self.port[1]['id'])
- self.assertIsNotNone(update_floating_ip['fixed_ip_address'])
- self.assertEqual(update_floating_ip['router_id'], self.router['id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id'])
+ self.assertEqual(updated_floating_ip['fixed_ip_address'],
+ self.ports[1]['fixed_ips'][0]['ip_address'])
+ self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
resp, floating_ip = self.client.update_floating_ip(
- create_floating_ip['id'], port_id=None)
+ created_floating_ip['id'], port_id=None)
self.assertEqual('200', resp['status'])
- update_floating_ip = floating_ip['floatingip']
- self.assertIsNone(update_floating_ip['port_id'])
- self.assertIsNone(update_floating_ip['fixed_ip_address'])
- self.assertIsNone(update_floating_ip['router_id'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertIsNone(updated_floating_ip['port_id'])
+ self.assertIsNone(updated_floating_ip['fixed_ip_address'])
+ self.assertIsNone(updated_floating_ip['router_id'])
+
+ @attr(type='smoke')
+ def test_floating_ip_delete_port(self):
+ # Create a floating IP
+ created_floating_ip = self.create_floating_ip(self.ext_net_id)
+ # Create a port
+ resp, port = self.client.create_port(self.network['id'])
+ created_port = port['port']
+ resp, floating_ip = self.client.update_floating_ip(
+ created_floating_ip['id'], port_id=created_port['id'])
+ self.assertEqual('200', resp['status'])
+ # Delete port
+ self.client.delete_port(created_port['id'])
+ # Verifies the details of the floating_ip
+ resp, floating_ip = self.client.show_floating_ip(
+ created_floating_ip['id'])
+ self.assertEqual('200', resp['status'])
+ shown_floating_ip = floating_ip['floatingip']
+ # Confirm the fields are back to None
+ self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
+ self.assertIsNone(shown_floating_ip['port_id'])
+ self.assertIsNone(shown_floating_ip['fixed_ip_address'])
+ self.assertIsNone(shown_floating_ip['router_id'])
+
+ @attr(type='smoke')
+ def test_floating_ip_update_different_router(self):
+ # Associate a floating IP to a port on a router
+ created_floating_ip = self.create_floating_ip(
+ self.ext_net_id, port_id=self.ports[1]['id'])
+ self.assertEqual(created_floating_ip['router_id'], self.router['id'])
+ network2 = self.create_network()
+ subnet2 = self.create_subnet(network2)
+ router2 = self.create_router(data_utils.rand_name('router-'),
+ external_network_id=self.ext_net_id)
+ self.create_router_interface(router2['id'], subnet2['id'])
+ port_other_router = self.create_port(network2)
+ # Associate floating IP to the other port on another router
+ resp, floating_ip = self.client.update_floating_ip(
+ created_floating_ip['id'], port_id=port_other_router['id'])
+ self.assertEqual('200', resp['status'])
+ updated_floating_ip = floating_ip['floatingip']
+ self.assertEqual(updated_floating_ip['router_id'], router2['id'])
+ self.assertEqual(updated_floating_ip['port_id'],
+ port_other_router['id'])
+ self.assertIsNotNone(updated_floating_ip['fixed_ip_address'])
class FloatingIPTestXML(FloatingIPTestJSON):
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 1f4b378..d1ad134 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -72,9 +72,11 @@
def test_create_update_delete_pool_vip(self):
# Creates a vip
name = data_utils.rand_name('vip-')
- resp, body = self.client.create_pool(data_utils.rand_name("pool-"),
- "ROUND_ROBIN", "HTTP",
- self.subnet['id'])
+ resp, body = self.client.create_pool(
+ name=data_utils.rand_name("pool-"),
+ lb_method='ROUND_ROBIN',
+ protocol='HTTP',
+ subnet_id=self.subnet['id'])
pool = body['pool']
resp, body = self.client.create_vip(name, "HTTP", 80,
self.subnet['id'], pool['id'])
@@ -92,7 +94,8 @@
self.assertEqual('204', resp['status'])
# Verification of pool update
new_name = "New_pool"
- resp, body = self.client.update_pool(pool['id'], new_name)
+ resp, body = self.client.update_pool(pool['id'],
+ name=new_name)
self.assertEqual('200', resp['status'])
updated_pool = body['pool']
self.assertEqual(updated_pool['name'], new_name)
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 21934f2..b6022e8 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -17,43 +17,18 @@
import netaddr
-from tempest.api.network import base
+from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
from tempest import test
-class RoutersTest(base.BaseAdminNetworkTest):
- # NOTE(salv-orlando): This class inherits from BaseAdminNetworkTest
- # as some router operations, such as enabling or disabling SNAT
- # require admin credentials by default
+class RoutersTest(base.BaseRouterTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
super(RoutersTest, cls).setUpClass()
- def _delete_router(self, router_id):
- resp, _ = self.client.delete_router(router_id)
- self.assertEqual(204, resp.status)
- # Asserting that the router is not found in the list
- # after deletion
- resp, list_body = self.client.list_routers()
- self.assertEqual('200', resp['status'])
- routers_list = list()
- for router in list_body['routers']:
- routers_list.append(router['id'])
- self.assertNotIn(router_id, routers_list)
-
- def _remove_router_interface_with_subnet_id(self, router_id, subnet_id):
- resp, _ = self.client.remove_router_interface_with_subnet_id(
- router_id, subnet_id)
- self.assertEqual('200', resp['status'])
-
- def _remove_router_interface_with_port_id(self, router_id, port_id):
- resp, _ = self.client.remove_router_interface_with_port_id(
- router_id, port_id)
- self.assertEqual('200', resp['status'])
-
@test.attr(type='smoke')
def test_create_show_list_update_delete_router(self):
# Create a router
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
new file mode 100644
index 0000000..520a612
--- /dev/null
+++ b/tempest/api/network/test_routers_negative.py
@@ -0,0 +1,57 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.api.network import base_routers as base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class RoutersNegativeTest(base.BaseRouterTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(RoutersNegativeTest, cls).setUpClass()
+ cls.router = cls.create_router(data_utils.rand_name('router-'))
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+
+ @attr(type=['negative', 'smoke'])
+ def test_router_add_gateway_invalid_network_returns_404(self):
+ self.assertRaises(exceptions.NotFound,
+ self.client.update_router,
+ self.router['id'],
+ external_gateway_info={
+ 'network_id': self.router['id']})
+
+ @attr(type=['negative', 'smoke'])
+ def test_router_add_gateway_net_not_external_returns_400(self):
+ self.create_subnet(self.network)
+ self.assertRaises(exceptions.BadRequest,
+ self.client.update_router,
+ self.router['id'],
+ external_gateway_info={
+ 'network_id': self.network['id']})
+
+ @attr(type=['negative', 'smoke'])
+ def test_router_remove_interface_in_use_returns_409(self):
+ self.client.add_router_interface_with_subnet_id(
+ self.router['id'], self.subnet['id'])
+ self.assertRaises(exceptions.Conflict,
+ self.client.delete_router,
+ self.router['id'])
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 9d5a1c0..d0e5353 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -39,27 +39,36 @@
def setUpClass(cls):
super(ObjectTempUrlTest, cls).setUpClass()
- # skip this test if CORS isn't enabled in the conf file.
+ # skip this test if TempUrl isn't enabled in the conf file.
if not cls.tempurl_available:
skip_msg = ("%s skipped as TempUrl middleware not available"
% cls.__name__)
raise cls.skipException(skip_msg)
+ # create a container
cls.container_name = data_utils.rand_name(name='TestContainer')
cls.container_client.create_container(cls.container_name)
cls.containers = [cls.container_name]
# update account metadata
cls.key = 'Meta'
+ cls.metadatas = []
cls.metadata = {'Temp-URL-Key': cls.key}
+ cls.metadatas.append(cls.metadata)
cls.account_client.create_account_metadata(metadata=cls.metadata)
- cls.account_client_metadata, _ = \
- cls.account_client.list_account_metadata()
+
+ # create an object
+ cls.object_name = data_utils.rand_name(name='ObjectTemp')
+ cls.content = data_utils.arbitrary_string(size=len(cls.object_name),
+ base_text=cls.object_name)
+ cls.object_client.create_object(cls.container_name,
+ cls.object_name, cls.content)
@classmethod
def tearDownClass(cls):
- resp, _ = cls.account_client.delete_account_metadata(
- metadata=cls.metadata)
+ for metadata in cls.metadata:
+ cls.account_client.delete_account_metadata(
+ metadata=metadata)
cls.delete_containers(cls.containers)
@@ -69,21 +78,16 @@
def setUp(self):
super(ObjectTempUrlTest, self).setUp()
+
# make sure the metadata has been set
+ account_client_metadata, _ = \
+ self.account_client.list_account_metadata()
self.assertIn('x-account-meta-temp-url-key',
- self.account_client_metadata)
-
+ account_client_metadata)
self.assertEqual(
- self.account_client_metadata['x-account-meta-temp-url-key'],
+ account_client_metadata['x-account-meta-temp-url-key'],
self.key)
- # create object
- self.object_name = data_utils.rand_name(name='ObjectTemp')
- self.data = data_utils.arbitrary_string(size=len(self.object_name),
- base_text=self.object_name)
- self.object_client.create_object(self.container_name,
- self.object_name, self.data)
-
def _get_expiry_date(self, expiration_time=1000):
return int(time.time() + expiration_time)
@@ -114,10 +118,10 @@
expires, self.key)
# trying to get object using temp url within expiry time
- resp, body = self.object_client.get_object_using_temp_url(url)
+ resp, body = self.object_client.get(url)
self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'GET')
- self.assertEqual(body, self.data)
+ self.assertEqual(body, self.content)
# Testing a HEAD on this Temp URL
resp, body = self.object_client.head(url)
@@ -129,23 +133,27 @@
key2 = 'Meta2-'
metadata = {'Temp-URL-Key-2': key2}
self.account_client.create_account_metadata(metadata=metadata)
+ self.metadatas.append(metadata)
- self.account_client_metadata, _ = \
+ # make sure the metadata has been set
+ account_client_metadata, _ = \
self.account_client.list_account_metadata()
self.assertIn('x-account-meta-temp-url-key-2',
- self.account_client_metadata)
+ account_client_metadata)
+ self.assertEqual(
+ account_client_metadata['x-account-meta-temp-url-key-2'],
+ key2)
expires = self._get_expiry_date()
url = self._get_temp_url(self.container_name,
self.object_name, "GET",
expires, key2)
- resp, body = self.object_client.get_object_using_temp_url(url)
+ resp, body = self.object_client.get(url)
self.assertIn(int(resp['status']), HTTP_SUCCESS)
- self.assertEqual(body, self.data)
+ self.assertEqual(body, self.content)
@attr(type='gate')
def test_put_object_using_temp_url(self):
- # make sure the metadata has been set
new_data = data_utils.arbitrary_string(
size=len(self.object_name),
base_text=data_utils.rand_name(name="random"))
@@ -156,9 +164,7 @@
expires, self.key)
# trying to put random data in the object using temp url
- resp, body = self.object_client.put_object_using_temp_url(
- url, new_data)
-
+ resp, body = self.object_client.put(url, new_data, None)
self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'PUT')
@@ -172,9 +178,23 @@
self.object_name, "GET",
expires, self.key)
- _, body = self.object_client.get_object_using_temp_url(url)
+ _, body = self.object_client.get(url)
self.assertEqual(body, new_data)
+ @attr(type='gate')
+ def test_head_object_using_temp_url(self):
+ expires = self._get_expiry_date()
+
+ # get a temp URL for the created object
+ url = self._get_temp_url(self.container_name,
+ self.object_name, "HEAD",
+ expires, self.key)
+
+ # Testing a HEAD on this Temp URL
+ resp, body = self.object_client.head(url)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Object', 'HEAD')
+
@attr(type=['gate', 'negative'])
def test_get_object_after_expiration_time(self):
@@ -188,5 +208,4 @@
time.sleep(2)
self.assertRaises(exceptions.Unauthorized,
- self.object_client.get_object_using_temp_url,
- url)
+ self.object_client.get, url)
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index f3ef99f..b6c03e0 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import time
-
from tempest import clients
from tempest.common.utils import data_utils
from tempest.openstack.common import log as logging
@@ -118,21 +116,6 @@
cls.clear_keypairs()
super(BaseOrchestrationTest, cls).tearDownClass()
- def wait_for(self, condition):
- """Repeatedly calls condition() until a timeout."""
- start_time = int(time.time())
- while True:
- try:
- condition()
- except Exception:
- pass
- else:
- return
- if int(time.time()) - start_time >= self.build_timeout:
- condition()
- return
- time.sleep(self.build_interval)
-
@staticmethod
def stack_output(stack, output_key):
"""Return a stack output value for a give key."""
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index 03e8469..c563259 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -22,7 +22,7 @@
LOG = logging.getLogger(__name__)
-class VolumeMultiBackendTest(base.BaseVolumeAdminTest):
+class VolumeMultiBackendTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 5e838e5..03fbd33 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -15,12 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeAdminTest
+from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.test import attr
-class SnapshotsActionsTest(BaseVolumeAdminTest):
+class SnapshotsActionsTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/admin/test_volume_hosts.py b/tempest/api/volume/admin/test_volume_hosts.py
index e7d8c02..4f40d4a 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -19,7 +19,7 @@
from tempest.test import attr
-class VolumeHostsAdminTestsJSON(base.BaseVolumeAdminTest):
+class VolumeHostsAdminTestsJSON(base.BaseVolumeV1AdminTest):
_interface = "json"
@attr(type='gate')
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 5218f83..3a92e8d 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -15,13 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeTest
+from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.services.volume.json.admin import volume_types_client
from tempest.test import attr
-class VolumeTypesTest(BaseVolumeTest):
+class VolumeTypesTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index dbb75af..f0fba07 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -20,7 +20,7 @@
from tempest.test import attr
-class VolumeTypesExtraSpecsTest(base.BaseVolumeAdminTest):
+class VolumeTypesExtraSpecsTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 8b5dce2..cf992f2 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -23,7 +23,7 @@
from tempest.test import attr
-class ExtraSpecsNegativeTest(base.BaseVolumeAdminTest):
+class ExtraSpecsNegativeTest(base.BaseVolumeV1AdminTest):
_interface = 'json'
@classmethod
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 44725df..3832048 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -22,7 +22,7 @@
from tempest.test import attr
-class VolumeTypesNegativeTest(base.BaseVolumeAdminTest):
+class VolumeTypesNegativeTest(base.BaseVolumeV1AdminTest):
_interface = 'json'
@attr(type='gate')
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index cb9ff11..941dc7e 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -15,12 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeAdminTest
+from tempest.api.volume import base
from tempest.common.utils import data_utils as utils
from tempest.test import attr
-class VolumesActionsTest(BaseVolumeAdminTest):
+class VolumesActionsTest(base.BaseVolumeV1AdminTest):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index ba99309..9c841cc 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -15,9 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
-import time
-
from tempest import clients
+from tempest.common.utils import data_utils
from tempest.openstack.common import log as logging
import tempest.test
@@ -36,13 +35,12 @@
skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
raise cls.skipException(skip_msg)
- os = cls.get_client_manager()
+ cls.os = cls.get_client_manager()
- cls.os = os
- cls.volumes_client = os.volumes_client
- cls.snapshots_client = os.snapshots_client
- cls.servers_client = os.servers_client
- cls.volumes_extension_client = os.volumes_extension_client
+ cls.volumes_client = cls.os.volumes_client
+ cls.snapshots_client = cls.os.snapshots_client
+ cls.servers_client = cls.os.servers_client
+ cls.volumes_extension_client = cls.os.volumes_extension_client
cls.image_ref = cls.config.compute.image_ref
cls.flavor_ref = cls.config.compute.flavor_ref
cls.build_interval = cls.config.volume.build_interval
@@ -50,12 +48,6 @@
cls.snapshots = []
cls.volumes = []
- cls.volumes_client.keystone_auth(cls.os.username,
- cls.os.password,
- cls.os.auth_url,
- cls.volumes_client.service,
- cls.os.tenant_name)
-
@classmethod
def tearDownClass(cls):
cls.clear_snapshots()
@@ -80,7 +72,10 @@
@classmethod
def create_volume(cls, size=1, **kwargs):
"""Wrapper utility that returns a test volume."""
- resp, volume = cls.volumes_client.create_volume(size, **kwargs)
+ vol_name = data_utils.rand_name('Volume')
+ resp, volume = cls.volumes_client.create_volume(size,
+ display_name=vol_name,
+ **kwargs)
assert 200 == resp.status
cls.volumes.append(volume)
cls.volumes_client.wait_for_volume_status(volume['id'], 'available')
@@ -114,27 +109,27 @@
except Exception:
pass
- def wait_for(self, condition):
- """Repeatedly calls condition() until a timeout."""
- start_time = int(time.time())
- while True:
- try:
- condition()
- except Exception:
- pass
- else:
- return
- if int(time.time()) - start_time >= self.build_timeout:
- condition()
- return
- time.sleep(self.build_interval)
+
+class BaseVolumeV1Test(BaseVolumeTest):
+ @classmethod
+ def setUpClass(cls):
+ if not cls.config.volume_feature_enabled.api_v1:
+ msg = "Volume API v1 not supported"
+ raise cls.skipException(msg)
+ super(BaseVolumeV1Test, cls).setUpClass()
+ cls.volumes_client = cls.os.volumes_client
+ cls.volumes_client.keystone_auth(cls.os.username,
+ cls.os.password,
+ cls.os.auth_url,
+ cls.volumes_client.service,
+ cls.os.tenant_name)
-class BaseVolumeAdminTest(BaseVolumeTest):
+class BaseVolumeV1AdminTest(BaseVolumeV1Test):
"""Base test case class for all Volume Admin API tests."""
@classmethod
def setUpClass(cls):
- super(BaseVolumeAdminTest, cls).setUpClass()
+ super(BaseVolumeV1AdminTest, cls).setUpClass()
cls.adm_user = cls.config.identity.admin_username
cls.adm_pass = cls.config.identity.admin_password
cls.adm_tenant = cls.config.identity.admin_tenant_name
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index dacebf1..34eab00 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -15,13 +15,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeTest
+from tempest.api.volume import base
from tempest import clients
-from tempest.common.utils.data_utils import rand_name
from tempest.test import attr
-class VolumesTransfersTest(BaseVolumeTest):
+class VolumesTransfersTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
@@ -61,10 +60,7 @@
@attr(type='gate')
def test_create_get_list_accept_volume_transfer(self):
# Create a volume first
- vol_name = rand_name('-Volume-')
- _, volume = self.client.create_volume(size=1, display_name=vol_name)
- self.addCleanup(self.adm_client.delete_volume, volume['id'])
- self.client.wait_for_volume_status(volume['id'], 'available')
+ volume = self.create_volume()
# Create a volume transfer
resp, transfer = self.client.create_volume_transfer(volume['id'])
@@ -93,10 +89,7 @@
def test_create_list_delete_volume_transfer(self):
# Create a volume first
- vol_name = rand_name('-Volume-')
- _, volume = self.client.create_volume(size=1, display_name=vol_name)
- self.addCleanup(self.adm_client.delete_volume, volume['id'])
- self.client.wait_for_volume_status(volume['id'], 'available')
+ volume = self.create_volume()
# Create a volume transfer
resp, body = self.client.create_volume_transfer(volume['id'])
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 8581d16..7a7ead6 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -15,14 +15,14 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.volume.base import BaseVolumeTest
+from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.test import attr
from tempest.test import services
from tempest.test import stresstest
-class VolumesActionsTest(BaseVolumeTest):
+class VolumesActionsTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
@@ -31,24 +31,19 @@
cls.client = cls.volumes_client
cls.image_client = cls.os.image_client
- # Create a test shared instance and volume for attach/detach tests
+ # Create a test shared instance
srv_name = data_utils.rand_name(cls.__name__ + '-Instance-')
- vol_name = data_utils.rand_name(cls.__name__ + '-Volume-')
resp, cls.server = cls.servers_client.create_server(srv_name,
cls.image_ref,
cls.flavor_ref)
cls.servers_client.wait_for_server_status(cls.server['id'], 'ACTIVE')
- resp, cls.volume = cls.client.create_volume(size=1,
- display_name=vol_name)
- cls.client.wait_for_volume_status(cls.volume['id'], 'available')
+ # Create a test shared volume for attach/detach tests
+ cls.volume = cls.create_volume()
@classmethod
def tearDownClass(cls):
- # Delete the test instance and volume
- cls.client.delete_volume(cls.volume['id'])
- cls.client.wait_for_resource_deletion(cls.volume['id'])
-
+ # Delete the test instance
cls.servers_client.delete_server(cls.server['id'])
cls.client.wait_for_resource_deletion(cls.server['id'])
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 14120fe..e342563 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -21,7 +21,7 @@
from tempest.test import services
-class VolumesGetTest(base.BaseVolumeTest):
+class VolumesGetTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
@@ -117,17 +117,10 @@
@attr(type='gate')
def test_volume_get_metadata_none(self):
# Create a volume without passing metadata, get details, and delete
- volume = {}
- v_name = data_utils.rand_name('Volume-')
+
# Create a volume without metadata
- resp, volume = self.client.create_volume(size=1,
- display_name=v_name,
- metadata={})
- self.assertEqual(200, resp.status)
- self.assertIn('id', volume)
- self.addCleanup(self._delete_volume, volume['id'])
- self.assertIn('display_name', volume)
- self.client.wait_for_volume_status(volume['id'], 'available')
+ volume = self.create_volume(metadata={})
+
# GET Volume
resp, fetched_volume = self.client.get_volume(volume['id'])
self.assertEqual(200, resp.status)
@@ -145,8 +138,7 @@
@attr(type='gate')
def test_volume_create_get_update_delete_as_clone(self):
- origin = self.create_volume(size=1,
- display_name="Volume Origin")
+ origin = self.create_volume()
self._volume_create_get_update_delete(source_volid=origin['id'])
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 3c66eb8..49a2f74 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -27,7 +27,7 @@
VOLUME_FIELDS = ('id', 'display_name')
-class VolumesListTest(base.BaseVolumeTest):
+class VolumesListTest(base.BaseVolumeV1Test):
"""
This test creates a number of 1G volumes. To run successfully,
@@ -66,17 +66,15 @@
cls.volume_id_list = []
cls.metadata = {'Type': 'work'}
for i in range(3):
- v_name = data_utils.rand_name('volume')
try:
- resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=cls.metadata)
- cls.client.wait_for_volume_status(volume['id'], 'available')
+ volume = cls.create_volume(metadata=cls.metadata)
+
resp, volume = cls.client.get_volume(volume['id'])
cls.volume_list.append(volume)
cls.volume_id_list.append(volume['id'])
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Failed to create volume. %d volumes were '
+ 'created' % len(cls.volume_id_list))
if cls.volume_list:
# We could not create all the volumes, though we were able
# to create *some* of the volumes. This is typically
@@ -85,7 +83,7 @@
for volid in cls.volume_id_list:
cls.client.delete_volume(volid)
cls.client.wait_for_resource_deletion(volid)
- raise exc
+ raise
@classmethod
def tearDownClass(cls):
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 928bd49..f14cfdc 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -23,7 +23,7 @@
from tempest.test import attr
-class VolumesNegativeTest(base.BaseVolumeTest):
+class VolumesNegativeTest(base.BaseVolumeV1Test):
_interface = 'json'
@classmethod
@@ -32,10 +32,7 @@
cls.client = cls.volumes_client
# Create a test shared instance and volume for attach/detach tests
- vol_name = data_utils.rand_name('Volume-')
-
- cls.volume = cls.create_volume(size=1, display_name=vol_name)
- cls.client.wait_for_volume_status(cls.volume['id'], 'available')
+ cls.volume = cls.create_volume()
cls.mountpoint = "/dev/vdc"
@attr(type=['negative', 'gate'])
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 6c45c3d..4e57007 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -20,7 +20,7 @@
LOG = logging.getLogger(__name__)
-class VolumesSnapshotTest(base.BaseVolumeTest):
+class VolumesSnapshotTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 04a4774..0e4f5dc 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -20,7 +20,7 @@
from tempest.test import attr
-class VolumesSnapshotNegativeTest(base.BaseVolumeTest):
+class VolumesSnapshotNegativeTest(base.BaseVolumeV1Test):
_interface = "json"
@attr(type=['negative', 'gate'])
diff --git a/tempest/cli/__init__.py b/tempest/cli/__init__.py
index ec8b3a1..547d0d0 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -86,6 +86,12 @@
return self.cmd_with_auth(
'ceilometer', action, flags, params, admin, fail_ok)
+ def heat(self, action, flags='', params='', admin=True,
+ fail_ok=False):
+ """Executes heat command for the given action."""
+ return self.cmd_with_auth(
+ 'heat', action, flags, params, admin, fail_ok)
+
def cinder(self, action, flags='', params='', admin=True, fail_ok=False):
"""Executes cinder command for the given action."""
return self.cmd_with_auth(
diff --git a/tempest/cli/simple_read_only/heat_templates/heat_minimal.yaml b/tempest/cli/simple_read_only/heat_templates/heat_minimal.yaml
new file mode 100644
index 0000000..7dcda39
--- /dev/null
+++ b/tempest/cli/simple_read_only/heat_templates/heat_minimal.yaml
@@ -0,0 +1,18 @@
+HeatTemplateFormatVersion: '2012-12-12'
+Description: Minimal template to test validation
+Parameters:
+ InstanceImage:
+ Description: Glance image name
+ Type: String
+ InstanceType:
+ Description: Nova instance type
+ Type: String
+ Default: m1.small
+ AllowedValues: [m1.tiny, m1.small, m1.medium, m1.large, m1.nano, m1.xlarge, m1.micro]
+ ConstraintDescription: must be a valid nova instance type.
+Resources:
+ InstanceResource:
+ Type: OS::Nova::Server
+ Properties:
+ flavor: {Ref: InstanceType}
+ image: {Ref: InstanceImage}
diff --git a/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml b/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml
new file mode 100644
index 0000000..6d89b7b
--- /dev/null
+++ b/tempest/cli/simple_read_only/heat_templates/heat_minimal_hot.yaml
@@ -0,0 +1,19 @@
+heat_template_version: 2013-05-23
+description: A minimal HOT test template
+parameters:
+ instance_image:
+ description: Glance image name
+ type: String
+ instance_type:
+ description: Nova instance type
+ type: String
+ default: m1.small
+ constraints:
+ - allowed_values: [m1.small, m1.medium, m1.large]
+ description: instance_type must be one of m1.small, m1.medium or m1.large
+resources:
+ instance:
+ type: OS::Nova::Server
+ properties:
+ image: { get_param: instance_image }
+ flavor: { get_param: instance_type }
diff --git a/tempest/cli/simple_read_only/test_ceilometer.py b/tempest/cli/simple_read_only/test_ceilometer.py
index 7f2864f..8bdd633 100644
--- a/tempest/cli/simple_read_only/test_ceilometer.py
+++ b/tempest/cli/simple_read_only/test_ceilometer.py
@@ -49,3 +49,6 @@
def test_ceilometermeter_alarm_list(self):
self.ceilometer('alarm-list')
+
+ def test_ceilometer_version(self):
+ self.ceilometer('', flags='--version')
diff --git a/tempest/cli/simple_read_only/test_heat.py b/tempest/cli/simple_read_only/test_heat.py
new file mode 100644
index 0000000..e2fefe8
--- /dev/null
+++ b/tempest/cli/simple_read_only/test_heat.py
@@ -0,0 +1,98 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+import os
+import yaml
+
+from oslo.config import cfg
+
+import tempest.cli
+from tempest.openstack.common import log as logging
+
+CONF = cfg.CONF
+
+LOG = logging.getLogger(__name__)
+
+
+class SimpleReadOnlyHeatClientTest(tempest.cli.ClientTestBase):
+ """Basic, read-only tests for Heat CLI client.
+
+ Basic smoke test for the heat CLI commands which do not require
+ creating or modifying stacks.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ if (not CONF.service_available.heat):
+ msg = ("Skipping all Heat cli tests because it is "
+ "not available")
+ raise cls.skipException(msg)
+ super(SimpleReadOnlyHeatClientTest, cls).setUpClass()
+
+ def test_heat_stack_list(self):
+ self.heat('stack-list')
+
+ def test_heat_stack_list_debug(self):
+ self.heat('stack-list', flags='--debug')
+
+ def test_heat_resource_template_fmt_default(self):
+ ret = self.heat('resource-template OS::Nova::Server')
+ self.assertIn('Type: OS::Nova::Server', ret)
+
+ def test_heat_resource_template_fmt_arg_short_yaml(self):
+ ret = self.heat('resource-template -F yaml OS::Nova::Server')
+ self.assertIn('Type: OS::Nova::Server', ret)
+ self.assertIsInstance(yaml.safe_load(ret), dict)
+
+ def test_heat_resource_template_fmt_arg_long_json(self):
+ ret = self.heat('resource-template --format json OS::Nova::Server')
+ self.assertIn('"Type": "OS::Nova::Server",', ret)
+ self.assertIsInstance(json.loads(ret), dict)
+
+ def test_heat_resource_type_list(self):
+ ret = self.heat('resource-type-list')
+ rsrc_types = self.parser.listing(ret)
+ self.assertTableStruct(rsrc_types, ['resource_type'])
+
+ def test_heat_resource_type_show(self):
+ rsrc_schema = self.heat('resource-type-show OS::Nova::Server')
+ # resource-type-show returns a json resource schema
+ self.assertIsInstance(json.loads(rsrc_schema), dict)
+
+ def test_heat_template_validate_yaml(self):
+ filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ 'heat_templates/heat_minimal.yaml')
+ ret = self.heat('template-validate -f %s' % filepath)
+ # On success template-validate returns a json representation
+ # of the template parameters
+ self.assertIsInstance(json.loads(ret), dict)
+
+ def test_heat_template_validate_hot(self):
+ filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ 'heat_templates/heat_minimal_hot.yaml')
+ ret = self.heat('template-validate -f %s' % filepath)
+ self.assertIsInstance(json.loads(ret), dict)
+
+ def test_heat_help(self):
+ self.heat('help')
+
+ def test_heat_help_cmd(self):
+ # Check requesting help for a specific command works
+ help_text = self.heat('help resource-template')
+ lines = help_text.split('\n')
+ self.assertFirstLineStartsWith(lines, 'usage: heat resource-template')
+
+ def test_heat_version(self):
+ self.heat('', flags='--version')
diff --git a/tempest/clients.py b/tempest/clients.py
index 3333b9b..83b72c6 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -50,32 +50,47 @@
TenantUsagesClientJSON
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
+from tempest.services.compute.v3.json.aggregates_client import \
+ AggregatesV3ClientJSON
from tempest.services.compute.v3.json.availability_zone_client import \
AvailabilityZoneV3ClientJSON
from tempest.services.compute.v3.json.certificates_client import \
CertificatesV3ClientJSON
from tempest.services.compute.v3.json.extensions_client import \
ExtensionsV3ClientJSON
+from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON
+from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON
from tempest.services.compute.v3.json.hypervisor_client import \
HypervisorV3ClientJSON
from tempest.services.compute.v3.json.interfaces_client import \
InterfacesV3ClientJSON
+from tempest.services.compute.v3.json.keypairs_client import \
+ KeyPairsV3ClientJSON
+from tempest.services.compute.v3.json.quotas_client import \
+ QuotasV3ClientJSON
from tempest.services.compute.v3.json.servers_client import \
ServersV3ClientJSON
from tempest.services.compute.v3.json.services_client import \
ServicesV3ClientJSON
from tempest.services.compute.v3.json.tenant_usages_client import \
TenantUsagesV3ClientJSON
+from tempest.services.compute.v3.xml.aggregates_client import \
+ AggregatesV3ClientXML
from tempest.services.compute.v3.xml.availability_zone_client import \
AvailabilityZoneV3ClientXML
from tempest.services.compute.v3.xml.certificates_client import \
CertificatesV3ClientXML
from tempest.services.compute.v3.xml.extensions_client import \
ExtensionsV3ClientXML
+from tempest.services.compute.v3.xml.flavors_client import FlavorsV3ClientXML
+from tempest.services.compute.v3.xml.hosts_client import HostsV3ClientXML
from tempest.services.compute.v3.xml.hypervisor_client import \
HypervisorV3ClientXML
from tempest.services.compute.v3.xml.interfaces_client import \
InterfacesV3ClientXML
+from tempest.services.compute.v3.xml.keypairs_client import KeyPairsV3ClientXML
+from tempest.services.compute.v3.xml.quotas_client import \
+ QuotasV3ClientXML
from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
from tempest.services.compute.v3.xml.services_client import \
ServicesV3ClientXML
@@ -91,6 +106,7 @@
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
from tempest.services.compute.xml.floating_ips_client import \
FloatingIPsClientXML
+from tempest.services.compute.xml.hosts_client import HostsClientXML
from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
from tempest.services.compute.xml.images_client import ImagesClientXML
from tempest.services.compute.xml.instance_usage_audit_log_client import \
@@ -220,9 +236,13 @@
self.servers_v3_client = ServersV3ClientXML(*client_args)
self.limits_client = LimitsClientXML(*client_args)
self.images_client = ImagesClientXML(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientXML(*client_args)
self.keypairs_client = KeyPairsClientXML(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientXML(*client_args)
self.quotas_client = QuotasClientXML(*client_args)
+ self.quotas_v3_client = QuotasV3ClientXML(*client_args)
self.flavors_client = FlavorsClientXML(*client_args)
+ self.flavors_v3_client = FlavorsV3ClientXML(*client_args)
self.extensions_v3_client = ExtensionsV3ClientXML(*client_args)
self.extensions_client = ExtensionsClientXML(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientXML(
@@ -246,12 +266,14 @@
*client_args)
self.services_v3_client = ServicesV3ClientXML(*client_args)
self.service_client = ServiceClientXML(*client_args)
+ self.aggregates_v3_client = AggregatesV3ClientXML(*client_args)
self.aggregates_client = AggregatesClientXML(*client_args)
self.services_client = ServicesClientXML(*client_args)
self.tenant_usages_v3_client = TenantUsagesV3ClientXML(
*client_args)
self.tenant_usages_client = TenantUsagesClientXML(*client_args)
self.policy_client = PolicyClientXML(*client_args)
+ self.hosts_client = HostsClientXML(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientXML(*client_args)
self.hypervisor_client = HypervisorClientXML(*client_args)
self.token_v3_client = V3TokenClientXML(*client_args)
@@ -262,6 +284,7 @@
self.volume_hosts_client = VolumeHostsClientXML(*client_args)
self.volumes_extension_client = VolumeExtensionClientXML(
*client_args)
+ self.hosts_v3_client = HostsV3ClientXML(*client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientXML(
@@ -275,9 +298,13 @@
self.servers_v3_client = ServersV3ClientJSON(*client_args)
self.limits_client = LimitsClientJSON(*client_args)
self.images_client = ImagesClientJSON(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientJSON(*client_args)
self.keypairs_client = KeyPairsClientJSON(*client_args)
+ self.keypairs_v3_client = KeyPairsV3ClientJSON(*client_args)
self.quotas_client = QuotasClientJSON(*client_args)
+ self.quotas_v3_client = QuotasV3ClientJSON(*client_args)
self.flavors_client = FlavorsClientJSON(*client_args)
+ self.flavors_v3_client = FlavorsV3ClientJSON(*client_args)
self.extensions_v3_client = ExtensionsV3ClientJSON(*client_args)
self.extensions_client = ExtensionsClientJSON(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientJSON(
@@ -301,12 +328,14 @@
*client_args)
self.services_v3_client = ServicesV3ClientJSON(*client_args)
self.service_client = ServiceClientJSON(*client_args)
+ self.aggregates_v3_client = AggregatesV3ClientJSON(*client_args)
self.aggregates_client = AggregatesClientJSON(*client_args)
self.services_client = ServicesClientJSON(*client_args)
self.tenant_usages_v3_client = TenantUsagesV3ClientJSON(
*client_args)
self.tenant_usages_client = TenantUsagesClientJSON(*client_args)
self.policy_client = PolicyClientJSON(*client_args)
+ self.hosts_client = HostsClientJSON(*client_args)
self.hypervisor_v3_client = HypervisorV3ClientJSON(*client_args)
self.hypervisor_client = HypervisorClientJSON(*client_args)
self.token_v3_client = V3TokenClientJSON(*client_args)
@@ -317,6 +346,7 @@
self.volume_hosts_client = VolumeHostsClientJSON(*client_args)
self.volumes_extension_client = VolumeExtensionClientJSON(
*client_args)
+ self.hosts_v3_client = HostsV3ClientJSON(*client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientJSON(
@@ -326,7 +356,6 @@
raise exceptions.InvalidConfiguration(msg)
# common clients
- self.hosts_client = HostsClientJSON(*client_args)
self.account_client = AccountClient(*client_args)
if CONF.service_available.glance:
self.image_client = ImageClientJSON(*client_args)
diff --git a/tempest/common/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py
index 22be4aa..6097aa8 100644
--- a/tempest/common/generate_sample_tempest.py
+++ b/tempest/common/generate_sample_tempest.py
@@ -33,5 +33,5 @@
if __name__ == "__main__":
- CONF = tempest.config.TempestConfig()
+ CONF = tempest.config.TempestConfigPrivate(False)
generator.generate(sys.argv[1:])
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index aedba15..ce620a8 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -29,7 +29,10 @@
"""Waits for a server to reach a given status."""
def _get_task_state(body):
- task_state = body.get('OS-EXT-STS:task_state', None)
+ if client.service == CONF.compute.catalog_v3_type:
+ task_state = body.get("os-extended-status:task_state", None)
+ else:
+ task_state = body.get('OS-EXT-STS:task_state', None)
return task_state
# NOTE(afazekas): UNKNOWN status possible on ERROR
diff --git a/tempest/config.py b/tempest/config.py
index 140c521..d42edc9 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -18,7 +18,6 @@
from __future__ import print_function
import os
-import sys
from oslo.config import cfg
@@ -378,6 +377,9 @@
default=['all'],
help='A list of enabled extensions with a special entry all '
'which indicates every extension is enabled'),
+ cfg.BoolOpt('api_v1',
+ default=True,
+ help="Is the v1 volume API enabled"),
]
@@ -471,6 +473,16 @@
]
+telemetry_group = cfg.OptGroup(name='telemetry',
+ title='Telemetry Service Options')
+
+TelemetryGroup = [
+ cfg.StrOpt('catalog_type',
+ default='metering',
+ help="Catalog type of the Telemetry service."),
+]
+
+
dashboard_group = cfg.OptGroup(name="dashboard",
title="Dashboard options")
@@ -644,7 +656,8 @@
]
-class TempestConfig(object):
+# this should never be called outside of this class
+class TempestConfigPrivate(object):
"""Provides OpenStack configuration information."""
DEFAULT_CONFIG_DIR = os.path.join(
@@ -653,9 +666,9 @@
DEFAULT_CONFIG_FILE = "tempest.conf"
- def __init__(self):
+ def __init__(self, parse_conf=True):
"""Initialize a configuration from a conf directory and conf file."""
- super(TempestConfig, self).__init__()
+ super(TempestConfigPrivate, self).__init__()
config_files = []
failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
@@ -671,10 +684,9 @@
'TEMPEST_CONFIG' in os.environ):
path = failsafe_path
- if not os.path.exists(path):
- msg = "Config file %s not found" % path
- print(RuntimeError(msg), file=sys.stderr)
- else:
+ # only parse the config file if we expect one to exist. This is needed
+ # to remove an issue with the config file up to date checker.
+ if parse_conf:
config_files.append(path)
cfg.CONF([], project='tempest', default_config_files=config_files)
@@ -698,6 +710,7 @@
register_opt_group(cfg.CONF, object_storage_feature_group,
ObjectStoreFeaturesGroup)
register_opt_group(cfg.CONF, orchestration_group, OrchestrationGroup)
+ register_opt_group(cfg.CONF, telemetry_group, TelemetryGroup)
register_opt_group(cfg.CONF, dashboard_group, DashboardGroup)
register_opt_group(cfg.CONF, data_processing_group,
DataProcessingGroup)
@@ -721,6 +734,7 @@
self.object_storage_feature_enabled = cfg.CONF[
'object-storage-feature-enabled']
self.orchestration = cfg.CONF.orchestration
+ self.telemetry = cfg.CONF.telemetry
self.dashboard = cfg.CONF.dashboard
self.data_processing = cfg.CONF.data_processing
self.boto = cfg.CONF.boto
@@ -740,7 +754,7 @@
def __getattr__(self, attr):
if not self._config:
- self._config = TempestConfig()
+ self._config = TempestConfigPrivate()
return getattr(self._config, attr)
diff --git a/tempest/openstack/common/config/generator.py b/tempest/openstack/common/config/generator.py
index 373f9a6..eeb5a32 100644
--- a/tempest/openstack/common/config/generator.py
+++ b/tempest/openstack/common/config/generator.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 SINA Corporation
# All Rights Reserved.
#
@@ -28,6 +26,7 @@
import textwrap
from oslo.config import cfg
+import six
from tempest.openstack.common import gettextutils
from tempest.openstack.common import importutils
@@ -78,12 +77,15 @@
# The options list is a list of (module, options) tuples
opts_by_group = {'DEFAULT': []}
- for module_name in os.getenv(
- "OSLO_CONFIG_GENERATOR_EXTRA_MODULES", "").split(','):
- module = _import_module(module_name)
- if module:
- for group, opts in _list_opts(module):
- opts_by_group.setdefault(group, []).append((module_name, opts))
+ extra_modules = os.getenv("TEMPEST_CONFIG_GENERATOR_EXTRA_MODULES", "")
+ if extra_modules:
+ for module_name in extra_modules.split(','):
+ module_name = module_name.strip()
+ module = _import_module(module_name)
+ if module:
+ for group, opts in _list_opts(module):
+ opts_by_group.setdefault(group, []).append((module_name,
+ opts))
for pkg_name in pkg_names:
mods = mods_by_pkg.get(pkg_name)
@@ -100,8 +102,8 @@
opts_by_group.setdefault(group, []).append((mod_str, opts))
print_group_opts('DEFAULT', opts_by_group.pop('DEFAULT', []))
- for group, opts in opts_by_group.items():
- print_group_opts(group, opts)
+ for group in sorted(opts_by_group.keys()):
+ print_group_opts(group, opts_by_group[group])
def _import_module(mod_str):
@@ -111,17 +113,17 @@
return sys.modules[mod_str[4:]]
else:
return importutils.import_module(mod_str)
- except ImportError as ie:
- sys.stderr.write("%s\n" % str(ie))
- return None
- except Exception:
+ except Exception as e:
+ sys.stderr.write("Error importing module %s: %s\n" % (mod_str, str(e)))
return None
def _is_in_group(opt, group):
"Check if opt is in group."
for key, value in group._opts.items():
- if value['opt'] == opt:
+ # NOTE(llu): Temporary workaround for bug #1262148, wait until
+ # newly released oslo.config support '==' operator.
+ if not(value['opt'] != opt):
return True
return False
@@ -233,7 +235,7 @@
if opt_default is None:
print('#%s=<None>' % opt_name)
elif opt_type == STROPT:
- assert(isinstance(opt_default, basestring))
+ assert(isinstance(opt_default, six.string_types))
print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
opt_default)))
elif opt_type == BOOLOPT:
diff --git a/tempest/openstack/common/excutils.py b/tempest/openstack/common/excutils.py
index c7bce72..dc365da 100644
--- a/tempest/openstack/common/excutils.py
+++ b/tempest/openstack/common/excutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# Copyright 2012, Red Hat, Inc.
#
@@ -26,7 +24,7 @@
import six
-from tempest.openstack.common.gettextutils import _ # noqa
+from tempest.openstack.common.gettextutils import _
class save_and_reraise_exception(object):
@@ -44,13 +42,13 @@
In some cases the caller may not want to re-raise the exception, and
for those circumstances this context provides a reraise flag that
- can be used to suppress the exception. For example:
+ can be used to suppress the exception. For example::
- except Exception:
- with save_and_reraise_exception() as ctxt:
- decide_if_need_reraise()
- if not should_be_reraised:
- ctxt.reraise = False
+ except Exception:
+ with save_and_reraise_exception() as ctxt:
+ decide_if_need_reraise()
+ if not should_be_reraised:
+ ctxt.reraise = False
"""
def __init__(self):
self.reraise = True
diff --git a/tempest/openstack/common/fileutils.py b/tempest/openstack/common/fileutils.py
index 15530af..1845ed2 100644
--- a/tempest/openstack/common/fileutils.py
+++ b/tempest/openstack/common/fileutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
@@ -22,7 +20,7 @@
import tempfile
from tempest.openstack.common import excutils
-from tempest.openstack.common.gettextutils import _ # noqa
+from tempest.openstack.common.gettextutils import _
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
diff --git a/tempest/openstack/common/fixture/config.py b/tempest/openstack/common/fixture/config.py
index 7b044ef..0bf90ff 100644
--- a/tempest/openstack/common/fixture/config.py
+++ b/tempest/openstack/common/fixture/config.py
@@ -1,4 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 Mirantis, Inc.
# Copyright 2013 OpenStack Foundation
@@ -30,7 +29,7 @@
the specified configuration option group.
All overrides are automatically cleared at the end of the current
- test by the reset() method, which is registred by addCleanup().
+ test by the reset() method, which is registered by addCleanup().
"""
def __init__(self, conf=cfg.CONF):
diff --git a/tempest/openstack/common/fixture/lockutils.py b/tempest/openstack/common/fixture/lockutils.py
index 21b4a48..5936687 100644
--- a/tempest/openstack/common/fixture/lockutils.py
+++ b/tempest/openstack/common/fixture/lockutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
@@ -17,7 +15,7 @@
import fixtures
-from tempest.openstack.common.lockutils import lock
+from tempest.openstack.common import lockutils
class LockFixture(fixtures.Fixture):
@@ -45,7 +43,7 @@
test method exits. (either by completing or raising an exception)
"""
def __init__(self, name, lock_file_prefix=None):
- self.mgr = lock(name, lock_file_prefix, True)
+ self.mgr = lockutils.lock(name, lock_file_prefix, True)
def setUp(self):
super(LockFixture, self).setUp()
diff --git a/tempest/openstack/common/fixture/mockpatch.py b/tempest/openstack/common/fixture/mockpatch.py
index cd0d6ca..858e77c 100644
--- a/tempest/openstack/common/fixture/mockpatch.py
+++ b/tempest/openstack/common/fixture/mockpatch.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
diff --git a/tempest/openstack/common/fixture/moxstubout.py b/tempest/openstack/common/fixture/moxstubout.py
index a0e74fd..e8c031f 100644
--- a/tempest/openstack/common/fixture/moxstubout.py
+++ b/tempest/openstack/common/fixture/moxstubout.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
diff --git a/tempest/openstack/common/gettextutils.py b/tempest/openstack/common/gettextutils.py
index 2939ed9..825c2e0 100644
--- a/tempest/openstack/common/gettextutils.py
+++ b/tempest/openstack/common/gettextutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 Red Hat, Inc.
# Copyright 2013 IBM Corp.
# All Rights Reserved.
@@ -317,7 +315,7 @@
# NOTE(luisg): Babel <1.0 used a function called list(), which was
# renamed to locale_identifiers() in >=1.0, the requirements master list
# requires >=0.9.6, uncapped, so defensively work with both. We can remove
- # this check when the master list updates to >=1.0, and all projects udpate
+ # this check when the master list updates to >=1.0, and update all projects
list_identifiers = (getattr(localedata, 'list', None) or
getattr(localedata, 'locale_identifiers'))
locale_identifiers = list_identifiers()
diff --git a/tempest/openstack/common/importutils.py b/tempest/openstack/common/importutils.py
index 7a303f9..4fd9ae2 100644
--- a/tempest/openstack/common/importutils.py
+++ b/tempest/openstack/common/importutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
diff --git a/tempest/openstack/common/jsonutils.py b/tempest/openstack/common/jsonutils.py
index b589545..53c0ad4 100644
--- a/tempest/openstack/common/jsonutils.py
+++ b/tempest/openstack/common/jsonutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 Justin Santa Barbara
@@ -41,8 +39,12 @@
try:
import xmlrpclib
except ImportError:
- # NOTE(jd): xmlrpclib is not shipped with Python 3
- xmlrpclib = None
+ # NOTE(jaypipes): xmlrpclib was renamed to xmlrpc.client in Python3
+ # however the function and object call signatures
+ # remained the same. This whole try/except block should
+ # be removed and replaced with a call to six.moves once
+ # six 1.4.2 is released. See http://bit.ly/1bqrVzu
+ import xmlrpc.client as xmlrpclib
import six
@@ -124,14 +126,14 @@
level=level,
max_depth=max_depth)
if isinstance(value, dict):
- return dict((k, recursive(v)) for k, v in value.iteritems())
+ return dict((k, recursive(v)) for k, v in six.iteritems(value))
elif isinstance(value, (list, tuple)):
return [recursive(lv) for lv in value]
# It's not clear why xmlrpclib created their own DateTime type, but
# for our purposes, make it a datetime type which is explicitly
# handled
- if xmlrpclib and isinstance(value, xmlrpclib.DateTime):
+ if isinstance(value, xmlrpclib.DateTime):
value = datetime.datetime(*tuple(value.timetuple())[:6])
if convert_datetime and isinstance(value, datetime.datetime):
diff --git a/tempest/openstack/common/local.py b/tempest/openstack/common/local.py
index e82f17d..0819d5b 100644
--- a/tempest/openstack/common/local.py
+++ b/tempest/openstack/common/local.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
diff --git a/tempest/openstack/common/lockutils.py b/tempest/openstack/common/lockutils.py
index 65f3548..53cada1 100644
--- a/tempest/openstack/common/lockutils.py
+++ b/tempest/openstack/common/lockutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
@@ -31,7 +29,7 @@
from oslo.config import cfg
from tempest.openstack.common import fileutils
-from tempest.openstack.common.gettextutils import _ # noqa
+from tempest.openstack.common.gettextutils import _
from tempest.openstack.common import local
from tempest.openstack.common import log as logging
@@ -148,16 +146,16 @@
True, in which case, it'll yield an InterProcessLock instance.
:param lock_file_prefix: The lock_file_prefix argument is used to provide
- lock files on disk with a meaningful prefix.
+ lock files on disk with a meaningful prefix.
:param external: The external keyword argument denotes whether this lock
- should work across multiple processes. This means that if two different
- workers both run a a method decorated with @synchronized('mylock',
- external=True), only one of them will execute at a time.
+ should work across multiple processes. This means that if two different
+ workers both run a a method decorated with @synchronized('mylock',
+ external=True), only one of them will execute at a time.
:param lock_path: The lock_path keyword argument is used to specify a
- special location for external lock files to live. If nothing is set, then
- CONF.lock_path is used as a default.
+ special location for external lock files to live. If nothing is set, then
+ CONF.lock_path is used as a default.
"""
with _semaphores_lock:
try:
diff --git a/tempest/openstack/common/log.py b/tempest/openstack/common/log.py
index abb44ef..7bebfdb 100644
--- a/tempest/openstack/common/log.py
+++ b/tempest/openstack/common/log.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
@@ -35,6 +33,7 @@
import logging.config
import logging.handlers
import os
+import re
import sys
import traceback
@@ -42,7 +41,7 @@
import six
from six import moves
-from tempest.openstack.common.gettextutils import _ # noqa
+from tempest.openstack.common.gettextutils import _
from tempest.openstack.common import importutils
from tempest.openstack.common import jsonutils
from tempest.openstack.common import local
@@ -50,6 +49,24 @@
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
+_SANITIZE_KEYS = ['adminPass', 'admin_pass', 'password', 'admin_password']
+
+# NOTE(ldbragst): Let's build a list of regex objects using the list of
+# _SANITIZE_KEYS we already have. This way, we only have to add the new key
+# to the list of _SANITIZE_KEYS and we can generate regular expressions
+# for XML and JSON automatically.
+_SANITIZE_PATTERNS = []
+_FORMAT_PATTERNS = [r'(%(key)s\s*[=]\s*[\"\']).*?([\"\'])',
+ r'(<%(key)s>).*?(</%(key)s>)',
+ r'([\"\']%(key)s[\"\']\s*:\s*[\"\']).*?([\"\'])',
+ r'([\'"].*?%(key)s[\'"]\s*:\s*u?[\'"]).*?([\'"])']
+
+for key in _SANITIZE_KEYS:
+ for pattern in _FORMAT_PATTERNS:
+ reg_ex = re.compile(pattern % {'key': key}, re.DOTALL)
+ _SANITIZE_PATTERNS.append(reg_ex)
+
+
common_cli_opts = [
cfg.BoolOpt('debug',
short='d',
@@ -64,11 +81,13 @@
]
logging_cli_opts = [
- cfg.StrOpt('log-config',
+ cfg.StrOpt('log-config-append',
metavar='PATH',
- help='If this option is specified, the logging configuration '
- 'file specified is used and overrides any other logging '
- 'options specified. Please see the Python logging module '
+ deprecated_name='log-config',
+ help='The name of logging configuration file. It does not '
+ 'disable existing loggers, but just appends specified '
+ 'logging configuration to any other existing logging '
+ 'options. Please see the Python logging module '
'documentation for details on logging configuration '
'files.'),
cfg.StrOpt('log-format',
@@ -111,7 +130,7 @@
log_opts = [
cfg.StrOpt('logging_context_format_string',
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
- '%(name)s [%(request_id)s %(user)s %(tenant)s] '
+ '%(name)s [%(request_id)s %(user_identity)s] '
'%(instance)s%(message)s',
help='format string to use for log messages with context'),
cfg.StrOpt('logging_default_format_string',
@@ -127,12 +146,13 @@
help='prefix each line of exception output with this format'),
cfg.ListOpt('default_log_levels',
default=[
+ 'amqp=WARN',
'amqplib=WARN',
- 'sqlalchemy=WARN',
'boto=WARN',
+ 'qpid=WARN',
+ 'sqlalchemy=WARN',
'suds=INFO',
- 'keystone=INFO',
- 'paramiko=INFO'
+ 'iso8601=WARN',
],
help='list of logger=LEVEL pairs'),
cfg.BoolOpt('publish_errors',
@@ -211,6 +231,40 @@
return None
+def mask_password(message, secret="***"):
+ """Replace password with 'secret' in message.
+
+ :param message: The string which includes security information.
+ :param secret: value with which to replace passwords.
+ :returns: The unicode value of message with the password fields masked.
+
+ For example:
+
+ >>> mask_password("'adminPass' : 'aaaaa'")
+ "'adminPass' : '***'"
+ >>> mask_password("'admin_pass' : 'aaaaa'")
+ "'admin_pass' : '***'"
+ >>> mask_password('"password" : "aaaaa"')
+ '"password" : "***"'
+ >>> mask_password("'original_password' : 'aaaaa'")
+ "'original_password' : '***'"
+ >>> mask_password("u'original_password' : u'aaaaa'")
+ "u'original_password' : u'***'"
+ """
+ message = six.text_type(message)
+
+ # NOTE(ldbragst): Check to see if anything in message contains any key
+ # specified in _SANITIZE_KEYS, if not then just return the message since
+ # we don't have to mask any passwords.
+ if not any(key in message for key in _SANITIZE_KEYS):
+ return message
+
+ secret = r'\g<1>' + secret + r'\g<2>'
+ for pattern in _SANITIZE_PATTERNS:
+ message = re.sub(pattern, secret, message)
+ return message
+
+
class BaseLoggerAdapter(logging.LoggerAdapter):
def audit(self, msg, *args, **kwargs):
@@ -278,10 +332,12 @@
elif instance_uuid:
instance_extra = (CONF.instance_uuid_format
% {'uuid': instance_uuid})
- extra.update({'instance': instance_extra})
+ extra['instance'] = instance_extra
- extra.update({"project": self.project})
- extra.update({"version": self.version})
+ extra.setdefault('user_identity', kwargs.pop('user_identity', None))
+
+ extra['project'] = self.project
+ extra['version'] = self.version
extra['extra'] = extra.copy()
return msg, kwargs
@@ -295,7 +351,7 @@
def formatException(self, ei, strip_newlines=True):
lines = traceback.format_exception(*ei)
if strip_newlines:
- lines = [itertools.ifilter(
+ lines = [moves.filter(
lambda x: x,
line.rstrip().splitlines()) for line in lines]
lines = list(itertools.chain(*lines))
@@ -333,10 +389,10 @@
def _create_logging_excepthook(product_name):
- def logging_excepthook(type, value, tb):
+ def logging_excepthook(exc_type, value, tb):
extra = {}
if CONF.verbose:
- extra['exc_info'] = (type, value, tb)
+ extra['exc_info'] = (exc_type, value, tb)
getLogger(product_name).critical(str(value), **extra)
return logging_excepthook
@@ -354,17 +410,18 @@
err_msg=self.err_msg)
-def _load_log_config(log_config):
+def _load_log_config(log_config_append):
try:
- logging.config.fileConfig(log_config)
+ logging.config.fileConfig(log_config_append,
+ disable_existing_loggers=False)
except moves.configparser.Error as exc:
- raise LogConfigError(log_config, str(exc))
+ raise LogConfigError(log_config_append, str(exc))
def setup(product_name):
"""Setup logging."""
- if CONF.log_config:
- _load_log_config(CONF.log_config)
+ if CONF.log_config_append:
+ _load_log_config(CONF.log_config_append)
else:
_setup_logging_from_conf()
sys.excepthook = _create_logging_excepthook(product_name)
@@ -420,7 +477,7 @@
streamlog = ColorHandler()
log_root.addHandler(streamlog)
- elif not CONF.log_file:
+ elif not logpath:
# pass sys.stdout as a positional argument
# python2.6 calls the argument strm, in 2.7 it's stream
streamlog = logging.StreamHandler(sys.stdout)
diff --git a/tempest/openstack/common/timeutils.py b/tempest/openstack/common/timeutils.py
index 98d877d..d5ed81d 100644
--- a/tempest/openstack/common/timeutils.py
+++ b/tempest/openstack/common/timeutils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
@@ -50,9 +48,9 @@
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
- raise ValueError(unicode(e))
+ raise ValueError(six.text_type(e))
except TypeError as e:
- raise ValueError(unicode(e))
+ raise ValueError(six.text_type(e))
def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
@@ -79,6 +77,9 @@
"""Return True if before is older than seconds."""
if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
+ else:
+ before = before.replace(tzinfo=None)
+
return utcnow() - before > datetime.timedelta(seconds=seconds)
@@ -86,6 +87,9 @@
"""Return True if after is newer than seconds."""
if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
+ else:
+ after = after.replace(tzinfo=None)
+
return after - utcnow() > datetime.timedelta(seconds=seconds)
@@ -178,6 +182,15 @@
datetime objects (as a float, to microsecond resolution).
"""
delta = after - before
+ return total_seconds(delta)
+
+
+def total_seconds(delta):
+ """Return the total seconds of datetime.timedelta object.
+
+ Compute total seconds of datetime.timedelta, datetime.timedelta
+ doesn't have method total_seconds in Python2.6, calculate it manually.
+ """
try:
return delta.total_seconds()
except AttributeError:
@@ -188,8 +201,8 @@
def is_soon(dt, window):
"""Determines if time is going to happen in the next window seconds.
- :params dt: the time
- :params window: minimum seconds to remain to consider the time not soon
+ :param dt: the time
+ :param window: minimum seconds to remain to consider the time not soon
:return: True if expiration is within the given duration
"""
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 2f28068..409fcc2 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -24,12 +24,14 @@
import cinderclient.client
import glanceclient
import heatclient.client
+import keystoneclient.apiclient.exceptions
import keystoneclient.v2_0.client
import netaddr
from neutronclient.common import exceptions as exc
import neutronclient.v2_0.client
import novaclient.client
from novaclient import exceptions as nova_exceptions
+import swiftclient
from tempest.api.network import common as net_common
from tempest.common import isolated_creds
@@ -74,6 +76,10 @@
self.volume_client = self._get_volume_client(username,
password,
tenant_name)
+ self.object_storage_client = self._get_object_storage_client(
+ username,
+ password,
+ tenant_name)
self.orchestration_client = self._get_orchestration_client(
username,
password,
@@ -122,6 +128,30 @@
region_name=region,
http_log_debug=True)
+ def _get_object_storage_client(self, username, password, tenant_name):
+ auth_url = self.config.identity.uri
+ # add current tenant to Member group.
+ keystone_admin = self._get_identity_client(
+ self.config.identity.admin_username,
+ self.config.identity.admin_password,
+ self.config.identity.admin_tenant_name)
+
+ # enable test user to operate swift by adding Member role to him.
+ roles = keystone_admin.roles.list()
+ member_role = [role for role in roles if role.name == 'Member'][0]
+ # NOTE(maurosr): This is surrounded in the try-except block cause
+ # neutron tests doesn't have tenant isolation.
+ try:
+ keystone_admin.roles.add_user_role(self.identity_client.user_id,
+ member_role.id,
+ self.identity_client.tenant_id)
+ except keystoneclient.apiclient.exceptions.Conflict:
+ pass
+
+ return swiftclient.Connection(auth_url, username, password,
+ tenant_name=tenant_name,
+ auth_version='2')
+
def _get_orchestration_client(self, username=None, password=None,
tenant_name=None):
if not username:
@@ -215,6 +245,7 @@
cls.identity_client = cls.manager.identity_client
cls.network_client = cls.manager.network_client
cls.volume_client = cls.manager.volume_client
+ cls.object_storage_client = cls.manager.object_storage_client
cls.orchestration_client = cls.manager.orchestration_client
cls.resource_keys = {}
cls.os_resources = []
@@ -954,7 +985,7 @@
username = cls.config.identity.admin_username
password = cls.config.identity.admin_password
tenant_name = cls.config.identity.tenant_name
- return username, tenant_name, password
+ return username, password, tenant_name
def _load_template(self, base_file, file_name):
filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 33dd6c0..3618a14 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -227,10 +227,10 @@
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address, ssh_login,
key.private_key)
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Tenant connectivity check failed')
debug.log_ip_ns()
- raise exc
+ raise
def _wait_for_floating_ip_association(self):
ip_tracker = FloatingIPCheckTracker(self.compute_client,
@@ -263,10 +263,10 @@
ssh_login,
private_key,
should_connect=should_connect)
- except Exception as exc:
- LOG.exception(exc)
+ except Exception:
+ LOG.exception('Public network connectivity check failed')
debug.log_ip_ns()
- raise exc
+ raise
def _disassociate_floating_ips(self):
for floating_ip, server in self.floating_ips.iteritems():
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
new file mode 100644
index 0000000..6763503
--- /dev/null
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -0,0 +1,101 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from tempest.common.utils.data_utils import rand_name
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest.test import services
+
+LOG = logging.getLogger(__name__)
+
+
+class TestSwiftBasicOps(manager.OfficialClientTest):
+ """
+ Test swift with the follow operations:
+ * get swift stat.
+ * create container.
+ * upload a file to the created container.
+ * list container's objects and assure that the uploaded file is present.
+ * delete object from container.
+ * list container's objects and assure that the deleted file is gone.
+ * delete a container.
+ * list containers and assure that the deleted container is gone.
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestSwiftBasicOps, cls).setUpClass()
+ if not cls.config.service_available.swift:
+ skip_msg = ("%s skipped as swift is not available" %
+ cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _get_swift_stat(self):
+ """get swift status for our user account."""
+ self.object_storage_client.get_account()
+ LOG.debug('Swift status information obtained successfully')
+
+ def _create_container(self, container_name=None):
+ name = container_name or rand_name('swift-scenario-container')
+ self.object_storage_client.put_container(name)
+ # look for the container to assure it is created
+ self._list_and_check_container_objects(name)
+ LOG.debug('Container %s created' % (name))
+ return name
+
+ def _delete_container(self, container_name):
+ self.object_storage_client.delete_container(container_name)
+ LOG.debug('Container %s deleted' % (container_name))
+
+ def _upload_object_to_container(self, container_name, obj_name=None):
+ obj_name = obj_name or rand_name('swift-scenario-object')
+ self.object_storage_client.put_object(container_name, obj_name,
+ rand_name('obj_data'),
+ content_type='text/plain')
+ return obj_name
+
+ def _delete_object(self, container_name, filename):
+ self.object_storage_client.delete_object(container_name, filename)
+ self._list_and_check_container_objects(container_name,
+ not_present_obj=[filename])
+
+ def _list_and_check_container_objects(self, container_name, present_obj=[],
+ not_present_obj=[]):
+ """
+ List objects for a given container and assert which are present and
+ which are not.
+ """
+ meta, response = self.object_storage_client.get_container(
+ container_name)
+ # create a list with file name only
+ object_list = [obj['name'] for obj in response]
+ if present_obj:
+ for obj in present_obj:
+ self.assertIn(obj, object_list)
+ if not_present_obj:
+ for obj in not_present_obj:
+ self.assertNotIn(obj, object_list)
+
+ @services('object')
+ def test_swift_basic_ops(self):
+ self._get_swift_stat()
+ container_name = self._create_container()
+ obj_name = self._upload_object_to_container(container_name)
+ self._list_and_check_container_objects(container_name, [obj_name])
+ self._delete_object(container_name, obj_name)
+ self._delete_container(container_name)
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 1f01437..361ec36 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -63,6 +63,25 @@
body = json.loads(body)
return resp, body['security_group']
+ def update_security_group(self, security_group_id, name=None,
+ description=None):
+ """
+ Update a security group.
+ security_group_id: a security_group to update
+ name: new name of security group
+ description: new description of security group
+ """
+ post_body = {}
+ if name:
+ post_body['name'] = name
+ if description:
+ post_body['description'] = description
+ post_body = json.dumps({'security_group': post_body})
+ resp, body = self.put('os-security-groups/%s' % str(security_group_id),
+ post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['security_group']
+
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
return self.delete('os-security-groups/%s' % str(security_group_id))
diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py
new file mode 100644
index 0000000..8ca2770
--- /dev/null
+++ b/tempest/services/compute/v3/json/aggregates_client.py
@@ -0,0 +1,111 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from tempest.common.rest_client import RestClient
+from tempest import exceptions
+
+
+class AggregatesV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(AggregatesV3ClientJSON, self).__init__(config, username,
+ password, auth_url,
+ tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_aggregates(self):
+ """Get aggregate list."""
+ resp, body = self.get("os-aggregates")
+ body = json.loads(body)
+ return resp, body['aggregates']
+
+ def get_aggregate(self, aggregate_id):
+ """Get details of the given aggregate."""
+ resp, body = self.get("os-aggregates/%s" % str(aggregate_id))
+ body = json.loads(body)
+ return resp, body['aggregate']
+
+ def create_aggregate(self, name, availability_zone=None):
+ """Creates a new aggregate."""
+ post_body = {
+ 'name': name,
+ 'availability_zone': availability_zone,
+ }
+ post_body = json.dumps({'aggregate': post_body})
+ resp, body = self.post('os-aggregates', post_body, self.headers)
+
+ body = json.loads(body)
+ return resp, body['aggregate']
+
+ def update_aggregate(self, aggregate_id, name, availability_zone=None):
+ """Update a aggregate."""
+ put_body = {
+ 'name': name,
+ 'availability_zone': availability_zone
+ }
+ put_body = json.dumps({'aggregate': put_body})
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
+ put_body, self.headers)
+
+ body = json.loads(body)
+ return resp, body['aggregate']
+
+ def delete_aggregate(self, aggregate_id):
+ """Deletes the given aggregate."""
+ return self.delete("os-aggregates/%s" % str(aggregate_id))
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_aggregate(id)
+ except exceptions.NotFound:
+ return True
+ return False
+
+ def add_host(self, aggregate_id, host):
+ """Adds a host to the given aggregate."""
+ post_body = {
+ 'host': host,
+ }
+ post_body = json.dumps({'add_host': post_body})
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['aggregate']
+
+ def remove_host(self, aggregate_id, host):
+ """Removes a host from the given aggregate."""
+ post_body = {
+ 'host': host,
+ }
+ post_body = json.dumps({'remove_host': post_body})
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['aggregate']
+
+ def set_metadata(self, aggregate_id, meta):
+ """Replaces the aggregate's existing metadata with new metadata."""
+ post_body = {
+ 'metadata': meta,
+ }
+ post_body = json.dumps({'set_metadata': post_body})
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['aggregate']
diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py
index 00d6f8a..e99ac91 100644
--- a/tempest/services/compute/v3/json/flavors_client.py
+++ b/tempest/services/compute/v3/json/flavors_client.py
@@ -21,12 +21,12 @@
from tempest.common.rest_client import RestClient
-class FlavorsClientJSON(RestClient):
+class FlavorsV3ClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(FlavorsClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(FlavorsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_flavors(self, params=None):
url = 'flavors'
@@ -67,7 +67,7 @@
if kwargs.get('rxtx'):
post_body['rxtx_factor'] = kwargs.get('rxtx')
if kwargs.get('is_public'):
- post_body['os-flavor-access:is_public'] = kwargs.get('is_public')
+ post_body['flavor-access:is_public'] = kwargs.get('is_public')
post_body = json.dumps({'flavor': post_body})
resp, body = self.post('flavors', post_body, self.headers)
@@ -91,27 +91,27 @@
def set_flavor_extra_spec(self, flavor_id, specs):
"""Sets extra Specs to the mentioned flavor."""
post_body = json.dumps({'extra_specs': specs})
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
post_body, self.headers)
body = json.loads(body)
return resp, body['extra_specs']
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs details of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id)
+ resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id)
body = json.loads(body)
return resp, body['extra_specs']
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
- resp, body = self.get('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ resp, body = self.get('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
body = json.loads(body)
return resp, body
def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
"""Update specified extra Specs of the mentioned flavor and key."""
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
+ resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
(flavor_id, key),
json.dumps(kwargs), self.headers)
body = json.loads(body)
@@ -119,12 +119,12 @@
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets extra Specs from the mentioned flavor."""
- return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ return self.delete('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id,
+ resp, body = self.get('flavors/%s/flavor-access' % flavor_id,
self.headers)
body = json.loads(body)
return resp, body['flavor_access']
@@ -132,8 +132,8 @@
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
post_body = {
- 'addTenantAccess': {
- 'tenant': tenant_id
+ 'add_tenant_access': {
+ 'tenant_id': tenant_id
}
}
post_body = json.dumps(post_body)
@@ -145,8 +145,8 @@
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
post_body = {
- 'removeTenantAccess': {
- 'tenant': tenant_id
+ 'remove_tenant_access': {
+ 'tenant_id': tenant_id
}
}
post_body = json.dumps(post_body)
diff --git a/tempest/services/compute/v3/json/hosts_client.py b/tempest/services/compute/v3/json/hosts_client.py
new file mode 100644
index 0000000..85cc34f
--- /dev/null
+++ b/tempest/services/compute/v3/json/hosts_client.py
@@ -0,0 +1,82 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2013 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+import urllib
+
+from tempest.common.rest_client import RestClient
+
+
+class HostsV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(HostsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_hosts(self, params=None):
+ """Lists all hosts."""
+
+ url = 'os-hosts'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['hosts']
+
+ def show_host_detail(self, hostname):
+ """Show detail information for the host."""
+
+ resp, body = self.get("os-hosts/%s" % str(hostname))
+ body = json.loads(body)
+ return resp, body['host']
+
+ def update_host(self, hostname, **kwargs):
+ """Update a host."""
+
+ request_body = {
+ 'status': None,
+ 'maintenance_mode': None,
+ }
+ request_body.update(**kwargs)
+ request_body = json.dumps({'host': request_body})
+
+ resp, body = self.put("os-hosts/%s" % str(hostname), request_body,
+ self.headers)
+ body = json.loads(body)
+ return resp, body
+
+ def startup_host(self, hostname):
+ """Startup a host."""
+
+ resp, body = self.get("os-hosts/%s/startup" % str(hostname))
+ body = json.loads(body)
+ return resp, body['host']
+
+ def shutdown_host(self, hostname):
+ """Shutdown a host."""
+
+ resp, body = self.get("os-hosts/%s/shutdown" % str(hostname))
+ body = json.loads(body)
+ return resp, body['host']
+
+ def reboot_host(self, hostname):
+ """reboot a host."""
+
+ resp, body = self.get("os-hosts/%s/reboot" % str(hostname))
+ body = json.loads(body)
+ return resp, body['host']
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
index 5e1900c..500aa0e 100644
--- a/tempest/services/compute/v3/json/keypairs_client.py
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -20,15 +20,15 @@
from tempest.common.rest_client import RestClient
-class KeyPairsClientJSON(RestClient):
+class KeyPairsV3ClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(KeyPairsClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(KeyPairsV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_keypairs(self):
- resp, body = self.get("os-keypairs")
+ resp, body = self.get("keypairs")
body = json.loads(body)
# Each returned keypair is embedded within an unnecessary 'keypair'
# element which is a deviation from other resources like floating-ips,
@@ -38,7 +38,7 @@
return resp, body['keypairs']
def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name))
+ resp, body = self.get("keypairs/%s" % str(key_name))
body = json.loads(body)
return resp, body['keypair']
@@ -47,10 +47,10 @@
if pub_key:
post_body['keypair']['public_key'] = pub_key
post_body = json.dumps(post_body)
- resp, body = self.post("os-keypairs",
+ resp, body = self.post("keypairs",
headers=self.headers, body=post_body)
body = json.loads(body)
return resp, body['keypair']
def delete_keypair(self, key_name):
- return self.delete("os-keypairs/%s" % str(key_name))
+ return self.delete("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/json/quotas_client.py b/tempest/services/compute/v3/json/quotas_client.py
index a910dec..cae2332 100644
--- a/tempest/services/compute/v3/json/quotas_client.py
+++ b/tempest/services/compute/v3/json/quotas_client.py
@@ -20,12 +20,12 @@
from tempest.common.rest_client import RestClient
-class QuotasClientJSON(RestClient):
+class QuotasV3ClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(QuotasClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(QuotasV3ClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def get_quota_set(self, tenant_id):
"""List the quota set for a tenant."""
@@ -44,11 +44,9 @@
return resp, body['quota_set']
def update_quota_set(self, tenant_id, force=None,
- injected_file_content_bytes=None,
metadata_items=None, ram=None, floating_ips=None,
fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, injected_files=None,
- cores=None, injected_file_path_bytes=None,
+ security_group_rules=None, cores=None,
security_groups=None):
"""
Updates the tenant's quota limits for one or more resources
@@ -58,10 +56,6 @@
if force is not None:
post_body['force'] = force
- if injected_file_content_bytes is not None:
- post_body['injected_file_content_bytes'] = \
- injected_file_content_bytes
-
if metadata_items is not None:
post_body['metadata_items'] = metadata_items
@@ -83,15 +77,9 @@
if security_group_rules is not None:
post_body['security_group_rules'] = security_group_rules
- if injected_files is not None:
- post_body['injected_files'] = injected_files
-
if cores is not None:
post_body['cores'] = cores
- if injected_file_path_bytes is not None:
- post_body['injected_file_path_bytes'] = injected_file_path_bytes
-
if security_groups is not None:
post_body['security_groups'] = security_groups
diff --git a/tempest/services/compute/v3/json/servers_client.py b/tempest/services/compute/v3/json/servers_client.py
index a7fcc6d..da31036 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -64,12 +64,14 @@
'flavor_ref': flavor_ref
}
- for option in ['personality', 'admin_password', 'key_name',
- 'security_groups', 'networks',
+ for option in ['personality', 'admin_password', 'key_name', 'networks',
+ ('os-security-groups:security_groups',
+ 'security_groups'),
('os-user-data:user_data', 'user_data'),
('os-availability-zone:availability_zone',
'availability_zone'),
- 'access_ip_v4', 'access_ip_v6',
+ ('os-access-ips:access_ip_v4', 'access_ip_v4'),
+ ('os-access-ips:access_ip_v6', 'access_ip_v6'),
('os-multiple-create:min_count', 'min_count'),
('os-multiple-create:max_count', 'max_count'),
('metadata', 'meta'),
@@ -91,8 +93,8 @@
body = json.loads(body)
# NOTE(maurosr): this deals with the case of multiple server create
# with return reservation id set True
- if 'reservation_id' in body:
- return resp, body
+ if 'servers_reservation' in body:
+ return resp, body['servers_reservation']
return resp, body['server']
def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
@@ -115,10 +117,10 @@
post_body['name'] = name
if access_ip_v4 is not None:
- post_body['access_ip_v4'] = access_ip_v4
+ post_body['os-access-ips:access_ip_v4'] = access_ip_v4
if access_ip_v6 is not None:
- post_body['access_ip_v6'] = access_ip_v6
+ post_body['os-access-ips:access_ip_v6'] = access_ip_v6
if disk_config is not None:
post_body['os-disk-config:disk_config'] = disk_config
@@ -205,6 +207,13 @@
body = json.loads(body)[response_key]
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "create_backup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, admin_password):
"""Changes the root password for the server."""
return self.action(server_id, 'change_password', None,
@@ -356,6 +365,14 @@
"""Resets the state of a server to active/error."""
return self.action(server_id, 'reset_state', None, state=state)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def get_console_output(self, server_id, length):
return self.action(server_id, 'get_console_output', 'output',
length=length)
@@ -388,3 +405,11 @@
(str(server_id), str(request_id)))
body = json.loads(body)
return resp, body['instance_action']
+
+ def force_delete_server(self, server_id, **kwargs):
+ """Force delete a server."""
+ return self.action(server_id, 'force_delete', None, **kwargs)
+
+ def restore_soft_deleted_server(self, server_id, **kwargs):
+ """Restore a soft-deleted server."""
+ return self.action(server_id, 'restore', None, **kwargs)
diff --git a/tempest/services/compute/v3/xml/aggregates_client.py b/tempest/services/compute/v3/xml/aggregates_client.py
new file mode 100644
index 0000000..7563fd6
--- /dev/null
+++ b/tempest/services/compute/v3/xml/aggregates_client.py
@@ -0,0 +1,130 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 NEC Corporation.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from lxml import etree
+
+from tempest.common.rest_client import RestClientXML
+from tempest import exceptions
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import Text
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class AggregatesV3ClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(AggregatesV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def _format_aggregate(self, g):
+ agg = xml_to_json(g)
+ aggregate = {}
+ for key, value in agg.items():
+ if key == 'hosts':
+ aggregate['hosts'] = []
+ for k, v in value.items():
+ aggregate['hosts'].append(v)
+ elif key == 'availability_zone':
+ aggregate[key] = None if value == 'None' else value
+ else:
+ aggregate[key] = value
+ return aggregate
+
+ def _parse_array(self, node):
+ return [self._format_aggregate(x) for x in node]
+
+ def list_aggregates(self):
+ """Get aggregate list."""
+ resp, body = self.get("os-aggregates", self.headers)
+ aggregates = self._parse_array(etree.fromstring(body))
+ return resp, aggregates
+
+ def get_aggregate(self, aggregate_id):
+ """Get details of the given aggregate."""
+ resp, body = self.get("os-aggregates/%s" % str(aggregate_id),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
+ def create_aggregate(self, name, availability_zone=None):
+ """Creates a new aggregate."""
+ post_body = Element("aggregate",
+ name=name,
+ availability_zone=availability_zone)
+ resp, body = self.post('os-aggregates',
+ str(Document(post_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
+ def update_aggregate(self, aggregate_id, name, availability_zone=None):
+ """Update a aggregate."""
+ put_body = Element("aggregate",
+ name=name,
+ availability_zone=availability_zone)
+ resp, body = self.put('os-aggregates/%s' % str(aggregate_id),
+ str(Document(put_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
+ def delete_aggregate(self, aggregate_id):
+ """Deletes the given aggregate."""
+ return self.delete("os-aggregates/%s" % str(aggregate_id),
+ self.headers)
+
+ def is_resource_deleted(self, id):
+ try:
+ self.get_aggregate(id)
+ except exceptions.NotFound:
+ return True
+ return False
+
+ def add_host(self, aggregate_id, host):
+ """Adds a host to the given aggregate."""
+ post_body = Element("add_host", host=host)
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ str(Document(post_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
+ def remove_host(self, aggregate_id, host):
+ """Removes a host from the given aggregate."""
+ post_body = Element("remove_host", host=host)
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ str(Document(post_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
+
+ def set_metadata(self, aggregate_id, meta):
+ """Replaces the aggregate's existing metadata with new metadata."""
+ post_body = Element("set_metadata")
+ metadata = Element("metadata")
+ post_body.append(metadata)
+ for k, v in meta.items():
+ meta = Element(k)
+ meta.append(Text(v))
+ metadata.append(meta)
+ resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
+ str(Document(post_body)),
+ self.headers)
+ aggregate = self._format_aggregate(etree.fromstring(body))
+ return resp, aggregate
diff --git a/tempest/services/compute/v3/xml/flavors_client.py b/tempest/services/compute/v3/xml/flavors_client.py
index a1c74d9..04c21b4 100644
--- a/tempest/services/compute/v3/xml/flavors_client.py
+++ b/tempest/services/compute/v3/xml/flavors_client.py
@@ -24,21 +24,18 @@
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import Text
from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml.common import XMLNS_V3
-
-XMLNS_OS_FLV_EXT_DATA = \
- "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1"
XMLNS_OS_FLV_ACCESS = \
- "http://docs.openstack.org/compute/ext/flavor_access/api/v2"
+ "http://docs.openstack.org/compute/core/flavor-access/api/v3"
-class FlavorsClientXML(RestClientXML):
+class FlavorsV3ClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(FlavorsClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(FlavorsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def _format_flavor(self, f):
flavor = {'links': []}
@@ -51,15 +48,12 @@
flavor['links'].append(v)
continue
- if k == '{%s}ephemeral' % XMLNS_OS_FLV_EXT_DATA:
- k = 'OS-FLV-EXT-DATA:ephemeral'
-
if k == '{%s}is_public' % XMLNS_OS_FLV_ACCESS:
- k = 'os-flavor-access:is_public'
+ k = 'flavor-access:is_public'
v = True if v == 'True' else False
if k == 'extra_specs':
- k = 'OS-FLV-WITH-EXT-SPECS:extra_specs'
+ k = 'flavor-extra-specs:extra_specs'
flavor[k] = dict(v)
continue
@@ -103,7 +97,7 @@
def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
"""Creates a new flavor or instance type."""
flavor = Element("flavor",
- xmlns=XMLNS_11,
+ xmlns=XMLNS_V3,
ram=ram,
vcpus=vcpus,
disk=disk,
@@ -114,13 +108,11 @@
if kwargs.get('swap'):
flavor.add_attr('swap', kwargs.get('swap'))
if kwargs.get('ephemeral'):
- flavor.add_attr('OS-FLV-EXT-DATA:ephemeral',
- kwargs.get('ephemeral'))
+ flavor.add_attr('ephemeral', kwargs.get('ephemeral'))
if kwargs.get('is_public'):
- flavor.add_attr('os-flavor-access:is_public',
+ flavor.add_attr('flavor-access:is_public',
kwargs.get('is_public'))
- flavor.add_attr('xmlns:OS-FLV-EXT-DATA', XMLNS_OS_FLV_EXT_DATA)
- flavor.add_attr('xmlns:os-flavor-access', XMLNS_OS_FLV_ACCESS)
+ flavor.add_attr('xmlns:flavor-access', XMLNS_OS_FLV_ACCESS)
resp, body = self.post('flavors', str(Document(flavor)), self.headers)
body = xml_to_json(etree.fromstring(body))
flavor = self._format_flavor(body)
@@ -145,21 +137,21 @@
extra_specs = Element("extra_specs")
for key in specs.keys():
extra_specs.add_attr(key, specs[key])
- resp, body = self.post('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.post('flavors/%s/flavor-extra-specs' % flavor_id,
str(Document(extra_specs)), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec(self, flavor_id):
"""Gets extra Specs of the mentioned flavor."""
- resp, body = self.get('flavors/%s/os-extra_specs' % flavor_id,
+ resp, body = self.get('flavors/%s/flavor-extra-specs' % flavor_id,
self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
def get_flavor_extra_spec_with_key(self, flavor_id, key):
"""Gets extra Specs key-value of the mentioned flavor and key."""
- resp, xml_body = self.get('flavors/%s/os-extra_specs/%s' %
+ resp, xml_body = self.get('flavors/%s/flavor-extra-specs/%s' %
(str(flavor_id), key), self.headers)
body = {}
element = etree.fromstring(xml_body)
@@ -176,7 +168,7 @@
value = Text(v)
element.append(value)
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
+ resp, body = self.put('flavors/%s/flavor-extra-specs/%s' %
(flavor_id, key),
str(doc), self.headers)
body = xml_to_json(etree.fromstring(body))
@@ -184,15 +176,15 @@
def unset_flavor_extra_spec(self, flavor_id, key):
"""Unsets an extra spec based on the mentioned flavor and key."""
- return self.delete('flavors/%s/os-extra_specs/%s' % (str(flavor_id),
- key))
+ return self.delete('flavors/%s/flavor-extra-specs/%s' %
+ (str(flavor_id), key))
def _parse_array_access(self, node):
return [xml_to_json(x) for x in node]
def list_flavor_access(self, flavor_id):
"""Gets flavor access information given the flavor id."""
- resp, body = self.get('flavors/%s/os-flavor-access' % str(flavor_id),
+ resp, body = self.get('flavors/%s/flavor-access' % str(flavor_id),
self.headers)
body = self._parse_array(etree.fromstring(body))
return resp, body
@@ -200,9 +192,9 @@
def add_flavor_access(self, flavor_id, tenant_id):
"""Add flavor access for the specified tenant."""
doc = Document()
- server = Element("addTenantAccess")
+ server = Element("add_tenant_access")
doc.append(server)
- server.add_attr("tenant", tenant_id)
+ server.add_attr("tenant_id", tenant_id)
resp, body = self.post('flavors/%s/action' % str(flavor_id),
str(doc), self.headers)
body = self._parse_array_access(etree.fromstring(body))
@@ -211,9 +203,9 @@
def remove_flavor_access(self, flavor_id, tenant_id):
"""Remove flavor access from the specified tenant."""
doc = Document()
- server = Element("removeTenantAccess")
+ server = Element("remove_tenant_access")
doc.append(server)
- server.add_attr("tenant", tenant_id)
+ server.add_attr("tenant_id", tenant_id)
resp, body = self.post('flavors/%s/action' % str(flavor_id),
str(doc), self.headers)
body = self._parse_array_access(etree.fromstring(body))
diff --git a/tempest/services/compute/v3/xml/hosts_client.py b/tempest/services/compute/v3/xml/hosts_client.py
new file mode 100644
index 0000000..82fb076
--- /dev/null
+++ b/tempest/services/compute/v3/xml/hosts_client.py
@@ -0,0 +1,92 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2013 IBM Corp.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import urllib
+
+from lxml import etree
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class HostsV3ClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(HostsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_hosts(self, params=None):
+ """Lists all hosts."""
+
+ url = 'os-hosts'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+
+ resp, body = self.get(url, self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
+
+ def show_host_detail(self, hostname):
+ """Show detail information for the host."""
+
+ resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(node)]
+ return resp, body
+
+ def update_host(self, hostname, **kwargs):
+ """Update a host."""
+
+ request_body = Element("host")
+ if kwargs:
+ for k, v in kwargs.iteritems():
+ request_body.append(Element(k, v))
+ resp, body = self.put("os-hosts/%s" % str(hostname),
+ str(Document(request_body)),
+ self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
+
+ def startup_host(self, hostname):
+ """Startup a host."""
+
+ resp, body = self.get("os-hosts/%s/startup" % str(hostname),
+ self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
+
+ def shutdown_host(self, hostname):
+ """Shutdown a host."""
+
+ resp, body = self.get("os-hosts/%s/shutdown" % str(hostname),
+ self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
+
+ def reboot_host(self, hostname):
+ """Reboot a host."""
+
+ resp, body = self.get("os-hosts/%s/reboot" % str(hostname),
+ self.headers)
+ node = etree.fromstring(body)
+ body = [xml_to_json(x) for x in node.getchildren()]
+ return resp, body
diff --git a/tempest/services/compute/v3/xml/keypairs_client.py b/tempest/services/compute/v3/xml/keypairs_client.py
index 0157245..d87daff 100644
--- a/tempest/services/compute/v3/xml/keypairs_client.py
+++ b/tempest/services/compute/v3/xml/keypairs_client.py
@@ -24,21 +24,21 @@
from tempest.services.compute.xml.common import xml_to_json
-class KeyPairsClientXML(RestClientXML):
+class KeyPairsV3ClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(KeyPairsClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(KeyPairsV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def list_keypairs(self):
- resp, body = self.get("os-keypairs", self.headers)
+ resp, body = self.get("keypairs", self.headers)
node = etree.fromstring(body)
body = [{'keypair': xml_to_json(x)} for x in node.getchildren()]
return resp, body
def get_keypair(self, key_name):
- resp, body = self.get("os-keypairs/%s" % str(key_name), self.headers)
+ resp, body = self.get("keypairs/%s" % str(key_name), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
@@ -60,10 +60,10 @@
doc.append(keypair_element)
- resp, body = self.post("os-keypairs",
+ resp, body = self.post("keypairs",
headers=self.headers, body=str(doc))
body = xml_to_json(etree.fromstring(body))
return resp, body
def delete_keypair(self, key_name):
- return self.delete("os-keypairs/%s" % str(key_name))
+ return self.delete("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/xml/quotas_client.py b/tempest/services/compute/v3/xml/quotas_client.py
index ef5362c..7ef2274 100644
--- a/tempest/services/compute/v3/xml/quotas_client.py
+++ b/tempest/services/compute/v3/xml/quotas_client.py
@@ -21,15 +21,15 @@
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml.common import XMLNS_V3
-class QuotasClientXML(RestClientXML):
+class QuotasV3ClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(QuotasClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
+ super(QuotasV3ClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
def _format_quota(self, q):
quota = {}
@@ -65,25 +65,19 @@
return resp, body
def update_quota_set(self, tenant_id, force=None,
- injected_file_content_bytes=None,
metadata_items=None, ram=None, floating_ips=None,
fixed_ips=None, key_pairs=None, instances=None,
- security_group_rules=None, injected_files=None,
- cores=None, injected_file_path_bytes=None,
+ security_group_rules=None, cores=None,
security_groups=None):
"""
Updates the tenant's quota limits for one or more resources
"""
post_body = Element("quota_set",
- xmlns=XMLNS_11)
+ xmlns=XMLNS_V3)
if force is not None:
post_body.add_attr('force', force)
- if injected_file_content_bytes is not None:
- post_body.add_attr('injected_file_content_bytes',
- injected_file_content_bytes)
-
if metadata_items is not None:
post_body.add_attr('metadata_items', metadata_items)
@@ -105,16 +99,9 @@
if security_group_rules is not None:
post_body.add_attr('security_group_rules', security_group_rules)
- if injected_files is not None:
- post_body.add_attr('injected_files', injected_files)
-
if cores is not None:
post_body.add_attr('cores', cores)
- if injected_file_path_bytes is not None:
- post_body.add_attr('injected_file_path_bytes',
- injected_file_path_bytes)
-
if security_groups is not None:
post_body.add_attr('security_groups', security_groups)
diff --git a/tempest/services/compute/v3/xml/servers_client.py b/tempest/services/compute/v3/xml/servers_client.py
index 7af4161..a5cc291 100644
--- a/tempest/services/compute/v3/xml/servers_client.py
+++ b/tempest/services/compute/v3/xml/servers_client.py
@@ -114,6 +114,10 @@
'/compute/ext/extended_status/api/v3}vm_state')
task_state = ('{http://docs.openstack.org'
'/compute/ext/extended_status/api/v3}task_state')
+ access_ip_v4 = ('{http://docs.openstack.org/compute/ext/'
+ 'os-access-ips/api/v3}access_ip_v4')
+ access_ip_v6 = ('{http://docs.openstack.org/compute/ext/'
+ 'os-access-ips/api/v3}access_ip_v6')
if disk_config in json:
json['os-disk-config:disk_config'] = json.pop(disk_config)
if terminated_at in json:
@@ -129,6 +133,10 @@
json['os-extended-status:vm_state'] = json.pop(vm_state)
if task_state in json:
json['os-extended-status:task_state'] = json.pop(task_state)
+ if access_ip_v4 in json:
+ json['os-access-ips:access_ip_v4'] = json.pop(access_ip_v4)
+ if access_ip_v6 in json:
+ json['os-access-ips:access_ip_v6'] = json.pop(access_ip_v6)
return json
@@ -214,6 +222,14 @@
"""Resets the state of a server to active/error."""
return self.action(server_id, 'reset_state', None, state=state)
+ def shelve_server(self, server_id, **kwargs):
+ """Shelves the provided server."""
+ return self.action(server_id, 'shelve', None, **kwargs)
+
+ def unshelve_server(self, server_id, **kwargs):
+ """Un-shelves the provided server."""
+ return self.action(server_id, 'unshelve', None, **kwargs)
+
def delete_server(self, server_id):
"""Deletes the given server."""
return self.delete("servers/%s" % str(server_id))
@@ -250,10 +266,14 @@
if name is not None:
server.add_attr("name", name)
+ if access_ip_v4 or access_ip_v6:
+ server.add_attr('xmlns:os-access-ips',
+ "http://docs.openstack.org/compute/ext/"
+ "os-access-ips/api/v3")
if access_ip_v4 is not None:
- server.add_attr("access_ip_v4", access_ip_v4)
+ server.add_attr("os-access-ips:access_ip_v4", access_ip_v4)
if access_ip_v6 is not None:
- server.add_attr("access_ip_v6", access_ip_v6)
+ server.add_attr("os-access-ips:access_ip_v6", access_ip_v6)
if disk_config is not None:
server.add_attr('xmlns:os-disk-config', "http://docs.openstack.org"
"/compute/ext/disk_config/api/v3")
@@ -294,12 +314,21 @@
return_reservation_id: Enable/Disable the return of reservation id.
"""
server = Element("server",
- imageRef=image_ref,
xmlns=XMLNS_V3,
flavor_ref=flavor_ref,
image_ref=image_ref,
name=name)
- attrs = ["admin_password", "access_ip_v4", "access_ip_v6", "key_name",
+ attrs = ["admin_password", "key_name",
+ ('os-access-ips:access_ip_v4',
+ 'access_ip_v4',
+ 'xmlns:os-access-ips',
+ "http://docs.openstack.org/compute/ext/"
+ "os-access-ips/api/v3"),
+ ('os-access-ips:access_ip_v6',
+ 'access_ip_v6',
+ 'xmlns:os-access-ips',
+ "http://docs.openstack.org/compute/ext/"
+ "os-access-ips/api/v3"),
("os-user-data:user_data",
'user_data',
'xmlns:os-user-data',
@@ -346,7 +375,10 @@
server.add_attr(post_param, value)
if 'security_groups' in kwargs:
- secgroups = Element("security_groups")
+ server.add_attr("xmlns:os-security-groups",
+ "http://docs.openstack.org/compute/ext/"
+ "securitygroups/api/v3")
+ secgroups = Element("os-security-groups:security_groups")
server.append(secgroups)
for secgroup in kwargs['security_groups']:
s = Element("security_group", name=secgroup['name'])
@@ -441,6 +473,13 @@
body = xml_to_json(etree.fromstring(body))
return resp, body
+ def create_backup(self, server_id, backup_type, rotation, name):
+ """Backup a server instance."""
+ return self.action(server_id, "create_backup", None,
+ backup_type=backup_type,
+ rotation=rotation,
+ name=name)
+
def change_password(self, server_id, password):
return self.action(server_id, "change_password", None,
admin_password=password)
@@ -621,3 +660,11 @@
(server_id, request_id), self.headers)
body = xml_to_json(etree.fromstring(body))
return resp, body
+
+ def force_delete_server(self, server_id, **kwargs):
+ """Force delete a server."""
+ return self.action(server_id, 'force_delete', None, **kwargs)
+
+ def restore_soft_deleted_server(self, server_id, **kwargs):
+ """Restore a soft-deleted server."""
+ return self.action(server_id, 'restore', None, **kwargs)
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index 860dd5b..d2a18a1 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -99,7 +99,15 @@
return self.__content
-def xml_to_json(node):
+def parse_array(node, plurals=None):
+ array = []
+ for child in node.getchildren():
+ array.append(xml_to_json(child,
+ plurals))
+ return array
+
+
+def xml_to_json(node, plurals=None):
"""This does a really braindead conversion of an XML tree to
something that looks like a json dump. In cases where the XML
and json structures are the same, then this "just works". In
@@ -115,7 +123,10 @@
tag = child.tag
if tag.startswith("{"):
ns, tag = tag.split("}", 1)
- json[tag] = xml_to_json(child)
+ if plurals is not None and tag in plurals:
+ json[tag] = parse_array(child)
+ else:
+ json[tag] = xml_to_json(child)
return json
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
index f7d7b0a..519798e 100644
--- a/tempest/services/compute/xml/hosts_client.py
+++ b/tempest/services/compute/xml/hosts_client.py
@@ -47,18 +47,16 @@
resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
node = etree.fromstring(body)
- body = [xml_to_json(x) for x in node.getchildren()]
+ body = [xml_to_json(node)]
return resp, body
- def update_host(self, hostname, status=None, maintenance_mode=None,
- **kwargs):
+ def update_host(self, hostname, **kwargs):
"""Update a host."""
- request_body = Element(status=status,
- maintenance_mode=maintenance_mode)
+ request_body = Element("updates")
if kwargs:
- for k, v in kwargs.iteritem():
- request_body.add_attr(k, v)
+ for k, v in kwargs.iteritems():
+ request_body.append(Element(k, v))
resp, body = self.put("os-hosts/%s" % str(hostname),
str(Document(request_body)),
self.headers)
diff --git a/tempest/services/compute/xml/security_groups_client.py b/tempest/services/compute/xml/security_groups_client.py
index 5d86790..aebeb4d 100644
--- a/tempest/services/compute/xml/security_groups_client.py
+++ b/tempest/services/compute/xml/security_groups_client.py
@@ -79,6 +79,30 @@
body = self._parse_body(etree.fromstring(body))
return resp, body
+ def update_security_group(self, security_group_id, name=None,
+ description=None):
+ """
+ Update a security group.
+ security_group_id: a security_group to update
+ name: new name of security group
+ description: new description of security group
+ """
+ security_group = Element("security_group")
+ if name:
+ sg_name = Element("name")
+ sg_name.append(Text(content=name))
+ security_group.append(sg_name)
+ if description:
+ des = Element("description")
+ des.append(Text(content=description))
+ security_group.append(des)
+ resp, body = self.put('os-security-groups/%s' %
+ str(security_group_id),
+ str(Document(security_group)),
+ self.headers)
+ body = self._parse_body(etree.fromstring(body))
+ return resp, body
+
def delete_security_group(self, security_group_id):
"""Deletes the provided Security Group."""
return self.delete('os-security-groups/%s' %
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index b323dc6..e26697e 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -46,6 +46,9 @@
# {'resources': [ res1, res2] }
return res[res.keys()[0]]
+ def serialize(self, data):
+ return json.dumps(data)
+
def create_network(self, name, **kwargs):
post_body = {'network': kwargs}
post_body['network']['name'] = name
@@ -303,21 +306,6 @@
body = json.loads(body)
return resp, body
- def create_pool(self, name, lb_method, protocol, subnet_id):
- post_body = {
- "pool": {
- "protocol": protocol,
- "name": name,
- "subnet_id": subnet_id,
- "lb_method": lb_method
- }
- }
- body = json.dumps(post_body)
- uri = '%s/lb/pools' % (self.uri_prefix)
- resp, body = self.post(uri, body)
- body = json.loads(body)
- return resp, body
-
def update_vip(self, vip_id, new_name):
put_body = {
"vip": {
@@ -330,18 +318,6 @@
body = json.loads(body)
return resp, body
- def update_pool(self, pool_id, new_name):
- put_body = {
- "pool": {
- "name": new_name,
- }
- }
- body = json.dumps(put_body)
- uri = '%s/lb/pools/%s' % (self.uri_prefix, pool_id)
- resp, body = self.put(uri, body)
- body = json.loads(body)
- return resp, body
-
def create_member(self, address, protocol_port, pool_id):
post_body = {
"member": {
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
index b48dd34..42ca5bf 100644
--- a/tempest/services/network/network_client_base.py
+++ b/tempest/services/network/network_client_base.py
@@ -14,7 +14,7 @@
import urllib
-# the folliwing map is used to construct proper URI
+# the following map is used to construct proper URI
# for the given neutron resource
service_resource_prefix_map = {
'networks': '',
@@ -124,11 +124,35 @@
return _show
+ def _creater(self, resource_name):
+ def _create(**kwargs):
+ plural = self.pluralize(resource_name)
+ uri = self.get_uri(plural)
+ post_data = self.serialize({resource_name: kwargs})
+ resp, body = self.post(uri, post_data)
+ body = self.deserialize_single(body)
+ return resp, body
+
+ return _create
+
+ def _updater(self, resource_name):
+ def _update(res_id, **kwargs):
+ plural = self.pluralize(resource_name)
+ uri = '%s/%s' % (self.get_uri(plural), res_id)
+ post_data = self.serialize({resource_name: kwargs})
+ resp, body = self.put(uri, post_data)
+ body = self.deserialize_single(body)
+ return resp, body
+
+ return _update
+
def __getattr__(self, name):
- method_prefixes = ["list_", "delete_", "show_"]
+ method_prefixes = ["list_", "delete_", "show_", "create_", "update_"]
method_functors = [self._lister,
self._deleter,
- self._shower]
+ self._shower,
+ self._creater,
+ self._updater]
for index, prefix in enumerate(method_prefixes):
prefix_len = len(prefix)
if name[:prefix_len] == prefix:
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index a999e31..a57f278 100644
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -19,23 +19,38 @@
from tempest.services.compute.xml.common import deep_dict_to_xml
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import parse_array
from tempest.services.compute.xml.common import xml_to_json
from tempest.services.network import network_client_base as client_base
class NetworkClientXML(client_base.NetworkClientBase):
+ # list of plurals used for xml serialization
+ PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
+ 'fixed_ips', 'extensions']
+
def get_rest_client(self, config, username, password,
auth_url, tenant_name=None):
return RestClientXML(config, username, password,
auth_url, tenant_name)
def deserialize_list(self, body):
- return self._parse_array(etree.fromstring(body))
+ return parse_array(etree.fromstring(body), self.PLURALS)
def deserialize_single(self, body):
return _root_tag_fetcher_and_xml_to_json_parse(body)
+ def serialize(self, body):
+ #TODO(enikanorov): implement better json to xml conversion
+ # expecting the dict with single key
+ root = body.keys()[0]
+ post_body = Element(root)
+ for name, attr in body[root].items():
+ elt = Element(name, attr)
+ post_body.append(elt)
+ return str(Document(post_body))
+
def create_network(self, name):
uri = '%s/networks' % (self.uri_prefix)
post_body = Element("network")
@@ -54,7 +69,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
networks = {"networks": networks}
return resp, networks
@@ -83,12 +98,6 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
def update_port(self, port_id, name):
uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
port = Element("port")
@@ -151,7 +160,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- subnets = self._parse_array(etree.fromstring(body))
+ subnets = parse_array(etree.fromstring(body))
subnets = {"subnets": subnets}
return resp, subnets
@@ -166,7 +175,7 @@
p1.append(p2)
post_body.append(p1)
resp, body = self.post(uri, str(Document(post_body)))
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body))
ports = {"ports": ports}
return resp, ports
@@ -196,28 +205,6 @@
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def create_pool(self, name, lb_method, protocol, subnet_id):
- uri = '%s/lb/pools' % (self.uri_prefix)
- post_body = Element("pool")
- p1 = Element("lb_method", lb_method)
- p2 = Element("protocol", protocol)
- p3 = Element("subnet_id", subnet_id)
- post_body.append(p1)
- post_body.append(p2)
- post_body.append(p3)
- resp, body = self.post(uri, str(Document(post_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def update_pool(self, pool_id, new_name):
- uri = '%s/lb/pools/%s' % (self.uri_prefix, str(pool_id))
- put_body = Element("pool")
- p2 = Element("name", new_name)
- put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)))
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
def create_member(self, address, protocol_port, pool_id):
uri = '%s/lb/members' % (self.uri_prefix)
post_body = Element("member")
@@ -366,7 +353,7 @@
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
resp, body = self.get(uri)
- ports = self._parse_array(etree.fromstring(body))
+ ports = parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
@@ -395,14 +382,14 @@
def list_dhcp_agent_hosting_network(self, network_id):
uri = '%s/networks/%s/dhcp-agents' % (self.uri_prefix, network_id)
resp, body = self.get(uri)
- agents = self._parse_array(etree.fromstring(body))
+ agents = parse_array(etree.fromstring(body))
body = {'agents': agents}
return resp, body
def list_networks_hosted_by_one_dhcp_agent(self, agent_id):
uri = '%s/agents/%s/dhcp-networks' % (self.uri_prefix, agent_id)
resp, body = self.get(uri)
- networks = self._parse_array(etree.fromstring(body))
+ networks = parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
@@ -418,7 +405,8 @@
root_tag = body.tag
if root_tag.startswith("{"):
ns, root_tag = root_tag.split("}", 1)
- body = xml_to_json(etree.fromstring(xml_returned_body))
+ body = xml_to_json(etree.fromstring(xml_returned_body),
+ NetworkClientXML.PLURALS)
nil = '{http://www.w3.org/2001/XMLSchema-instance}nil'
for key, val in body.iteritems():
if isinstance(val, dict):
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 9e0adff..5c86d1f 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -134,14 +134,6 @@
resp, body = self.put(url, data, self.headers)
return resp, body
- def get_object_using_temp_url(self, url):
- """Retrieve object's data using temp URL."""
- return self.get(url)
-
- def put_object_using_temp_url(self, url, data):
- """Put data in an object using temp URL."""
- return self.put(url, data, None)
-
class ObjectClientCustomizedHeader(RestClient):
diff --git a/tempest/test.py b/tempest/test.py
index 56c0554..342846f 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -112,15 +112,24 @@
@param bug: bug number causing the test to skip
@param condition: optional condition to be True for the skip to have place
+ @param interface: skip the test if it is the same as self._interface
"""
def decorator(f):
@functools.wraps(f)
- def wrapper(*func_args, **func_kwargs):
- if "bug" in kwargs:
- if "condition" not in kwargs or kwargs["condition"] is True:
- msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
- raise testtools.TestCase.skipException(msg)
- return f(*func_args, **func_kwargs)
+ def wrapper(self, *func_args, **func_kwargs):
+ skip = False
+ if "condition" in kwargs:
+ if kwargs["condition"] is True:
+ skip = True
+ elif "interface" in kwargs:
+ if kwargs["interface"] == self._interface:
+ skip = True
+ else:
+ skip = True
+ if "bug" in kwargs and skip is True:
+ msg = "Skipped until Bug: %s is resolved." % kwargs["bug"]
+ raise testtools.TestCase.skipException(msg)
+ return f(self, *func_args, **func_kwargs)
return wrapper
return decorator
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 2f7a650..2ce5cce 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -245,20 +245,20 @@
@classmethod
def tearDownClass(cls):
"""Calls the callables added by addResourceCleanUp,
- when you overwire this function dont't forget to call this too.
+ when you overwrite this function don't forget to call this too.
"""
fail_count = 0
trash_keys = sorted(cls._resource_trash_bin, reverse=True)
for key in trash_keys:
(function, pos_args, kw_args) = cls._resource_trash_bin[key]
try:
- LOG.debug("Cleaning up: %s" %
- friendly_function_call_str(function, *pos_args,
- **kw_args))
+ func_name = friendly_function_call_str(function, *pos_args,
+ **kw_args)
+ LOG.debug("Cleaning up: %s" % func_name)
function(*pos_args, **kw_args)
- except BaseException as exc:
+ except BaseException:
fail_count += 1
- LOG.exception(exc)
+ LOG.exception("Cleanup failed %s" % func_name)
finally:
del cls._resource_trash_bin[key]
super(BotoTestCase, cls).tearDownClass()
@@ -428,12 +428,12 @@
try:
bucket.delete_key(obj.key)
obj.close()
- except BaseException as exc:
- LOG.exception(exc)
+ except BaseException:
+ LOG.exception("Failed to delete key %s " % obj.key)
exc_num += 1
conn.delete_bucket(bucket)
- except BaseException as exc:
- LOG.exception(exc)
+ except BaseException:
+ LOG.exception("Failed to destroy bucket %s " % bucket)
exc_num += 1
if exc_num:
raise exceptions.TearDownException(num=exc_num)
@@ -463,8 +463,8 @@
try:
instance.terminate()
re_search_wait(_instance_state, "_GONE")
- except BaseException as exc:
- LOG.exception(exc)
+ except BaseException:
+ LOG.exception("Failed to terminate instance %s " % instance)
exc_num += 1
if exc_num:
raise exceptions.TearDownException(num=exc_num)
@@ -497,8 +497,8 @@
try:
if volume.status != "available":
volume.detach(force=True)
- except BaseException as exc:
- LOG.exception(exc)
+ except BaseException:
+ LOG.exception("Failed to detach volume %s" % volume)
# exc_num += 1 "nonlocal" not in python2
return volume.status
@@ -506,8 +506,8 @@
re_search_wait(_volume_state, "available") # not validates status
LOG.info(_volume_state())
volume.delete()
- except BaseException as exc:
- LOG.exception(exc)
+ except BaseException:
+ LOG.exception("Failed to delete volume %s" % volume)
exc_num += 1
if exc_num:
raise exceptions.TearDownException(num=exc_num)
diff --git a/tools/config/generate_sample.sh b/tools/config/generate_sample.sh
index b86e0c2..607fecb 100755
--- a/tools/config/generate_sample.sh
+++ b/tools/config/generate_sample.sh
@@ -91,3 +91,9 @@
MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH}
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
python -m $MODULEPATH $FILES > $OUTPUTFILE
+
+# Hook to allow projects to append custom config file snippets
+CONCAT_FILES=$(ls $BASEDIR/tools/config/*.conf.sample 2>/dev/null)
+for CONCAT_FILE in $CONCAT_FILES; do
+ cat $CONCAT_FILE >> $OUTPUTFILE
+done
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 1bab88a..46822e3 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# Copyright 2013 IBM Corp.
#
diff --git a/tox.ini b/tox.ini
index b44b3e0..6d596e3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,13 +4,14 @@
skipsdist = True
[testenv]
+sitepackages = True
setenv = VIRTUAL_ENV={envdir}
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_ALL=C
OS_TEST_PATH=./tempest/test_discover
usedevelop = True
-install_command = pip install -U {opts} {packages}
+install_command = pip install {opts} {packages}
[testenv:py26]
setenv = OS_TEST_PATH=./tempest/tests
@@ -25,38 +26,32 @@
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:all]
-sitepackages = True
setenv = VIRTUAL_ENV={envdir}
commands =
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:full]
-sitepackages = True
# The regex below is used to select which tests to run and exclude the slow tag:
# See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:testr-full]
-sitepackages = True
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:heat-slow]
-sitepackages = True
setenv = OS_TEST_TIMEOUT=1200
# The regex below is used to select heat api/scenario tests tagged as slow.
commands =
bash tools/pretty_tox_serial.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}'
[testenv:large-ops]
-sitepackages = True
commands =
python setup.py testr --slowest --testr-args='tempest.scenario.test_large_ops {posargs}'
[testenv:py26-full]
-sitepackages = True
setenv = VIRTUAL_ENV={envdir}
NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_COLOR=1
@@ -81,12 +76,10 @@
nosetests --logging-format '%(asctime)-15s %(message)s' --with-xunit -sv --attr=type=smoke --xunit-file=nosetests-smoke.xml tempest {posargs}
[testenv:smoke]
-sitepackages = True
commands =
bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:smoke-serial]
-sitepackages = True
# This is still serial because neutron doesn't work with parallel. See:
# https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke
# job would fail if we moved it to parallel.
@@ -94,7 +87,6 @@
bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
[testenv:stress]
-sitepackages = True
commands =
python -m tempest/stress/run_stress -a -d 3600 -S