Merge "Catch ssh exception and detach in min scenario"
diff --git a/.testr.conf b/.testr.conf
index 05b12c4..abaf14a 100644
--- a/.testr.conf
+++ b/.testr.conf
@@ -2,7 +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} \
- ${PYTHON:-python} -m subunit.run discover -t ./ ./tempest $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/HACKING.rst b/HACKING.rst
index a74ff73..3fa1ff5 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -9,8 +9,8 @@
------------------------------
- [T102] Cannot import OpenStack python clients in tempest/api tests
-- [T103] tempest/tests is deprecated
- [T104] Scenario tests require a services decorator
+- [T105] Unit tests cannot use setUpClass
Test Data/Configuration
-----------------------
@@ -39,7 +39,7 @@
when the additional operations leads to another exception.
Just letting an exception to propagate, is not bad idea in a test case,
- at all.
+at all.
Try to avoid using any exception handling construct which can hide the errors
origin.
@@ -53,10 +53,10 @@
test fails part way through.
Use the ``self.assert*`` methods provided by the unit test framework
- the signal failures early.
+the signal failures early.
Avoid using the ``self.fail`` alone, it's stack trace will signal
- the ``self.fail`` line as the origin of the error.
+the ``self.fail`` line as the origin of the error.
Avoid constructing complex boolean expressions for assertion.
The ``self.assertTrue`` or ``self.assertFalse`` without a ``msg`` argument,
@@ -192,3 +192,15 @@
The sample config file is autogenerated using a script. If any changes are made
to the config variables in tempest then the sample config file must be
regenerated. This can be done running the script: tools/generate_sample.sh
+
+Unit Tests
+----------
+Unit tests are a separate class of tests in tempest. They verify tempest
+itself, and thus have a different set of guidelines around them:
+
+1. They can not require anything running externally. All you should need to
+ run the unit tests is the git tree, python and the dependencies installed.
+ This includes running services, a config file, etc.
+
+2. The unit tests cannot use setUpClass, instead fixtures and testresources
+ should be used for shared state between tests.
diff --git a/README.rst b/README.rst
index 96f6e4c..bff2bf8 100644
--- a/README.rst
+++ b/README.rst
@@ -63,13 +63,13 @@
used tool. After setting up your configuration file, you can execute
the set of Tempest tests by using ``testr`` ::
- $> testr run --parallel tempest
+ $> testr run --parallel
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
+Alternatively, you can use the run_tempest.sh script which will create a venv
and run the tests or use tox to do the same.
Configuration
@@ -101,3 +101,20 @@
For the moment, the best solution is to provide the same image uuid for
both image_ref and image_ref_alt. Tempest will skip tests as needed if it
detects that both images are the same.
+
+Unit Tests
+----------
+
+Tempest also has a set of unit tests which test the tempest code itself. These
+tests can be run by specifing the test discovery path::
+
+ $> OS_TEST_PATH=./tempest/tests testr run --parallel
+
+By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
+should only be run on the unit test directory. The default value of OS_TEST_PATH
+is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
+tempest suite.
+
+Alternatively, you can use the run_tests.sh script which will create a venv and
+run the unit tests. There are also the py26, py27, or py33 tox jobs which will
+run the unit tests with the corresponding version of python.
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 1080ddf..bb9a68e 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,118 +95,78 @@
#syslog_log_facility=LOG_USER
-[identity]
+[baremetal]
#
# 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
+# Catalog type of the baremetal provisioning service. (string
# 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
+#catalog_type=baremetal
-[stress]
+[boto]
#
# Options defined in tempest.config
#
-# Directory containing log files on the compute nodes (string
-# value)
-#nova_logdir=<None>
+# EC2 URL (string value)
+#ec2_url=http://localhost:8773/services/Cloud
-# Maximum number of instances to create during test. (integer
-# value)
-#max_instances=16
+# S3 URL (string value)
+#s3_url=http://localhost:8080
-# Controller host. (string value)
-#controller=<None>
+# AWS Secret Key (string value)
+#aws_secret=<None>
-# Controller host. (string value)
-#target_controller=<None>
+# AWS Access Key (string value)
+#aws_access=<None>
-# ssh user. (string value)
-#target_ssh_user=<None>
+# S3 Materials Path (string value)
+#s3_materials_path=/opt/stack/devstack/files/images/s3-materials/cirros-0.3.0
-# Path to private key. (string value)
-#target_private_key_path=<None>
+# ARI Ramdisk Image manifest (string value)
+#ari_manifest=cirros-0.3.0-x86_64-initrd.manifest.xml
-# regexp for list of log files. (string value)
-#target_logfiles=<None>
+# AMI Machine Image manifest (string value)
+#ami_manifest=cirros-0.3.0-x86_64-blank.img.manifest.xml
-# time (in seconds) between log file error checks. (integer
-# value)
-#log_check_interval=60
+# AKI Kernel Image manifest (string value)
+#aki_manifest=cirros-0.3.0-x86_64-vmlinuz.manifest.xml
-# The number of threads created while stress test. (integer
-# value)
-#default_thread_number_per_action=4
+# 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
-[image-feature-enabled]
+[cli]
#
-# Options defined in tempest.config
+# Options defined in tempest.cli
#
-# Is the v2 image API enabled (boolean value)
-#api_v2=true
+# enable cli tests (boolean value)
+#enabled=true
-# Is the v1 image API enabled (boolean value)
-#api_v1=true
+# directory where python client binaries are located (string
+# value)
+#cli_dir=/usr/local/bin
+
+# Number of seconds to wait on a CLI timeout (integer value)
+#timeout=15
[compute]
@@ -256,7 +217,7 @@
# (integer value)
#build_timeout=300
-# Does the test environment support snapshots? (boolean value)
+# Should the tests ssh to instances? (boolean value)
#run_ssh=false
# User name used to authenticate to an instance. (string
@@ -318,6 +279,231 @@
# (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
+
+
+[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
+
+
+[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 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
+
+
+[dashboard]
+
+#
+# Options defined in tempest.config
+#
+
+# Where the dashboard can be found (string value)
+#dashboard_url=http://localhost/
+
+# Login page for the dashboard (string value)
+#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 for Keystone 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
+
+
+[identity-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# Does the identity service have delegation and impersonation
+# enabled (boolean value)
+#trust=true
+
+
+[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
+
+
+[input-scenario]
+
+#
+# Options defined in tempest.config
+#
+
+# Matching images become parameters for scenario tests (string
+# value)
+#image_regex=^cirros-0.3.1-x86_64-uec$
+
+# Matching flavors become parameters for scenario tests
+# (string value)
+#flavor_regex=^m1.(micro|nano|tiny)$
+
+# SSH verification in tests is skippedfor matching images
+# (string value)
+#non_ssh_image_regex=^.*[Ww]in.*$
+
+# List of user mapped to regex to matching image names.
+# (string value)
+#ssh_user_regex=[["^.*[Cc]irros.*$", "root"]]
+
[network]
@@ -354,51 +540,103 @@
#public_router_id=
-[boto]
+[network-feature-enabled]
#
# Options defined in tempest.config
#
-# EC2 URL (string value)
-#ec2_url=http://localhost:8773/services/Cloud
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
-# S3 URL (string value)
-#s3_url=http://localhost:8080
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
-# AWS Secret Key (string value)
-#aws_secret=<None>
+# A list of enabled extensions with a special entry all which
+# indicates every extension is enabled (list value)
+#api_extensions=all
-# AWS Access Key (string value)
-#aws_access=<None>
-# S3 Materials Path (string value)
-#s3_materials_path=/opt/stack/devstack/files/images/s3-materials/cirros-0.3.0
+[object-storage]
-# ARI Ramdisk Image manifest (string value)
-#ari_manifest=cirros-0.3.0-x86_64-initrd.manifest.xml
+#
+# Options defined in tempest.config
+#
-# AMI Machine Image manifest (string value)
-#ami_manifest=cirros-0.3.0-x86_64-blank.img.manifest.xml
+# Catalog type of the Object-Storage service. (string value)
+#catalog_type=object-store
-# AKI Kernel Image manifest (string value)
-#aki_manifest=cirros-0.3.0-x86_64-vmlinuz.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=
-# Instance type (string value)
-#instance_type=m1.tiny
+# Number of seconds to time on waiting for a container to
+# container synchronization complete. (integer value)
+#container_sync_timeout=120
-# boto Http socket timeout (integer value)
-#http_socket_timeout=3
+# Number of seconds to wait while looping to check the status
+# of a container to container synchronization (integer value)
+#container_sync_interval=5
-# boto num_retries on error (integer value)
-#num_retries=1
+# Role to add to users created for swift tests to enable
+# creating containers (string value)
+#operator_role=Member
-# Status Change Timeout (integer value)
-#build_timeout=60
-# Status Change Test Interval (integer value)
+[object-storage-feature-enabled]
+
+#
+# Options defined in tempest.config
+#
+
+# A list of the enabled optional discoverable apis. A single
+# entry, all, indicates that all of these features are
+# expected to be enabled (list value)
+#discoverable_apis=all
+
+
+[orchestration]
+
+#
+# Options defined in tempest.config
+#
+
+# Catalog type of the Orchestration service. (string value)
+#catalog_type=orchestration
+
+# The orchestration 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=
+
+# Time in seconds between build status checks. (integer value)
#build_interval=1
+# Timeout in seconds to wait for a stack to build. (integer
+# value)
+#build_timeout=300
+
+# Instance type for tests. Needs to be big enough for a full
+# OS plus the test workload (string value)
+#instance_type=m1.micro
+
+# Name of heat-cfntools enabled image to use when launching
+# test instances. (string value)
+#image_ref=<None>
+
+# Name of existing keypair to launch servers with. (string
+# value)
+#keypair_name=<None>
+
+# Value must match heat configuration of the same name.
+# (integer value)
+#max_template_size=524288
+
[scenario]
@@ -426,58 +664,99 @@
#large_ops_number=0
-[image]
+[service_available]
#
# 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
+# Whether or not cinder is expected to be available (boolean
# value)
-#region=
+#cinder=true
-# http accessible image (string value)
-#http_image=http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz
+# Whether or not neutron is expected to be available (boolean
+# value)
+#neutron=false
+
+# Whether or not glance is expected to be available (boolean
+# value)
+#glance=true
+
+# Whether or not swift is expected to be available (boolean
+# value)
+#swift=true
+
+# Whether or not nova is expected to be available (boolean
+# value)
+#nova=true
+
+# Whether or not Heat is expected to be available (boolean
+# value)
+#heat=false
+
+# Whether or not Ceilometer is expected to be available
+# (boolean value)
+#ceilometer=true
+
+# Whether or not Horizon is expected to be available (boolean
+# value)
+#horizon=true
+
+# Whether or not Savanna is expected to be available (boolean
+# value)
+#savanna=false
+
+# Whether or not Ironic is expected to be available (boolean
+# value)
+#ironic=false
-[compute-admin]
+[stress]
#
# 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
-
-
-[cli]
-
-#
-# Options defined in tempest.cli
-#
-
-# enable cli tests (boolean value)
-#enabled=true
-
-# directory where python client binaries are located (string
+# Directory containing log files on the compute nodes (string
# value)
-#cli_dir=/usr/local/bin
+#nova_logdir=<None>
-# Number of seconds to wait on a CLI timeout (integer value)
-#timeout=15
+# 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]
@@ -524,218 +803,6 @@
#disk_format=raw
-[debug]
-
-#
-# Options defined in tempest.config
-#
-
-# Enable diagnostic commands (boolean value)
-#enable=true
-
-
-[dashboard]
-
-#
-# Options defined in tempest.config
-#
-
-# Where the dashboard can be found (string value)
-#dashboard_url=http://localhost/
-
-# Login page for the dashboard (string value)
-#login_url=http://localhost/auth/login/
-
-
-[orchestration]
-
-#
-# Options defined in tempest.config
-#
-
-# Catalog type of the Orchestration service. (string value)
-#catalog_type=orchestration
-
-# The orchestration 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=
-
-# 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
-
-# Timeout in seconds to wait for a stack to build. (integer
-# value)
-#build_timeout=300
-
-# Instance type for tests. Needs to be big enough for a full
-# OS plus the test workload (string value)
-#instance_type=m1.micro
-
-# Name of heat-cfntools enabled image to use when launching
-# test instances. (string value)
-#image_ref=<None>
-
-# Name of existing keypair to launch servers with. (string
-# value)
-#keypair_name=<None>
-
-# Value must match heat configuration of the same name.
-# (integer value)
-#max_template_size=524288
-
-
-[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
-
-
-[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
-
-
-[service_available]
-
-#
-# Options defined in tempest.config
-#
-
-# Whether or not cinder is expected to be available (boolean
-# value)
-#cinder=true
-
-# Whether or not neutron is expected to be available (boolean
-# value)
-#neutron=false
-
-# Whether or not glance is expected to be available (boolean
-# value)
-#glance=true
-
-# Whether or not swift is expected to be available (boolean
-# value)
-#swift=true
-
-# Whether or not nova is expected to be available (boolean
-# value)
-#nova=true
-
-# Whether or not Heat is expected to be available (boolean
-# value)
-#heat=false
-
-# Whether or not Ceilometer is expected to be available
-# (boolean value)
-#ceilometer=true
-
-# Whether or not Horizon is expected to be available (boolean
-# value)
-#horizon=true
-
-
-[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
-
-
-[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
-
-
[volume-feature-enabled]
#
@@ -746,8 +813,7 @@
# (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
+# Is the v1 volume API enabled (boolean value)
+#api_v1=true
diff --git a/etc/whitelist.yaml b/etc/whitelist.yaml
index a822fae..1c12b6c 100644
--- a/etc/whitelist.yaml
+++ b/etc/whitelist.yaml
@@ -39,6 +39,8 @@
message: "Instance failed network setup after 1 attempt"
- module: "nova.compute.manager"
message: "Periodic sync_power_state task had an error"
+ - module: "nova.virt.driver"
+ message: "Info cache for instance .* could not be found"
g-api:
- module: "glance.store.sheepdog"
@@ -73,6 +75,10 @@
- module: "ceilometer.compute.pollsters.disk"
message: ".*"
+ceilometer-acentral:
+ - module: "ceilometer.central.manager"
+ message: "403 Forbidden"
+
ceilometer-alarm-evaluator:
- module: "ceilometer.alarm.service"
message: "alarm evaluation cycle failed"
@@ -218,3 +224,6 @@
- module: ".*"
message: ".*"
+s-proxy:
+ - module: "proxy-server"
+ message: "Timeout talking to memcached"
diff --git a/requirements.txt b/requirements.txt
index cd11aa7..3b3e1fa 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,11 +14,12 @@
python-neutronclient>=2.3.0,<3
python-cinderclient>=1.0.6
python-heatclient>=0.2.3
+python-swiftclient>=1.5
testresources>=0.2.4
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
+testscenarios>=0.4
diff --git a/run_tempest.sh b/run_tempest.sh
new file mode 100755
index 0000000..be9b38a
--- /dev/null
+++ b/run_tempest.sh
@@ -0,0 +1,158 @@
+#!/usr/bin/env bash
+
+function usage {
+ echo "Usage: $0 [OPTION]..."
+ echo "Run Tempest test suite"
+ echo ""
+ echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
+ echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
+ echo " -n, --no-site-packages Isolate the virtualenv from the global Python environment"
+ echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
+ echo " -u, --update Update the virtual environment with any newer package versions"
+ echo " -s, --smoke Only run smoke tests"
+ echo " -t, --serial Run testr serially"
+ echo " -C, --config Config file location"
+ echo " -h, --help Print this usage message"
+ echo " -d, --debug Debug this script -- set -o xtrace"
+ echo " -l, --logging Enable logging"
+ echo " -L, --logging-config Logging config file location. Default is etc/logging.conf"
+ echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr "
+}
+
+testrargs=""
+venv=.venv
+with_venv=tools/with_venv.sh
+serial=0
+always_venv=0
+never_venv=0
+no_site_packages=0
+force=0
+wrapper=""
+config_file=""
+update=0
+logging=0
+logging_config=etc/logging.conf
+
+if ! options=$(getopt -o VNnfusthdC:lL: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,serial,help,debug,config:,logging,logging-config: -- "$@")
+then
+ # parse error
+ usage
+ exit 1
+fi
+
+eval set -- $options
+first_uu=yes
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h|--help) usage; exit;;
+ -V|--virtual-env) always_venv=1; never_venv=0;;
+ -N|--no-virtual-env) always_venv=0; never_venv=1;;
+ -n|--no-site-packages) no_site_packages=1;;
+ -f|--force) force=1;;
+ -u|--update) update=1;;
+ -d|--debug) set -o xtrace;;
+ -C|--config) config_file=$2; shift;;
+ -s|--smoke) testrargs+="smoke"; noseargs+="--attr=type=smoke";;
+ -t|--serial) serial=1;;
+ -l|--logging) logging=1;;
+ -L|--logging-config) logging_config=$2; shift;;
+ --) [ "yes" == "$first_uu" ] || testrargs="$testrargs $1"; first_uu=no ;;
+ *) testrargs="$testrargs $1"; noseargs+=" $1" ;;
+ esac
+ shift
+done
+
+if [ -n "$config_file" ]; then
+ config_file=`readlink -f "$config_file"`
+ export TEMPEST_CONFIG_DIR=`dirname "$config_file"`
+ export TEMPEST_CONFIG=`basename "$config_file"`
+fi
+
+if [ $logging -eq 1 ]; then
+ if [ ! -f "$logging_config" ]; then
+ echo "No such logging config file: $logging_config"
+ exit 1
+ fi
+ logging_config=`readlink -f "$logging_config"`
+ export TEMPEST_LOG_CONFIG_DIR=`dirname "$logging_config"`
+ export TEMPEST_LOG_CONFIG=`basename "$logging_config"`
+fi
+
+cd `dirname "$0"`
+
+if [ $no_site_packages -eq 1 ]; then
+ installvenvopts="--no-site-packages"
+fi
+
+function testr_init {
+ if [ ! -d .testrepository ]; then
+ ${wrapper} testr init
+ fi
+}
+
+function run_tests {
+ testr_init
+ ${wrapper} find . -type f -name "*.pyc" -delete
+ export OS_TEST_PATH=./tempest/test_discover
+ if [ $serial -eq 1 ]; then
+ ${wrapper} testr run --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
+ else
+ ${wrapper} testr run --parallel --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
+ fi
+}
+
+function run_tests_nose {
+ export NOSE_WITH_OPENSTACK=1
+ export NOSE_OPENSTACK_COLOR=1
+ export NOSE_OPENSTACK_RED=15.00
+ export NOSE_OPENSTACK_YELLOW=3.00
+ export NOSE_OPENSTACK_SHOW_ELAPSED=1
+ export NOSE_OPENSTACK_STDOUT=1
+ export TEMPEST_PY26_NOSE_COMPAT=1
+ if [[ "x$noseargs" =~ "tempest" ]]; then
+ noseargs="$testrargs"
+ else
+ noseargs="$noseargs tempest"
+ fi
+ ${wrapper} nosetests $noseargs
+}
+
+if [ $never_venv -eq 0 ]
+then
+ # Remove the virtual environment if --force used
+ if [ $force -eq 1 ]; then
+ echo "Cleaning virtualenv..."
+ rm -rf ${venv}
+ fi
+ if [ $update -eq 1 ]; then
+ echo "Updating virtualenv..."
+ python tools/install_venv.py $installvenvopts
+ fi
+ if [ -e ${venv} ]; then
+ wrapper="${with_venv}"
+ else
+ if [ $always_venv -eq 1 ]; then
+ # Automatically install the virtualenv
+ python tools/install_venv.py $installvenvopts
+ wrapper="${with_venv}"
+ else
+ echo -e "No virtual environment found...create one? (Y/n) \c"
+ read use_ve
+ if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
+ # Install the virtualenv and run the test suite in it
+ python tools/install_venv.py $installvenvopts
+ wrapper=${with_venv}
+ fi
+ fi
+ fi
+fi
+
+py_version=`${wrapper} python --version 2>&1`
+if [[ $py_version =~ "2.6" ]] ; then
+ run_tests_nose
+else
+ run_tests
+fi
+retval=$?
+
+exit $retval
diff --git a/run_tests.sh b/run_tests.sh
index 3c9c051..3f00453 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -2,21 +2,18 @@
function usage {
echo "Usage: $0 [OPTION]..."
- echo "Run Tempest test suite"
+ echo "Run Tempest unit tests"
echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
echo " -n, --no-site-packages Isolate the virtualenv from the global Python environment"
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -u, --update Update the virtual environment with any newer package versions"
- echo " -s, --smoke Only run smoke tests"
echo " -t, --serial Run testr serially"
- echo " -C, --config Config file location"
echo " -p, --pep8 Just run pep8"
+ echo " -c, --coverage Generate coverage report"
echo " -h, --help Print this usage message"
echo " -d, --debug Debug this script -- set -o xtrace"
- echo " -l, --logging Enable logging"
- echo " -L, --logging-config Logging config file location. Default is etc/logging.conf"
echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr "
}
@@ -29,13 +26,12 @@
never_venv=0
no_site_packages=0
force=0
+coverage=0
wrapper=""
config_file=""
update=0
-logging=0
-logging_config=etc/logging.conf
-if ! options=$(getopt -o VNnfustphdC:lL: -l virtual-env,no-virtual-env,no-site-packages,force,update,smoke,serial,pep8,help,debug,config:,logging,logging-config: -- "$@")
+if ! options=$(getopt -o VNnfuctphd -l virtual-env,no-virtual-env,no-site-packages,force,update,serial,coverage,pep8,help,debug -- "$@")
then
# parse error
usage
@@ -53,33 +49,15 @@
-f|--force) force=1;;
-u|--update) update=1;;
-d|--debug) set -o xtrace;;
- -C|--config) config_file=$2; shift;;
-p|--pep8) let just_pep8=1;;
- -s|--smoke) testrargs+="smoke"; noseargs+="--attr=type=smoke";;
+ -c|--coverage) coverage=1;;
-t|--serial) serial=1;;
- -l|--logging) logging=1;;
- -L|--logging-config) logging_config=$2; shift;;
--) [ "yes" == "$first_uu" ] || testrargs="$testrargs $1"; first_uu=no ;;
*) testrargs="$testrargs $1"; noseargs+=" $1" ;;
esac
shift
done
-if [ -n "$config_file" ]; then
- config_file=`readlink -f "$config_file"`
- export TEMPEST_CONFIG_DIR=`dirname "$config_file"`
- export TEMPEST_CONFIG=`basename "$config_file"`
-fi
-
-if [ $logging -eq 1 ]; then
- if [ ! -f "$logging_config" ]; then
- echo "No such logging config file: $logging_config"
- exit 1
- fi
- logging_config=`readlink -f "$logging_config"`
- export TEMPEST_LOG_CONFIG_DIR=`dirname "$logging_config"`
- export TEMPEST_LOG_CONFIG=`basename "$logging_config"`
-fi
cd `dirname "$0"`
@@ -96,6 +74,7 @@
function run_tests {
testr_init
${wrapper} find . -type f -name "*.pyc" -delete
+ export OS_TEST_PATH=./tempest/tests
if [ $serial -eq 1 ]; then
${wrapper} testr run --subunit $testrargs | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py
else
@@ -103,22 +82,6 @@
fi
}
-function run_tests_nose {
- export NOSE_WITH_OPENSTACK=1
- export NOSE_OPENSTACK_COLOR=1
- export NOSE_OPENSTACK_RED=15.00
- export NOSE_OPENSTACK_YELLOW=3.00
- export NOSE_OPENSTACK_SHOW_ELAPSED=1
- export NOSE_OPENSTACK_STDOUT=1
- export TEMPEST_PY26_NOSE_COMPAT=1
- if [[ "x$noseargs" =~ "tempest" ]]; then
- noseargs="$testrargs"
- else
- noseargs="$noseargs tempest"
- fi
- ${wrapper} nosetests $noseargs
-}
-
function run_pep8 {
echo "Running flake8 ..."
if [ $never_venv -eq 1 ]; then
@@ -163,12 +126,11 @@
exit
fi
-py_version=`${wrapper} python --version 2>&1`
-if [[ $py_version =~ "2.6" ]] ; then
- run_tests_nose
-else
- run_tests
+if [ $coverage -eq 1 ]; then
+ $testrargs = "--coverage $testrargs"
fi
+
+run_tests
retval=$?
if [ -z "$testrargs" ]; then
diff --git a/tempest/api/__init__.py b/tempest/api/__init__.py
index 0b3d2db..e69de29 100644
--- a/tempest/api/__init__.py
+++ b/tempest/api/__init__.py
@@ -1,16 +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.
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/api/baremetal/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/api/baremetal/__init__.py
diff --git a/tempest/api/baremetal/base.py b/tempest/api/baremetal/base.py
new file mode 100644
index 0000000..ec87321
--- /dev/null
+++ b/tempest/api/baremetal/base.py
@@ -0,0 +1,169 @@
+# 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 functools
+
+from tempest import clients
+from tempest.common.utils import data_utils
+from tempest import exceptions as exc
+from tempest import test
+
+
+def creates(resource):
+ """Decorator that adds resources to the appropriate cleanup list."""
+
+ def decorator(f):
+ @functools.wraps(f)
+ def wrapper(cls, *args, **kwargs):
+ result = f(cls, *args, **kwargs)
+ body = result[resource]
+
+ if 'uuid' in body:
+ cls.created_objects[resource].add(body['uuid'])
+
+ return result
+ return wrapper
+ return decorator
+
+
+class BaseBaremetalTest(test.BaseTestCase):
+ """Base class for Baremetal API tests."""
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseBaremetalTest, cls).setUpClass()
+
+ if not cls.config.service_available.ironic:
+ skip_msg = ('%s skipped as Ironic is not available' % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ mgr = clients.AdminManager()
+ cls.client = mgr.baremetal_client
+
+ cls.created_objects = {'chassis': set(),
+ 'port': set(),
+ 'node': set()}
+
+ @classmethod
+ def tearDownClass(cls):
+ """Ensure that all created objects get destroyed."""
+
+ try:
+ for resource, uuids in cls.created_objects.iteritems():
+ delete_method = getattr(cls.client, 'delete_%s' % resource)
+ for u in uuids:
+ delete_method(u, ignore_errors=exc.NotFound)
+ finally:
+ super(BaseBaremetalTest, cls).tearDownClass()
+
+ @classmethod
+ @creates('chassis')
+ def create_chassis(cls, description=None, expect_errors=False):
+ """
+ Wrapper utility for creating test chassis.
+
+ :param description: A description of the chassis. if not supplied,
+ a random value will be generated.
+ :return: Created chassis.
+
+ """
+ description = description or data_utils.rand_name('test-chassis-')
+ resp, body = cls.client.create_chassis(description=description)
+
+ return {'chassis': body, 'response': resp}
+
+ @classmethod
+ @creates('node')
+ def create_node(cls, chassis_id, cpu_arch='x86', cpu_num=8, storage=1024,
+ memory=4096, driver='fake'):
+ """
+ Wrapper utility for creating test baremetal nodes.
+
+ :param cpu_arch: CPU architecture of the node. Default: x86.
+ :param cpu_num: Number of CPUs. Default: 8.
+ :param storage: Disk size. Default: 1024.
+ :param memory: Available RAM. Default: 4096.
+ :return: Created node.
+
+ """
+ resp, body = cls.client.create_node(chassis_id, cpu_arch=cpu_arch,
+ cpu_num=cpu_num, storage=storage,
+ memory=memory, driver=driver)
+
+ return {'node': body, 'response': resp}
+
+ @classmethod
+ @creates('port')
+ def create_port(cls, node_id, address=None):
+ """
+ Wrapper utility for creating test ports.
+
+ :param address: MAC address of the port. If not supplied, a random
+ value will be generated.
+ :return: Created port.
+
+ """
+ address = address or data_utils.rand_mac_address()
+ resp, body = cls.client.create_port(address=address, node_id=node_id)
+
+ return {'port': body, 'response': resp}
+
+ @classmethod
+ def delete_chassis(cls, chassis_id):
+ """
+ Deletes a chassis having the specified UUID.
+
+ :param uuid: The unique identifier of the chassis.
+ :return: Server response.
+
+ """
+
+ resp, body = cls.client.delete_chassis(chassis_id)
+
+ if chassis_id in cls.created_objects['chassis']:
+ cls.created_objects['chassis'].remove(chassis_id)
+
+ return resp
+
+ @classmethod
+ def delete_node(cls, node_id):
+ """
+ Deletes a node having the specified UUID.
+
+ :param uuid: The unique identifier of the node.
+ :return: Server response.
+
+ """
+
+ resp, body = cls.client.delete_node(node_id)
+
+ if node_id in cls.created_objects['node']:
+ cls.created_objects['node'].remove(node_id)
+
+ return resp
+
+ @classmethod
+ def delete_port(cls, port_id):
+ """
+ Deletes a port having the specified UUID.
+
+ :param uuid: The unique identifier of the port.
+ :return: Server response.
+
+ """
+
+ resp, body = cls.client.delete_port(port_id)
+
+ if port_id in cls.created_objects['port']:
+ cls.created_objects['port'].remove(port_id)
+
+ return resp
diff --git a/tempest/api/baremetal/test_api_discovery.py b/tempest/api/baremetal/test_api_discovery.py
new file mode 100644
index 0000000..e594b3e
--- /dev/null
+++ b/tempest/api/baremetal/test_api_discovery.py
@@ -0,0 +1,44 @@
+# 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.baremetal import base
+from tempest import test
+
+
+class TestApiDiscovery(base.BaseBaremetalTest):
+ """Tests for API discovery features."""
+
+ @test.attr(type='smoke')
+ def test_api_versions(self):
+ resp, descr = self.client.get_api_description()
+ expected_versions = ('v1',)
+
+ versions = [version['id'] for version in descr['versions']]
+
+ for v in expected_versions:
+ self.assertIn(v, versions)
+
+ @test.attr(type='smoke')
+ def test_default_version(self):
+ resp, descr = self.client.get_api_description()
+ default_version = descr['default_version']
+
+ self.assertEqual(default_version['id'], 'v1')
+
+ @test.attr(type='smoke')
+ def test_version_1_resources(self):
+ resp, descr = self.client.get_version_description(version='v1')
+ expected_resources = ('nodes', 'chassis',
+ 'ports', 'links', 'media_types')
+
+ for res in expected_resources:
+ self.assertIn(res, descr)
diff --git a/tempest/api/baremetal/test_chassis.py b/tempest/api/baremetal/test_chassis.py
new file mode 100644
index 0000000..7af1336
--- /dev/null
+++ b/tempest/api/baremetal/test_chassis.py
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+# 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.baremetal import base
+from tempest.common.utils import data_utils
+from tempest import exceptions as exc
+from tempest import test
+
+
+class TestChassis(base.BaseBaremetalTest):
+ """Tests for chassis."""
+
+ @test.attr(type='smoke')
+ def test_create_chassis(self):
+ descr = data_utils.rand_name('test-chassis-')
+ ch = self.create_chassis(description=descr)['chassis']
+
+ self.assertEqual(ch['description'], descr)
+
+ @test.attr(type='smoke')
+ def test_create_chassis_unicode_description(self):
+ # Use a unicode string for testing:
+ # 'We ♡ OpenStack in Ukraine'
+ descr = u'В Україні ♡ OpenStack!'
+ ch = self.create_chassis(description=descr)['chassis']
+
+ self.assertEqual(ch['description'], descr)
+
+ @test.attr(type='smoke')
+ def test_show_chassis(self):
+ descr = data_utils.rand_name('test-chassis-')
+ uuid = self.create_chassis(description=descr)['chassis']['uuid']
+
+ resp, chassis = self.client.show_chassis(uuid)
+
+ self.assertEqual(chassis['uuid'], uuid)
+ self.assertEqual(chassis['description'], descr)
+
+ @test.attr(type="smoke")
+ def test_list_chassis(self):
+ created_ids = [self.create_chassis()['chassis']['uuid']
+ for i in range(0, 5)]
+
+ resp, body = self.client.list_chassis()
+ loaded_ids = [ch['uuid'] for ch in body['chassis']]
+
+ for i in created_ids:
+ self.assertIn(i, loaded_ids)
+
+ @test.attr(type='smoke')
+ def test_delete_chassis(self):
+ uuid = self.create_chassis()['chassis']['uuid']
+
+ self.delete_chassis(uuid)
+
+ self.assertRaises(exc.NotFound, self.client.show_chassis, uuid)
+
+ @test.attr(type='smoke')
+ def test_update_chassis(self):
+ chassis_id = self.create_chassis()['chassis']['uuid']
+
+ new_description = data_utils.rand_name('new-description-')
+ self.client.update_chassis(chassis_id, description=new_description)
+
+ resp, chassis = self.client.show_chassis(chassis_id)
+ self.assertEqual(chassis['description'], new_description)
diff --git a/tempest/api/baremetal/test_nodes.py b/tempest/api/baremetal/test_nodes.py
new file mode 100644
index 0000000..0f585cb
--- /dev/null
+++ b/tempest/api/baremetal/test_nodes.py
@@ -0,0 +1,95 @@
+# 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 six
+
+from tempest.api.baremetal import base
+from tempest import exceptions as exc
+from tempest import test
+
+
+class TestNodes(base.BaseBaremetalTest):
+ '''Tests for baremetal nodes.'''
+
+ def setUp(self):
+ super(TestNodes, self).setUp()
+
+ self.chassis = self.create_chassis()['chassis']
+
+ @test.attr(type='smoke')
+ def test_create_node(self):
+ params = {'cpu_arch': 'x86_64',
+ 'cpu_num': '12',
+ 'storage': '10240',
+ 'memory': '1024'}
+
+ node = self.create_node(self.chassis['uuid'], **params)['node']
+
+ for key in params:
+ self.assertEqual(node['properties'][key], params[key])
+
+ @test.attr(type='smoke')
+ def test_delete_node(self):
+ node = self.create_node(self.chassis['uuid'])['node']
+ node_id = node['uuid']
+
+ resp = self.delete_node(node_id)
+
+ self.assertEqual(resp['status'], '204')
+ self.assertRaises(exc.NotFound, self.client.show_node, node_id)
+
+ @test.attr(type='smoke')
+ def test_show_node(self):
+ params = {'cpu_arch': 'x86_64',
+ 'cpu_num': '4',
+ 'storage': '100',
+ 'memory': '512'}
+
+ created_node = self.create_node(self.chassis['uuid'], **params)['node']
+ resp, loaded_node = self.client.show_node(created_node['uuid'])
+
+ for key, val in created_node.iteritems():
+ if key not in ('created_at', 'updated_at'):
+ self.assertEqual(loaded_node[key], val)
+
+ @test.attr(type='smoke')
+ def test_list_nodes(self):
+ uuids = [self.create_node(self.chassis['uuid'])['node']['uuid']
+ for i in range(0, 5)]
+
+ resp, body = self.client.list_nodes()
+ loaded_uuids = [n['uuid'] for n in body['nodes']]
+
+ for u in uuids:
+ self.assertIn(u, loaded_uuids)
+
+ @test.attr(type='smoke')
+ def test_update_node(self):
+ props = {'cpu_arch': 'x86_64',
+ 'cpu_num': '12',
+ 'storage': '10',
+ 'memory': '128'}
+
+ node = self.create_node(self.chassis['uuid'], **props)['node']
+ node_id = node['uuid']
+
+ new_props = {'cpu_arch': 'x86',
+ 'cpu_num': '1',
+ 'storage': '10000',
+ 'memory': '12300'}
+
+ self.client.update_node(node_id, properties=new_props)
+ resp, node = self.client.show_node(node_id)
+
+ for name, value in six.iteritems(new_props):
+ if name not in ('created_at', 'updated_at'):
+ self.assertEqual(node['properties'][name], value)
diff --git a/tempest/api/baremetal/test_ports.py b/tempest/api/baremetal/test_ports.py
new file mode 100644
index 0000000..fb2acc7
--- /dev/null
+++ b/tempest/api/baremetal/test_ports.py
@@ -0,0 +1,83 @@
+# 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.baremetal import base
+from tempest.common.utils import data_utils
+from tempest import exceptions as exc
+from tempest import test
+
+
+class TestPorts(base.BaseBaremetalTest):
+ """Tests for ports."""
+
+ def setUp(self):
+ super(TestPorts, self).setUp()
+
+ chassis = self.create_chassis()['chassis']
+ self.node = self.create_node(chassis['uuid'])['node']
+
+ @test.attr(type='smoke')
+ def test_create_port(self):
+ node_id = self.node['uuid']
+ address = data_utils.rand_mac_address()
+
+ port = self.create_port(node_id=node_id, address=address)['port']
+
+ self.assertEqual(port['address'], address)
+ self.assertEqual(port['node_uuid'], node_id)
+
+ @test.attr(type='smoke')
+ def test_delete_port(self):
+ node_id = self.node['uuid']
+ port_id = self.create_port(node_id=node_id)['port']['uuid']
+
+ resp = self.delete_port(port_id)
+
+ self.assertEqual(resp['status'], '204')
+ self.assertRaises(exc.NotFound, self.client.show_port, port_id)
+
+ @test.attr(type='smoke')
+ def test_show_port(self):
+ node_id = self.node['uuid']
+ address = data_utils.rand_mac_address()
+
+ port_id = self.create_port(node_id=node_id,
+ address=address)['port']['uuid']
+
+ resp, port = self.client.show_port(port_id)
+
+ self.assertEqual(port['uuid'], port_id)
+ self.assertEqual(port['address'], address)
+
+ @test.attr(type='smoke')
+ def test_list_ports(self):
+ node_id = self.node['uuid']
+
+ uuids = [self.create_port(node_id=node_id)['port']['uuid']
+ for i in range(0, 5)]
+
+ resp, body = self.client.list_ports()
+ loaded_uuids = [p['uuid'] for p in body['ports']]
+
+ for u in uuids:
+ self.assertIn(u, loaded_uuids)
+
+ @test.attr(type='smoke')
+ def test_update_port(self):
+ node_id = self.node['uuid']
+ port_id = self.create_port(node_id=node_id)['port']['uuid']
+
+ new_address = data_utils.rand_mac_address()
+ self.client.update_port(port_id, address=new_address)
+
+ resp, body = self.client.show_port(port_id)
+ self.assertEqual(body['address'], new_address)
diff --git a/tempest/api/baremetal/test_ports_negative.py b/tempest/api/baremetal/test_ports_negative.py
new file mode 100644
index 0000000..6cb8812
--- /dev/null
+++ b/tempest/api/baremetal/test_ports_negative.py
@@ -0,0 +1,40 @@
+# 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.baremetal import base
+from tempest.common.utils import data_utils
+from tempest import exceptions as exc
+from tempest import test
+
+
+class TestPortsNegative(base.BaseBaremetalTest):
+ """Negative tests for ports."""
+
+ def setUp(self):
+ super(TestPortsNegative, self).setUp()
+
+ chassis = self.create_chassis()['chassis']
+ self.node = self.create_node(chassis['uuid'])['node']
+
+ @test.attr(type='negative')
+ def test_create_port_invalid_mac(self):
+ node_id = self.node['uuid']
+ address = 'not an uuid'
+
+ self.assertRaises(exc.BadRequest,
+ self.create_port, node_id=node_id, address=address)
+
+ @test.attr(type='negative')
+ def test_create_port_wrong_node_id(self):
+ node_id = str(data_utils.rand_uuid())
+
+ self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id)
diff --git a/tempest/api/compute/__init__.py b/tempest/api/compute/__init__.py
index d20068e..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.TempestConfig()
-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_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 467a6f9..362cf2d 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
@@ -18,7 +16,6 @@
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.test import attr
@@ -35,7 +32,6 @@
def setUpClass(cls):
super(AggregatesAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.aggregates_client
- cls.user_client = cls.aggregates_client
cls.aggregate_name_prefix = 'test_aggregate_'
cls.az_name_prefix = 'test_az_'
@@ -141,54 +137,6 @@
(x['id'], x['name'], x['availability_zone']),
aggregates))
- @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)
-
- @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.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.delete_aggregate,
- aggregate['id'])
-
- @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)
-
- @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.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.get_aggregate,
- aggregate['id'])
-
- @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)
-
- @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)
-
@attr(type='gate')
def test_aggregate_add_remove_host(self):
# Add an host to the given aggregate and remove.
@@ -262,48 +210,6 @@
resp, body = admin_servers_client.get_server(server['id'])
self.assertEqual(self.host, body[self._host_key])
- @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.os_adm.hosts_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)
-
- @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.addCleanup(self.client.delete_aggregate, aggregate['id'])
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.add_host,
- aggregate['id'], self.host)
-
- @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.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)
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.remove_host,
- aggregate['id'], self.host)
-
class AggregatesAdminTestXML(AggregatesAdminTestJSON):
_host_key = (
diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py
new file mode 100644
index 0000000..5107d8e
--- /dev/null
+++ b/tempest/api/compute/admin/test_aggregates_negative.py
@@ -0,0 +1,194 @@
+# 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.test import attr
+
+
+class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ """
+ Tests Aggregates API that require admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AggregatesAdminNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.os_adm.aggregates_client
+ cls.user_client = cls.aggregates_client
+ cls.aggregate_name_prefix = 'test_aggregate_'
+ cls.az_name_prefix = 'test_az_'
+
+ resp, hosts_all = cls.os_adm.hosts_client.list_hosts()
+ hosts = map(lambda x: x['host_name'],
+ filter(lambda y: y['service'] == 'compute', hosts_all))
+ cls.host = hosts[0]
+
+ @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)
+
+ @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,
+ '')
+
+ @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)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Conflict,
+ self.client.create_aggregate,
+ aggregate_name)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.delete_aggregate,
+ aggregate['id'])
+
+ @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)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.get_aggregate,
+ aggregate['id'])
+
+ @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)
+
+ @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)
+
+ @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.os_adm.hosts_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)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.add_host,
+ aggregate['id'], self.host)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ resp, body = self.client.add_host(aggregate['id'], self.host)
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
+
+ self.assertRaises(exceptions.Conflict, self.client.add_host,
+ aggregate['id'], self.host)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+ resp, body = self.client.add_host(aggregate['id'], self.host)
+ self.assertEqual(200, 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)
+
+ @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(200, resp.status)
+ self.addCleanup(self.client.delete_aggregate, aggregate['id'])
+
+ self.assertRaises(exceptions.NotFound, self.client.remove_host,
+ aggregate['id'], non_exist_host)
+
+
+class AggregatesAdminNegativeTestXML(AggregatesAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_availability_zone.py b/tempest/api/compute/admin/test_availability_zone.py
index d6488c4..18e4452 100644
--- a/tempest/api/compute/admin/test_availability_zone.py
+++ b/tempest/api/compute/admin/test_availability_zone.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -16,21 +14,20 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
-class AvailabilityZoneAdminTestJSON(base.BaseV2ComputeAdminTest):
+class AZAdminTestJSON(base.BaseV2ComputeAdminTest):
"""
- Tests Availability Zone API List that require admin privileges
+ Tests Availability Zone API List
"""
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(AvailabilityZoneAdminTestJSON, cls).setUpClass()
+ super(AZAdminTestJSON, cls).setUpClass()
cls.client = cls.os_adm.availability_zone_client
cls.non_adm_client = cls.availability_zone_client
@@ -57,14 +54,6 @@
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
- @attr(type=['negative', 'gate'])
- def test_get_availability_zone_list_detail_with_non_admin_user(self):
- # List of availability zones and available services with
- # non-administrator user
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_availability_zone_list_detail)
-
-class AvailabilityZoneAdminTestXML(AvailabilityZoneAdminTestJSON):
+class AZAdminTestXML(AZAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py
new file mode 100644
index 0000000..d13618c
--- /dev/null
+++ b/tempest/api/compute/admin/test_availability_zone_negative.py
@@ -0,0 +1,43 @@
+# 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 import exceptions
+from tempest.test import attr
+
+
+class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ """
+ Tests Availability Zone API List
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AZAdminNegativeTestJSON, cls).setUpClass()
+ cls.non_adm_client = cls.availability_zone_client
+
+ @attr(type=['negative', 'gate'])
+ def test_get_availability_zone_list_detail_with_non_admin_user(self):
+ # List of availability zones and available services with
+ # non-administrator user
+ self.assertRaises(
+ exceptions.Unauthorized,
+ self.non_adm_client.get_availability_zone_list_detail)
+
+
+class AZAdminNegativeTestXML(AZAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_fixed_ips.py b/tempest/api/compute/admin/test_fixed_ips.py
index 427f728..0c36837 100644
--- a/tempest/api/compute/admin/test_fixed_ips.py
+++ b/tempest/api/compute/admin/test_fixed_ips.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
@@ -16,7 +14,6 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
@@ -30,7 +27,6 @@
msg = ("%s skipped as neutron is available" % cls.__name__)
raise cls.skipException(msg)
cls.client = cls.os_adm.fixed_ips_client
- cls.non_admin_client = cls.fixed_ips_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
resp, server = cls.servers_client.get_server(server['id'])
for ip_set in server['addresses']:
@@ -46,11 +42,6 @@
resp, fixed_ip = self.client.get_fixed_ip_details(self.ip)
self.assertEqual(fixed_ip['address'], self.ip)
- @attr(type=['negative', 'gate'])
- def test_list_fixed_ip_details_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.get_fixed_ip_details, self.ip)
-
@attr(type='gate')
def test_set_reserve(self):
body = {"reserve": "None"}
@@ -63,36 +54,6 @@
resp, body = self.client.reserve_fixed_ip(self.ip, body)
self.assertEqual(resp.status, 202)
- @attr(type=['negative', 'gate'])
- def test_set_reserve_with_non_admin_user(self):
- body = {"reserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
-
- @attr(type=['negative', 'gate'])
- def test_set_unreserve_with_non_admin_user(self):
- body = {"unreserve": "None"}
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.reserve_fixed_ip,
- self.ip, body)
-
- @attr(type=['negative', 'gate'])
- def test_set_reserve_with_invalid_ip(self):
- # NOTE(maurosr): since this exercises the same code snippet, we do it
- # only for reserve action
- body = {"reserve": "None"}
- self.assertRaises(exceptions.NotFound,
- self.client.reserve_fixed_ip,
- "my.invalid.ip", body)
-
- @attr(type=['negative', 'gate'])
- def test_fixed_ip_with_invalid_action(self):
- body = {"invalid_action": "None"}
- self.assertRaises(exceptions.BadRequest,
- self.client.reserve_fixed_ip,
- self.ip, body)
-
class FixedIPsTestXml(FixedIPsTestJson):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py
new file mode 100644
index 0000000..bf7fd51
--- /dev/null
+++ b/tempest/api/compute/admin/test_fixed_ips_negative.py
@@ -0,0 +1,78 @@
+# 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 import exceptions
+from tempest.test import attr
+
+
+class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FixedIPsNegativeTestJson, cls).setUpClass()
+ if cls.config.service_available.neutron:
+ msg = ("%s skipped as neutron is available" % cls.__name__)
+ raise cls.skipException(msg)
+ cls.client = cls.os_adm.fixed_ips_client
+ cls.non_admin_client = cls.fixed_ips_client
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ resp, server = cls.servers_client.get_server(server['id'])
+ for ip_set in server['addresses']:
+ for ip in server['addresses'][ip_set]:
+ if ip['OS-EXT-IPS:type'] == 'fixed':
+ cls.ip = ip['addr']
+ break
+ if cls.ip:
+ break
+
+ @attr(type=['negative', 'gate'])
+ def test_list_fixed_ip_details_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.get_fixed_ip_details, self.ip)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_reserve_with_non_admin_user(self):
+ body = {"reserve": "None"}
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.reserve_fixed_ip,
+ self.ip, body)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_unreserve_with_non_admin_user(self):
+ body = {"unreserve": "None"}
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.reserve_fixed_ip,
+ self.ip, body)
+
+ @attr(type=['negative', 'gate'])
+ def test_set_reserve_with_invalid_ip(self):
+ # NOTE(maurosr): since this exercises the same code snippet, we do it
+ # only for reserve action
+ body = {"reserve": "None"}
+ self.assertRaises(exceptions.NotFound,
+ self.client.reserve_fixed_ip,
+ "my.invalid.ip", body)
+
+ @attr(type=['negative', 'gate'])
+ def test_fixed_ip_with_invalid_action(self):
+ body = {"invalid_action": "None"}
+ self.assertRaises(exceptions.BadRequest,
+ self.client.reserve_fixed_ip,
+ self.ip, body)
+
+
+class FixedIPsNegativeTestXml(FixedIPsNegativeTestJson):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index cf72e49..252f4be 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -130,40 +128,6 @@
flag = True
self.assertTrue(flag)
- @test.attr(type=['negative', 'gate'])
- def test_get_flavor_details_for_deleted_flavor(self):
- # Delete a flavor and ensure it is not listed
- # Create a test flavor
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- resp, flavor = self.client.create_flavor(flavor_name,
- self.ram,
- self.vcpus, self.disk,
- new_flavor_id,
- ephemeral=self.ephemeral,
- swap=self.swap,
- rxtx=self.rxtx)
- # Delete the flavor
- new_flavor_id = flavor['id']
- resp_delete, body = self.client.delete_flavor(new_flavor_id)
- self.assertEqual(200, resp.status)
- self.assertEqual(202, resp_delete.status)
-
- # Deleted flavors can be seen via detailed GET
- resp, flavor = self.client.get_flavor_details(new_flavor_id)
- self.assertEqual(resp.status, 200)
- self.assertEqual(flavor['name'], flavor_name)
-
- # Deleted flavors should not show up in a list however
- resp, flavors = self.client.list_flavors_with_detail()
- self.assertEqual(resp.status, 200)
- flag = True
- for flavor in flavors:
- if flavor['name'] == flavor_name:
- flag = False
- self.assertTrue(flag)
-
@test.attr(type='gate')
def test_create_list_flavor_without_extra_data(self):
# Create a flavor and ensure it is listed
@@ -347,49 +311,6 @@
self.assertEqual(flavor['ram'], int(ram))
self.assertEqual(int(flavor['id']), new_flavor_id)
- @test.attr(type=['negative', 'gate'])
- def test_invalid_is_public_string(self):
- self.assertRaises(exceptions.BadRequest,
- self.client.list_flavors_with_detail,
- {'is_public': 'invalid'})
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_as_user(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.create_flavor,
- flavor_name, self.ram, self.vcpus, self.disk,
- new_flavor_id, ephemeral=self.ephemeral,
- swap=self.swap, rxtx=self.rxtx)
-
- @test.attr(type=['negative', 'gate'])
- def test_delete_flavor_as_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.user_client.delete_flavor,
- self.flavor_ref_alt)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_ram(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, -1, self.vcpus,
- self.disk, new_flavor_id)
-
- @test.attr(type=['negative', 'gate'])
- def test_create_flavor_using_invalid_vcpus(self):
- flavor_name = data_utils.rand_name(self.flavor_name_prefix)
- new_flavor_id = data_utils.rand_int_id(start=1000)
-
- self.assertRaises(exceptions.BadRequest,
- self.client.create_flavor,
- flavor_name, self.ram, 0,
- self.disk, new_flavor_id)
-
class FlavorsAdminTestXML(FlavorsAdminTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 048312b..da11ab5 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py
index 976124e..c4d54b6 100644
--- a/tempest/api/compute/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/admin/test_flavors_access_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs.py b/tempest/api/compute/admin/test_flavors_extra_specs.py
index 875f742..1afa693 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
index fb09a63..cdf97cc 100644
--- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
+++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
# Copyright 2013 IBM Corp.
diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py
new file mode 100644
index 0000000..ad4ceeb
--- /dev/null
+++ b/tempest/api/compute/admin/test_flavors_negative.py
@@ -0,0 +1,342 @@
+# 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 uuid
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class FlavorsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
+
+ """
+ Tests Flavors API Create and Delete that require admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FlavorsAdminNegativeTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('FlavorExtraData', 'compute'):
+ msg = "FlavorExtraData extension not enabled."
+ raise cls.skipException(msg)
+
+ cls.client = cls.os_adm.flavors_client
+ cls.user_client = cls.os.flavors_client
+ cls.flavor_name_prefix = 'test_flavor_'
+ cls.ram = 512
+ cls.vcpus = 1
+ cls.disk = 10
+ cls.ephemeral = 10
+ cls.swap = 1024
+ cls.rxtx = 2
+
+ def flavor_clean_up(self, flavor_id):
+ resp, body = self.client.delete_flavor(flavor_id)
+ self.assertEqual(resp.status, 202)
+ self.client.wait_for_resource_deletion(flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_flavor_details_for_deleted_flavor(self):
+ # Delete a flavor and ensure it is not listed
+ # Create a test flavor
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+
+ # no need to specify flavor_id, we can get the flavor_id from a
+ # response of create_flavor() call.
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram,
+ self.vcpus, self.disk,
+ '',
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+ # Delete the flavor
+ new_flavor_id = flavor['id']
+ resp_delete, body = self.client.delete_flavor(new_flavor_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(202, resp_delete.status)
+
+ # Deleted flavors can be seen via detailed GET
+ resp, flavor = self.client.get_flavor_details(new_flavor_id)
+ self.assertEqual(resp.status, 200)
+ self.assertEqual(flavor['name'], flavor_name)
+
+ # Deleted flavors should not show up in a list however
+ resp, flavors = self.client.list_flavors_with_detail()
+ self.assertEqual(resp.status, 200)
+ flag = True
+ for flavor in flavors:
+ if flavor['name'] == flavor_name:
+ flag = False
+ self.assertTrue(flag)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_invalid_is_public_string(self):
+ # the 'is_public' parameter can be 'none/true/false' if it exists
+ self.assertRaises(exceptions.BadRequest,
+ self.client.list_flavors_with_detail,
+ {'is_public': 'invalid'})
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_as_user(self):
+ # only admin user can create a flavor
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.create_flavor,
+ flavor_name, self.ram, self.vcpus, self.disk,
+ new_flavor_id, ephemeral=self.ephemeral,
+ swap=self.swap, rxtx=self.rxtx)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_flavor_as_user(self):
+ # only admin user can delete a flavor
+ self.assertRaises(exceptions.Unauthorized,
+ self.user_client.delete_flavor,
+ self.flavor_ref_alt)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_using_invalid_ram(self):
+ # the 'ram' attribute must be positive integer
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ flavor_name, -1, self.vcpus,
+ self.disk, new_flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_using_invalid_vcpus(self):
+ # the 'vcpu' attribute must be positive integer
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ flavor_name, self.ram, -1,
+ self.disk, new_flavor_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_name_length_less_than_1(self):
+ # ensure name length >= 1
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ '',
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_name_length_exceeds_255(self):
+ # ensure name do not exceed 255 characters
+ new_flavor_name = 'a' * 256
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_name(self):
+ # the regex of flavor_name is '^[\w\.\- ]*$'
+ invalid_flavor_name = data_utils.rand_name('invalid-!@#$%-')
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ invalid_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_flavor_id(self):
+ # the regex of flavor_id is '^[\w\.\- ]*$', and it cannot contain
+ # leading and/or trailing whitespace
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ invalid_flavor_id = '!@#$%'
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ invalid_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_id_length_exceeds_255(self):
+ # the length of flavor_id should not exceed 255 characters
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ invalid_flavor_id = 'a' * 256
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ invalid_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_root_gb(self):
+ # root_gb attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ -1,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_ephemeral_gb(self):
+ # ephemeral_gb attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=-1,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_swap(self):
+ # swap attribute should be non-negative ( >= 0) integer
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=-1,
+ rxtx=self.rxtx,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_rxtx_factor(self):
+ # rxtx_factor attribute should be a positive float
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=-1.5,
+ is_public='False')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_with_invalid_is_public(self):
+ # is_public attribute should be boolean
+ new_flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_flavor,
+ new_flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx,
+ is_public='Invalid')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_flavor_already_exists(self):
+ flavor_name = data_utils.rand_name(self.flavor_name_prefix)
+ new_flavor_id = str(uuid.uuid4())
+
+ resp, flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+
+ self.assertRaises(exceptions.Conflict,
+ self.client.create_flavor,
+ flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ ephemeral=self.ephemeral,
+ swap=self.swap,
+ rxtx=self.rxtx)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_delete_nonexistent_flavor(self):
+ nonexistent_flavor_id = str(uuid.uuid4())
+
+ self.assertRaises(exceptions.NotFound,
+ self.client.delete_flavor,
+ nonexistent_flavor_id)
+
+
+class FlavorsAdminNegativeTestXML(FlavorsAdminNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 22e6cf1..a3b4b47 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 6b24e72..cb034c9 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -1,5 +1,3 @@
-# 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
@@ -17,7 +15,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 +39,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,15 +58,18 @@
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()
self.assertRaises(exceptions.Unauthorized,
self.non_admin_client.update_host,
- hostname)
+ hostname,
+ status='enable',
+ maintenance_mode='enable')
- @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..989c0d8 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
@@ -38,24 +36,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 +69,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 +88,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_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index c6455b5..e41bd18 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log.py b/tempest/api/compute/admin/test_instance_usage_audit_log.py
index cea6e92..c617178 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
index dcf41c5..10bb1aa 100644
--- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
+++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index f49aae4..dfcc6a9 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -22,6 +20,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class QuotasAdminTestJSON(base.BaseV2ComputeAdminTest):
_interface = 'json'
@@ -156,7 +156,7 @@
self.assertRaises(exceptions.OverLimit, self.create_test_server)
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
@@ -180,7 +180,7 @@
"sg-overlimit", "sg-desc")
@skip_because(bug="1186354",
- condition=config.TempestConfig().service_available.neutron)
+ 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
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
new file mode 100644
index 0000000..0cfa344
--- /dev/null
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -0,0 +1,96 @@
+# Copyright 2013 NTT Data
+# 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.test import attr
+
+CONF = config.CONF
+
+
+class SecurityGroupsTestAdminJSON(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(SecurityGroupsTestAdminJSON, cls).setUpClass()
+ cls.adm_client = cls.os_adm.security_groups_client
+ cls.client = cls.security_groups_client
+
+ def _delete_security_group(self, securitygroup_id, admin=True):
+ if admin:
+ resp, _ = self.adm_client.delete_security_group(securitygroup_id)
+ else:
+ resp, _ = self.client.delete_security_group(securitygroup_id)
+
+ self.assertEqual(202, resp.status)
+
+ @testtools.skipIf(CONF.service_available.neutron,
+ "Skipped because neutron do not support all_tenants"
+ "search filter.")
+ @attr(type='smoke')
+ def test_list_security_groups_list_all_tenants_filter(self):
+ # Admin can list security groups of all tenants
+ # List of all security groups created
+ security_group_list = []
+ # Create two security groups for a non-admin tenant
+ for i in range(2):
+ name = data_utils.rand_name('securitygroup-')
+ description = data_utils.rand_name('description-')
+ resp, securitygroup = (self.client
+ .create_security_group(name, description))
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self._delete_security_group,
+ securitygroup['id'], admin=False)
+ security_group_list.append(securitygroup)
+
+ client_tenant_id = securitygroup['tenant_id']
+ # Create two security groups for admin tenant
+ for i in range(2):
+ name = data_utils.rand_name('securitygroup-')
+ description = data_utils.rand_name('description-')
+ resp, adm_securitygroup = (self.adm_client
+ .create_security_group(name,
+ description))
+ self.assertEqual(200, resp.status)
+ self.addCleanup(self._delete_security_group,
+ adm_securitygroup['id'])
+ security_group_list.append(adm_securitygroup)
+
+ # Fetch all security groups based on 'all_tenants' search filter
+ param = {'all_tenants': 'true'}
+ resp, fetched_list = self.adm_client.list_security_groups(params=param)
+ self.assertEqual(200, resp.status)
+ sec_group_id_list = map(lambda sg: sg['id'], fetched_list)
+ # Now check if all created Security Groups are present in fetched list
+ for sec_group in security_group_list:
+ self.assertIn(sec_group['id'], sec_group_id_list)
+
+ # Fetch all security groups for non-admin user with 'all_tenants'
+ # search filter
+ resp, fetched_list = self.client.list_security_groups(params=param)
+ self.assertEqual(200, resp.status)
+ # Now check if all created Security Groups are present in fetched list
+ for sec_group in fetched_list:
+ self.assertEqual(sec_group['tenant_id'], client_tenant_id,
+ "Failed to get all security groups for "
+ "non admin user.")
+
+
+class SecurityGroupsTestAdminXML(SecurityGroupsTestAdminJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index 6fe3186..10484a9 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -44,6 +42,7 @@
cls.s2_name = data_utils.rand_name('server')
resp, server = cls.create_test_server(name=cls.s2_name,
wait_until='ACTIVE')
+ cls.s2_id = server['id']
def _get_unused_flavor_id(self):
flavor_id = data_utils.rand_int_id(start=1000)
@@ -64,6 +63,22 @@
self.assertEqual([], servers)
@attr(type='gate')
+ def test_list_servers_filter_by_error_status(self):
+ # Filter the list of servers by server error status
+ params = {'status': 'error'}
+ resp, server = self.client.reset_state(self.s1_id, state='error')
+ resp, body = self.non_admin_client.list_servers(params)
+ # Reset server's state to 'active'
+ resp, server = self.client.reset_state(self.s1_id, state='active')
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ACTIVE')
+ servers = body['servers']
+ # Verify error server in list result
+ self.assertIn(self.s1_id, map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s2_id, map(lambda x: x['id'], 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
diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py
index 77d873b..9580a06 100644
--- a/tempest/api/compute/admin/test_servers_negative.py
+++ b/tempest/api/compute/admin/test_servers_negative.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/api/compute/admin/test_services.py b/tempest/api/compute/admin/test_services.py
index 6122758..16dcfcc 100644
--- a/tempest/api/compute/admin/test_services.py
+++ b/tempest/api/compute/admin/test_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py
index da1482e..a1809c4 100644
--- a/tempest/api/compute/admin/test_services_negative.py
+++ b/tempest/api/compute/admin/test_services_negative.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/api/compute/admin/test_simple_tenant_usage.py b/tempest/api/compute/admin/test_simple_tenant_usage.py
index a599f06..dcb9aed 100644
--- a/tempest/api/compute/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/admin/test_simple_tenant_usage.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -18,7 +16,6 @@
import datetime
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
import time
@@ -83,33 +80,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..2a30348
--- /dev/null
+++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py
@@ -0,0 +1,74 @@
+# 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 d18b749..9b9eb9f 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -100,9 +98,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
@@ -131,12 +128,22 @@
r, b = cls.servers_client.list_servers()
servers = [s for s in b['servers'] if s['name'].startswith(name)]
- cls.servers.extend(servers)
-
if 'wait_until' in kwargs:
for server in servers:
- cls.servers_client.wait_for_server_status(
- server['id'], kwargs['wait_until'])
+ try:
+ cls.servers_client.wait_for_server_status(
+ server['id'], kwargs['wait_until'])
+ except Exception as ex:
+ if ('preserve_server_on_error' not in kwargs
+ or kwargs['preserve_server_on_error'] is False):
+ for server in servers:
+ try:
+ cls.servers_client.delete_server(server['id'])
+ except Exception:
+ pass
+ raise ex
+
+ cls.servers.extend(servers)
return resp, body
@@ -160,6 +167,8 @@
@classmethod
def setUpClass(cls):
+ # By default compute tests do not create network resources
+ cls.set_network_resources()
super(BaseV2ComputeTest, cls).setUpClass()
cls.servers_client = cls.os.servers_client
cls.flavors_client = cls.os.flavors_client
@@ -214,8 +223,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']
@@ -251,6 +260,13 @@
@classmethod
def setUpClass(cls):
+ # By default compute tests do not create network resources
+ if cls._interface == "xml":
+ skip_msg = ("XML interface is being removed from Nova v3. "
+ "%s will be removed shortly" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ cls.set_network_resources()
super(BaseV3ComputeTest, cls).setUpClass()
if not cls.config.compute_feature_enabled.api_v3:
cls.tearDownClass()
@@ -260,13 +276,23 @@
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.instance_usages_audit_log_client = \
+ cls.os.instance_usages_audit_log_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
+ cls.version_client = cls.os.version_v3_client
@classmethod
def create_image_from_server(cls, server_id, **kwargs):
@@ -293,8 +319,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']
@@ -325,9 +351,15 @@
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.instance_usages_audit_log_admin_client = \
+ cls.os_adm.instance_usages_audit_log_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/certificates/test_certificates.py b/tempest/api/compute/certificates/test_certificates.py
index 4be1cff..79619bc 100644
--- a/tempest/api/compute/certificates/test_certificates.py
+++ b/tempest/api/compute/certificates/test_certificates.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 092fd65..b0a7fed 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/flavors/test_flavors_negative.py b/tempest/api/compute/flavors/test_flavors_negative.py
index 81e4f87..7474996 100644
--- a/tempest/api/compute/flavors/test_flavors_negative.py
+++ b/tempest/api/compute/flavors/test_flavors_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,7 +16,6 @@
import uuid
from tempest.api.compute import base
-from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.test import attr
@@ -31,14 +28,6 @@
super(FlavorsNegativeTestJSON, cls).setUpClass()
cls.client = cls.flavors_client
- # Generating a nonexistent flavor id
- resp, flavors = cls.client.list_flavors()
- flavor_ids = [flavor['id'] for flavor in flavors]
- while True:
- cls.nonexistent_flavor_id = data_utils.rand_int_id(start=999)
- if cls.nonexistent_flavor_id not in flavor_ids:
- break
-
@attr(type=['negative', 'gate'])
def test_invalid_minRam_filter(self):
self.assertRaises(exceptions.BadRequest,
@@ -52,17 +41,11 @@
{'minDisk': 'invalid'})
@attr(type=['negative', 'gate'])
- def test_get_flavor_details_for_invalid_flavor_id(self):
- # Ensure 404 returned for invalid flavor ID
- invalid_flavor_id = str(uuid.uuid4())
- self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
- invalid_flavor_id)
-
- @attr(type=['negative', 'gate'])
def test_non_existent_flavor_id(self):
# flavor details are not returned for non-existent flavors
+ nonexistent_flavor_id = str(uuid.uuid4())
self.assertRaises(exceptions.NotFound, self.client.get_flavor_details,
- self.nonexistent_flavor_id)
+ nonexistent_flavor_id)
class FlavorsNegativeTestXML(FlavorsNegativeTestJSON):
diff --git a/tempest/api/compute/floating_ips/base.py b/tempest/api/compute/floating_ips/base.py
new file mode 100644
index 0000000..e2c9b04
--- /dev/null
+++ b/tempest/api/compute/floating_ips/base.py
@@ -0,0 +1,28 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2014 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
+
+
+class BaseFloatingIPsTest(base.BaseV2ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ # Floating IP actions might need a full network configuration
+ cls.set_network_resources(network=True, subnet=True,
+ router=True, dhcp=True)
+ super(BaseFloatingIPsTest, cls).setUpClass()
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..2c89391 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.compute import base
+from tempest.api.compute.floating_ips import base
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
-class FloatingIPsTestJSON(base.BaseV2ComputeTest):
+class FloatingIPsTestJSON(base.BaseFloatingIPsTest):
_interface = 'json'
server_id = None
floating_ip = None
@@ -51,17 +49,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_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
index 89315bb..e4d83c5 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,13 +15,13 @@
import uuid
-from tempest.api.compute import base
+from tempest.api.compute.floating_ips import base
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.test import attr
-class FloatingIPsNegativeTestJSON(base.BaseV2ComputeTest):
+class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest):
_interface = 'json'
server_id = None
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 6387f4e..fa2d558 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,11 +13,7 @@
# 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
@@ -58,43 +52,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)
-
- @attr(type=['negative', 'gate'])
- def test_get_nonexistant_floating_ip_details(self):
- # Negative test:Should not be able to GET the details
- # of non-existent floating IP
- floating_ip_id = []
- resp, body = self.client.list_floating_ips()
- for i in range(len(body)):
- floating_ip_id.append(body[i]['id'])
- # Creating a non-existent floatingIP id
- while True:
- non_exist_id = data_utils.rand_int_id(start=999)
- if self.config.service_available.neutron:
- non_exist_id = str(uuid.uuid4())
- if non_exist_id not in floating_ip_id:
- break
- self.assertRaises(exceptions.NotFound,
- self.client.get_floating_ip_details, non_exist_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/floating_ips/test_list_floating_ips_negative.py b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
new file mode 100644
index 0000000..bb1c828
--- /dev/null
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips_negative.py
@@ -0,0 +1,46 @@
+# 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 uuid
+
+from tempest.api.compute import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class FloatingIPDetailsNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(FloatingIPDetailsNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.floating_ips_client
+
+ @attr(type=['negative', 'gate'])
+ def test_get_nonexistent_floating_ip_details(self):
+ # Negative test:Should not be able to GET the details
+ # of non-existent floating IP
+ # Creating a non-existent floatingIP id
+ if self.config.service_available.neutron:
+ non_exist_id = str(uuid.uuid4())
+ else:
+ non_exist_id = data_utils.rand_int_id(start=999)
+ self.assertRaises(exceptions.NotFound,
+ self.client.get_floating_ip_details, non_exist_id)
+
+
+class FloatingIPDetailsNegativeTestXML(FloatingIPDetailsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/images/test_image_metadata.py b/tempest/api/compute/images/test_image_metadata.py
index 618abe2..89a2f75 100644
--- a/tempest/api/compute/images/test_image_metadata.py
+++ b/tempest/api/compute/images/test_image_metadata.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,7 +15,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 +107,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..4878936
--- /dev/null
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -0,0 +1,79 @@
+# 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.py b/tempest/api/compute/images/test_images.py
index f7db89b..fc09741 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index b0ff7ab..0cb748b 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,13 +15,14 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -45,10 +44,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
@@ -84,7 +84,7 @@
resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
return flavor['disk']
- @testtools.skipUnless(compute.CREATE_IMAGE_ENABLED,
+ @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
'Environment unable to create images.')
@attr(type='smoke')
def test_create_delete_image(self):
@@ -117,6 +117,20 @@
self.assertEqual('204', resp['status'])
self.client.wait_for_resource_deletion(image_id)
+ @attr(type=['gate'])
+ def test_create_image_specify_multibyte_character_image_name(self):
+ if self.__class__._interface == "xml":
+ # NOTE(sdague): not entirely accurage, but we'd need a ton of work
+ # in our XML client to make this good
+ raise self.skipException("Not testable in XML")
+ # prefix character is:
+ # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
+ utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
+ resp, body = self.client.create_image(self.server_id, utf8_name)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.client.delete_image, image_id)
+ self.assertEqual('202', resp['status'])
+
class ImagesOneServerTestXML(ImagesOneServerTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index ea6608c..3f93fbe 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
@@ -45,11 +43,15 @@
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
- self.__class__.server_id = self.rebuild_server(self.server_id)
+ # Usually it means the server had a serious accident
+ self._reset_server()
+
+ def _reset_server(self):
+ self.__class__.server_id = self.rebuild_server(self.server_id)
@classmethod
def setUpClass(cls):
@@ -83,11 +85,15 @@
@skip_because(bug="1006725")
@attr(type=['negative', 'gate'])
def test_create_image_specify_multibyte_character_image_name(self):
- # Return an error if the image name has multi-byte characters
- snapshot_name = data_utils.rand_name('\xef\xbb\xbf')
+ if self.__class__._interface == "xml":
+ raise self.skipException("Not testable in XML")
+ # invalid multibyte sequence from:
+ # http://stackoverflow.com/questions/1301402/
+ # example-invalid-utf8-string
+ invalid_name = data_utils.rand_name(u'\xc3\x28')
self.assertRaises(exceptions.BadRequest,
self.client.create_image, self.server_id,
- snapshot_name)
+ invalid_name)
@attr(type=['negative', 'gate'])
def test_create_image_specify_invalid_metadata(self):
@@ -116,12 +122,12 @@
self.assertEqual(202, resp.status)
image_id = data_utils.parse_image_id(resp['location'])
self.image_ids.append(image_id)
+ self.addCleanup(self._reset_server)
# Create second snapshot
alt_snapshot_name = data_utils.rand_name('test-snap-')
self.assertRaises(exceptions.Conflict, self.client.create_image,
self.server_id, alt_snapshot_name)
- self.client.wait_for_image_status(image_id, 'ACTIVE')
@attr(type=['negative', 'gate'])
def test_create_image_specify_name_over_256_chars(self):
@@ -140,6 +146,7 @@
self.assertEqual(202, resp.status)
image_id = data_utils.parse_image_id(resp['location'])
self.image_ids.append(image_id)
+ self.addCleanup(self._reset_server)
# Do not wait, attempt to delete the image, ensure it's successful
resp, body = self.client.delete_image(image_id)
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index ac2ecba..c04729c 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -59,8 +57,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
@@ -222,7 +220,7 @@
self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
@attr(type=['negative', 'gate'])
- def test_get_nonexistant_image(self):
+ def test_get_nonexistent_image(self):
# Negative test: GET on non-existent image should fail
self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index a6726b6..ae1e8d0 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index 50b6c77..d4554bc 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,7 +15,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class KeyPairsTestJSON(base.BaseV2ComputeTest):
@@ -28,14 +26,23 @@
super(KeyPairsTestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
- @attr(type='gate')
+ def _delete_keypair(self, keypair_name):
+ resp, _ = self.client.delete_keypair(keypair_name)
+ self.assertEqual(202, resp.status)
+
+ def _create_keypair(self, keypair_name, pub_key=None):
+ resp, body = self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self._delete_keypair, keypair_name)
+ return resp, body
+
+ @test.attr(type='gate')
def test_keypairs_create_list_delete(self):
# Keypairs created should be available in the response list
# Create 3 keypairs
key_list = list()
for i in range(3):
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self.client.create_keypair(k_name)
+ resp, keypair = self._create_keypair(k_name)
# Need to pop these keys so that our compare doesn't fail later,
# as the keypair dicts from list API doesn't have them.
keypair.pop('private_key')
@@ -57,16 +64,12 @@
self.assertFalse(missing_kps,
"Failed to find keypairs %s in fetched list"
% ', '.join(m_key['name'] for m_key in missing_kps))
- # Delete all the keypairs created
- for keypair in key_list:
- resp, _ = self.client.delete_keypair(keypair['name'])
- self.assertEqual(202, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_keypair_create_delete(self):
# Keypair should be created, verified and deleted
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self.client.create_keypair(k_name)
+ resp, keypair = self._create_keypair(k_name)
self.assertEqual(200, resp.status)
private_key = keypair['private_key']
key_name = keypair['name']
@@ -75,15 +78,12 @@
"to the requested name")
self.assertTrue(private_key is not None,
"Field private_key is empty or not found.")
- resp, _ = self.client.delete_keypair(k_name)
- self.assertEqual(202, resp.status)
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_keypair_detail(self):
# Keypair should be created, Got details by name and deleted
k_name = data_utils.rand_name('keypair-')
- resp, keypair = self.client.create_keypair(k_name)
- self.addCleanup(self.client.delete_keypair, k_name)
+ resp, keypair = self._create_keypair(k_name)
resp, keypair_detail = self.client.get_keypair(k_name)
self.assertEqual(200, resp.status)
self.assertIn('name', keypair_detail)
@@ -95,7 +95,7 @@
self.assertTrue(public_key is not None,
"Field public_key is empty or not found.")
- @attr(type='gate')
+ @test.attr(type='gate')
def test_keypair_create_with_pub_key(self):
# Keypair should be created with a given public key
k_name = data_utils.rand_name('keypair-')
@@ -108,7 +108,7 @@
"LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
"XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
"snSA8wzBx3A/8y9Pp1B nova@ubuntu")
- resp, keypair = self.client.create_keypair(k_name, pub_key)
+ resp, keypair = self._create_keypair(k_name, pub_key)
self.assertEqual(200, resp.status)
self.assertFalse('private_key' in keypair,
"Field private_key is not empty!")
@@ -116,8 +116,6 @@
self.assertEqual(key_name, k_name,
"The created keypair name is not equal "
"to the requested name!")
- resp, _ = self.client.delete_keypair(k_name)
- self.assertEqual(202, resp.status)
class KeyPairsTestXML(KeyPairsTestJSON):
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index fad985e..93b0692 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp
# All Rights Reserved.
@@ -19,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 KeyPairsNegativeTestJSON(base.BaseV2ComputeTest):
@@ -30,67 +28,71 @@
super(KeyPairsNegativeTestJSON, cls).setUpClass()
cls.client = cls.keypairs_client
- @attr(type=['negative', 'gate'])
+ def _create_keypair(self, keypair_name, pub_key=None):
+ self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self.client.delete_keypair, keypair_name)
+
+ @test.attr(type=['negative', 'gate'])
def test_keypair_create_with_invalid_pub_key(self):
# Keypair should not be created with a non RSA public key
k_name = data_utils.rand_name('keypair-')
pub_key = "ssh-rsa JUNK nova@ubuntu"
self.assertRaises(exceptions.BadRequest,
- self.client.create_keypair, k_name, pub_key)
+ self._create_keypair, k_name, pub_key)
- @attr(type=['negative', 'gate'])
- def test_keypair_delete_nonexistant_key(self):
- # Non-existant key deletion should throw a proper error
- k_name = data_utils.rand_name("keypair-non-existant-")
+ @test.attr(type=['negative', 'gate'])
+ def test_keypair_delete_nonexistent_key(self):
+ # Non-existent key deletion should throw a proper error
+ k_name = data_utils.rand_name("keypair-non-existent-")
self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
k_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_with_empty_public_key(self):
# Keypair should not be created with an empty public key
k_name = data_utils.rand_name("keypair-")
pub_key = ' '
- self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name, pub_key)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
# Keypair should not be created when public key bits are too long
k_name = data_utils.rand_name("keypair-")
pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
- self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name, pub_key)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_with_duplicate_name(self):
# 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)
# Now try the same keyname to create another key
- self.assertRaises(exceptions.Conflict, self.client.create_keypair,
+ self.assertRaises(exceptions.Conflict, self._create_keypair,
k_name)
resp, _ = self.client.delete_keypair(k_name)
self.assertEqual(202, resp.status)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_with_empty_name_string(self):
# Keypairs with name being an empty string should not be created
- self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
'')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_with_long_keynames(self):
# Keypairs with name longer than 255 chars should not be created
k_name = 'keypair-'.ljust(260, '0')
- self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_keypair_invalid_name(self):
# Keypairs with name being an invalid name should not be created
k_name = 'key_/.\@:'
- self.assertRaises(exceptions.BadRequest, self.client.create_keypair,
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
k_name)
diff --git a/tempest/api/compute/limits/test_absolute_limits.py b/tempest/api/compute/limits/test_absolute_limits.py
index 2809244..0e234fb 100644
--- a/tempest/api/compute/limits/test_absolute_limits.py
+++ b/tempest/api/compute/limits/test_absolute_limits.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,8 +14,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 +24,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 +45,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..ac8af3b
--- /dev/null
+++ b/tempest/api/compute/limits/test_absolute_limits_negative.py
@@ -0,0 +1,51 @@
+# 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/base.py b/tempest/api/compute/security_groups/base.py
new file mode 100644
index 0000000..66f2600
--- /dev/null
+++ b/tempest/api/compute/security_groups/base.py
@@ -0,0 +1,27 @@
+# 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
+
+
+class BaseSecurityGroupsTest(base.BaseV2ComputeTest):
+
+ @classmethod
+ def setUpClass(cls):
+ # A network and a subnet will be created for these tests
+ cls.set_network_resources(network=True, subnet=True)
+ super(BaseSecurityGroupsTest, cls).setUpClass()
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index 2ccc3a8..6aa5cb5 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.compute import base
+from tempest.api.compute.security_groups import base
from tempest.common.utils import data_utils
from tempest.test import attr
-class SecurityGroupRulesTestJSON(base.BaseV2ComputeTest):
+class SecurityGroupRulesTestJSON(base.BaseSecurityGroupsTest):
_interface = 'json'
@classmethod
diff --git a/tempest/api/compute/security_groups/test_security_group_rules_negative.py b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
index 1c38268..4831939 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules_negative.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
@@ -17,15 +15,17 @@
import testtools
-from tempest.api.compute import base
+from tempest.api.compute.security_groups 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
-class SecurityGroupRulesNegativeTestJSON(base.BaseV2ComputeTest):
+
+class SecurityGroupRulesNegativeTestJSON(base.BaseSecurityGroupsTest):
_interface = 'json'
@classmethod
@@ -34,7 +34,7 @@
cls.client = cls.security_groups_client
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_non_existent_id(self):
# Negative test: Creation of Security Group rule should FAIL
@@ -48,7 +48,7 @@
self.client.create_security_group_rule,
parent_group_id, ip_protocol, from_port, to_port)
- @testtools.skipIf(config.TempestConfig().service_available.neutron,
+ @testtools.skipIf(CONF.service_available.neutron,
"Neutron not check the security_group_id")
@attr(type=['negative', 'smoke'])
def test_create_security_group_rule_with_invalid_id(self):
@@ -168,7 +168,7 @@
secgroup_id, ip_protocol, from_port, to_port)
@skip_because(bug="1182384",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type=['negative', 'smoke'])
def test_delete_security_group_rule_with_non_existent_id(self):
# Negative test: Deletion of Security Group rule should be FAIL
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index 7cb96af..bff6e14 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,31 +13,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-import uuid
-
-from tempest.api.compute import base
+from tempest.api.compute.security_groups 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 SecurityGroupsTestJSON(base.BaseV2ComputeTest):
+class SecurityGroupsTestJSON(base.BaseSecurityGroupsTest):
_interface = 'json'
@classmethod
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
@@ -67,7 +59,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-')
@@ -86,7 +78,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-')
@@ -110,121 +102,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=config.TempestConfig().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=config.TempestConfig().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(config.TempestConfig().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.
@@ -280,6 +158,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..98ed8e8
--- /dev/null
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -0,0 +1,214 @@
+# 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.security_groups 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.BaseSecurityGroupsTest):
+ _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_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py
index a177cea..4dacb48 100644
--- a/tempest/api/compute/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/servers/test_attach_interfaces.py
@@ -14,6 +14,7 @@
# under the License.
from tempest.api.compute import base
+from tempest import exceptions
from tempest.test import attr
import time
@@ -26,6 +27,8 @@
def setUpClass(cls):
if not cls.config.service_available.neutron:
raise cls.skipException("Neutron is required")
+ # This test class requires network and subnet
+ cls.set_network_resources(network=True, subnet=True)
super(AttachInterfacesTestJSON, cls).setUpClass()
cls.client = cls.os.interfaces_client
@@ -73,15 +76,19 @@
# NOTE(danms): delete not the first or last, but one in the middle
iface = ifs[1]
self.client.delete_interface(server['id'], iface['port_id'])
- for i in range(0, 5):
- _r, _ifs = self.client.list_interfaces(server['id'])
- if len(ifs) != len(_ifs):
- break
- time.sleep(1)
+ _ifs = self.client.list_interfaces(server['id'])[1]
+ start = int(time.time())
- self.assertEqual(len(_ifs), len(ifs) - 1)
- for _iface in _ifs:
- self.assertNotEqual(iface['port_id'], _iface['port_id'])
+ while len(ifs) == len(_ifs):
+ time.sleep(self.build_interval)
+ _ifs = self.client.list_interfaces(server['id'])[1]
+ timed_out = int(time.time()) - start >= self.build_timeout
+ if len(ifs) == len(_ifs) and timed_out:
+ message = ('Failed to delete interface within '
+ 'the required time: %s sec.' % self.build_timeout)
+ raise exceptions.TimeoutException(message)
+
+ self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs])
return _ifs
def _compare_iface_list(self, list1, list2):
@@ -92,7 +99,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 24ade96..887608f 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,17 +18,18 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
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 ServersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
disk_config = 'AUTO'
@classmethod
@@ -93,13 +92,6 @@
@testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
@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')
def test_verify_created_server_vcpus(self):
# Verify that the number of vcpus reported by the instance matches
# the amount stated by the flavor
@@ -115,12 +107,110 @@
self.assertTrue(linux_client.hostname_equals_servername(self.name))
+class ServersWithSpecificFlavorTestJSON(base.BaseV2ComputeAdminTest):
+ _interface = 'json'
+ run_ssh = CONF.compute.run_ssh
+ disk_config = 'AUTO'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersWithSpecificFlavorTestJSON, cls).setUpClass()
+ cls.meta = {'hello': 'world'}
+ cls.accessIPv4 = '1.1.1.1'
+ cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
+ cls.name = data_utils.rand_name('server')
+ file_contents = 'This is a test file.'
+ personality = [{'path': '/test.txt',
+ 'contents': base64.b64encode(file_contents)}]
+ cls.client = cls.servers_client
+ cls.flavor_client = cls.os_adm.flavors_client
+ cli_resp = cls.create_test_server(name=cls.name,
+ meta=cls.meta,
+ accessIPv4=cls.accessIPv4,
+ accessIPv6=cls.accessIPv6,
+ personality=personality,
+ disk_config=cls.disk_config)
+ cls.resp, cls.server_initial = cli_resp
+ cls.password = cls.server_initial['adminPass']
+ cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
+ resp, cls.server = cls.client.get_server(cls.server_initial['id'])
+
+ @testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
+ @attr(type='gate')
+ def test_verify_created_server_ephemeral_disk(self):
+ # Verify that the ephemeral disk is created when creating server
+
+ def create_flavor_with_extra_specs(self):
+ flavor_with_eph_disk_name = data_utils.rand_name('eph_flavor')
+ flavor_with_eph_disk_id = data_utils.rand_int_id(start=1000)
+ ram = 64
+ vcpus = 1
+ disk = 0
+
+ # Create a flavor with extra specs
+ resp, flavor = (self.flavor_client.
+ create_flavor(flavor_with_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_with_eph_disk_id,
+ ephemeral=1))
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(200, resp.status)
+
+ return flavor['id']
+
+ def create_flavor_without_extra_specs(self):
+ flavor_no_eph_disk_name = data_utils.rand_name('no_eph_flavor')
+ flavor_no_eph_disk_id = data_utils.rand_int_id(start=1000)
+
+ ram = 64
+ vcpus = 1
+ disk = 0
+
+ # Create a flavor without extra specs
+ resp, flavor = (self.flavor_client.
+ create_flavor(flavor_no_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_no_eph_disk_id))
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(200, resp.status)
+
+ return flavor['id']
+
+ def flavor_clean_up(self, flavor_id):
+ resp, body = self.flavor_client.delete_flavor(flavor_id)
+ self.assertEqual(resp.status, 202)
+ self.flavor_client.wait_for_resource_deletion(flavor_id)
+
+ flavor_with_eph_disk_id = self.create_flavor_with_extra_specs()
+ flavor_no_eph_disk_id = self.create_flavor_without_extra_specs()
+
+ admin_pass = self.image_ssh_password
+
+ resp, server_no_eph_disk = (self.
+ create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_no_eph_disk_id))
+ resp, server_with_eph_disk = (self.create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_with_eph_disk_id))
+ # Get partition number of server without extra specs.
+ linux_client = RemoteClient(server_no_eph_disk,
+ self.ssh_user, self.password)
+ partition_num = len(linux_client.get_partitions())
+
+ linux_client = RemoteClient(server_with_eph_disk,
+ self.ssh_user, self.password)
+ self.assertEqual(partition_num + 1, linux_client.get_partitions())
+
+
class ServersTestManualDisk(ServersTestJSON):
disk_config = 'MANUAL'
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServersTestManualDisk, cls).setUpClass()
@@ -128,3 +218,7 @@
class ServersTestXML(ServersTestJSON):
_interface = 'xml'
+
+
+class ServersWithSpecificFlavorTestXML(ServersWithSpecificFlavorTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_disk_config.py b/tempest/api/compute/servers/test_disk_config.py
index 0121c42..0d79161 100644
--- a/tempest/api/compute/servers/test_disk_config.py
+++ b/tempest/api/compute/servers/test_disk_config.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,17 +15,19 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
+from tempest import config
from tempest.test import attr
+CONF = config.CONF
+
class ServerDiskConfigTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ if not CONF.compute_feature_enabled.disk_config:
msg = "DiskConfig extension not enabled."
raise cls.skipException(msg)
super(ServerDiskConfigTestJSON, cls).setUpClass()
@@ -85,7 +85,8 @@
else:
return self.flavor_ref
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_manual_to_auto(self):
# A server should be resized from manual to auto disk config
@@ -101,7 +102,8 @@
resp, server = self.client.get_server(self.server_id)
self.assertEqual('AUTO', server['OS-DCF:diskConfig'])
- @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.')
+ @testtools.skipUnless(CONF.compute_feature_enabled.resize,
+ 'Resize not available.')
@attr(type='gate')
def test_resize_server_from_auto_to_manual(self):
# A server should be resized from auto to manual disk config
diff --git a/tempest/api/compute/servers/test_instance_actions.py b/tempest/api/compute/servers/test_instance_actions.py
index 5019003..667b84f 100644
--- a/tempest/api/compute/servers/test_instance_actions.py
+++ b/tempest/api/compute/servers/test_instance_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -16,8 +14,7 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class InstanceActionsTestJSON(base.BaseV2ComputeTest):
@@ -31,7 +28,7 @@
cls.request_id = resp['x-compute-request-id']
cls.server_id = server['id']
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_instance_actions(self):
# List actions of the provided server
resp, body = self.client.reboot(self.server_id, 'HARD')
@@ -43,7 +40,7 @@
self.assertTrue(any([i for i in body if i['action'] == 'create']))
self.assertTrue(any([i for i in body if i['action'] == 'reboot']))
- @attr(type='gate')
+ @test.attr(type='gate')
def test_get_instance_action(self):
# Get the action details of the provided server
resp, body = self.client.get_instance_action(self.server_id,
@@ -52,18 +49,6 @@
self.assertEqual(self.server_id, body['instance_uuid'])
self.assertEqual('create', body['action'])
- @attr(type=['negative', 'gate'])
- def test_list_instance_actions_invalid_server(self):
- # List actions of the invalid server id
- self.assertRaises(exceptions.NotFound,
- self.client.list_instance_actions, 'server-999')
-
- @attr(type=['negative', 'gate'])
- def test_get_instance_action_invalid_request(self):
- # Get the action details of the provided server with invalid request
- self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
- self.server_id, '999')
-
class InstanceActionsTestXML(InstanceActionsTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_instance_actions_negative.py b/tempest/api/compute/servers/test_instance_actions_negative.py
new file mode 100644
index 0000000..2503eb2
--- /dev/null
+++ b/tempest/api/compute/servers/test_instance_actions_negative.py
@@ -0,0 +1,48 @@
+# 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.utils import data_utils
+from tempest import exceptions
+from tempest import test
+
+
+class InstanceActionsNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceActionsNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.servers_client
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+
+ @test.attr(type=['negative', 'gate'])
+ def test_list_instance_actions_non_existent_server(self):
+ # List actions of the non-existent server id
+ non_existent_server_id = data_utils.rand_uuid()
+ self.assertRaises(exceptions.NotFound,
+ self.client.list_instance_actions,
+ non_existent_server_id)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_instance_action_invalid_request(self):
+ # Get the action details of the provided server with invalid request
+ self.assertRaises(exceptions.NotFound, self.client.get_instance_action,
+ self.server_id, '999')
+
+
+class InstanceActionsNegativeTestXML(InstanceActionsNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 4cbf94d..1dc0a39 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -23,6 +21,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
@@ -119,6 +119,23 @@
self.assertIn(self.s3['id'], map(lambda x: x['id'], servers))
@attr(type='gate')
+ def test_list_servers_filter_by_shutoff_status(self):
+ # Filter the list of servers by server shutoff status
+ params = {'status': 'shutoff'}
+ self.client.stop(self.s1['id'])
+ self.client.wait_for_server_status(self.s1['id'],
+ 'SHUTOFF')
+ resp, body = self.client.list_servers(params)
+ self.client.start(self.s1['id'])
+ self.client.wait_for_server_status(self.s1['id'],
+ 'ACTIVE')
+ servers = body['servers']
+
+ self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s3['id'], map(lambda x: x['id'], servers))
+
+ @attr(type='gate')
def test_list_servers_filter_by_limit(self):
# Verify only the expected number of servers are returned
params = {'limit': 1}
@@ -210,7 +227,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/servers/test_list_servers_negative.py b/tempest/api/compute/servers/test_list_servers_negative.py
index 521a480..a0aefd8 100644
--- a/tempest/api/compute/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/servers/test_list_servers_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_multiple_create.py b/tempest/api/compute/servers/test_multiple_create.py
index 080bd1a..cf4d646 100644
--- a/tempest/api/compute/servers/test_multiple_create.py
+++ b/tempest/api/compute/servers/test_multiple_create.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
@@ -17,8 +15,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 +35,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 +46,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..e289717
--- /dev/null
+++ b/tempest/api/compute/servers/test_multiple_create_negative.py
@@ -0,0 +1,73 @@
+# 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_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 3c40e80..582faf8 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,21 +18,21 @@
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +51,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
@@ -67,7 +65,7 @@
# Verify that the user can authenticate with the new password
resp, server = self.client.get_server(self.server_id)
linux_client = RemoteClient(server, self.ssh_user, new_password)
- self.assertTrue(linux_client.can_authenticate())
+ linux_client.validate_authentication()
@attr(type='smoke')
def test_reboot_server_hard(self):
@@ -141,7 +139,7 @@
if self.run_ssh:
# Verify that the user can authenticate with the provided password
linux_client = RemoteClient(server, self.ssh_user, password)
- self.assertTrue(linux_client.can_authenticate())
+ linux_client.validate_authentication()
@attr(type='gate')
def test_rebuild_server_in_stop_state(self):
@@ -174,7 +172,7 @@
def _detect_server_image_flavor(self, server_id):
# Detects the current server image flavor ref.
- resp, server = self.client.get_server(self.server_id)
+ resp, server = self.client.get_server(server_id)
current_flavor = server['flavor']['id']
new_flavor_ref = self.flavor_ref_alt \
if current_flavor == self.flavor_ref else self.flavor_ref
@@ -247,6 +245,7 @@
image1_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(_clean_oldest_backup, image1_id)
self.assertEqual(202, resp.status)
+ self.os.image_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')
@@ -257,6 +256,7 @@
image2_id = data_utils.parse_image_id(resp['location'])
self.addCleanup(self.os.image_client.delete_image, image2_id)
self.assertEqual(202, resp.status)
+ self.os.image_client.wait_for_image_status(image2_id, 'active')
# verify they have been created
properties = {
@@ -285,6 +285,7 @@
self.addCleanup(self.os.image_client.delete_image, image3_id)
self.assertEqual(202, resp.status)
# the first back up should be deleted
+ self.servers_client.wait_for_server_status(self.server_id, 'ACTIVE')
self.os.image_client.wait_for_resource_deletion(image1_id)
oldest_backup_exist = False
resp, image_list = self.os.image_client.image_list_detail(
diff --git a/tempest/api/compute/servers/test_server_addresses.py b/tempest/api/compute/servers/test_server_addresses.py
index 7ca8a52..8e432c4 100644
--- a/tempest/api/compute/servers/test_server_addresses.py
+++ b/tempest/api/compute/servers/test_server_addresses.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,34 +14,22 @@
# 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()
+ # This test module might use a network and a subnet
+ cls.set_network_resources(network=True, subnet=True)
+ 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..c69c5eb
--- /dev/null
+++ b/tempest/api/compute/servers/test_server_addresses_negative.py
@@ -0,0 +1,47 @@
+# 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):
+ cls.set_network_resources(network=True, subnet=True)
+ 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_server_metadata.py b/tempest/api/compute/servers/test_server_metadata.py
index ee0f4a9..80ac4da 100644
--- a/tempest/api/compute/servers/test_server_metadata.py
+++ b/tempest/api/compute/servers/test_server_metadata.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_server_password.py b/tempest/api/compute/servers/test_server_password.py
index 93c6e44..06697a5 100644
--- a/tempest/api/compute/servers/test_server_password.py
+++ b/tempest/api/compute/servers/test_server_password.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py
index c6d2e44..bb14a4c 100644
--- a/tempest/api/compute/servers/test_server_personality.py
+++ b/tempest/api/compute/servers/test_server_personality.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 1008670..45fe5ac 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
@@ -70,7 +68,7 @@
cls.rescue_password = resc_server['adminPass']
cls.servers_client.rescue_server(
- cls.rescue_id, cls.rescue_password)
+ cls.rescue_id, adminPass=cls.rescue_password)
cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
def setUp(self):
@@ -111,7 +109,7 @@
@attr(type='smoke')
def test_rescue_unrescue_instance(self):
resp, body = self.servers_client.rescue_server(
- self.server_id, self.password)
+ self.server_id, adminPass=self.password)
self.assertEqual(200, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
resp, body = self.servers_client.unrescue_server(self.server_id)
@@ -152,7 +150,8 @@
@attr(type=['negative', 'gate'])
def test_rescued_vm_attach_volume(self):
# Rescue the server
- self.servers_client.rescue_server(self.server_id, self.password)
+ self.servers_client.rescue_server(self.server_id,
+ adminPass=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
@@ -173,7 +172,8 @@
self.volume_to_detach['id'], 'in-use')
# Rescue the server
- self.servers_client.rescue_server(self.server_id, self.password)
+ self.servers_client.rescue_server(self.server_id,
+ adminPass=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
# addCleanup is a LIFO queue
self.addCleanup(self._detach, self.server_id,
@@ -190,7 +190,7 @@
def test_rescued_vm_associate_dissociate_floating_ip(self):
# Rescue the server
self.servers_client.rescue_server(
- self.server_id, self.password)
+ self.server_id, adminPass=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
@@ -210,7 +210,7 @@
def test_rescued_vm_add_remove_security_group(self):
# Rescue the server
self.servers_client.rescue_server(
- self.server_id, self.password)
+ self.server_id, adminPass=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
# Add Security group
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index d72476d..8ae43b5 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 8142250..8f49aec 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,13 +15,12 @@
import base64
import sys
-import uuid
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
class ServersNegativeTestJSON(base.BaseV2ComputeTest):
@@ -40,13 +37,12 @@
def setUpClass(cls):
super(ServersNegativeTestJSON, cls).setUpClass()
cls.client = cls.servers_client
- cls.img_client = cls.images_client
cls.alt_os = clients.AltManager()
cls.alt_client = cls.alt_os.servers_client
resp, server = cls.create_test_server(wait_until='ACTIVE')
cls.server_id = server['id']
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_server_name_blank(self):
# Create a server with name parameter empty
@@ -54,7 +50,7 @@
self.create_test_server,
name='')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_personality_file_contents_not_encoded(self):
# Use an unencoded file when creating a server with personality
@@ -66,7 +62,7 @@
self.create_test_server,
personality=person)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -74,7 +70,7 @@
self.create_test_server,
image_id=-1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
@@ -82,7 +78,7 @@
self.create_test_server,
flavor=-1,)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_access_ip_v4_address(self):
# An access IPv4 address must match a valid address pattern
@@ -90,7 +86,7 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv4=IPv4)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
# An access IPv6 address must match a valid address pattern
@@ -99,34 +95,35 @@
self.assertRaises(exceptions.BadRequest,
self.create_test_server, accessIPv6=IPv6)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
- nonexistent_server = str(uuid.uuid4())
+ # Resize a non-existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.resize,
nonexistent_server, self.flavor_ref)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_non_existent_flavor(self):
# Resize a server with non-existent flavor
- nonexistent_flavor = str(uuid.uuid4())
+ nonexistent_flavor = data_utils.rand_uuid()
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref=nonexistent_flavor)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_null_flavor(self):
# Resize a server with null flavor
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref="")
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_non_existent_server(self):
# Reboot a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_paused_server(self):
# Pause a paused server.
self.client.pause_server(self.server_id)
@@ -137,7 +134,7 @@
self.client.pause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_reboot_deleted_server(self):
# Rebuild and Reboot a deleted server
_, server = self.create_test_server()
@@ -150,10 +147,10 @@
self.assertRaises(exceptions.NotFound, self.client.reboot,
server['id'], 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_non_existent_server(self):
# Rebuild a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
file_contents = 'Test server rebuild.'
@@ -167,7 +164,7 @@
personality=personality,
adminPass='rebuild')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
if self.__class__._interface == "xml":
@@ -178,7 +175,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_name_length_exceeds_256(self):
# Create a server with name length exceeding 256 characters
@@ -187,7 +184,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_network_uuid(self):
# Pass invalid network uuid while creating a server
@@ -197,8 +194,8 @@
self.create_test_server,
networks=networks)
- @attr(type=['negative', 'gate'])
- def test_create_with_non_existant_keypair(self):
+ @test.attr(type=['negative', 'gate'])
+ def test_create_with_non_existent_keypair(self):
# Pass a non-existent keypair while creating a server
key_name = data_utils.rand_name('key')
@@ -206,7 +203,7 @@
self.create_test_server,
key_name=key_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_metadata_exceeds_length_limit(self):
# Pass really long metadata while creating a server
@@ -215,7 +212,7 @@
self.create_test_server,
meta=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_name_of_non_existent_server(self):
# Update name of a non-existent server
@@ -225,7 +222,7 @@
self.assertRaises(exceptions.NotFound, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_set_empty_name(self):
# Update name of the server to an empty string
@@ -235,7 +232,7 @@
self.assertRaises(exceptions.BadRequest, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
@@ -244,7 +241,7 @@
self.alt_client.update_server, self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
@@ -254,34 +251,35 @@
self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_server(self):
# Delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.delete_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_negative_id(self):
# Pass an invalid string parameter to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_id_exceeding_length_limit(self):
# Pass a server ID that exceeds length limit to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server,
sys.maxint + 1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_nonexistent_security_group(self):
# Create a server with a nonexistent security group
@@ -290,49 +288,49 @@
self.create_test_server,
security_groups=security_groups)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_non_existent_server(self):
# Get a non existent server details
-
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.get_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.pause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.
self.assertRaises(exceptions.Conflict,
self.client.unpause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_non_existent_server(self):
# suspend a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.suspend_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_server_invalid_state(self):
# suspend a suspended server.
resp, _ = self.client.suspend_server(self.server_id)
@@ -344,66 +342,66 @@
self.client.suspend_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_non_existent_server(self):
# resume a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.resume_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
# resume an active server.
self.assertRaises(exceptions.Conflict,
self.client.resume_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_console_output_of_non_existent_server(self):
# get the console output for a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.get_console_output,
nonexistent_server, 10)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # force-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.force_delete_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_server_invalid_state(self):
# we can only force-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.force_delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # restore-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.restore_soft_deleted_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_server_invalid_state(self):
# we can only restore-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.restore_soft_deleted_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_non_existent_server(self):
# shelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.shelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_shelved_server(self):
# shelve a shelved server.
resp, server = self.client.shelve_server(self.server_id)
@@ -430,14 +428,14 @@
self.client.shelve_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_non_existent_server(self):
# unshelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_server_invalid_state(self):
# unshelve an active server.
self.assertRaises(exceptions.Conflict,
diff --git a/tempest/api/compute/servers/test_virtual_interfaces.py b/tempest/api/compute/servers/test_virtual_interfaces.py
index 77ada0b..32376eb 100644
--- a/tempest/api/compute/servers/test_virtual_interfaces.py
+++ b/tempest/api/compute/servers/test_virtual_interfaces.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,28 +16,27 @@
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):
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
+ # This test needs a network and a subnet
+ cls.set_network_resources(network=True, subnet=True)
super(VirtualInterfacesTestJSON, cls).setUpClass()
cls.client = cls.servers_client
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..f73218c
--- /dev/null
+++ b/tempest/api/compute/servers/test_virtual_interfaces_negative.py
@@ -0,0 +1,44 @@
+# 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):
+ # For this test no network resources are needed
+ cls.set_network_resources()
+ 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 ffeede8..0000000
--- a/tempest/api/compute/test_auth_token.py
+++ /dev/null
@@ -1,52 +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
-
-
-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 config.TempestConfig().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/test_authorization.py b/tempest/api/compute/test_authorization.py
index 327c7d1..13b75cf 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -30,6 +28,8 @@
@classmethod
def setUpClass(cls):
+ # No network resources required for this test
+ cls.set_network_resources()
super(AuthorizationTestJSON, cls).setUpClass()
if not cls.multi_user:
msg = "Need >1 user"
diff --git a/tempest/api/compute/test_extensions.py b/tempest/api/compute/test_extensions.py
index 8f1e446..aac635c 100644
--- a/tempest/api/compute/test_extensions.py
+++ b/tempest/api/compute/test_extensions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,18 +15,41 @@
from tempest.api.compute import base
-from tempest.test import attr
+from tempest.openstack.common import log as logging
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
class ExtensionsTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
+ if len(self.config.compute_feature_enabled.api_extensions) == 0:
+ raise self.skipException('There are not any extensions configured')
resp, extensions = self.extensions_client.list_extensions()
- self.assertIn("extensions", extensions)
self.assertEqual(200, resp.status)
+ ext = self.config.compute_feature_enabled.api_extensions[0]
+ if ext == 'all':
+ self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+ elif ext:
+ self.assertIn(ext, map(lambda x: x['name'], extensions))
+ else:
+ raise self.skipException('There are not any extensions configured')
+ # Log extensions list
+ extension_list = map(lambda x: x['name'], extensions)
+ LOG.debug("Nova extensions: %s" % ','.join(extension_list))
+
+ @test.requires_ext(extension='os-consoles', service='compute')
+ @test.attr(type='gate')
+ def test_get_extension(self):
+ # get the specified extensions
+ resp, extension = self.extensions_client.get_extension('os-consoles')
+ self.assertEqual(200, resp.status)
+ self.assertEqual('os-consoles', extension['alias'])
class ExtensionsTestXML(ExtensionsTestJSON):
diff --git a/tempest/api/compute/test_live_block_migration.py b/tempest/api/compute/test_live_block_migration.py
index a7b6cd2..85d314b 100644
--- a/tempest/api/compute/test_live_block_migration.py
+++ b/tempest/api/compute/test_live_block_migration.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -30,7 +28,7 @@
_host_key = 'OS-EXT-SRV-ATTR:host'
_interface = 'json'
- CONF = config.TempestConfig()
+ CONF = config.CONF
@classmethod
def setUpClass(cls):
diff --git a/tempest/api/compute/test_quotas.py b/tempest/api/compute/test_quotas.py
index 475d055..112e4fb 100644
--- a/tempest/api/compute/test_quotas.py
+++ b/tempest/api/compute/test_quotas.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
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..7491742
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_aggregates.py
@@ -0,0 +1,219 @@
+# 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..4eb75a5
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_aggregates_negative.py
@@ -0,0 +1,194 @@
+# 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_availability_zone.py b/tempest/api/compute/v3/admin/test_availability_zone.py
index ff2765c..2955dc8 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -16,21 +14,20 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
-class AvailabilityZoneAdminV3TestJSON(base.BaseV3ComputeAdminTest):
+class AZAdminV3TestJSON(base.BaseV3ComputeAdminTest):
"""
- Tests Availability Zone API List that require admin privileges
+ Tests Availability Zone API List
"""
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(AvailabilityZoneAdminV3TestJSON, cls).setUpClass()
+ super(AZAdminV3TestJSON, cls).setUpClass()
cls.client = cls.availability_zone_admin_client
cls.non_adm_client = cls.availability_zone_client
@@ -57,14 +54,6 @@
self.assertEqual(200, resp.status)
self.assertTrue(len(availability_zone) > 0)
- @attr(type=['negative', 'gate'])
- def test_get_availability_zone_list_detail_with_non_admin_user(self):
- # List of availability zones and available services with
- # non-administrator user
- self.assertRaises(
- exceptions.Unauthorized,
- self.non_adm_client.get_availability_zone_list_detail)
-
-class AvailabilityZoneAdminV3TestXML(AvailabilityZoneAdminV3TestJSON):
+class AZAdminV3TestXML(AZAdminV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_availability_zone_negative.py b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
new file mode 100644
index 0000000..d69e956
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_availability_zone_negative.py
@@ -0,0 +1,45 @@
+# 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 import exceptions
+from tempest.test import attr
+
+
+class AZAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Availability Zone API List
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AZAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.availability_zone_admin_client
+ cls.non_adm_client = cls.availability_zone_client
+
+ @attr(type=['negative', 'gate'])
+ def test_get_availability_zone_list_detail_with_non_admin_user(self):
+ # List of availability zones and available services with
+ # non-administrator user
+ self.assertRaises(
+ exceptions.Unauthorized,
+ self.non_adm_client.get_availability_zone_list_detail)
+
+
+class AZAdminNegativeV3TestXML(AZAdminNegativeV3TestJSON):
+ _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..532dc48 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
@@ -20,7 +18,7 @@
from tempest import test
-class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -31,19 +29,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 +55,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 +101,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..e9d811c 100644
--- a/tempest/api/compute/v3/admin/test_flavors_access_negative.py
+++ b/tempest/api/compute/v3/admin/test_flavors_access_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
@@ -23,7 +21,7 @@
from tempest import test
-class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsAccessNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Access API extension.
@@ -34,19 +32,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 +58,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 +142,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..b084157 100644
--- a/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
+++ b/tempest/api/compute/v3/admin/test_flavors_extra_specs.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,7 +18,7 @@
from tempest import test
-class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Tests Flavor Extra Spec API extension.
@@ -32,12 +30,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 +53,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 +64,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 +90,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 +112,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 +122,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..a81edb1 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
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
# Copyright 2013 IBM Corp.
@@ -22,7 +20,7 @@
from tempest import test
-class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest):
+class FlavorsExtraSpecsNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
"""
Negative Tests Flavor Extra Spec API extension.
@@ -33,12 +31,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 +54,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 +71,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 +126,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..a110d02
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_hosts.py
@@ -0,0 +1,92 @@
+# 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..9841950
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_hosts_negative.py
@@ -0,0 +1,174 @@
+# 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,
+ status='enable',
+ maintenance_mode='enable')
+
+ @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_hypervisor.py b/tempest/api/compute/v3/admin/test_hypervisor.py
index 3da3369..84f6b4d 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/v3/admin/test_hypervisor_negative.py b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
index 847679e..68b0af0 100644
--- a/tempest/api/compute/v3/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/v3/admin/test_hypervisor_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
new file mode 100644
index 0000000..fada98c
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log.py
@@ -0,0 +1,63 @@
+# Copyright 2013 IBM 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
+import urllib
+
+from tempest.api.compute import base
+from tempest import test
+
+
+class InstanceUsageAuditLogV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceUsageAuditLogV3TestJSON, cls).setUpClass()
+ cls.adm_client = cls.instance_usages_audit_log_admin_client
+
+ @test.attr(type='gate')
+ def test_list_instance_usage_audit_logs(self):
+ # list instance usage audit logs
+ resp, body = self.adm_client.list_instance_usage_audit_logs()
+ self.assertEqual(200, resp.status)
+ expected_items = ['total_errors', 'total_instances', 'log',
+ 'num_hosts_running', 'num_hosts_done',
+ 'num_hosts', 'hosts_not_run', 'overall_status',
+ 'period_ending', 'period_beginning',
+ 'num_hosts_not_run']
+ for item in expected_items:
+ self.assertIn(item, body)
+
+ @test.attr(type='gate')
+ def test_list_instance_usage_audit_logs_with_filter_before(self):
+ # Get instance usage audit log before specified time
+ ending_time = datetime.datetime(2012, 12, 24)
+ resp, body = self.adm_client.list_instance_usage_audit_logs(
+ urllib.quote(ending_time.strftime("%Y-%m-%d %H:%M:%S")))
+
+ self.assertEqual(200, resp.status)
+ expected_items = ['total_errors', 'total_instances', 'log',
+ 'num_hosts_running', 'num_hosts_done', 'num_hosts',
+ 'hosts_not_run', 'overall_status', 'period_ending',
+ 'period_beginning', 'num_hosts_not_run']
+ for item in expected_items:
+ self.assertIn(item, body)
+ self.assertEqual(body['period_ending'], "2012-12-23 23:00:00")
+
+
+class InstanceUsageAuditLogV3TestXML(InstanceUsageAuditLogV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
new file mode 100644
index 0000000..06b3711
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_instance_usage_audit_log_negative.py
@@ -0,0 +1,46 @@
+# Copyright 2013 IBM 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 import exceptions
+from tempest import test
+
+
+class InstanceUsageLogNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(InstanceUsageLogNegativeV3TestJSON, cls).setUpClass()
+ cls.adm_client = cls.instance_usages_audit_log_admin_client
+
+ @test.attr(type=['negative', 'gate'])
+ def test_instance_usage_audit_logs_with_nonadmin_user(self):
+ # the instance_usage_audit_logs API just can be accessed by admin user
+ self.assertRaises(exceptions.Unauthorized,
+ self.instance_usages_audit_log_client.
+ list_instance_usage_audit_logs)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_get_instance_usage_audit_logs_with_invalid_time(self):
+ self.assertRaises(exceptions.BadRequest,
+ self.adm_client.list_instance_usage_audit_logs,
+ "invalid_time")
+
+
+class InstanceUsageLogNegativeV3TestXML(
+ InstanceUsageLogNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_quotas.py b/tempest/api/compute/v3/admin/test_quotas.py
index f49aae4..ed4561d 100644
--- a/tempest/api/compute/v3/admin/test_quotas.py
+++ b/tempest/api/compute/v3/admin/test_quotas.py
@@ -1,6 +1,4 @@
-# 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,39 +15,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
+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'])
@@ -60,15 +53,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
@@ -81,10 +73,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_')
@@ -104,7 +97,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)
@@ -119,7 +112,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)
@@ -134,14 +127,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)
@@ -155,66 +148,6 @@
instances=default_instances_quota)
self.assertRaises(exceptions.OverLimit, self.create_test_server)
- @skip_because(bug="1186354",
- condition=config.TempestConfig().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=config.TempestConfig().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..dec573e
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_servers.py
@@ -0,0 +1,161 @@
+# 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 ServersAdminV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Servers API using admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersAdminV3TestJSON, cls).setUpClass()
+ cls.client = cls.servers_admin_client
+ cls.non_admin_client = cls.servers_client
+ cls.flavors_client = cls.flavors_admin_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')
+ cls.s2_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='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_list_servers_filter_by_error_status(self):
+ # Filter the list of servers by server error status
+ params = {'status': 'error'}
+ resp, server = self.client.reset_state(self.s1_id, state='error')
+ resp, body = self.non_admin_client.list_servers(params)
+ # Reset server's state to 'active'
+ resp, server = self.client.reset_state(self.s1_id, state='active')
+ # Verify server's state
+ resp, server = self.client.get_server(self.s1_id)
+ self.assertEqual(server['status'], 'ACTIVE')
+ servers = body['servers']
+ # Verify error server in list result
+ self.assertIn(self.s1_id, map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s2_id, map(lambda x: x['id'], servers))
+
+ @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 ServersAdminV3TestXML(ServersAdminV3TestJSON):
+ _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..fb4b043
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_servers_negative.py
@@ -0,0 +1,141 @@
+# 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 ServersAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Servers API using admin privileges
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.servers_admin_client
+ cls.non_adm_client = cls.servers_client
+ cls.flavors_client = cls.flavors_admin_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 ServersAdminNegativeV3TestXML(ServersAdminNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services.py b/tempest/api/compute/v3/admin/test_services.py
index 64135ed..ba32739 100644
--- a/tempest/api/compute/v3/admin/test_services.py
+++ b/tempest/api/compute/v3/admin/test_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
@@ -17,7 +15,6 @@
# under the License.
from tempest.api.compute import base
-from tempest import exceptions
from tempest.test import attr
@@ -33,7 +30,6 @@
def setUpClass(cls):
super(ServicesAdminV3TestJSON, cls).setUpClass()
cls.client = cls.services_admin_client
- cls.non_admin_client = cls.services_client
@attr(type='gate')
def test_list_services(self):
@@ -41,11 +37,6 @@
self.assertEqual(200, resp.status)
self.assertNotEqual(0, len(services))
- @attr(type=['negative', 'gate'])
- def test_list_services_with_non_admin_user(self):
- self.assertRaises(exceptions.Unauthorized,
- self.non_admin_client.list_services)
-
@attr(type='gate')
def test_get_service_by_service_binary_name(self):
binary_name = 'nova-compute'
@@ -74,15 +65,6 @@
# on order.
self.assertEqual(sorted(s1), sorted(s2))
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_params(self):
- # return all services if send the request with invalid parameter
- resp, services = self.client.list_services()
- params = {'xxx': 'nova-compute'}
- resp, services_xxx = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(len(services), len(services_xxx))
-
@attr(type='gate')
def test_get_service_by_service_and_host_name(self):
resp, services = self.client.list_services()
@@ -95,24 +77,6 @@
self.assertEqual(host_name, services[0]['host'])
self.assertEqual(binary_name, services[0]['binary'])
- @attr(type=['negative', 'gate'])
- def test_get_service_by_invalid_service_and_valid_host(self):
- resp, services = self.client.list_services()
- host_name = services[0]['host']
- params = {'host': host_name, 'binary': 'xxx'}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
- @attr(type=['negative', 'gate'])
- def test_get_service_with_valid_service_and_invalid_host(self):
- resp, services = self.client.list_services()
- binary_name = services[0]['binary']
- params = {'host': 'xxx', 'binary': binary_name}
- resp, services = self.client.list_services(params)
- self.assertEqual(200, resp.status)
- self.assertEqual(0, len(services))
-
class ServicesAdminV3TestXML(ServicesAdminV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/admin/test_services_negative.py b/tempest/api/compute/v3/admin/test_services_negative.py
new file mode 100644
index 0000000..6f583fa
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_services_negative.py
@@ -0,0 +1,70 @@
+# Copyright 2013 NEC Corporation
+# 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 import exceptions
+from tempest.test import attr
+
+
+class ServicesAdminNegativeV3TestJSON(base.BaseV3ComputeAdminTest):
+
+ """
+ Tests Services API. List and Enable/Disable require admin privileges.
+ """
+
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServicesAdminNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.services_admin_client
+ cls.non_admin_client = cls.services_client
+
+ @attr(type=['negative', 'gate'])
+ def test_list_services_with_non_admin_user(self):
+ self.assertRaises(exceptions.Unauthorized,
+ self.non_admin_client.list_services)
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_params(self):
+ # return all services if send the request with invalid parameter
+ resp, services = self.client.list_services()
+ params = {'xxx': 'nova-compute'}
+ resp, services_xxx = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(len(services), len(services_xxx))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_by_invalid_service_and_valid_host(self):
+ resp, services = self.client.list_services()
+ host_name = services[0]['host']
+ params = {'host': host_name, 'binary': 'xxx'}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(services))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_service_with_valid_service_and_invalid_host(self):
+ resp, services = self.client.list_services()
+ binary_name = services[0]['binary']
+ params = {'host': 'xxx', 'binary': binary_name}
+ resp, services = self.client.list_services(params)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(0, len(services))
+
+
+class ServicesAdminNegativeV3TestXML(ServicesAdminNegativeV3TestJSON):
+ _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..3a2d2e5 100644
--- a/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -18,7 +16,7 @@
import datetime
from tempest.api.compute import base
-from tempest import exceptions
+from tempest import test
from tempest.test import attr
import time
@@ -51,6 +49,7 @@
# Returns formatted datetime
return at.strftime('%Y-%m-%dT%H:%M:%S.%f')
+ @test.skip_because(bug='1265416')
@attr(type='gate')
def test_list_usage_all_tenants(self):
# Get usage for all tenants
@@ -61,6 +60,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
+ @test.skip_because(bug='1265416')
@attr(type='gate')
def test_get_usage_tenant(self):
# Get usage for a specific tenant
@@ -72,6 +72,7 @@
self.assertEqual(200, resp.status)
self.assertEqual(len(tenant_usage), 8)
+ @test.skip_because(bug='1265416')
@attr(type='gate')
def test_get_usage_tenant_with_non_admin_user(self):
# Get usage for a specific tenant with non admin user
@@ -83,33 +84,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..58acd07
--- /dev/null
+++ b/tempest/api/compute/v3/admin/test_simple_tenant_usage_negative.py
@@ -0,0 +1,77 @@
+# 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 import test
+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)
+
+ @test.skip_because(bug='1265416')
+ @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)
+
+ @test.skip_because(bug='1265416')
+ @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/services/compute/v3/xml/__init__.py b/tempest/api/compute/v3/certificates/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/api/compute/v3/certificates/__init__.py
diff --git a/tempest/api/compute/v3/certificates/test_certificates.py b/tempest/api/compute/v3/certificates/test_certificates.py
new file mode 100644
index 0000000..4dfa3be
--- /dev/null
+++ b/tempest/api/compute/v3/certificates/test_certificates.py
@@ -0,0 +1,38 @@
+# 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.test import attr
+
+
+class CertificatesV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_create_and_get_root_certificate(self):
+ # create certificates
+ resp, create_body = self.certificates_client.create_certificate()
+ self.assertEqual(201, resp.status)
+ self.assertIn('data', create_body)
+ self.assertIn('private_key', create_body)
+ # get the root certificate
+ resp, body = self.certificates_client.get_certificate('root')
+ self.assertEqual(200, resp.status)
+ self.assertIn('data', body)
+ self.assertIn('private_key', body)
+
+
+class CertificatesV3TestXML(CertificatesV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata.py b/tempest/api/compute/v3/images/test_image_metadata.py
new file mode 100644
index 0000000..89a2f75
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_image_metadata.py
@@ -0,0 +1,112 @@
+# 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.common.utils import data_utils
+from tempest.test import attr
+
+
+class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesMetadataTestJSON, cls).setUpClass()
+ if not cls.config.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ cls.servers_client = cls.servers_client
+ cls.client = cls.images_client
+
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+
+ # Snapshot the server once to save time
+ name = data_utils.rand_name('image')
+ resp, _ = cls.client.create_image(cls.server_id, name, {})
+ cls.image_id = resp['location'].rsplit('/', 1)[1]
+
+ cls.client.wait_for_image_status(cls.image_id, 'ACTIVE')
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.client.delete_image(cls.image_id)
+ super(ImagesMetadataTestJSON, cls).tearDownClass()
+
+ def setUp(self):
+ super(ImagesMetadataTestJSON, self).setUp()
+ meta = {'key1': 'value1', 'key2': 'value2'}
+ resp, _ = self.client.set_image_metadata(self.image_id, meta)
+ self.assertEqual(resp.status, 200)
+
+ @attr(type='gate')
+ def test_list_image_metadata(self):
+ # All metadata key/value pairs for an image should be returned
+ resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ expected = {'key1': 'value1', 'key2': 'value2'}
+ self.assertEqual(expected, resp_metadata)
+
+ @attr(type='gate')
+ def test_set_image_metadata(self):
+ # The metadata for the image should match the new values
+ req_metadata = {'meta2': 'value2', 'meta3': 'value3'}
+ resp, body = self.client.set_image_metadata(self.image_id,
+ req_metadata)
+
+ resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ self.assertEqual(req_metadata, resp_metadata)
+
+ @attr(type='gate')
+ def test_update_image_metadata(self):
+ # The metadata for the image should match the updated values
+ req_metadata = {'key1': 'alt1', 'key3': 'value3'}
+ resp, metadata = self.client.update_image_metadata(self.image_id,
+ req_metadata)
+
+ resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ expected = {'key1': 'alt1', 'key2': 'value2', 'key3': 'value3'}
+ self.assertEqual(expected, resp_metadata)
+
+ @attr(type='gate')
+ def test_get_image_metadata_item(self):
+ # The value for a specific metadata key should be returned
+ resp, meta = self.client.get_image_metadata_item(self.image_id,
+ 'key2')
+ self.assertEqual('value2', meta['key2'])
+
+ @attr(type='gate')
+ def test_set_image_metadata_item(self):
+ # The value provided for the given meta item should be set for
+ # the image
+ meta = {'key1': 'alt'}
+ resp, body = self.client.set_image_metadata_item(self.image_id,
+ 'key1', meta)
+ resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ expected = {'key1': 'alt', 'key2': 'value2'}
+ self.assertEqual(expected, resp_metadata)
+
+ @attr(type='gate')
+ def test_delete_image_metadata_item(self):
+ # The metadata value/key pair should be deleted from the image
+ resp, body = self.client.delete_image_metadata_item(self.image_id,
+ 'key1')
+ resp, resp_metadata = self.client.list_image_metadata(self.image_id)
+ expected = {'key2': 'value2'}
+ self.assertEqual(expected, resp_metadata)
+
+
+class ImagesMetadataTestXML(ImagesMetadataTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_image_metadata_negative.py b/tempest/api/compute/v3/images/test_image_metadata_negative.py
new file mode 100644
index 0000000..4878936
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_image_metadata_negative.py
@@ -0,0 +1,79 @@
+# 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/v3/images/test_images.py b/tempest/api/compute/v3/images/test_images.py
index a179d65..ea097ad 100644
--- a/tempest/api/compute/v3/images/test_images.py
+++ b/tempest/api/compute/v3/images/test_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/compute/v3/images/test_images_oneserver.py b/tempest/api/compute/v3/images/test_images_oneserver.py
new file mode 100644
index 0000000..0cb748b
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_images_oneserver.py
@@ -0,0 +1,136 @@
+# 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 testtools
+
+from tempest.api.compute import base
+from tempest import clients
+from tempest.common.utils import data_utils
+from tempest import config
+from tempest.openstack.common import log as logging
+from tempest.test import attr
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+class ImagesOneServerTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ def tearDown(self):
+ """Terminate test instances created after a test is executed."""
+ for image_id in self.image_ids:
+ self.client.delete_image(image_id)
+ self.image_ids.remove(image_id)
+ super(ImagesOneServerTestJSON, self).tearDown()
+
+ def setUp(self):
+ # NOTE(afazekas): Normally we use the same server with all test cases,
+ # but if it has an issue, we build a new one
+ super(ImagesOneServerTestJSON, self).setUp()
+ # Check if the server is in a clean state after test
+ try:
+ self.servers_client.wait_for_server_status(self.server_id,
+ 'ACTIVE')
+ 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 serious accident
+ self.__class__.server_id = self.rebuild_server(self.server_id)
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesOneServerTestJSON, cls).setUpClass()
+ cls.client = cls.images_client
+ if not cls.config.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ try:
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+ except Exception:
+ cls.tearDownClass()
+ raise
+
+ cls.image_ids = []
+
+ if cls.multi_user:
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls.isolated_creds.get_alt_creds()
+ username, tenant_name, password = creds
+ cls.alt_manager = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name)
+ else:
+ # Use the alt_XXX credentials in the config file
+ cls.alt_manager = clients.AltManager()
+ cls.alt_client = cls.alt_manager.images_client
+
+ def _get_default_flavor_disk_size(self, flavor_id):
+ resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
+ return flavor['disk']
+
+ @testtools.skipUnless(CONF.compute_feature_enabled.create_image,
+ 'Environment unable to create images.')
+ @attr(type='smoke')
+ def test_create_delete_image(self):
+
+ # Create a new image
+ name = data_utils.rand_name('image')
+ meta = {'image_type': 'test'}
+ resp, body = self.client.create_image(self.server_id, name, meta)
+ self.assertEqual(202, resp.status)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.client.wait_for_image_status(image_id, 'ACTIVE')
+
+ # Verify the image was created correctly
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(name, image['name'])
+ self.assertEqual('test', image['metadata']['image_type'])
+
+ resp, original_image = self.client.get_image(self.image_ref)
+
+ # Verify minRAM is the same as the original image
+ self.assertEqual(image['minRam'], original_image['minRam'])
+
+ # Verify minDisk is the same as the original image or the flavor size
+ flavor_disk_size = self._get_default_flavor_disk_size(self.flavor_ref)
+ self.assertIn(str(image['minDisk']),
+ (str(original_image['minDisk']), str(flavor_disk_size)))
+
+ # Verify the image was deleted correctly
+ resp, body = self.client.delete_image(image_id)
+ self.assertEqual('204', resp['status'])
+ self.client.wait_for_resource_deletion(image_id)
+
+ @attr(type=['gate'])
+ def test_create_image_specify_multibyte_character_image_name(self):
+ if self.__class__._interface == "xml":
+ # NOTE(sdague): not entirely accurage, but we'd need a ton of work
+ # in our XML client to make this good
+ raise self.skipException("Not testable in XML")
+ # prefix character is:
+ # http://www.fileformat.info/info/unicode/char/1F4A9/index.htm
+ utf8_name = data_utils.rand_name(u'\xF0\x9F\x92\xA9')
+ resp, body = self.client.create_image(self.server_id, utf8_name)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.addCleanup(self.client.delete_image, image_id)
+ self.assertEqual('202', resp['status'])
+
+
+class ImagesOneServerTestXML(ImagesOneServerTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_images_oneserver_negative.py b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
new file mode 100644
index 0000000..3f93fbe
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_images_oneserver_negative.py
@@ -0,0 +1,160 @@
+# Copyright 2012 OpenStack Foundation
+# 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 import clients
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.openstack.common import log as logging
+from tempest.test import attr
+from tempest.test import skip_because
+
+LOG = logging.getLogger(__name__)
+
+
+class ImagesOneServerNegativeTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ def tearDown(self):
+ """Terminate test instances created after a test is executed."""
+ for image_id in self.image_ids:
+ self.client.delete_image(image_id)
+ self.image_ids.remove(image_id)
+ super(ImagesOneServerNegativeTestJSON, self).tearDown()
+
+ def setUp(self):
+ # NOTE(afazekas): Normally we use the same server with all test cases,
+ # but if it has an issue, we build a new one
+ super(ImagesOneServerNegativeTestJSON, self).setUp()
+ # Check if the server is in a clean state after test
+ try:
+ self.servers_client.wait_for_server_status(self.server_id,
+ 'ACTIVE')
+ 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 serious accident
+ self._reset_server()
+
+ def _reset_server(self):
+ self.__class__.server_id = self.rebuild_server(self.server_id)
+
+ @classmethod
+ def setUpClass(cls):
+ super(ImagesOneServerNegativeTestJSON, cls).setUpClass()
+ cls.client = cls.images_client
+ if not cls.config.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ try:
+ resp, server = cls.create_test_server(wait_until='ACTIVE')
+ cls.server_id = server['id']
+ except Exception:
+ cls.tearDownClass()
+ raise
+
+ cls.image_ids = []
+
+ if cls.multi_user:
+ if cls.config.compute.allow_tenant_isolation:
+ creds = cls.isolated_creds.get_alt_creds()
+ username, tenant_name, password = creds
+ cls.alt_manager = clients.Manager(username=username,
+ password=password,
+ tenant_name=tenant_name)
+ else:
+ # Use the alt_XXX credentials in the config file
+ cls.alt_manager = clients.AltManager()
+ cls.alt_client = cls.alt_manager.images_client
+
+ @skip_because(bug="1006725")
+ @attr(type=['negative', 'gate'])
+ def test_create_image_specify_multibyte_character_image_name(self):
+ if self.__class__._interface == "xml":
+ raise self.skipException("Not testable in XML")
+ # invalid multibyte sequence from:
+ # http://stackoverflow.com/questions/1301402/
+ # example-invalid-utf8-string
+ invalid_name = data_utils.rand_name(u'\xc3\x28')
+ self.assertRaises(exceptions.BadRequest,
+ self.client.create_image, self.server_id,
+ invalid_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_image_specify_invalid_metadata(self):
+ # Return an error when creating image with invalid metadata
+ snapshot_name = data_utils.rand_name('test-snap-')
+ meta = {'': ''}
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.server_id, snapshot_name, meta)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_image_specify_metadata_over_limits(self):
+ # Return an error when creating image with meta data over 256 chars
+ snapshot_name = data_utils.rand_name('test-snap-')
+ meta = {'a' * 260: 'b' * 260}
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.server_id, snapshot_name, meta)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_second_image_when_first_image_is_being_saved(self):
+ # Disallow creating another image when first image is being saved
+
+ # Create first snapshot
+ snapshot_name = data_utils.rand_name('test-snap-')
+ resp, body = self.client.create_image(self.server_id,
+ snapshot_name)
+ self.assertEqual(202, resp.status)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.image_ids.append(image_id)
+ self.addCleanup(self._reset_server)
+
+ # Create second snapshot
+ alt_snapshot_name = data_utils.rand_name('test-snap-')
+ self.assertRaises(exceptions.Conflict, self.client.create_image,
+ self.server_id, alt_snapshot_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_create_image_specify_name_over_256_chars(self):
+ # Return an error if snapshot name over 256 characters is passed
+
+ snapshot_name = data_utils.rand_name('a' * 260)
+ self.assertRaises(exceptions.BadRequest, self.client.create_image,
+ self.server_id, snapshot_name)
+
+ @attr(type=['negative', 'gate'])
+ def test_delete_image_that_is_not_yet_active(self):
+ # Return an error while trying to delete an image what is creating
+
+ snapshot_name = data_utils.rand_name('test-snap-')
+ resp, body = self.client.create_image(self.server_id, snapshot_name)
+ self.assertEqual(202, resp.status)
+ image_id = data_utils.parse_image_id(resp['location'])
+ self.image_ids.append(image_id)
+ self.addCleanup(self._reset_server)
+
+ # Do not wait, attempt to delete the image, ensure it's successful
+ resp, body = self.client.delete_image(image_id)
+ self.assertEqual('204', resp['status'])
+ self.image_ids.remove(image_id)
+
+ self.assertRaises(exceptions.NotFound, self.client.get_image, image_id)
+
+
+class ImagesOneServerNegativeTestXML(ImagesOneServerNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/images/test_list_image_filters.py b/tempest/api/compute/v3/images/test_list_image_filters.py
new file mode 100644
index 0000000..c04729c
--- /dev/null
+++ b/tempest/api/compute/v3/images/test_list_image_filters.py
@@ -0,0 +1,229 @@
+# 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.openstack.common import log as logging
+from tempest.test import attr
+
+
+LOG = logging.getLogger(__name__)
+
+
+class ListImageFiltersTestJSON(base.BaseV2ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ListImageFiltersTestJSON, cls).setUpClass()
+ if not cls.config.service_available.glance:
+ skip_msg = ("%s skipped as glance is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+ cls.client = cls.images_client
+ cls.image_ids = []
+
+ try:
+ resp, cls.server1 = cls.create_test_server()
+ resp, cls.server2 = cls.create_test_server(wait_until='ACTIVE')
+ # NOTE(sdague) this is faster than doing the sync wait_util on both
+ cls.servers_client.wait_for_server_status(cls.server1['id'],
+ 'ACTIVE')
+
+ # Create images to be used in the filter tests
+ resp, cls.image1 = cls.create_image_from_server(
+ cls.server1['id'], wait_until='ACTIVE')
+ cls.image1_id = cls.image1['id']
+
+ # Servers have a hidden property for when they are being imaged
+ # Performing back-to-back create image calls on a single
+ # server will sometimes cause failures
+ resp, cls.image3 = cls.create_image_from_server(
+ cls.server2['id'], wait_until='ACTIVE')
+ cls.image3_id = cls.image3['id']
+
+ # Wait for the server to be active after the image upload
+ resp, cls.image2 = cls.create_image_from_server(
+ cls.server1['id'], wait_until='ACTIVE')
+ cls.image2_id = cls.image2['id']
+ except Exception:
+ LOG.exception('setUpClass failed')
+ cls.tearDownClass()
+ raise
+
+ @attr(type=['negative', 'gate'])
+ def test_get_image_not_existing(self):
+ # Check raises a NotFound
+ self.assertRaises(exceptions.NotFound, self.client.get_image,
+ "nonexistingimageid")
+
+ @attr(type='gate')
+ def test_list_images_filter_by_status(self):
+ # The list of images should contain only images with the
+ # provided status
+ params = {'status': 'ACTIVE'}
+ resp, images = self.client.list_images(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_filter_by_name(self):
+ # List of all images should contain the expected images filtered
+ # by name
+ params = {'name': self.image1['name']}
+ resp, images = self.client.list_images(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_filter_by_server_id(self):
+ # The images should contain images filtered by server id
+ params = {'server': self.server1['id']}
+ resp, images = self.client.list_images(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]),
+ "Failed to find image %s in images. Got images %s" %
+ (self.image1_id, images))
+ self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_filter_by_server_ref(self):
+ # The list of servers should be filtered by server ref
+ server_links = self.server2['links']
+
+ # Try all server link types
+ for link in server_links:
+ params = {'server': link['href']}
+ resp, images = self.client.list_images(params)
+
+ self.assertFalse(any([i for i in images
+ if i['id'] == self.image1_id]))
+ self.assertFalse(any([i for i in images
+ if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images
+ if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_filter_by_type(self):
+ # The list of servers should be filtered by image type
+ params = {'type': 'snapshot'}
+ resp, images = self.client.list_images(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
+
+ @attr(type='gate')
+ def test_list_images_limit_results(self):
+ # Verify only the expected number of results are returned
+ params = {'limit': '1'}
+ resp, images = self.client.list_images(params)
+ # when _interface='xml', one element for images_links in images
+ # ref: Question #224349
+ self.assertEqual(1, len([x for x in images if 'id' in x]))
+
+ @attr(type='gate')
+ def test_list_images_filter_by_changes_since(self):
+ # Verify only updated images are returned in the detailed list
+
+ # Becoming ACTIVE will modify the updated time
+ # Filter by the image's created time
+ params = {'changes-since': self.image3['created']}
+ resp, images = self.client.list_images(params)
+ found = any([i for i in images if i['id'] == self.image3_id])
+ self.assertTrue(found)
+
+ @attr(type='gate')
+ def test_list_images_with_detail_filter_by_status(self):
+ # Detailed list of all images should only contain images
+ # with the provided status
+ params = {'status': 'ACTIVE'}
+ resp, images = self.client.list_images_with_detail(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_with_detail_filter_by_name(self):
+ # Detailed list of all images should contain the expected
+ # images filtered by name
+ params = {'name': self.image1['name']}
+ resp, images = self.client.list_images_with_detail(params)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_with_detail_limit_results(self):
+ # Verify only the expected number of results (with full details)
+ # are returned
+ params = {'limit': '1'}
+ resp, images = self.client.list_images_with_detail(params)
+ self.assertEqual(1, len(images))
+
+ @attr(type='gate')
+ def test_list_images_with_detail_filter_by_server_ref(self):
+ # Detailed list of servers should be filtered by server ref
+ server_links = self.server2['links']
+
+ # Try all server link types
+ for link in server_links:
+ params = {'server': link['href']}
+ resp, images = self.client.list_images_with_detail(params)
+
+ self.assertFalse(any([i for i in images
+ if i['id'] == self.image1_id]))
+ self.assertFalse(any([i for i in images
+ if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images
+ if i['id'] == self.image3_id]))
+
+ @attr(type='gate')
+ def test_list_images_with_detail_filter_by_type(self):
+ # The detailed list of servers should be filtered by image type
+ params = {'type': 'snapshot'}
+ resp, images = self.client.list_images_with_detail(params)
+ resp, image4 = self.client.get_image(self.image_ref)
+
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
+ self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+ self.assertFalse(any([i for i in images if i['id'] == self.image_ref]))
+
+ @attr(type='gate')
+ def test_list_images_with_detail_filter_by_changes_since(self):
+ # Verify an update image is returned
+
+ # Becoming ACTIVE will modify the updated time
+ # Filter by the image's created time
+ params = {'changes-since': self.image1['created']}
+ resp, images = self.client.list_images_with_detail(params)
+ self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+
+ @attr(type=['negative', 'gate'])
+ def test_get_nonexistent_image(self):
+ # Negative test: GET on non-existent image should fail
+ self.assertRaises(exceptions.NotFound, self.client.get_image, 999)
+
+
+class ListImageFiltersTestXML(ListImageFiltersTestJSON):
+ _interface = 'xml'
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/api/compute/v3/keypairs/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/api/compute/v3/keypairs/__init__.py
diff --git a/tempest/api/compute/v3/keypairs/test_keypairs.py b/tempest/api/compute/v3/keypairs/test_keypairs.py
new file mode 100644
index 0000000..3b449f7
--- /dev/null
+++ b/tempest/api/compute/v3/keypairs/test_keypairs.py
@@ -0,0 +1,122 @@
+# 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.common.utils import data_utils
+from tempest import test
+
+
+class KeyPairsV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(KeyPairsV3TestJSON, cls).setUpClass()
+ cls.client = cls.keypairs_client
+
+ def _delete_keypair(self, keypair_name):
+ resp, _ = self.client.delete_keypair(keypair_name)
+ self.assertEqual(204, resp.status)
+
+ def _create_keypair(self, keypair_name, pub_key=None):
+ resp, body = self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self._delete_keypair, keypair_name)
+ return resp, body
+
+ @test.attr(type='gate')
+ def test_keypairs_create_list_delete(self):
+ # Keypairs created should be available in the response list
+ # Create 3 keypairs
+ key_list = list()
+ for i in range(3):
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ # Need to pop these keys so that our compare doesn't fail later,
+ # as the keypair dicts from list API doesn't have them.
+ keypair.pop('private_key')
+ keypair.pop('user_id')
+ self.assertEqual(201, resp.status)
+ key_list.append(keypair)
+ # Fetch all keypairs and verify the list
+ # has all created keypairs
+ resp, fetched_list = self.client.list_keypairs()
+ self.assertEqual(200, resp.status)
+ # We need to remove the extra 'keypair' element in the
+ # returned dict. See comment in keypairs_client.list_keypairs()
+ new_list = list()
+ for keypair in fetched_list:
+ new_list.append(keypair['keypair'])
+ fetched_list = new_list
+ # Now check if all the created keypairs are in the fetched list
+ missing_kps = [kp for kp in key_list if kp not in fetched_list]
+ self.assertFalse(missing_kps,
+ "Failed to find keypairs %s in fetched list"
+ % ', '.join(m_key['name'] for m_key in missing_kps))
+
+ @test.attr(type='gate')
+ def test_keypair_create_delete(self):
+ # Keypair should be created, verified and deleted
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ self.assertEqual(201, resp.status)
+ private_key = keypair['private_key']
+ key_name = keypair['name']
+ self.assertEqual(key_name, k_name,
+ "The created keypair name is not equal "
+ "to the requested name")
+ self.assertTrue(private_key is not None,
+ "Field private_key is empty or not found.")
+
+ @test.attr(type='gate')
+ def test_get_keypair_detail(self):
+ # Keypair should be created, Got details by name and deleted
+ k_name = data_utils.rand_name('keypair-')
+ resp, keypair = self._create_keypair(k_name)
+ resp, keypair_detail = self.client.get_keypair(k_name)
+ self.assertEqual(200, resp.status)
+ self.assertIn('name', keypair_detail)
+ self.assertIn('public_key', keypair_detail)
+ self.assertEqual(keypair_detail['name'], k_name,
+ "The created keypair name is not equal "
+ "to requested name")
+ public_key = keypair_detail['public_key']
+ self.assertTrue(public_key is not None,
+ "Field public_key is empty or not found.")
+
+ @test.attr(type='gate')
+ def test_keypair_create_with_pub_key(self):
+ # Keypair should be created with a given public key
+ k_name = data_utils.rand_name('keypair-')
+ pub_key = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCs"
+ "Ne3/1ILNCqFyfYWDeTKLD6jEXC2OQHLmietMWW+/vd"
+ "aZq7KZEwO0jhglaFjU1mpqq4Gz5RX156sCTNM9vRbw"
+ "KAxfsdF9laBYVsex3m3Wmui3uYrKyumsoJn2g9GNnG1P"
+ "I1mrVjZ61i0GY3khna+wzlTpCCmy5HNlrmbj3XLqBUpip"
+ "TOXmsnr4sChzC53KCd8LXuwc1i/CZPvF+3XipvAgFSE53pCt"
+ "LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
+ "XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
+ "snSA8wzBx3A/8y9Pp1B nova@ubuntu")
+ resp, keypair = self._create_keypair(k_name, pub_key)
+ self.assertEqual(201, resp.status)
+ self.assertFalse('private_key' in keypair,
+ "Field private_key is not empty!")
+ key_name = keypair['name']
+ self.assertEqual(key_name, k_name,
+ "The created keypair name is not equal "
+ "to the requested name!")
+
+
+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
new file mode 100644
index 0000000..be7ee65
--- /dev/null
+++ b/tempest/api/compute/v3/keypairs/test_keypairs_negative.py
@@ -0,0 +1,99 @@
+# Copyright 2012 OpenStack Foundation
+# 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 KeyPairsNegativeV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(KeyPairsNegativeV3TestJSON, cls).setUpClass()
+ cls.client = cls.keypairs_client
+
+ def _create_keypair(self, keypair_name, pub_key=None):
+ self.client.create_keypair(keypair_name, pub_key)
+ self.addCleanup(self.client.delete_keypair, keypair_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_keypair_create_with_invalid_pub_key(self):
+ # Keypair should not be created with a non RSA public key
+ k_name = data_utils.rand_name('keypair-')
+ pub_key = "ssh-rsa JUNK nova@ubuntu"
+ self.assertRaises(exceptions.BadRequest,
+ self._create_keypair, k_name, pub_key)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_keypair_delete_nonexistent_key(self):
+ # Non-existent key deletion should throw a proper error
+ k_name = data_utils.rand_name("keypair-non-existent-")
+ self.assertRaises(exceptions.NotFound, self.client.delete_keypair,
+ k_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_empty_public_key(self):
+ # Keypair should not be created with an empty public key
+ k_name = data_utils.rand_name("keypair-")
+ pub_key = ' '
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name, pub_key)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_when_public_key_bits_exceeds_maximum(self):
+ # Keypair should not be created when public key bits are too long
+ k_name = data_utils.rand_name("keypair-")
+ pub_key = 'ssh-rsa ' + 'A' * 2048 + ' openstack@ubuntu'
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name, pub_key)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_duplicate_name(self):
+ # Keypairs with duplicate names should not be created
+ k_name = data_utils.rand_name('keypair-')
+ resp, _ = self.client.create_keypair(k_name)
+ 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)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_empty_name_string(self):
+ # Keypairs with name being an empty string should not be created
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ '')
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_with_long_keynames(self):
+ # Keypairs with name longer than 255 chars should not be created
+ k_name = 'keypair-'.ljust(260, '0')
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name)
+
+ @test.attr(type=['negative', 'gate'])
+ def test_create_keypair_invalid_name(self):
+ # Keypairs with name being an invalid name should not be created
+ k_name = 'key_/.\@:'
+ self.assertRaises(exceptions.BadRequest, self._create_keypair,
+ k_name)
+
+
+class KeyPairsNegativeV3TestXML(KeyPairsNegativeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_attach_interfaces.py b/tempest/api/compute/v3/servers/test_attach_interfaces.py
index f208a4b..8f69c54 100644
--- a/tempest/api/compute/v3/servers/test_attach_interfaces.py
+++ b/tempest/api/compute/v3/servers/test_attach_interfaces.py
@@ -14,6 +14,7 @@
# under the License.
from tempest.api.compute import base
+from tempest import exceptions
from tempest.test import attr
import time
@@ -26,6 +27,8 @@
def setUpClass(cls):
if not cls.config.service_available.neutron:
raise cls.skipException("Neutron is required")
+ # This test class requires network and subnet
+ cls.set_network_resources(network=True, subnet=True)
super(AttachInterfacesV3TestJSON, cls).setUpClass()
cls.client = cls.interfaces_client
@@ -73,15 +76,19 @@
# NOTE(danms): delete not the first or last, but one in the middle
iface = ifs[1]
self.client.delete_interface(server['id'], iface['port_id'])
- for i in range(0, 5):
- _r, _ifs = self.client.list_interfaces(server['id'])
- if len(ifs) != len(_ifs):
- break
- time.sleep(1)
+ _ifs = self.client.list_interfaces(server['id'])[1]
+ start = int(time.time())
- self.assertEqual(len(_ifs), len(ifs) - 1)
- for _iface in _ifs:
- self.assertNotEqual(iface['port_id'], _iface['port_id'])
+ while len(ifs) == len(_ifs):
+ time.sleep(self.build_interval)
+ _ifs = self.client.list_interfaces(server['id'])[1]
+ timed_out = int(time.time()) - start >= self.build_timeout
+ if len(ifs) == len(_ifs) and timed_out:
+ message = ('Failed to delete interface within '
+ 'the required time: %s sec.' % self.build_timeout)
+ raise exceptions.TimeoutException(message)
+
+ self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs])
return _ifs
def _compare_iface_list(self, list1, list2):
@@ -92,7 +99,7 @@
self.assertEqual(sorted(list1), sorted(list2))
- @attr(type='gate')
+ @attr(type='smoke')
def test_create_list_show_delete_interfaces(self):
server, ifs = self._create_server_get_interfaces()
interface_count = len(ifs)
diff --git a/tempest/api/compute/v3/servers/test_attach_volume.py b/tempest/api/compute/v3/servers/test_attach_volume.py
new file mode 100644
index 0000000..ff95ca4
--- /dev/null
+++ b/tempest/api/compute/v3/servers/test_attach_volume.py
@@ -0,0 +1,118 @@
+# 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.
+
+import testtools
+
+from tempest.api.compute import base
+from tempest.common.utils.linux.remote_client import RemoteClient
+from tempest import config
+from tempest.test import attr
+
+CONF = config.CONF
+
+
+class AttachVolumeV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+ run_ssh = CONF.compute.run_ssh
+
+ def __init__(self, *args, **kwargs):
+ super(AttachVolumeV3TestJSON, self).__init__(*args, **kwargs)
+ self.server = None
+ self.volume = None
+ self.attached = False
+
+ @classmethod
+ def setUpClass(cls):
+ super(AttachVolumeV3TestJSON, cls).setUpClass()
+ cls.device = cls.config.compute.volume_device_name
+ if not cls.config.service_available.cinder:
+ skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
+ raise cls.skipException(skip_msg)
+
+ def _detach(self, server_id, volume_id):
+ if self.attached:
+ self.servers_client.detach_volume(server_id, volume_id)
+ self.volumes_client.wait_for_volume_status(volume_id, 'available')
+
+ def _delete_volume(self):
+ if self.volume:
+ self.volumes_client.delete_volume(self.volume['id'])
+ self.volume = None
+
+ def _create_and_attach(self):
+ # Start a server and wait for it to become ready
+ admin_pass = self.image_ssh_password
+ resp, server = self.create_test_server(wait_until='ACTIVE',
+ admin_password=admin_pass)
+ self.server = server
+
+ # Record addresses so that we can ssh later
+ resp, server['addresses'] = \
+ self.servers_client.list_addresses(server['id'])
+
+ # Create a volume and wait for it to become ready
+ resp, volume = self.volumes_client.create_volume(1,
+ display_name='test')
+ self.volume = volume
+ self.addCleanup(self._delete_volume)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'available')
+
+ # Attach the volume to the server
+ self.servers_client.attach_volume(server['id'], volume['id'],
+ device='/dev/%s' % self.device)
+ self.volumes_client.wait_for_volume_status(volume['id'], 'in-use')
+
+ self.attached = True
+ self.addCleanup(self._detach, server['id'], volume['id'])
+
+ @testtools.skipIf(not run_ssh, 'SSH required for this test')
+ @attr(type='gate')
+ def test_attach_detach_volume(self):
+ # Stop and Start a server with an attached volume, ensuring that
+ # the volume remains attached.
+ self._create_and_attach()
+ server = self.server
+ volume = self.volume
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ server['admin_password'])
+ partitions = linux_client.get_partitions()
+ self.assertIn(self.device, partitions)
+
+ self._detach(server['id'], volume['id'])
+ self.attached = False
+
+ self.servers_client.stop(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'SHUTOFF')
+
+ self.servers_client.start(server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+
+ linux_client = RemoteClient(server,
+ self.image_ssh_user,
+ server['admin_password'])
+ partitions = linux_client.get_partitions()
+ self.assertNotIn(self.device, partitions)
+
+
+class AttachVolumeV3TestXML(AttachVolumeV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_create_server.py b/tempest/api/compute/v3/servers/test_create_server.py
index 24ade96..7c63865 100644
--- a/tempest/api/compute/v3/servers/test_create_server.py
+++ b/tempest/api/compute/v3/servers/test_create_server.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,22 +18,23 @@
import netaddr
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
-from tempest.test import attr
+from tempest import config
+from tempest import test
+
+CONF = config.CONF
-class ServersTestJSON(base.BaseV2ComputeTest):
+class ServersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ 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'
@@ -46,36 +45,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()
@@ -83,7 +83,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()
@@ -92,14 +92,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
@@ -108,23 +108,125 @@
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 ServersWithSpecificFlavorV3TestJSON(base.BaseV3ComputeAdminTest):
+ _interface = 'json'
+ run_ssh = CONF.compute.run_ssh
+ disk_config = 'AUTO'
+
+ @classmethod
+ def setUpClass(cls):
+ super(ServersWithSpecificFlavorV3TestJSON, cls).setUpClass()
+ cls.meta = {'hello': 'world'}
+ cls.accessIPv4 = '1.1.1.1'
+ cls.accessIPv6 = '0000:0000:0000:0000:0000:babe:220.12.22.2'
+ cls.name = data_utils.rand_name('server')
+ file_contents = 'This is a test file.'
+ personality = [{'path': '/test.txt',
+ 'contents': base64.b64encode(file_contents)}]
+ cls.client = cls.servers_client
+ cls.flavor_client = cls.flavors_admin_client
+ cli_resp = cls.create_test_server(name=cls.name,
+ meta=cls.meta,
+ 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['admin_password']
+ cls.client.wait_for_server_status(cls.server_initial['id'], 'ACTIVE')
+ resp, cls.server = cls.client.get_server(cls.server_initial['id'])
+
+ @testtools.skipIf(not run_ssh, 'Instance validation tests are disabled.')
+ @test.attr(type='gate')
+ def test_verify_created_server_ephemeral_disk(self):
+ # Verify that the ephemeral disk is created when creating server
+
+ def create_flavor_with_extra_specs(self):
+ flavor_with_eph_disk_name = data_utils.rand_name('eph_flavor')
+ flavor_with_eph_disk_id = data_utils.rand_int_id(start=1000)
+ ram = 512
+ vcpus = 1
+ disk = 10
+
+ # Create a flavor with extra specs
+ resp, flavor = (self.flavor_client.
+ create_flavor(flavor_with_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_with_eph_disk_id,
+ ephemeral=1, swap=1024, rxtx=1))
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(200, resp.status)
+
+ return flavor['id']
+
+ def create_flavor_without_extra_specs(self):
+ flavor_no_eph_disk_name = data_utils.rand_name('no_eph_flavor')
+ flavor_no_eph_disk_id = data_utils.rand_int_id(start=1000)
+
+ ram = 512
+ vcpus = 1
+ disk = 10
+
+ # Create a flavor without extra specs
+ resp, flavor = (self.flavor_client.
+ create_flavor(flavor_no_eph_disk_name,
+ ram, vcpus, disk,
+ flavor_no_eph_disk_id))
+ self.addCleanup(self.flavor_clean_up, flavor['id'])
+ self.assertEqual(200, resp.status)
+
+ return flavor['id']
+
+ def flavor_clean_up(self, flavor_id):
+ resp, body = self.flavor_client.delete_flavor(flavor_id)
+ self.assertEqual(resp.status, 202)
+ self.flavor_client.wait_for_resource_deletion(flavor_id)
+
+ flavor_with_eph_disk_id = self.create_flavor_with_extra_specs()
+ flavor_no_eph_disk_id = self.create_flavor_without_extra_specs()
+
+ admin_pass = self.image_ssh_password
+
+ resp, server_no_eph_disk = (self.
+ create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_no_eph_disk_id))
+ resp, server_with_eph_disk = (self.create_test_server(
+ wait_until='ACTIVE',
+ adminPass=admin_pass,
+ flavor=flavor_with_eph_disk_id))
+ # Get partition number of server without extra specs.
+ linux_client = RemoteClient(server_no_eph_disk,
+ self.ssh_user, self.password)
+ partition_num = len(linux_client.get_partitions())
+
+ linux_client = RemoteClient(server_with_eph_disk,
+ self.ssh_user, self.password)
+ self.assertEqual(partition_num + 1, linux_client.get_partitions())
+
+
+class ServersV3TestManualDisk(ServersV3TestJSON):
disk_config = 'MANUAL'
@classmethod
def setUpClass(cls):
- if not compute.DISK_CONFIG_ENABLED:
+ 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'
+
+
+class ServersWithSpecificFlavorV3TestXML(ServersWithSpecificFlavorV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_instance_actions.py b/tempest/api/compute/v3/servers/test_instance_actions.py
index ea92c9f..0b4b9bf 100644
--- a/tempest/api/compute/v3/servers/test_instance_actions.py
+++ b/tempest/api/compute/v3/servers/test_instance_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index d333a1d..99cf8e1 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -23,6 +21,8 @@
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ListServerFiltersV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@@ -174,6 +174,23 @@
self.assertEqual(['ACTIVE'] * 3, [x['status'] for x in servers])
@attr(type='gate')
+ def test_list_servers_filter_by_shutoff_status(self):
+ # Filter the list of servers by server shutoff status
+ params = {'status': 'shutoff'}
+ self.client.stop(self.s1['id'])
+ self.client.wait_for_server_status(self.s1['id'],
+ 'SHUTOFF')
+ resp, body = self.client.list_servers(params)
+ self.client.start(self.s1['id'])
+ self.client.wait_for_server_status(self.s1['id'],
+ 'ACTIVE')
+ servers = body['servers']
+
+ self.assertIn(self.s1['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s2['id'], map(lambda x: x['id'], servers))
+ self.assertNotIn(self.s3['id'], map(lambda x: x['id'], servers))
+
+ @attr(type='gate')
def test_list_servers_filtered_by_name_wildcard(self):
# List all servers that contains '-instance' in name
params = {'name': '-instance'}
@@ -211,7 +228,7 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@skip_because(bug="1182883",
- condition=config.TempestConfig().service_available.neutron)
+ condition=CONF.service_available.neutron)
@attr(type='gate')
def test_list_servers_filtered_by_ip_regex(self):
# Filter servers by regex ip
diff --git a/tempest/api/compute/v3/servers/test_list_servers_negative.py b/tempest/api/compute/v3/servers/test_list_servers_negative.py
index 3f7f885..7217148 100644
--- a/tempest/api/compute/v3/servers/test_list_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_list_servers_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,69 +16,18 @@
import datetime
from tempest.api.compute import base
-from tempest import clients
from tempest import exceptions
from tempest.test import attr
class ListServersNegativeV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
-
- @classmethod
- def _ensure_no_servers(cls, servers, username, tenant_name):
- """
- If there are servers and there is tenant isolation then a
- skipException is raised to skip the test since it requires no servers
- to already exist for the given user/tenant.
- If there are servers and there is not tenant isolation then the test
- blocks while the servers are being deleted.
- """
- if len(servers):
- if not cls.config.compute.allow_tenant_isolation:
- for srv in servers:
- cls.client.wait_for_server_termination(srv['id'],
- ignore_error=True)
- else:
- msg = ("User/tenant %(u)s/%(t)s already have "
- "existing server instances. Skipping test." %
- {'u': username, 't': tenant_name})
- raise cls.skipException(msg)
+ force_tenant_isolation = True
@classmethod
def setUpClass(cls):
super(ListServersNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
- cls.servers = []
-
- if cls.multi_user:
- if cls.config.compute.allow_tenant_isolation:
- creds = cls.isolated_creds.get_alt_creds()
- username, tenant_name, password = creds
- cls.alt_manager = clients.Manager(username=username,
- password=password,
- tenant_name=tenant_name)
- else:
- # Use the alt_XXX credentials in the config file
- cls.alt_manager = clients.AltManager()
- cls.alt_client = cls.alt_manager.servers_client
-
- # Under circumstances when there is not a tenant/user
- # created for the test case, the test case checks
- # to see if there are existing servers for the
- # either the normal user/tenant or the alt user/tenant
- # and if so, the whole test is skipped. We do this
- # because we assume a baseline of no servers at the
- # start of the test instead of destroying any existing
- # servers.
- resp, body = cls.client.list_servers()
- cls._ensure_no_servers(body['servers'],
- cls.os.username,
- cls.os.tenant_name)
-
- resp, body = cls.alt_client.list_servers()
- cls._ensure_no_servers(body['servers'],
- cls.alt_manager.username,
- cls.alt_manager.tenant_name)
# The following servers are created for use
# by the test methods in this class. These
diff --git a/tempest/api/compute/v3/servers/test_multiple_create.py b/tempest/api/compute/v3/servers/test_multiple_create.py
index 080bd1a..c7377a6 100644
--- a/tempest/api/compute/v3/servers/test_multiple_create.py
+++ b/tempest/api/compute/v3/servers/test_multiple_create.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
@@ -18,10 +16,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 +36,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 +47,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 +79,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 +89,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 090f4dd..eb7bc94 100644
--- a/tempest/api/compute/v3/servers/test_server_actions.py
+++ b/tempest/api/compute/v3/servers/test_server_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,26 +13,25 @@
# License for the specific language governing permissions and limitations
# under the License.
-import base64
import time
import testtools
-from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.test import attr
from tempest.test import skip_because
+CONF = config.CONF
+
class ServerActionsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- resize_available = tempest.config.TempestConfig().\
- compute_feature_enabled.resize
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ resize_available = CONF.compute_feature_enabled.resize
+ run_ssh = CONF.compute.run_ssh
def setUp(self):
# NOTE(afazekas): Normally we use the same server with all test cases,
@@ -53,7 +50,7 @@
cls.client = cls.servers_client
cls.server_id = cls.rebuild_server(None)
- @testtools.skipUnless(compute.CHANGE_PASSWORD_AVAILABLE,
+ @testtools.skipUnless(CONF.compute_feature_enabled.change_password,
'Change password not available.')
@attr(type='gate')
def test_change_server_password(self):
@@ -67,7 +64,7 @@
# Verify that the user can authenticate with the new password
resp, server = self.client.get_server(self.server_id)
linux_client = RemoteClient(server, self.ssh_user, new_password)
- self.assertTrue(linux_client.can_authenticate())
+ linux_client.validate_authentication()
@attr(type='smoke')
def test_reboot_server_hard(self):
@@ -113,16 +110,13 @@
# The server should be rebuilt using the provided image and data
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
- file_contents = 'Test server rebuild.'
- personality = [{'path': 'rebuild.txt',
- 'contents': base64.b64encode(file_contents)}]
password = 'rebuildPassw0rd'
resp, rebuilt_server = self.client.rebuild(self.server_id,
self.image_ref_alt,
name=new_name,
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'])
@@ -133,18 +127,47 @@
# Verify the server properties after the rebuild completes
self.client.wait_for_server_status(rebuilt_server['id'], 'ACTIVE')
resp, server = self.client.get_server(rebuilt_server['id'])
- rebuilt_image_id = rebuilt_server['image']['id']
+ rebuilt_image_id = server['image']['id']
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
- self.assertEqual(new_name, rebuilt_server['name'])
+ self.assertEqual(new_name, server['name'])
if self.run_ssh:
# Verify that the user can authenticate with the provided password
linux_client = RemoteClient(server, self.ssh_user, password)
- self.assertTrue(linux_client.can_authenticate())
+ 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)
+ resp, server = self.client.get_server(server_id)
current_flavor = server['flavor']['id']
new_flavor_ref = self.flavor_ref_alt \
if current_flavor == self.flavor_ref else self.flavor_ref
@@ -199,32 +222,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 +351,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_server_addresses.py b/tempest/api/compute/v3/servers/test_server_addresses.py
index 82588b6..6ecd28b 100644
--- a/tempest/api/compute/v3/servers/test_server_addresses.py
+++ b/tempest/api/compute/v3/servers/test_server_addresses.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -25,6 +23,8 @@
@classmethod
def setUpClass(cls):
+ # This test module might use a network and a subnet
+ cls.set_network_resources(network=True, subnet=True)
super(ServerAddressesV3Test, cls).setUpClass()
cls.client = cls.servers_client
diff --git a/tempest/api/compute/v3/servers/test_server_metadata.py b/tempest/api/compute/v3/servers/test_server_metadata.py
index ee0f4a9..0571f38 100644
--- a/tempest/api/compute/v3/servers/test_server_metadata.py
+++ b/tempest/api/compute/v3/servers/test_server_metadata.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,12 +18,12 @@
from tempest.test import attr
-class ServerMetadataTestJSON(base.BaseV2ComputeTest):
+class ServerMetadataV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
@classmethod
def setUpClass(cls):
- super(ServerMetadataTestJSON, cls).setUpClass()
+ super(ServerMetadataV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
cls.quotas = cls.quotas_client
cls.admin_client = cls._get_identity_admin_client()
@@ -37,7 +35,7 @@
cls.server_id = server['id']
def setUp(self):
- super(ServerMetadataTestJSON, self).setUp()
+ super(ServerMetadataV3TestJSON, self).setUp()
meta = {'key1': 'value1', 'key2': 'value2'}
resp, _ = self.client.set_server_metadata(self.server_id, meta)
self.assertEqual(resp.status, 200)
@@ -88,7 +86,7 @@
meta = {'key1': 'alt1', 'key3': 'value3'}
resp, metadata = self.client.update_server_metadata(self.server_id,
meta)
- self.assertEqual(200, resp.status)
+ self.assertEqual(201, resp.status)
# Verify the values have been updated to the proper values
resp, resp_metadata = self.client.list_server_metadata(self.server_id)
@@ -213,5 +211,5 @@
self.server_id, meta=meta, no_metadata_field=True)
-class ServerMetadataTestXML(ServerMetadataTestJSON):
+class ServerMetadataV3TestXML(ServerMetadataV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_server_personality.py b/tempest/api/compute/v3/servers/test_server_personality.py
deleted file mode 100644
index c6d2e44..0000000
--- a/tempest/api/compute/v3/servers/test_server_personality.py
+++ /dev/null
@@ -1,68 +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.
-
-import base64
-
-from tempest.api.compute import base
-from tempest import exceptions
-from tempest.test import attr
-
-
-class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
- _interface = 'json'
-
- @classmethod
- def setUpClass(cls):
- super(ServerPersonalityTestJSON, cls).setUpClass()
- cls.client = cls.servers_client
- cls.user_client = cls.limits_client
-
- @attr(type='gate')
- def test_personality_files_exceed_limit(self):
- # Server creation should fail if greater than the maximum allowed
- # number of files are injected into the server.
- file_contents = 'This is a test file.'
- personality = []
- max_file_limit = \
- self.user_client.get_specific_absolute_limit("maxPersonality")
- for i in range(0, int(max_file_limit) + 1):
- path = 'etc/test' + str(i) + '.txt'
- personality.append({'path': path,
- 'contents': base64.b64encode(file_contents)})
- self.assertRaises(exceptions.OverLimit, self.create_test_server,
- personality=personality)
-
- @attr(type='gate')
- def test_can_create_server_with_max_number_personality_files(self):
- # Server should be created successfully if maximum allowed number of
- # files is injected into the server during creation.
- file_contents = 'This is a test file.'
- max_file_limit = \
- self.user_client.get_specific_absolute_limit("maxPersonality")
- person = []
- for i in range(0, int(max_file_limit)):
- path = 'etc/test' + str(i) + '.txt'
- person.append({
- 'path': path,
- 'contents': base64.b64encode(file_contents),
- })
- resp, server = self.create_test_server(personality=person)
- self.assertEqual('202', resp['status'])
-
-
-class ServerPersonalityTestXML(ServerPersonalityTestJSON):
- _interface = "xml"
diff --git a/tempest/api/compute/v3/servers/test_server_rescue.py b/tempest/api/compute/v3/servers/test_server_rescue.py
index eebd4d8..870432b 100644
--- a/tempest/api/compute/v3/servers/test_server_rescue.py
+++ b/tempest/api/compute/v3/servers/test_server_rescue.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
@@ -56,7 +54,7 @@
cls.rescue_password = resc_server['admin_password']
cls.servers_client.rescue_server(
- cls.rescue_id, cls.rescue_password)
+ cls.rescue_id, admin_password=cls.rescue_password)
cls.servers_client.wait_for_server_status(cls.rescue_id, 'RESCUE')
def setUp(self):
@@ -93,7 +91,7 @@
@attr(type='smoke')
def test_rescue_unrescue_instance(self):
resp, body = self.servers_client.rescue_server(
- self.server_id, self.password)
+ self.server_id, admin_password=self.password)
self.assertEqual(202, resp.status)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
resp, body = self.servers_client.unrescue_server(self.server_id)
@@ -134,7 +132,8 @@
@attr(type=['negative', 'gate'])
def test_rescued_vm_attach_volume(self):
# Rescue the server
- self.servers_client.rescue_server(self.server_id, self.password)
+ self.servers_client.rescue_server(self.server_id,
+ admin_password=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
self.addCleanup(self._unrescue, self.server_id)
@@ -155,7 +154,8 @@
self.volume_to_detach['id'], 'in-use')
# Rescue the server
- self.servers_client.rescue_server(self.server_id, self.password)
+ self.servers_client.rescue_server(self.server_id,
+ admin_password=self.password)
self.servers_client.wait_for_server_status(self.server_id, 'RESCUE')
# addCleanup is a LIFO queue
self.addCleanup(self._detach, self.server_id,
diff --git a/tempest/api/compute/v3/servers/test_servers.py b/tempest/api/compute/v3/servers/test_servers.py
index d72476d..40ca0f0 100644
--- a/tempest/api/compute/v3/servers/test_servers.py
+++ b/tempest/api/compute/v3/servers/test_servers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,31 +15,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 +58,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 +71,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 +86,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 8142250..29cbc92 100644
--- a/tempest/api/compute/v3/servers/test_servers_negative.py
+++ b/tempest/api/compute/v3/servers/test_servers_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,20 +15,19 @@
import base64
import sys
-import uuid
from tempest.api.compute import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import exceptions
-from tempest.test import attr
+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:
@@ -38,15 +35,14 @@
@classmethod
def setUpClass(cls):
- super(ServersNegativeTestJSON, cls).setUpClass()
+ super(ServersNegativeV3TestJSON, cls).setUpClass()
cls.client = cls.servers_client
- cls.img_client = cls.images_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']
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_server_name_blank(self):
# Create a server with name parameter empty
@@ -54,19 +50,7 @@
self.create_test_server,
name='')
- @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)
-
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_image(self):
# Create a server with an unknown image
@@ -74,7 +58,7 @@
self.create_test_server,
image_id=-1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_invalid_flavor(self):
# Create a server with an unknown flavor
@@ -82,51 +66,52 @@
self.create_test_server,
flavor=-1,)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_access_ip_v4_address(self):
# An access IPv4 address must match a valid address pattern
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)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_invalid_ip_v6_address(self):
# An access IPv6 address must match a valid address pattern
IPv6 = 'notvalid'
self.assertRaises(exceptions.BadRequest,
- self.create_test_server, accessIPv6=IPv6)
+ self.create_test_server, access_ip_v6=IPv6)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_nonexistent_server(self):
- nonexistent_server = str(uuid.uuid4())
+ # Resize a non-existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.resize,
nonexistent_server, self.flavor_ref)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_non_existent_flavor(self):
# Resize a server with non-existent flavor
- nonexistent_flavor = str(uuid.uuid4())
+ nonexistent_flavor = data_utils.rand_uuid()
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref=nonexistent_flavor)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resize_server_with_null_flavor(self):
# Resize a server with null flavor
self.assertRaises(exceptions.BadRequest, self.client.resize,
self.server_id, flavor_ref="")
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_reboot_non_existent_server(self):
# Reboot a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.reboot,
nonexistent_server, 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_paused_server(self):
# Pause a paused server.
self.client.pause_server(self.server_id)
@@ -137,7 +122,7 @@
self.client.pause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_reboot_deleted_server(self):
# Rebuild and Reboot a deleted server
_, server = self.create_test_server()
@@ -150,10 +135,10 @@
self.assertRaises(exceptions.NotFound, self.client.reboot,
server['id'], 'SOFT')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_rebuild_non_existent_server(self):
# Rebuild a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
meta = {'rebuild': 'server'}
new_name = data_utils.rand_name('server')
file_contents = 'Test server rebuild.'
@@ -167,7 +152,7 @@
personality=personality,
adminPass='rebuild')
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_numeric_server_name(self):
# Create a server with a numeric name
if self.__class__._interface == "xml":
@@ -178,7 +163,7 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_name_length_exceeds_256(self):
# Create a server with name length exceeding 256 characters
@@ -187,18 +172,18 @@
self.create_test_server,
name=server_name)
- @attr(type=['negative', 'gate'])
+ @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)
- @attr(type=['negative', 'gate'])
- def test_create_with_non_existant_keypair(self):
+ @test.attr(type=['negative', 'gate'])
+ def test_create_with_non_existent_keypair(self):
# Pass a non-existent keypair while creating a server
key_name = data_utils.rand_name('key')
@@ -206,7 +191,7 @@
self.create_test_server,
key_name=key_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_server_metadata_exceeds_length_limit(self):
# Pass really long metadata while creating a server
@@ -215,7 +200,7 @@
self.create_test_server,
meta=metadata)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_name_of_non_existent_server(self):
# Update name of a non-existent server
@@ -225,7 +210,7 @@
self.assertRaises(exceptions.NotFound, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_set_empty_name(self):
# Update name of the server to an empty string
@@ -235,7 +220,7 @@
self.assertRaises(exceptions.BadRequest, self.client.update_server,
server_name, name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_of_another_tenant(self):
# Update name of a server that belongs to another tenant
@@ -244,7 +229,7 @@
self.alt_client.update_server, self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_update_server_name_length_exceeds_256(self):
# Update name of server exceed the name length limit
@@ -254,34 +239,35 @@
self.server_id,
name=new_name)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_non_existent_server(self):
# Delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.delete_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_a_server_of_another_tenant(self):
# Delete a server that belongs to another tenant
self.assertRaises(exceptions.NotFound,
self.alt_client.delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_negative_id(self):
# Pass an invalid string parameter to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server, -1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_delete_server_pass_id_exceeding_length_limit(self):
# Pass a server ID that exceeds length limit to delete server
self.assertRaises(exceptions.NotFound, self.client.delete_server,
sys.maxint + 1)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_create_with_nonexistent_security_group(self):
# Create a server with a nonexistent security group
@@ -290,49 +276,49 @@
self.create_test_server,
security_groups=security_groups)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_non_existent_server(self):
# Get a non existent server details
-
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.get_server,
- '999erra43')
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_stop_non_existent_server(self):
# Stop a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.servers_client.stop,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_pause_non_existent_server(self):
# pause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.pause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_non_existent_server(self):
# unpause a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unpause_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unpause_server_invalid_state(self):
# unpause an active server.
self.assertRaises(exceptions.Conflict,
self.client.unpause_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_non_existent_server(self):
# suspend a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.suspend_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_suspend_server_invalid_state(self):
# suspend a suspended server.
resp, _ = self.client.suspend_server(self.server_id)
@@ -344,66 +330,66 @@
self.client.suspend_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_non_existent_server(self):
# resume a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.resume_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_resume_server_invalid_state(self):
# resume an active server.
self.assertRaises(exceptions.Conflict,
self.client.resume_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_get_console_output_of_non_existent_server(self):
# get the console output for a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.get_console_output,
nonexistent_server, 10)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # force-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.force_delete_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_force_delete_server_invalid_state(self):
# we can only force-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.force_delete_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_nonexistent_server_id(self):
- non_existent_server_id = str(uuid.uuid4())
-
+ # restore-delete a non existent server
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound,
self.client.restore_soft_deleted_server,
- non_existent_server_id)
+ nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_restore_server_invalid_state(self):
# we can only restore-delete a server in 'soft-delete' state
self.assertRaises(exceptions.Conflict,
self.client.restore_soft_deleted_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_non_existent_server(self):
# shelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.shelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_shelve_shelved_server(self):
# shelve a shelved server.
resp, server = self.client.shelve_server(self.server_id)
@@ -421,8 +407,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'])
@@ -430,14 +415,14 @@
self.client.shelve_server,
self.server_id)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_non_existent_server(self):
# unshelve a non existent server
- nonexistent_server = str(uuid.uuid4())
+ nonexistent_server = data_utils.rand_uuid()
self.assertRaises(exceptions.NotFound, self.client.unshelve_server,
nonexistent_server)
- @attr(type=['negative', 'gate'])
+ @test.attr(type=['negative', 'gate'])
def test_unshelve_server_invalid_state(self):
# unshelve an active server.
self.assertRaises(exceptions.Conflict,
@@ -445,5 +430,5 @@
self.server_id)
-class ServersNegativeTestXML(ServersNegativeTestJSON):
+class ServersNegativeV3TestXML(ServersNegativeV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
index d7269d1..8a88fca 100644
--- a/tempest/api/compute/v3/test_extensions.py
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,18 +15,40 @@
from tempest.api.compute import base
-from tempest.test import attr
+from tempest.openstack.common import log as logging
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
class ExtensionsV3TestJSON(base.BaseV3ComputeTest):
_interface = 'json'
- @attr(type='gate')
+ @test.attr(type='gate')
def test_list_extensions(self):
# List of all extensions
+ if len(self.config.compute_feature_enabled.api_v3_extensions) == 0:
+ raise self.skipException('There are not any extensions configured')
resp, extensions = self.extensions_client.list_extensions()
- self.assertIn("extensions", extensions)
self.assertEqual(200, resp.status)
+ ext = self.config.compute_feature_enabled.api_v3_extensions[0]
+ if ext == 'all':
+ self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+ elif ext:
+ self.assertIn(ext, map(lambda x: x['name'], extensions))
+ else:
+ raise self.skipException('There are not any extensions configured')
+ # Log extensions list
+ extension_list = map(lambda x: x['name'], extensions)
+ LOG.debug("Nova extensions: %s" % ','.join(extension_list))
+
+ @test.attr(type='gate')
+ def test_get_extension(self):
+ # get the specified extensions
+ resp, extension = self.extensions_client.get_extension('servers')
+ self.assertEqual(200, resp.status)
+ self.assertEqual('servers', extension['alias'])
class ExtensionsV3TestXML(ExtensionsV3TestJSON):
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..50a5f3c
--- /dev/null
+++ b/tempest/api/compute/v3/test_live_block_migration.py
@@ -0,0 +1,171 @@
+# 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..df25249 100644
--- a/tempest/api/compute/v3/test_quotas.py
+++ b/tempest/api/compute/v3/test_quotas.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,29 +14,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 +44,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 +54,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 +65,5 @@
self.assertEqual(defualt_quota_set, tenant_quota_set)
-class QuotasTestXML(QuotasTestJSON):
+class QuotasV3TestXML(QuotasV3TestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/v3/test_version.py b/tempest/api/compute/v3/test_version.py
new file mode 100644
index 0000000..166d161
--- /dev/null
+++ b/tempest/api/compute/v3/test_version.py
@@ -0,0 +1,34 @@
+# Copyright 2014 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 import test
+
+
+class VersionV3TestJSON(base.BaseV3ComputeTest):
+ _interface = 'json'
+
+ @test.attr(type='gate')
+ def test_version(self):
+ # Get version information
+ resp, version = self.version_client.get_version()
+ self.assertEqual(200, resp.status)
+ self.assertIn("id", version)
+ self.assertEqual("v3.0", version["id"])
+
+
+class VersionV3TestXML(VersionV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index 660de95..d51bf13 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
@@ -19,13 +17,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 AttachVolumeTestJSON(base.BaseV2ComputeTest):
_interface = 'json'
- run_ssh = tempest.config.TempestConfig().compute.run_ssh
+ run_ssh = CONF.compute.run_ssh
def __init__(self, *args, **kwargs):
super(AttachVolumeTestJSON, self).__init__(*args, **kwargs)
diff --git a/tempest/api/compute/volumes/test_volumes_get.py b/tempest/api/compute/volumes/test_volumes_get.py
index ae6996d..d8cc190 100644
--- a/tempest/api/compute/volumes/test_volumes_get.py
+++ b/tempest/api/compute/volumes/test_volumes_get.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,6 +16,7 @@
from tempest.api.compute import base
from tempest.common.utils import data_utils
from tempest.test import attr
+from testtools.matchers import ContainsAll
class VolumesGetTestJSON(base.BaseV2ComputeTest):
@@ -65,29 +64,10 @@
fetched_volume['id'],
'The fetched Volume is different '
'from the created Volume')
- self.assertEqual(metadata,
- fetched_volume['metadata'],
- 'The fetched Volume is different '
- 'from the created Volume')
-
- @attr(type='gate')
- def test_volume_get_metadata_none(self):
- # CREATE, GET empty metadata dict
- v_name = data_utils.rand_name('Volume-')
- # Create volume
- resp, volume = self.client.create_volume(size=1,
- display_name=v_name,
- metadata={})
- self.addCleanup(self._delete_volume, volume)
- self.assertEqual(200, resp.status)
- self.assertIn('id', volume)
- self.assertIn('displayName', volume)
- # Wait for Volume status to become ACTIVE
- self.client.wait_for_volume_status(volume['id'], 'available')
- # GET Volume
- resp, fetched_volume = self.client.get_volume(volume['id'])
- self.assertEqual(200, resp.status)
- self.assertEqual(fetched_volume['metadata'], {})
+ self.assertThat(fetched_volume['metadata'].items(),
+ ContainsAll(metadata.items()),
+ 'The fetched Volume metadata misses data '
+ 'from the created Volume')
def _delete_volume(self, volume):
# Delete the Volume created in this method
diff --git a/tempest/api/compute/volumes/test_volumes_list.py b/tempest/api/compute/volumes/test_volumes_list.py
index f54e9b3..ac89f99 100644
--- a/tempest/api/compute/volumes/test_volumes_list.py
+++ b/tempest/api/compute/volumes/test_volumes_list.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -109,6 +107,65 @@
', '.join(m_vol['displayName']
for m_vol in missing_volumes))
+ @attr(type='gate')
+ def test_volume_list_param_limit(self):
+ # Return the list of volumes based on limit set
+ params = {'limit': 2}
+ resp, fetched_vol_list = self.client.list_volumes(params=params)
+ self.assertEqual(200, resp.status)
+
+ self.assertEqual(len(fetched_vol_list), params['limit'],
+ "Failed to list volumes by limit set")
+
+ @attr(type='gate')
+ def test_volume_list_with_detail_param_limit(self):
+ # Return the list of volumes with details based on limit set.
+ params = {'limit': 2}
+ resp, fetched_vol_list = \
+ self.client.list_volumes_with_detail(params=params)
+ self.assertEqual(200, resp.status)
+
+ self.assertEqual(len(fetched_vol_list), params['limit'],
+ "Failed to list volume details by limit set")
+
+ @attr(type='gate')
+ def test_volume_list_param_offset_and_limit(self):
+ # Return the list of volumes based on offset and limit set.
+ # get all volumes list
+ response, all_vol_list = self.client.list_volumes()
+ params = {'offset': 1, 'limit': 1}
+ resp, fetched_vol_list = self.client.list_volumes(params=params)
+ self.assertEqual(200, resp.status)
+
+ # Validating length of the fetched volumes
+ self.assertEqual(len(fetched_vol_list), params['limit'],
+ "Failed to list volumes by offset and limit")
+ # Validating offset of fetched volume
+ for index, volume in enumerate(fetched_vol_list):
+ self.assertEqual(volume['id'],
+ all_vol_list[index + params['offset']]['id'],
+ "Failed to list volumes by offset and limit")
+
+ @attr(type='gate')
+ def test_volume_list_with_detail_param_offset_and_limit(self):
+ # Return the list of volumes details based on offset and limit set.
+ # get all volumes list
+ response, all_vol_list = self.client.list_volumes_with_detail()
+ params = {'offset': 1, 'limit': 1}
+ resp, fetched_vol_list = \
+ self.client.list_volumes_with_detail(params=params)
+ self.assertEqual(200, resp.status)
+
+ # Validating length of the fetched volumes
+ self.assertEqual(len(fetched_vol_list), params['limit'],
+ "Failed to list volume details by offset and limit")
+ # Validating offset of fetched volume
+ for index, volume in enumerate(fetched_vol_list):
+ self.assertEqual(volume['id'],
+ all_vol_list[index + params['offset']]['id'],
+ "Failed to list volume details by "
+ "offset and limit")
+
class VolumesTestXML(VolumesTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 785902e..e01e349 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -35,18 +33,18 @@
raise cls.skipException(skip_msg)
@attr(type=['negative', 'gate'])
- def test_volume_get_nonexistant_volume_id(self):
- # Negative: Should not be able to get details of nonexistant volume
- # Creating a nonexistant volume id
- # Trying to GET a non existant volume
+ def test_volume_get_nonexistent_volume_id(self):
+ # Negative: Should not be able to get details of nonexistent volume
+ # Creating a nonexistent volume id
+ # Trying to GET a non existent volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@attr(type=['negative', 'gate'])
- def test_volume_delete_nonexistant_volume_id(self):
- # Negative: Should not be able to delete nonexistant Volume
- # Creating nonexistant volume id
- # Trying to DELETE a non existant volume
+ def test_volume_delete_nonexistent_volume_id(self):
+ # Negative: Should not be able to delete nonexistent Volume
+ # Creating nonexistent volume id
+ # Trying to DELETE a non existent volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
diff --git a/tempest/api/identity/__init__.py b/tempest/api/identity/__init__.py
index c9d43e9..9614b49 100644
--- a/tempest/api/identity/__init__.py
+++ b/tempest/api/identity/__init__.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_roles.py b/tempest/api/identity/admin/test_roles.py
index 8205d15..f1124e4 100644
--- a/tempest/api/identity/admin/test_roles.py
+++ b/tempest/api/identity/admin/test_roles.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py
index 83d1d4d..4eaa255 100644
--- a/tempest/api/identity/admin/test_roles_negative.py
+++ b/tempest/api/identity/admin/test_roles_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
@@ -194,37 +192,37 @@
self.client.clear_auth()
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_user(self):
+ def test_remove_user_role_non_existent_user(self):
# Attempt to remove a role from a non existent user should fail
(user, tenant, role) = self._get_role_params()
resp, user_role = self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- non_existant_user = str(uuid.uuid4().hex)
+ non_existent_user = str(uuid.uuid4().hex)
self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- tenant['id'], non_existant_user, role['id'])
+ tenant['id'], non_existent_user, role['id'])
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_role(self):
+ def test_remove_user_role_non_existent_role(self):
# Attempt to delete a non existent role from a user should fail
(user, tenant, role) = self._get_role_params()
resp, user_role = self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- non_existant_role = str(uuid.uuid4().hex)
+ non_existent_role = str(uuid.uuid4().hex)
self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- tenant['id'], user['id'], non_existant_role)
+ tenant['id'], user['id'], non_existent_role)
@attr(type=['negative', 'gate'])
- def test_remove_user_role_non_existant_tenant(self):
+ def test_remove_user_role_non_existent_tenant(self):
# Attempt to remove a role from a non existent tenant should fail
(user, tenant, role) = self._get_role_params()
resp, user_role = self.client.assign_user_role(tenant['id'],
user['id'],
role['id'])
- non_existant_tenant = str(uuid.uuid4().hex)
+ non_existent_tenant = str(uuid.uuid4().hex)
self.assertRaises(exceptions.NotFound, self.client.remove_user_role,
- non_existant_tenant, user['id'], role['id'])
+ non_existent_tenant, user['id'], role['id'])
@attr(type=['negative', 'gate'])
def test_list_user_roles_by_unauthorized_user(self):
diff --git a/tempest/api/identity/admin/test_services.py b/tempest/api/identity/admin/test_services.py
index 7fe5171..8ba333f 100644
--- a/tempest/api/identity/admin/test_services.py
+++ b/tempest/api/identity/admin/test_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -25,47 +23,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/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py
index d10080b..a4d9d97 100644
--- a/tempest/api/identity/admin/test_tenant_negative.py
+++ b/tempest/api/identity/admin/test_tenant_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_tenants.py b/tempest/api/identity/admin/test_tenants.py
index e36b543..46fa7a9 100644
--- a/tempest/api/identity/admin/test_tenants.py
+++ b/tempest/api/identity/admin/test_tenants.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_tokens.py b/tempest/api/identity/admin/test_tokens.py
index 334a5aa..cfe17fb 100644
--- a/tempest/api/identity/admin/test_tokens.py
+++ b/tempest/api/identity/admin/test_tokens.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD.
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 5d5a814..14222fb 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py
index 3163c16..ba7af09 100644
--- a/tempest/api/identity/admin/test_users_negative.py
+++ b/tempest/api/identity/admin/test_users_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -66,7 +64,7 @@
self.data.tenant['id'], self.data.test_email)
@attr(type=['negative', 'gate'])
- def test_create_user_for_non_existant_tenant(self):
+ def test_create_user_for_non_existent_tenant(self):
# Attempt to create a user in a non-existent tenant should fail
self.assertRaises(exceptions.NotFound, self.client.create_user,
self.alt_user, self.alt_password, '49ffgg99999',
@@ -98,7 +96,7 @@
self.alt_email, enabled=3)
@attr(type=['negative', 'gate'])
- def test_update_user_for_non_existant_user(self):
+ def test_update_user_for_non_existent_user(self):
# Attempt to update a user non-existent user should fail
user_name = data_utils.rand_name('user-')
non_existent_id = str(uuid.uuid4())
@@ -135,7 +133,7 @@
self.data.user['id'])
@attr(type=['negative', 'gate'])
- def test_delete_non_existant_user(self):
+ def test_delete_non_existent_user(self):
# Attempt to delete a non-existent user should fail
self.assertRaises(exceptions.NotFound, self.client.delete_user,
'junk12345123')
diff --git a/tempest/api/identity/admin/v3/test_credentials.py b/tempest/api/identity/admin/v3/test_credentials.py
index 0b494f3..753eaa6 100644
--- a/tempest/api/identity/admin/v3/test_credentials.py
+++ b/tempest/api/identity/admin/v3/test_credentials.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index ed776cd..4017b62 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index d4d2109..4ae7884 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_groups.py b/tempest/api/identity/admin/v3/test_groups.py
new file mode 100644
index 0000000..ca8ca54
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_groups.py
@@ -0,0 +1,84 @@
+# 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.identity import base
+from tempest.common.utils import data_utils
+from tempest import test
+
+
+class GroupsV3TestJSON(base.BaseIdentityAdminTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(GroupsV3TestJSON, cls).setUpClass()
+
+ @test.attr(type='smoke')
+ def test_group_create_update_get(self):
+ name = data_utils.rand_name('Group')
+ description = data_utils.rand_name('Description')
+ resp, group = self.v3_client.create_group(name,
+ description=description)
+ self.addCleanup(self.v3_client.delete_group, group['id'])
+ self.assertEqual(resp['status'], '201')
+ self.assertEqual(group['name'], name)
+ self.assertEqual(group['description'], description)
+
+ new_name = data_utils.rand_name('UpdateGroup')
+ new_desc = data_utils.rand_name('UpdateDescription')
+ resp, updated_group = self.v3_client.update_group(group['id'],
+ name=new_name,
+ description=new_desc)
+ self.assertEqual(resp['status'], '200')
+ self.assertEqual(updated_group['name'], new_name)
+ self.assertEqual(updated_group['description'], new_desc)
+
+ resp, new_group = self.v3_client.get_group(group['id'])
+ self.assertEqual(resp['status'], '200')
+ self.assertEqual(group['id'], new_group['id'])
+ self.assertEqual(new_name, new_group['name'])
+ self.assertEqual(new_desc, new_group['description'])
+
+ @test.attr(type='smoke')
+ def test_group_users_add_list_delete(self):
+ name = data_utils.rand_name('Group')
+ resp, group = self.v3_client.create_group(name)
+ self.addCleanup(self.v3_client.delete_group, group['id'])
+ # add user into group
+ users = []
+ for i in range(3):
+ name = data_utils.rand_name('User')
+ resp, user = self.v3_client.create_user(name)
+ users.append(user)
+ self.addCleanup(self.v3_client.delete_user, user['id'])
+ self.v3_client.add_group_user(group['id'], user['id'])
+
+ # list users in group
+ resp, group_users = self.v3_client.list_group_users(group['id'])
+ self.assertEqual(resp['status'], '200')
+ self.assertEqual(users.sort(), group_users.sort())
+ # delete user in group
+ for user in users:
+ resp, body = self.v3_client.delete_group_user(group['id'],
+ user['id'])
+ self.assertEqual(resp['status'], '204')
+ resp, group_users = self.v3_client.list_group_users(group['id'])
+ self.assertEqual(len(group_users), 0)
+
+
+class GroupsV3TestXML(GroupsV3TestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index 48f8fcd..0e8e4c3 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_projects.py b/tempest/api/identity/admin/v3/test_projects.py
index cbfcd04..1fc5a6a 100644
--- a/tempest/api/identity/admin/v3/test_projects.py
+++ b/tempest/api/identity/admin/v3/test_projects.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack, LLC
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_roles.py b/tempest/api/identity/admin/v3/test_roles.py
index a6a2bd7..efaed39 100644
--- a/tempest/api/identity/admin/v3/test_roles.py
+++ b/tempest/api/identity/admin/v3/test_roles.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index 1751638..4d6c22f 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 2541e25..d17dc4a 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/admin/v3/test_trusts.py b/tempest/api/identity/admin/v3/test_trusts.py
new file mode 100644
index 0000000..0bded78
--- /dev/null
+++ b/tempest/api/identity/admin/v3/test_trusts.py
@@ -0,0 +1,266 @@
+# 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
+import re
+from tempest.api.identity import base
+from tempest import clients
+from tempest.common.utils.data_utils import rand_name
+from tempest import config
+from tempest import exceptions
+from tempest.openstack.common import timeutils
+from tempest.test import attr
+
+CONF = config.CONF
+
+
+class BaseTrustsV3Test(base.BaseIdentityAdminTest):
+
+ def setUp(self):
+ super(BaseTrustsV3Test, self).setUp()
+ # Use alt_username as the trustee
+ if not CONF.identity_feature_enabled.trust:
+ raise self.skipException("Trusts aren't enabled")
+
+ self.trustee_username = self.config.identity.alt_username
+ self.trust_id = None
+
+ 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
+ self.trustor_project_name = self.v3_client.tenant_name
+ self.trustor_project_id = self.get_tenant_by_name(
+ self.trustor_project_name)['id']
+ self.assertIsNotNone(self.trustor_project_id)
+
+ # Create a trustor User
+ self.trustor_username = rand_name('user-')
+ u_desc = self.trustor_username + 'description'
+ u_email = self.trustor_username + '@testmail.xx'
+ self.trustor_password = rand_name('pass-')
+ resp, user = self.v3_client.create_user(
+ self.trustor_username,
+ description=u_desc,
+ password=self.trustor_password,
+ email=u_email,
+ project_id=self.trustor_project_id)
+ self.assertEqual(resp['status'], '201')
+ self.trustor_user_id = user['id']
+
+ # And two roles, one we'll delegate and one we won't
+ self.delegated_role = rand_name('DelegatedRole-')
+ self.not_delegated_role = rand_name('NotDelegatedRole-')
+
+ resp, role = self.v3_client.create_role(self.delegated_role)
+ self.assertEqual(resp['status'], '201')
+ self.delegated_role_id = role['id']
+
+ resp, role = self.v3_client.create_role(self.not_delegated_role)
+ self.assertEqual(resp['status'], '201')
+ self.not_delegated_role_id = role['id']
+
+ # Assign roles to trustor
+ self.v3_client.assign_user_role(self.trustor_project_id,
+ self.trustor_user_id,
+ self.delegated_role_id)
+ self.v3_client.assign_user_role(self.trustor_project_id,
+ self.trustor_user_id,
+ self.not_delegated_role_id)
+
+ # Get trustee user ID, use the demo user
+ trustee_username = self.v3_non_admin_client.user
+ self.trustee_user_id = self.get_user_by_name(trustee_username)['id']
+ self.assertIsNotNone(self.trustee_user_id)
+
+ # Initialize a new client with the trustor credentials
+ os = clients.Manager(username=self.trustor_username,
+ password=self.trustor_password,
+ tenant_name=self.trustor_project_name,
+ interface=self._interface)
+ self.trustor_v3_client = os.identity_v3_client
+
+ 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:
+ self.v3_client.delete_role(self.delegated_role_id)
+ if self.not_delegated_role_id:
+ self.v3_client.delete_role(self.not_delegated_role_id)
+
+ def create_trust(self, impersonate=True, expires=None):
+
+ resp, trust_create = self.trustor_v3_client.create_trust(
+ trustor_user_id=self.trustor_user_id,
+ trustee_user_id=self.trustee_user_id,
+ project_id=self.trustor_project_id,
+ role_names=[self.delegated_role],
+ impersonation=impersonate,
+ expires_at=expires)
+ self.assertEqual('201', resp['status'])
+ self.trust_id = trust_create['id']
+ return trust_create
+
+ def validate_trust(self, trust, impersonate=True, expires=None,
+ summary=False):
+ self.assertIsNotNone(trust['id'])
+ self.assertEqual(impersonate, trust['impersonation'])
+ # 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'])
+ self.assertEqual(self.trustor_project_id, trust['project_id'])
+ if not summary:
+ self.assertEqual(self.delegated_role, trust['roles'][0]['name'])
+ self.assertEqual(1, len(trust['roles']))
+
+ def get_trust(self):
+ resp, trust_get = self.trustor_v3_client.get_trust(self.trust_id)
+ self.assertEqual('200', resp['status'])
+ return trust_get
+
+ def validate_role(self, role):
+ self.assertEqual(self.delegated_role_id, role['id'])
+ self.assertEqual(self.delegated_role, role['name'])
+ self.assertIn('v3/roles/%s' % self.delegated_role_id,
+ role['links']['self'])
+ self.assertNotEqual(self.not_delegated_role_id, role['id'])
+ self.assertNotEqual(self.not_delegated_role, role['name'])
+ self.assertNotIn('v3/roles/%s' % self.not_delegated_role_id,
+ role['links']['self'])
+
+ def check_trust_roles(self):
+ # Check we find the delegated role
+ resp, roles_get = self.trustor_v3_client.get_trust_roles(
+ self.trust_id)
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(1, len(roles_get))
+ self.validate_role(roles_get[0])
+
+ resp, role_get = self.trustor_v3_client.get_trust_role(
+ self.trust_id, self.delegated_role_id)
+ self.assertEqual('200', resp['status'])
+ self.validate_role(role_get)
+
+ resp, role_get = self.trustor_v3_client.check_trust_role(
+ self.trust_id, self.delegated_role_id)
+ self.assertEqual('204', resp['status'])
+
+ # And that we don't find not_delegated_role
+ self.assertRaises(exceptions.NotFound,
+ self.trustor_v3_client.get_trust_role,
+ self.trust_id,
+ self.not_delegated_role_id)
+
+ self.assertRaises(exceptions.NotFound,
+ self.trustor_v3_client.check_trust_role,
+ self.trust_id,
+ self.not_delegated_role_id)
+
+ def delete_trust(self):
+ resp, trust_delete = self.trustor_v3_client.delete_trust(self.trust_id)
+ self.assertEqual('204', resp['status'])
+ self.assertRaises(exceptions.NotFound,
+ self.trustor_v3_client.get_trust,
+ self.trust_id)
+ self.trust_id = None
+
+
+class TrustsV3TestJSON(BaseTrustsV3Test):
+ _interface = 'json'
+
+ def setUp(self):
+ super(TrustsV3TestJSON, self).setUp()
+ self.create_trustor_and_roles()
+ self.addCleanup(self.cleanup_user_and_roles)
+
+ @attr(type='smoke')
+ def test_trust_impersonate(self):
+ # Test case to check we can create, get and delete a trust
+ # updates are not supported for trusts
+ trust = self.create_trust()
+ self.validate_trust(trust)
+
+ trust_get = self.get_trust()
+ self.validate_trust(trust_get)
+
+ self.check_trust_roles()
+
+ @attr(type='smoke')
+ def test_trust_noimpersonate(self):
+ # Test case to check we can create, get and delete a trust
+ # with impersonation=False
+ trust = self.create_trust(impersonate=False)
+ self.validate_trust(trust, impersonate=False)
+
+ trust_get = self.get_trust()
+ self.validate_trust(trust_get, impersonate=False)
+
+ self.check_trust_roles()
+
+ @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):
+ # Test case to check we can check an invlaid expiry time
+ # is rejected with the correct error
+ # with an expiry specified
+ expires_str = 'bad.123Z'
+ 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/identity/admin/v3/test_users.py b/tempest/api/identity/admin/v3/test_users.py
index b1c4d82..7cae856 100644
--- a/tempest/api/identity/admin/v3/test_users.py
+++ b/tempest/api/identity/admin/v3/test_users.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/identity/base.py b/tempest/api/identity/base.py
index 876edfd..a3fc65a 100644
--- a/tempest/api/identity/base.py
+++ b/tempest/api/identity/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index 28ed5b6..2e69579 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -31,10 +29,12 @@
@classmethod
def setUpClass(cls):
+ cls.set_network_resources()
super(BaseImageTest, cls).setUpClass()
cls.created_images = []
cls._interface = 'json'
- cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)
+ cls.isolated_creds = isolated_creds.IsolatedCreds(
+ cls.__name__, network_resources=cls.network_resources)
if not cls.config.service_available.glance:
skip_msg = ("%s skipped as glance is not available" % cls.__name__)
raise cls.skipException(skip_msg)
@@ -129,11 +129,11 @@
raise cls.skipException(msg)
-class BaseV2MemeberImageTest(BaseImageTest):
+class BaseV2MemberImageTest(BaseV2ImageTest):
@classmethod
def setUpClass(cls):
- super(BaseV2MemeberImageTest, cls).setUpClass()
+ super(BaseV2MemberImageTest, cls).setUpClass()
if cls.config.compute.allow_tenant_isolation:
creds = cls.isolated_creds.get_alt_creds()
username, tenant_name, password = creds
diff --git a/tempest/api/image/v1/test_image_members.py b/tempest/api/image/v1/test_image_members.py
index 437527d..e6a078e 100644
--- a/tempest/api/image/v1/test_image_members.py
+++ b/tempest/api/image/v1/test_image_members.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/image/v1/test_image_members_negative.py b/tempest/api/image/v1/test_image_members_negative.py
index 83f7a0f..d68ef03 100644
--- a/tempest/api/image/v1/test_image_members_negative.py
+++ b/tempest/api/image/v1/test_image_members_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/image/v1/test_images.py b/tempest/api/image/v1/test_images.py
index 558e2ec..3c8d95e 100644
--- a/tempest/api/image/v1/test_images.py
+++ b/tempest/api/image/v1/test_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/image/v1/test_images_negative.py b/tempest/api/image/v1/test_images_negative.py
index 1bcf120..5695884 100644
--- a/tempest/api/image/v1/test_images_negative.py
+++ b/tempest/api/image/v1/test_images_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 6408c15..bfc2287 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# Copyright 2013 IBM Corp
# All Rights Reserved.
@@ -25,7 +23,6 @@
class BasicOperationsImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the basic operations of images
"""
@@ -95,7 +92,6 @@
class ListImagesTest(base.BaseV2ImageTest):
-
"""
Here we test the listing of image information
"""
@@ -105,31 +101,114 @@
super(ListImagesTest, cls).setUpClass()
# We add a few images here to test the listing functionality of
# the images API
- for x in xrange(0, 10):
- cls._create_standard_image(x)
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('bare', 'raw')
+ cls._create_standard_image('ami', 'raw')
+ # Add some more for listing
+ cls._create_standard_image('ami', 'ami')
+ cls._create_standard_image('ari', 'ari')
+ cls._create_standard_image('aki', 'aki')
@classmethod
- def _create_standard_image(cls, number):
+ def _create_standard_image(cls, container_format, disk_format):
"""
Create a new standard image and return the ID of the newly-registered
image. Note that the size of the new image is a random number between
1024 and 4096
"""
image_file = StringIO.StringIO('*' * random.randint(1024, 4096))
- name = 'New Standard Image %s' % number
- resp, body = cls.create_image(name=name, container_format='bare',
- disk_format='raw',
+ name = data_utils.rand_name('image-')
+ resp, body = cls.create_image(name=name,
+ container_format=container_format,
+ disk_format=disk_format,
visibility='public')
image_id = body['id']
resp, body = cls.client.store_image(image_id, data=image_file)
return image_id
+ def _list_by_param_value_and_assert(self, params):
+ """
+ Perform list action with given params and validates result.
+ """
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(200, resp.status)
+ # Validating params of fetched images
+ for image in images_list:
+ for key in params:
+ msg = "Failed to list images by %s" % key
+ self.assertEqual(params[key], image[key], msg)
+
@attr(type='gate')
def test_index_no_params(self):
# Simple test to see all fixture images returned
resp, images_list = self.client.image_list()
self.assertEqual(resp['status'], '200')
image_list = map(lambda x: x['id'], images_list)
+
for image in self.created_images:
self.assertIn(image, image_list)
+
+ @attr(type='gate')
+ def test_list_images_param_container_format(self):
+ # Test to get all images with container_format='bare'
+ params = {"container_format": "bare"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_disk_format(self):
+ # Test to get all images with disk_format = raw
+ params = {"disk_format": "raw"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_visibility(self):
+ # Test to get all images with visibility = public
+ params = {"visibility": "public"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_size(self):
+ # Test to get all images by size
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ params = {"size": image['size']}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_min_max_size(self):
+ # Test to get all images with size between 2000 to 3000
+ image_id = self.created_images[1]
+ # Get image metadata
+ resp, image = self.client.get_image(image_id)
+ self.assertEqual(resp['status'], '200')
+
+ size = image['size']
+ params = {"size_min": size - 500, "size_max": size + 500}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+ image_size_list = map(lambda x: x['size'], images_list)
+
+ for image_size in image_size_list:
+ self.assertTrue(image_size >= params['size_min'] and
+ image_size <= params['size_max'],
+ "Failed to get images by size_min and size_max")
+
+ @attr(type='gate')
+ def test_list_images_param_status(self):
+ # Test to get all available images
+ params = {"status": "available"}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_list_images_param_limit(self):
+ # Test to get images by limit
+ params = {"limit": 2}
+ resp, images_list = self.client.image_list(params=params)
+ self.assertEqual(resp['status'], '200')
+
+ self.assertEqual(len(images_list), params['limit'],
+ "Failed to get images by limit")
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index 954c79d..41fc49d 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -1,5 +1,3 @@
-# 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
@@ -16,7 +14,7 @@
from tempest.test import attr
-class ImagesMemberTest(base.BaseV2MemeberImageTest):
+class ImagesMemberTest(base.BaseV2MemberImageTest):
_interface = 'json'
@attr(type='gate')
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index 3c17959..4c7cc5a 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -1,5 +1,3 @@
-# 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
@@ -17,7 +15,7 @@
from tempest.test import attr
-class ImagesMemberNegativeTest(base.BaseV2MemeberImageTest):
+class ImagesMemberNegativeTest(base.BaseV2MemberImageTest):
_interface = 'json'
@attr(type=['negative', 'gate'])
diff --git a/tempest/api/image/v2/test_images_negative.py b/tempest/api/image/v2/test_images_negative.py
index 1cd6f29..b8ba868 100644
--- a/tempest/api/image/v2/test_images_negative.py
+++ b/tempest/api/image/v2/test_images_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
# Copyright 2013 IBM Corp.
diff --git a/tempest/api/image/v2/test_images_tags.py b/tempest/api/image/v2/test_images_tags.py
index e37e462..f0e343d 100644
--- a/tempest/api/image/v2/test_images_tags.py
+++ b/tempest/api/image/v2/test_images_tags.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/image/v2/test_images_tags_negative.py b/tempest/api/image/v2/test_images_tags_negative.py
index e0d84de..0628d29 100644
--- a/tempest/api/image/v2/test_images_tags_negative.py
+++ b/tempest/api/image/v2/test_images_tags_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
new file mode 100644
index 0000000..ca3bd8d
--- /dev/null
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -0,0 +1,86 @@
+# 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.network import base
+from tempest.common import tempest_fixtures as fixtures
+from tempest.test import attr
+
+
+class AgentManagementTestJSON(base.BaseAdminNetworkTest):
+ _interface = 'json'
+
+ @classmethod
+ def setUpClass(cls):
+ super(AgentManagementTestJSON, cls).setUpClass()
+ resp, body = cls.admin_client.list_agents()
+ agents = body['agents']
+ cls.agent = agents[0]
+
+ @attr(type='smoke')
+ def test_list_agent(self):
+ resp, body = self.admin_client.list_agents()
+ self.assertEqual('200', resp['status'])
+ agents = body['agents']
+ self.assertIn(self.agent, agents)
+
+ @attr(type=['smoke'])
+ def test_list_agents_non_admin(self):
+ resp, body = self.client.list_agents()
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(len(body["agents"]), 0)
+
+ @attr(type='smoke')
+ def test_show_agent(self):
+ resp, body = self.admin_client.show_agent(self.agent['id'])
+ agent = body['agent']
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(agent['id'], self.agent['id'])
+
+ @attr(type='smoke')
+ def test_update_agent_status(self):
+ origin_status = self.agent['admin_state_up']
+ # Try to update the 'admin_state_up' to the original
+ # one to avoid the negative effect.
+ agent_status = {'admin_state_up': origin_status}
+ resp, body = self.admin_client.update_agent(agent_id=self.agent['id'],
+ agent_info=agent_status)
+ updated_status = body['agent']['admin_state_up']
+ self.assertEqual('200', resp['status'])
+ self.assertEqual(origin_status, updated_status)
+
+ @attr(type='smoke')
+ def test_update_agent_description(self):
+ self.useFixture(fixtures.LockFixture('agent_description'))
+ description = 'description for update agent.'
+ agent_description = {'description': description}
+ resp, body = self.admin_client.update_agent(
+ agent_id=self.agent['id'],
+ agent_info=agent_description)
+ self.assertEqual('200', resp['status'])
+ self.addCleanup(self._restore_agent)
+ updated_description = body['agent']['description']
+ self.assertEqual(updated_description, description)
+
+ def _restore_agent(self):
+ """
+ Restore the agent description after update test.
+ """
+ description = self.agent['description'] or ''
+ origin_agent = {'description': description}
+ self.admin_client.update_agent(agent_id=self.agent['id'],
+ agent_info=origin_agent)
+
+
+class AgentManagementTestXML(AgentManagementTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index ac10e68..13309cd 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 9c187fd..bfb7b48 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -16,7 +14,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class L3AgentSchedulerJSON(base.BaseAdminNetworkTest):
@@ -36,8 +34,11 @@
@classmethod
def setUpClass(cls):
super(L3AgentSchedulerJSON, cls).setUpClass()
+ if not test.is_extension_enabled('l3_agent_scheduler', 'network'):
+ msg = "L3 Agent Scheduler Extension not enabled."
+ raise cls.skipException(msg)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_routers_on_l3_agent(self):
resp, body = self.admin_client.list_agents()
agents = body['agents']
@@ -48,7 +49,7 @@
agent['id'])
self.assertEqual('200', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_l3_agents_hosting_router(self):
name = data_utils.rand_name('router-')
resp, router = self.client.create_router(name)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 61af91f..d7df6b2 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -50,6 +48,8 @@
@classmethod
def setUpClass(cls):
+ # Create no network resources for these test.
+ cls.set_network_resources()
super(BaseNetworkTest, cls).setUpClass()
os = clients.Manager(interface=cls._interface)
cls.network_cfg = os.config.network
@@ -66,15 +66,19 @@
cls.health_monitors = []
cls.vpnservices = []
cls.ikepolicies = []
+ cls.floating_ips = []
@classmethod
def tearDownClass(cls):
# Clean up ike policies
for ikepolicy in cls.ikepolicies:
- cls.client.delete_ike_policy(ikepolicy['id'])
+ cls.client.delete_ikepolicy(ikepolicy['id'])
# Clean up vpn services
for vpnservice in cls.vpnservices:
- cls.client.delete_vpn_service(vpnservice['id'])
+ 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,
@@ -213,7 +237,7 @@
@classmethod
def create_vpnservice(cls, subnet_id, router_id):
"""Wrapper utility that returns a test vpn service."""
- resp, body = cls.client.create_vpn_service(
+ resp, body = cls.client.create_vpnservice(
subnet_id, router_id, admin_state_up=True,
name=data_utils.rand_name("vpnservice-"))
vpnservice = body['vpnservice']
@@ -221,9 +245,9 @@
return vpnservice
@classmethod
- def create_ike_policy(cls, name):
+ def create_ikepolicy(cls, name):
"""Wrapper utility that returns a test ike policy."""
- resp, body = cls.client.create_ike_policy(name)
+ resp, body = cls.client.create_ikepolicy(name)
ikepolicy = body['ikepolicy']
cls.ikepolicies.append(ikepolicy)
return ikepolicy
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
new file mode 100644
index 0000000..304b2ca
--- /dev/null
+++ b/tempest/api/network/base_routers.py
@@ -0,0 +1,48 @@
+# 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/base_security_groups.py b/tempest/api/network/base_security_groups.py
index 5ab1748..38ae4ac 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
index ab19fa8..0ce1769 100644
--- a/tempest/api/network/common.py
+++ b/tempest/api/network/common.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
@@ -47,6 +45,9 @@
def delete(self):
raise NotImplemented()
+ def __hash__(self):
+ return id(self)
+
class DeletableNetwork(DeletableResource):
@@ -86,6 +87,22 @@
class DeletableFloatingIp(DeletableResource):
+ def update(self, *args, **kwargs):
+ result = self.client.update_floatingip(floatingip=self.id,
+ body=dict(
+ floatingip=dict(*args,
+ **kwargs)
+ ))
+ super(DeletableFloatingIp, self).update(**result['floatingip'])
+
+ def __repr__(self):
+ return '<%s addr="%s">' % (self.__class__.__name__,
+ self.floating_ip_address)
+
+ def __str__(self):
+ return '<"FloatingIP" addr="%s" id="%s">' % (self.floating_ip_address,
+ self.id)
+
def delete(self):
self.client.delete_floatingip(self.id)
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index 1b27d1b..a177d65 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack, Foundation
# All Rights Reserved.
#
@@ -17,7 +15,7 @@
from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
class ExtensionsTestJSON(base.BaseNetworkTest):
@@ -38,7 +36,7 @@
def setUpClass(cls):
super(ExtensionsTestJSON, cls).setUpClass()
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_show_extensions(self):
# List available extensions for the tenant
expected_alias = ['security-group', 'l3_agent_scheduler',
@@ -55,7 +53,7 @@
ext_name = ext['name']
ext_alias = ext['alias']
actual_alias.append(ext['alias'])
- resp, ext_details = self.client.show_extension_details(ext_alias)
+ resp, ext_details = self.client.show_extension(ext_alias)
self.assertEqual('200', resp['status'])
ext_details = ext_details['extension']
@@ -70,9 +68,11 @@
self.assertEqual(ext_details['alias'], ext_alias)
self.assertEqual(ext_details, ext)
# Verify if expected extensions are present in the actual list
- # of extensions returned
+ # of extensions returned, but only for those that have been
+ # enabled via configuration
for e in expected_alias:
- self.assertIn(e, actual_alias)
+ if test.is_extension_enabled(e, 'network'):
+ self.assertIn(e, actual_alias)
class ExtensionsTestXML(ExtensionsTestJSON):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 35d4fa8..e050c17 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -25,15 +23,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,89 +48,109 @@
# 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_floating_ip(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_floating_ips()
- 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_floating_ips()
+ resp, floating_ips = self.client.list_floatingips()
self.assertEqual('200', resp['status'])
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 7e4ec37..65eebf2 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,7 +15,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class LoadBalancerJSON(base.BaseNetworkTest):
@@ -42,6 +40,9 @@
@classmethod
def setUpClass(cls):
super(LoadBalancerJSON, cls).setUpClass()
+ if not test.is_extension_enabled('lbaas', 'network'):
+ msg = "lbaas extension not enabled."
+ raise cls.skipException(msg)
cls.network = cls.create_network()
cls.name = cls.network['name']
cls.subnet = cls.create_subnet(cls.network)
@@ -53,7 +54,7 @@
cls.member = cls.create_member(80, cls.pool)
cls.health_monitor = cls.create_health_monitor(4, 3, "TCP", 1)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_vips(self):
# Verify the vIP exists in the list of all vIPs
resp, body = self.client.list_vips()
@@ -69,9 +70,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'])
@@ -89,7 +92,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)
@@ -97,7 +101,7 @@
resp, body = self.client.delete_pool(pool['id'])
self.assertEqual('204', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_vip(self):
# Verifies the details of a vip
resp, body = self.client.show_vip(self.vip['id'])
@@ -106,7 +110,7 @@
self.assertEqual(self.vip['id'], vip['id'])
self.assertEqual(self.vip['name'], vip['name'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_pool(self):
# Verifies the details of a pool
resp, body = self.client.show_pool(self.pool['id'])
@@ -115,7 +119,7 @@
self.assertEqual(self.pool['id'], pool['id'])
self.assertEqual(self.pool['name'], pool['name'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_pools(self):
# Verify the pool exists in the list of all pools
resp, body = self.client.list_pools()
@@ -123,7 +127,7 @@
pools = body['pools']
self.assertIn(self.pool['id'], [p['id'] for p in pools])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_members(self):
# Verify the member exists in the list of all members
resp, body = self.client.list_members()
@@ -131,7 +135,7 @@
members = body['members']
self.assertIn(self.member['id'], [m['id'] for m in members])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_update_delete_member(self):
# Creates a member
resp, body = self.client.create_member("10.0.9.47", 80,
@@ -148,7 +152,7 @@
resp, body = self.client.delete_member(member['id'])
self.assertEqual('204', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_member(self):
# Verifies the details of a member
resp, body = self.client.show_member(self.member['id'])
@@ -158,7 +162,7 @@
self.assertEqual(self.member['admin_state_up'],
member['admin_state_up'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_health_monitors(self):
# Verify the health monitor exists in the list of all health monitors
resp, body = self.client.list_health_monitors()
@@ -167,7 +171,7 @@
self.assertIn(self.health_monitor['id'],
[h['id'] for h in health_monitors])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_update_delete_health_monitor(self):
# Creates a health_monitor
resp, body = self.client.create_health_monitor(4, 3, "TCP", 1)
@@ -184,7 +188,7 @@
resp, body = self.client.delete_health_monitor(health_monitor['id'])
self.assertEqual('204', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_health_monitor(self):
# Verifies the details of a health_monitor
resp, body = self.client.show_health_monitor(self.health_monitor['id'])
@@ -194,7 +198,7 @@
self.assertEqual(self.health_monitor['admin_state_up'],
health_monitor['admin_state_up'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_associate_disassociate_health_monitor_with_pool(self):
# Verify that a health monitor can be associated with a pool
resp, body = (self.client.associate_health_monitor_with_pool
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index 14c8500..4269644 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -127,6 +125,21 @@
self.assertIsNotNone(found, msg)
@attr(type='smoke')
+ def test_list_networks_fields(self):
+ # Verify listing some fields of the networks
+ resp, body = self.client.list_networks(fields='id')
+ self.assertEqual('200', resp['status'])
+ networks = body['networks']
+ found = None
+ for n in networks:
+ self.assertEqual(len(n), 1)
+ self.assertIn('id', n)
+ if (n['id'] == self.network['id']):
+ found = n['id']
+ self.assertIsNotNone(found,
+ "Created network id not found in the list")
+
+ @attr(type='smoke')
def test_show_subnet(self):
# Verifies the details of a subnet
resp, body = self.client.show_subnet(self.subnet['id'])
@@ -149,6 +162,21 @@
self.assertIsNotNone(found, msg)
@attr(type='smoke')
+ def test_list_subnets_fields(self):
+ # Verify listing some fields of the subnets
+ resp, body = self.client.list_subnets(fields='id')
+ self.assertEqual('200', resp['status'])
+ subnets = body['subnets']
+ found = None
+ for n in subnets:
+ self.assertEqual(len(n), 1)
+ self.assertIn('id', n)
+ if (n['id'] == self.subnet['id']):
+ found = n['id']
+ self.assertIsNotNone(found,
+ "Created subnet id not found in the list")
+
+ @attr(type='smoke')
def test_create_update_delete_port(self):
# Verify that successful port creation, update & deletion
resp, body = self.client.create_port(self.network['id'])
@@ -184,23 +212,20 @@
found = n['id']
self.assertIsNotNone(found, "Port list doesn't contain created port")
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_network(self):
- non_exist_id = data_utils.rand_name('network')
- self.assertRaises(exceptions.NotFound, self.client.show_network,
- non_exist_id)
-
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_subnet(self):
- non_exist_id = data_utils.rand_name('subnet')
- self.assertRaises(exceptions.NotFound, self.client.show_subnet,
- non_exist_id)
-
- @attr(type=['negative', 'smoke'])
- def test_show_non_existent_port(self):
- non_exist_id = data_utils.rand_name('port')
- self.assertRaises(exceptions.NotFound, self.client.show_port,
- non_exist_id)
+ @attr(type='smoke')
+ def test_list_ports_fields(self):
+ # Verify listing some fields of the ports
+ resp, body = self.client.list_ports(fields='id')
+ self.assertEqual('200', resp['status'])
+ ports_list = body['ports']
+ found = None
+ for n in ports_list:
+ self.assertEqual(len(n), 1)
+ self.assertIn('id', n)
+ if (n['id'] == self.port['id']):
+ found = n['id']
+ self.assertIsNotNone(found,
+ "Created port id not found in the list")
class NetworksTestXML(NetworksTestJSON):
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
new file mode 100644
index 0000000..67306e9
--- /dev/null
+++ b/tempest/api/network/test_networks_negative.py
@@ -0,0 +1,58 @@
+# Copyright 2013 Huawei Technologies Co.,LTD.
+# 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.network import base
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.test import attr
+
+
+class NetworksNegativeTestJSON(base.BaseNetworkTest):
+ _interface = 'json'
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_network(self):
+ non_exist_id = data_utils.rand_name('network')
+ self.assertRaises(exceptions.NotFound, self.client.show_network,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_subnet(self):
+ non_exist_id = data_utils.rand_name('subnet')
+ self.assertRaises(exceptions.NotFound, self.client.show_subnet,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ def test_show_non_existent_port(self):
+ non_exist_id = data_utils.rand_name('port')
+ self.assertRaises(exceptions.NotFound, self.client.show_port,
+ non_exist_id)
+
+ @attr(type=['negative', 'smoke'])
+ def test_update_non_existent_network(self):
+ non_exist_id = data_utils.rand_name('network')
+ self.assertRaises(exceptions.NotFound, self.client.update_network,
+ non_exist_id, "new_name")
+
+ @attr(type=['negative', 'smoke'])
+ def test_delete_non_existent_network(self):
+ non_exist_id = data_utils.rand_name('network')
+ self.assertRaises(exceptions.NotFound, self.client.delete_network,
+ non_exist_id)
+
+
+class NetworksNegativeTestXML(NetworksNegativeTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/network/test_quotas.py b/tempest/api/network/test_quotas.py
index f7ba3cb..a5be395 100644
--- a/tempest/api/network/test_quotas.py
+++ b/tempest/api/network/test_quotas.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -74,12 +72,13 @@
resp, non_default_quotas = self.admin_client.list_quotas()
self.assertEqual('200', resp['status'])
found = False
- for qs in non_default_quotas:
+ for qs in non_default_quotas['quotas']:
if qs['tenant_id'] == tenant_id:
found = True
self.assertTrue(found)
# Confirm from APi quotas were changed as requested for tenant
resp, quota_set = self.admin_client.show_quotas(tenant_id)
+ quota_set = quota_set['quota']
self.assertEqual('200', resp['status'])
self.assertEqual(0, quota_set['network'])
self.assertEqual(0, quota_set['security_group'])
@@ -88,5 +87,5 @@
self.assertEqual('204', resp['status'])
resp, non_default_quotas = self.admin_client.list_quotas()
self.assertEqual('200', resp['status'])
- for q in non_default_quotas:
+ for q in non_default_quotas['quotas']:
self.assertNotEqual(tenant_id, q['tenant_id'])
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index 3cbe23f..e746597 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,44 +13,21 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.network import base
+import netaddr
+
+from tempest.api.network import base_routers as base
from tempest.common.utils import data_utils
-from tempest.test import attr
+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'])
-
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_show_list_update_delete_router(self):
# Create a router
# NOTE(salv-orlando): Do not invoke self.create_router
@@ -95,7 +70,7 @@
create_body['router']['id'])
self.assertEqual(show_body['router']['name'], updated_name)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_subnet_id(self):
network = self.create_network()
subnet = self.create_subnet(network)
@@ -114,7 +89,7 @@
self.assertEqual(show_port_body['port']['device_id'],
router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_add_remove_router_interface_with_port_id(self):
network = self.create_network()
self.create_subnet(network)
@@ -158,7 +133,7 @@
public_subnet_id = public_net_body['network']['subnets'][0]
self.assertEqual(fixed_ips[0]['subnet_id'], public_subnet_id)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway(self):
router = self.create_router(data_utils.rand_name('router-'))
self.client.update_router(
@@ -173,7 +148,7 @@
{'network_id': self.network_cfg.public_network_id})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_with_snat_explicit(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -187,7 +162,7 @@
'enable_snat': True})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_set_gateway_without_snat(self):
router = self.create_router(data_utils.rand_name('router-'))
self.admin_client.update_router_with_snat_gw_info(
@@ -201,7 +176,7 @@
'enable_snat': False})
self._verify_gateway_port(router['id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_unset_gateway(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -214,7 +189,7 @@
device_id=router['id'])
self.assertFalse(list_body['ports'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_update_router_reset_gateway_without_snat(self):
router = self.create_router(
data_utils.rand_name('router-'),
@@ -229,3 +204,23 @@
{'network_id': self.network_cfg.public_network_id,
'enable_snat': False})
self._verify_gateway_port(router['id'])
+
+ @test.requires_ext(extension='extraroute', service='network')
+ @test.attr(type='smoke')
+ def test_update_extra_route(self):
+ self.network = self.create_network()
+ self.name = self.network['name']
+ self.subnet = self.create_subnet(self.network)
+ # Add router interface with subnet id
+ self.router = self.create_router(data_utils.rand_name('router-'), True)
+ self.create_router_interface(self.router['id'], self.subnet['id'])
+ self.addCleanup(
+ self._delete_extra_routes,
+ self.router['id'])
+ # Update router extra route
+ cidr = netaddr.IPNetwork(self.subnet['cidr'])
+ resp, extra_route = self.client.update_extra_routes(
+ self.router['id'], str(cidr[0]), str(self.subnet['cidr']))
+
+ def _delete_extra_routes(self, router_id):
+ resp, _ = self.client.delete_extra_routes(router_id)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
new file mode 100644
index 0000000..0d65b64
--- /dev/null
+++ b/tempest/api/network/test_routers_negative.py
@@ -0,0 +1,55 @@
+# 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/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index 9b0a3de..b95182d 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -82,6 +80,36 @@
for rule in rule_list_body['security_group_rules']]
self.assertIn(rule_create_body['security_group_rule']['id'], rule_list)
+ @attr(type='smoke')
+ def test_create_security_group_rule_with_additional_args(self):
+ # Verify creating security group rule with the following
+ # arguments works: "protocol": "tcp", "port_range_max": 77,
+ # "port_range_min": 77, "direction":"ingress".
+ group_create_body, _ = self._create_security_group()
+
+ direction = 'ingress'
+ protocol = 'tcp'
+ port_range_min = 77
+ port_range_max = 77
+ resp, rule_create_body = self.client.create_security_group_rule(
+ group_create_body['security_group']['id'],
+ direction=direction,
+ protocol=protocol,
+ port_range_min=port_range_min,
+ port_range_max=port_range_max
+ )
+
+ self.assertEqual('201', resp['status'])
+ sec_group_rule = rule_create_body['security_group_rule']
+ self.addCleanup(self._delete_security_group_rule,
+ sec_group_rule['id']
+ )
+
+ self.assertEqual(sec_group_rule['direction'], direction)
+ self.assertEqual(sec_group_rule['protocol'], protocol)
+ self.assertEqual(int(sec_group_rule['port_range_min']), port_range_min)
+ self.assertEqual(int(sec_group_rule['port_range_max']), port_range_max)
+
class SecGroupTestXML(SecGroupTest):
_interface = 'xml'
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 32f4c95..98e109e 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index ae03e96..d272c47 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -1,5 +1,3 @@
-# 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
@@ -13,13 +11,20 @@
# under the License.
from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
class ServiceTypeManagementTestJSON(base.BaseNetworkTest):
_interface = 'json'
- @attr(type='smoke')
+ @classmethod
+ def setUpClass(cls):
+ super(ServiceTypeManagementTestJSON, cls).setUpClass()
+ if not test.is_extension_enabled('service-type', 'network'):
+ msg = "Neutron Service Type Management not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
def test_service_provider_list(self):
resp, body = self.client.list_service_providers()
self.assertEqual(resp['status'], '200')
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 63a8e24..089f9ef 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -17,7 +15,7 @@
from tempest.api.network import base
from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
class VPNaaSJSON(base.BaseNetworkTest):
@@ -38,6 +36,9 @@
@classmethod
def setUpClass(cls):
super(VPNaaSJSON, cls).setUpClass()
+ if not test.is_extension_enabled('vpnaas', 'network'):
+ msg = "vpnaas extension not enabled."
+ raise cls.skipException(msg)
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
cls.router = cls.create_router(
@@ -46,45 +47,45 @@
cls.create_router_interface(cls.router['id'], cls.subnet['id'])
cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
cls.router['id'])
- cls.ikepolicy = cls.create_ike_policy(data_utils.rand_name(
- "ike-policy-"))
+ cls.ikepolicy = cls.create_ikepolicy(
+ data_utils.rand_name("ike-policy-"))
def _delete_ike_policy(self, ike_policy_id):
# Deletes a ike policy and verifies if it is deleted or not
ike_list = list()
- resp, all_ike = self.client.list_ike_policies()
+ resp, all_ike = self.client.list_ikepolicies()
for ike in all_ike['ikepolicies']:
ike_list.append(ike['id'])
if ike_policy_id in ike_list:
- resp, _ = self.client.delete_ike_policy(ike_policy_id)
+ resp, _ = self.client.delete_ikepolicy(ike_policy_id)
self.assertEqual(204, resp.status)
# Asserting that the policy is not found in list after deletion
- resp, ikepolicies = self.client.list_ike_policies()
+ resp, ikepolicies = self.client.list_ikepolicies()
ike_id_list = list()
for i in ikepolicies['ikepolicies']:
ike_id_list.append(i['id'])
self.assertNotIn(ike_policy_id, ike_id_list)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_vpn_services(self):
# Verify the VPN service exists in the list of all VPN services
- resp, body = self.client.list_vpn_services()
+ resp, body = self.client.list_vpnservices()
self.assertEqual('200', resp['status'])
vpnservices = body['vpnservices']
self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_update_delete_vpn_service(self):
# Creates a VPN service
name = data_utils.rand_name('vpn-service-')
- resp, body = self.client.create_vpn_service(self.subnet['id'],
- self.router['id'],
- name=name,
- admin_state_up=True)
+ resp, body = self.client.create_vpnservice(self.subnet['id'],
+ self.router['id'],
+ name=name,
+ admin_state_up=True)
self.assertEqual('201', resp['status'])
vpnservice = body['vpnservice']
# Assert if created vpnservices are not found in vpnservices list
- resp, body = self.client.list_vpn_services()
+ resp, body = self.client.list_vpnservices()
vpn_services = [vs['id'] for vs in body['vpnservices']]
self.assertIsNotNone(vpnservice['id'])
self.assertIn(vpnservice['id'], vpn_services)
@@ -95,17 +96,17 @@
# should be "ACTIVE" not "PENDING*"
# Verification of vpn service delete
- resp, body = self.client.delete_vpn_service(vpnservice['id'])
+ resp, body = self.client.delete_vpnservice(vpnservice['id'])
self.assertEqual('204', resp['status'])
# Asserting if vpn service is found in the list after deletion
- resp, body = self.client.list_vpn_services()
+ resp, body = self.client.list_vpnservices()
vpn_services = [vs['id'] for vs in body['vpnservices']]
self.assertNotIn(vpnservice['id'], vpn_services)
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_vpn_service(self):
# Verifies the details of a vpn service
- resp, body = self.client.show_vpn_service(self.vpnservice['id'])
+ resp, body = self.client.show_vpnservice(self.vpnservice['id'])
self.assertEqual('200', resp['status'])
vpnservice = body['vpnservice']
self.assertEqual(self.vpnservice['id'], vpnservice['id'])
@@ -116,19 +117,19 @@
self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_list_ike_policies(self):
# Verify the ike policy exists in the list of all IKE policies
- resp, body = self.client.list_ike_policies()
+ resp, body = self.client.list_ikepolicies()
self.assertEqual('200', resp['status'])
ikepolicies = body['ikepolicies']
self.assertIn(self.ikepolicy['id'], [i['id'] for i in ikepolicies])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_create_update_delete_ike_policy(self):
# Creates a IKE policy
name = data_utils.rand_name('ike-policy-')
- resp, body = (self.client.create_ike_policy(
+ resp, body = (self.client.create_ikepolicy(
name,
ike_version="v1",
encryption_algorithm="aes-128",
@@ -140,19 +141,19 @@
description = "Updated ike policy"
new_ike = {'description': description, 'pfs': 'group5',
'name': data_utils.rand_name("New-IKE-")}
- resp, body = self.client.update_ike_policy(ikepolicy['id'],
- **new_ike)
+ resp, body = self.client.update_ikepolicy(ikepolicy['id'],
+ **new_ike)
self.assertEqual('200', resp['status'])
updated_ike_policy = body['ikepolicy']
self.assertEqual(updated_ike_policy['description'], description)
# Verification of ike policy delete
- resp, body = self.client.delete_ike_policy(ikepolicy['id'])
+ resp, body = self.client.delete_ikepolicy(ikepolicy['id'])
self.assertEqual('204', resp['status'])
- @attr(type='smoke')
+ @test.attr(type='smoke')
def test_show_ike_policy(self):
# Verifies the details of a ike policy
- resp, body = self.client.show_ike_policy(self.ikepolicy['id'])
+ resp, body = self.client.show_ikepolicy(self.ikepolicy['id'])
self.assertEqual('200', resp['status'])
ikepolicy = body['ikepolicy']
self.assertEqual(self.ikepolicy['id'], ikepolicy['id'])
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index e7cb806..41f23b3 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -28,11 +26,13 @@
@classmethod
def setUpClass(cls):
+ cls.set_network_resources()
super(BaseObjectTest, 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)
- cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)
+ cls.isolated_creds = isolated_creds.IsolatedCreds(
+ cls.__name__, network_resources=cls.network_resources)
if cls.config.compute.allow_tenant_isolation:
# Get isolated creds for normal user
creds = cls.isolated_creds.get_primary_creds()
@@ -101,6 +101,7 @@
The containers should be visible from the container_client given.
Will not throw any error if the containers don't exist.
+ Will not check that object and container deletions succeed.
:param containers: list of container names to remove
:param container_client: if None, use cls.container_client, this means
diff --git a/tempest/api/object_storage/test_account_quotas.py b/tempest/api/object_storage/test_account_quotas.py
index c1b3391..6312f69 100644
--- a/tempest/api/object_storage/test_account_quotas.py
+++ b/tempest/api/object_storage/test_account_quotas.py
@@ -14,19 +14,17 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.object_storage import base
from tempest import clients
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
+from tempest import test
+
+CONF = config.CONF
class AccountQuotasTest(base.BaseObjectTest):
- accounts_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.accounts_quotas
@classmethod
def setUpClass(cls):
@@ -97,9 +95,8 @@
cls.data.teardown_all()
super(AccountQuotasTest, cls).tearDownClass()
- @testtools.skipIf(not accounts_quotas_available,
- "Account Quotas middleware not available")
- @attr(type="smoke")
+ @test.attr(type="smoke")
+ @test.requires_ext(extension='account_quotas', service='object')
def test_upload_valid_object(self):
object_name = data_utils.rand_name(name="TestObject")
data = data_utils.arbitrary_string()
@@ -109,9 +106,8 @@
self.assertEqual(resp["status"], "201")
self.assertHeaders(resp, 'Object', 'PUT')
- @testtools.skipIf(not accounts_quotas_available,
- "Account Quotas middleware not available")
- @attr(type=["negative", "smoke"])
+ @test.attr(type=["negative", "smoke"])
+ @test.requires_ext(extension='account_quotas', service='object')
def test_upload_large_object(self):
object_name = data_utils.rand_name(name="TestObject")
data = data_utils.arbitrary_string(30)
@@ -119,9 +115,8 @@
self.object_client.create_object,
self.container_name, object_name, data)
- @testtools.skipIf(not accounts_quotas_available,
- "Account Quotas middleware not available")
- @attr(type=["smoke"])
+ @test.attr(type=["smoke"])
+ @test.requires_ext(extension='account_quotas', service='object')
def test_admin_modify_quota(self):
"""Test that the ResellerAdmin is able to modify and remove the quota
on a user's account.
@@ -144,9 +139,8 @@
self.assertEqual(resp["status"], "204")
self.assertHeaders(resp, 'Account', 'POST')
- @testtools.skipIf(not accounts_quotas_available,
- "Account Quotas middleware not available")
- @attr(type=["negative", "smoke"])
+ @test.attr(type=["negative", "smoke"])
+ @test.requires_ext(extension='account_quotas', service='object')
def test_user_modify_quota(self):
"""Test that a user is not able to modify or remove a quota on
its account.
diff --git a/tempest/api/object_storage/test_account_services.py b/tempest/api/object_storage/test_account_services.py
index 12c823b..68b9222 100644
--- a/tempest/api/object_storage/test_account_services.py
+++ b/tempest/api/object_storage/test_account_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/object_storage/test_container_acl.py b/tempest/api/object_storage/test_container_acl.py
index b2dc20f..a01b703 100644
--- a/tempest/api/object_storage/test_container_acl.py
+++ b/tempest/api/object_storage/test_container_acl.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/object_storage/test_container_quotas.py b/tempest/api/object_storage/test_container_quotas.py
index c7b5e28..59b84d9 100644
--- a/tempest/api/object_storage/test_container_quotas.py
+++ b/tempest/api/object_storage/test_container_quotas.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Cloudwatt
# All Rights Reserved.
#
@@ -15,24 +13,19 @@
# License for the specific language governing permissions and limitations
# under the License.
-import testtools
-
from tempest.api.object_storage 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 HTTP_SUCCESS
+from tempest import test
+CONF = config.CONF
QUOTA_BYTES = 10
QUOTA_COUNT = 3
-SKIP_MSG = "Container quotas middleware not available."
class ContainerQuotasTest(base.BaseObjectTest):
"""Attemps to test the perfect behavior of quotas in a container."""
- container_quotas_available = \
- config.TempestConfig().object_storage_feature_enabled.container_quotas
def setUp(self):
"""Creates and sets a container with quotas.
@@ -57,8 +50,8 @@
self.delete_containers([self.container_name])
super(ContainerQuotasTest, self).tearDown()
- @testtools.skipIf(not container_quotas_available, SKIP_MSG)
- @attr(type="smoke")
+ @test.requires_ext(extension='container_quotas', service='object')
+ @test.attr(type="smoke")
def test_upload_valid_object(self):
"""Attempts to uploads an object smaller than the bytes quota."""
object_name = data_utils.rand_name(name="TestObject")
@@ -68,14 +61,14 @@
resp, _ = self.object_client.create_object(
self.container_name, object_name, data)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'PUT')
nafter = self._get_bytes_used()
self.assertEqual(nbefore + len(data), nafter)
- @testtools.skipIf(not container_quotas_available, SKIP_MSG)
- @attr(type="smoke")
+ @test.requires_ext(extension='container_quotas', service='object')
+ @test.attr(type="smoke")
def test_upload_large_object(self):
"""Attempts to upload an object lagger than the bytes quota."""
object_name = data_utils.rand_name(name="TestObject")
@@ -90,8 +83,8 @@
nafter = self._get_bytes_used()
self.assertEqual(nbefore, nafter)
- @testtools.skipIf(not container_quotas_available, SKIP_MSG)
- @attr(type="smoke")
+ @test.requires_ext(extension='container_quotas', service='object')
+ @test.attr(type="smoke")
def test_upload_too_many_objects(self):
"""Attempts to upload many objects that exceeds the count limit."""
for _ in range(QUOTA_COUNT):
diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py
index 04de072..0d477d9 100644
--- a/tempest/api/object_storage/test_container_services.py
+++ b/tempest/api/object_storage/test_container_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index dcfe219..32bbcbd 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,25 +14,38 @@
# under the License.
import time
+import urlparse
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest.test import attr
-from tempest.test import skip_because
+from tempest.test import HTTP_SUCCESS
+
+# This test can be quite long to run due to its
+# dependency on container-sync process running interval.
+# You can obviously reduce the container-sync interval in the
+# container-server configuration.
class ContainerSyncTest(base.BaseObjectTest):
+
@classmethod
def setUpClass(cls):
super(ContainerSyncTest, cls).setUpClass()
cls.containers = []
cls.objects = []
+
+ # Default container-server config only allows localhost
+ cls.local_ip = '127.0.0.1'
+
+ # Must be configure according to container-sync interval
container_sync_timeout = \
int(cls.config.object_storage.container_sync_timeout)
cls.container_sync_interval = \
int(cls.config.object_storage.container_sync_interval)
cls.attempts = \
int(container_sync_timeout / cls.container_sync_interval)
+
# define container and object clients
cls.clients = {}
cls.clients[data_utils.rand_name(name='TestContainerSync')] = \
@@ -51,8 +62,7 @@
cls.delete_containers(cls.containers, client[0], client[1])
super(ContainerSyncTest, cls).tearDownClass()
- @skip_because(bug="1093743")
- @attr(type='gate')
+ @attr(type='slow')
def test_container_synchronization(self):
# container to container synchronization
# to allow/accept sync requests to/from other accounts
@@ -62,51 +72,53 @@
cont_client = [self.clients[c][0] for c in cont]
obj_client = [self.clients[c][1] for c in cont]
# tell first container to synchronize to a second
+ client_proxy_ip = \
+ urlparse.urlparse(cont_client[1].base_url).netloc.split(':')[0]
+ client_base_url = \
+ cont_client[1].base_url.replace(client_proxy_ip,
+ self.local_ip)
headers = {'X-Container-Sync-Key': 'sync_key',
'X-Container-Sync-To': "%s/%s" %
- (cont_client[1].base_url, str(cont[1]))}
+ (client_base_url, str(cont[1]))}
resp, body = \
cont_client[0].put(str(cont[0]), body=None, headers=headers)
- self.assertIn(resp['status'], ('202', '201'),
- 'Error installing X-Container-Sync-To '
- 'for the container "%s"' % (cont[0]))
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
# create object in container
object_name = data_utils.rand_name(name='TestSyncObject')
data = object_name[::-1] # data_utils.arbitrary_string()
resp, _ = obj_client[0].create_object(cont[0], object_name, data)
- self.assertEqual(resp['status'], '201',
- 'Error creating the object "%s" in'
- 'the container "%s"'
- % (object_name, cont[0]))
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
self.objects.append(object_name)
# wait until container contents list is not empty
cont_client = [self.clients[c][0] for c in self.containers]
params = {'format': 'json'}
while self.attempts > 0:
- # get first container content
- resp, object_list_0 = \
- cont_client[0].\
- list_container_contents(self.containers[0], params=params)
- self.assertEqual(resp['status'], '200',
- 'Error listing the destination container`s'
- ' "%s" contents' % (self.containers[0]))
- object_list_0 = dict((obj['name'], obj) for obj in object_list_0)
- # get second container content
- resp, object_list_1 = \
- cont_client[1].\
- list_container_contents(self.containers[1], params=params)
- self.assertEqual(resp['status'], '200',
- 'Error listing the destination container`s'
- ' "%s" contents' % (self.containers[1]))
- object_list_1 = dict((obj['name'], obj) for obj in object_list_1)
+ object_lists = []
+ for client_index in (0, 1):
+ resp, object_list = \
+ cont_client[client_index].\
+ list_container_contents(self.containers[client_index],
+ params=params)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ object_lists.append(dict(
+ (obj['name'], obj) for obj in object_list))
# check that containers are not empty and have equal keys()
# or wait for next attempt
- if not object_list_0 or not object_list_1 or \
- set(object_list_0.keys()) != set(object_list_1.keys()):
+ if not object_lists[0] or not object_lists[1] or \
+ set(object_lists[0].keys()) != set(object_lists[1].keys()):
time.sleep(self.container_sync_interval)
self.attempts -= 1
else:
break
- self.assertEqual(object_list_0, object_list_1,
+
+ self.assertEqual(object_lists[0], object_lists[1],
'Different object lists in containers.')
+
+ # Verify object content
+ obj_clients = [(self.clients[c][1], c) for c in self.containers]
+ for obj_client, cont in obj_clients:
+ for obj_name in object_lists[0]:
+ resp, object_content = obj_client.get_object(cont, obj_name)
+ self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertEqual(object_content, obj_name[::-1])
diff --git a/tempest/api/object_storage/test_crossdomain.py b/tempest/api/object_storage/test_crossdomain.py
index 51ecd16..71e123c 100644
--- a/tempest/api/object_storage/test_crossdomain.py
+++ b/tempest/api/object_storage/test_crossdomain.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
@@ -19,25 +17,14 @@
from tempest.api.object_storage import base
from tempest import clients
from tempest.common import custom_matchers
-from tempest import config
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
class CrossdomainTest(base.BaseObjectTest):
- crossdomain_available = \
- config.TempestConfig().object_storage_feature_enabled.crossdomain
@classmethod
def setUpClass(cls):
super(CrossdomainTest, cls).setUpClass()
-
- # skip this test if CORS isn't enabled in the conf file.
- if not cls.crossdomain_available:
- skip_msg = ("%s skipped as Crossdomain middleware not available"
- % cls.__name__)
- raise cls.skipException(skip_msg)
-
# creates a test user. The test user will set its base_url to the Swift
# endpoint and test the healthcheck feature.
cls.data.setup_test_user()
@@ -73,12 +60,13 @@
super(CrossdomainTest, self).tearDown()
- @attr('gate')
+ @test.attr('gate')
+ @test.requires_ext(extension='crossdomain', service='object')
def test_get_crossdomain_policy(self):
resp, body = self.os_test_user.account_client.get("crossdomain.xml",
{})
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertTrue(body.startswith(self.xml_start) and
body.endswith(self.xml_end))
diff --git a/tempest/api/object_storage/test_healthcheck.py b/tempest/api/object_storage/test_healthcheck.py
index 7bbdd1e..fdac12f 100644
--- a/tempest/api/object_storage/test_healthcheck.py
+++ b/tempest/api/object_storage/test_healthcheck.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
diff --git a/tempest/api/object_storage/test_object_expiry.py b/tempest/api/object_storage/test_object_expiry.py
index 4958f70..7ca0e51 100644
--- a/tempest/api/object_storage/test_object_expiry.py
+++ b/tempest/api/object_storage/test_object_expiry.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -21,7 +19,6 @@
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest.test import attr
-from tempest.test import skip_because
class ObjectExpiryTest(base.BaseObjectTest):
@@ -33,31 +30,20 @@
@classmethod
def tearDownClass(cls):
- """The test script fails in tear down class
- as the container contains expired objects (LP bug 1069849).
- But delete action for the expired object is raising
- NotFound exception and also non empty container cannot be deleted.
- """
cls.delete_containers([cls.container_name])
super(ObjectExpiryTest, cls).tearDownClass()
- @skip_because(bug="1069849")
- @attr(type='gate')
- def test_get_object_after_expiry_time(self):
- # TODO(harika-vakadi): similar test case has to be created for
- # "X-Delete-At", after this test case works.
-
+ def _test_object_expiry(self, metadata):
# create object
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
resp, _ = self.object_client.create_object(self.container_name,
- object_name, data)
- # update object metadata with expiry time of 3 seconds
- metadata = {'X-Delete-After': '3'}
+ object_name, '')
+ # update object metadata
resp, _ = \
self.object_client.update_object_metadata(self.container_name,
object_name, metadata,
metadata_prefix='')
+ # verify object metadata
resp, _ = \
self.object_client.list_object_metadata(self.container_name,
object_name)
@@ -69,10 +55,20 @@
self.assertEqual(resp['status'], '200')
self.assertHeaders(resp, 'Object', 'GET')
self.assertIn('x-delete-at', resp)
- # check data
- self.assertEqual(body, data)
+
# sleep for over 5 seconds, so that object expires
time.sleep(5)
+
# object should not be there anymore
self.assertRaises(exceptions.NotFound, self.object_client.get_object,
self.container_name, object_name)
+
+ @attr(type='gate')
+ def test_get_object_after_expiry_time(self):
+ metadata = {'X-Delete-After': '3'}
+ self._test_object_expiry(metadata)
+
+ @attr(type='gate')
+ def test_get_object_at_expiry_time(self):
+ metadata = {'X-Delete-At': str(int(time.time()) + 3)}
+ self._test_object_expiry(metadata)
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index 817c892..621a693 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -1,4 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Christian Schwede <christian.schwede@enovance.com>
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index c7fdd0e..256165b 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index 997120a..ee7f6a4 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NTT Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index bb03932..0523c68 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -1,4 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Joe H. Rahme <joe.hakim.rahme@enovance.com>
@@ -24,40 +23,40 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import exceptions
-from tempest.test import attr
-from tempest.test import HTTP_SUCCESS
+from tempest import test
+
+CONF = config.CONF
class ObjectTempUrlTest(base.BaseObjectTest):
- tempurl_available = \
- config.TempestConfig().object_storage_feature_enabled.tempurl
-
@classmethod
def setUpClass(cls):
super(ObjectTempUrlTest, cls).setUpClass()
-
- # skip this test if CORS 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)
@@ -67,21 +66,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)
@@ -102,7 +96,8 @@
return url
- @attr(type='gate')
+ @test.attr(type='gate')
+ @test.requires_ext(extension='tempurl', service='object')
def test_get_object_using_temp_url(self):
expires = self._get_expiry_date()
@@ -112,38 +107,44 @@
expires, self.key)
# trying to get object using temp url within expiry time
- resp, body = self.object_client.get_object_using_temp_url(url)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ resp, body = self.object_client.get(url)
+ self.assertIn(int(resp['status']), test.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)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'HEAD')
- @attr(type='gate')
+ @test.attr(type='gate')
+ @test.requires_ext(extension='tempurl', service='object')
def test_get_object_using_temp_url_key_2(self):
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)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
- self.assertEqual(body, self.data)
+ resp, body = self.object_client.get(url)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
+ self.assertEqual(body, self.content)
- @attr(type='gate')
+ @test.attr(type='gate')
+ @test.requires_ext(extension='tempurl', service='object')
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"))
@@ -154,15 +155,13 @@
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)
-
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ resp, body = self.object_client.put(url, new_data, None)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'PUT')
# Testing a HEAD on this Temp URL
resp, body = self.object_client.head(url)
- self.assertIn(int(resp['status']), HTTP_SUCCESS)
+ self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, 'Object', 'HEAD')
# Validate that the content of the object has been modified
@@ -170,10 +169,26 @@
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', 'negative'])
+ @test.attr(type='gate')
+ @test.requires_ext(extension='tempurl', service='object')
+ 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']), test.HTTP_SUCCESS)
+ self.assertHeaders(resp, 'Object', 'HEAD')
+
+ @test.attr(type=['gate', 'negative'])
+ @test.requires_ext(extension='tempurl', service='object')
def test_get_object_after_expiration_time(self):
expires = self._get_expiry_date(1)
@@ -186,5 +201,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/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index d706eef..75293d2 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index f3ef99f..b69cc49 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -1,5 +1,3 @@
-# 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
@@ -12,8 +10,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 +114,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/orchestration/stacks/test_limits.py b/tempest/api/orchestration/stacks/test_limits.py
index d294c7a..2b5bd8f 100644
--- a/tempest/api/orchestration/stacks/test_limits.py
+++ b/tempest/api/orchestration/stacks/test_limits.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index c86edf0..bed72c8 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index 35a7326..11d01f7 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -1,5 +1,3 @@
-# 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
@@ -28,75 +26,61 @@
template = """
HeatTemplateFormatVersion: '2012-12-12'
Description: |
- Template which creates single EC2 instance
+ Template which creates some simple resources
Parameters:
- KeyName:
+ trigger:
Type: String
- InstanceType:
- Type: String
- ImageId:
- Type: String
- Subnet:
- Type: String
+ Default: not_yet
Resources:
- SmokeServer:
- Type: AWS::EC2::Instance
+ fluffy:
+ Type: AWS::AutoScaling::LaunchConfiguration
Metadata:
- Name: SmokeServer
+ kittens:
+ - Tom
+ - Stinky
Properties:
- ImageId: {Ref: ImageId}
- InstanceType: {Ref: InstanceType}
- KeyName: {Ref: KeyName}
- SubnetId: {Ref: Subnet}
+ ImageId: not_used
+ InstanceType: not_used
UserData:
- Fn::Base64:
- Fn::Join:
- - ''
- - - '#!/bin/bash -v
-
- '
- - /opt/aws/bin/cfn-signal -e 0 -r "SmokeServer created" '
- - {Ref: WaitHandle}
- - '''
-
- '
- WaitHandle:
- Type: AWS::CloudFormation::WaitConditionHandle
- WaitCondition:
- Type: AWS::CloudFormation::WaitCondition
- DependsOn: SmokeServer
- Properties:
- Handle: {Ref: WaitHandle}
- Timeout: '600'
+ Fn::Replace:
+ - variable_a: {Ref: trigger}
+ variable_b: bee
+ - |
+ A == variable_a
+ B == variable_b
+Outputs:
+ fluffy:
+ Description: "fluffies irc nick"
+ Value:
+ Fn::Replace:
+ - nick: {Ref: fluffy}
+ - |
+ #nick
"""
@classmethod
def setUpClass(cls):
super(StacksTestJSON, cls).setUpClass()
- if not cls.orchestration_cfg.image_ref:
- raise cls.skipException("No image available to test")
cls.client = cls.orchestration_client
cls.stack_name = data_utils.rand_name('heat')
- keypair_name = (cls.orchestration_cfg.keypair_name or
- cls._create_keypair()['name'])
# create the stack
- subnet = cls._get_default_network()['subnets'][0]
cls.stack_identifier = cls.create_stack(
cls.stack_name,
cls.template,
parameters={
- 'KeyName': keypair_name,
- 'InstanceType': cls.orchestration_cfg.instance_type,
- 'ImageId': cls.orchestration_cfg.image_ref,
- 'Subnet': subnet
+ 'trigger': 'start'
})
cls.stack_id = cls.stack_identifier.split('/')[1]
- cls.resource_name = 'SmokeServer'
- cls.resource_type = 'AWS::EC2::Instance'
+ cls.resource_name = 'fluffy'
+ cls.resource_type = 'AWS::AutoScaling::LaunchConfiguration'
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
- @attr(type='slow')
+ def assert_fields_in_dict(self, obj, *fields):
+ for field in fields:
+ self.assertIn(field, obj)
+
+ @attr(type='gate')
def test_stack_list(self):
"""Created stack should be on the list of existing stacks."""
resp, stacks = self.client.list_stacks()
@@ -105,22 +89,50 @@
stacks_names = map(lambda stack: stack['stack_name'], stacks)
self.assertIn(self.stack_name, stacks_names)
- @attr(type='slow')
+ @attr(type='gate')
def test_stack_show(self):
"""Getting details about created stack should be possible."""
resp, stack = self.client.get_stack(self.stack_name)
self.assertEqual('200', resp['status'])
self.assertIsInstance(stack, dict)
+ self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
+ 'parameters', 'outputs', 'disable_rollback',
+ 'stack_status_reason', 'stack_status',
+ 'creation_time', 'updated_time',
+ 'capabilities', 'notification_topics',
+ 'timeout_mins', 'template_description')
+ self.assert_fields_in_dict(stack['parameters'], 'AWS::StackId',
+ 'trigger', 'AWS::Region', 'AWS::StackName')
+ self.assertEqual(True, stack['disable_rollback'],
+ 'disable_rollback should default to True')
self.assertEqual(self.stack_name, stack['stack_name'])
self.assertEqual(self.stack_id, stack['id'])
+ self.assertEqual('fluffy', stack['outputs'][0]['output_key'])
- @attr(type='slow')
+ @attr(type='gate')
+ def test_suspend_resume_stack(self):
+ """suspend and resume a stack."""
+ resp, suspend_stack = self.client.suspend_stack(self.stack_identifier)
+ self.assertEqual('200', resp['status'])
+ self.client.wait_for_stack_status(self.stack_identifier,
+ 'SUSPEND_COMPLETE')
+ resp, resume_stack = self.client.resume_stack(self.stack_identifier)
+ self.assertEqual('200', resp['status'])
+ self.client.wait_for_stack_status(self.stack_identifier,
+ 'RESUME_COMPLETE')
+
+ @attr(type='gate')
def test_list_resources(self):
"""Getting list of created resources for the stack should be possible.
"""
resp, resources = self.client.list_resources(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(resources, list)
+ for res in resources:
+ self.assert_fields_in_dict(res, 'logical_resource_id',
+ 'resource_type', 'resource_status',
+ 'updated_time')
+
resources_names = map(lambda resource: resource['logical_resource_id'],
resources)
self.assertIn(self.resource_name, resources_names)
@@ -128,16 +140,21 @@
resources)
self.assertIn(self.resource_type, resources_types)
- @attr(type='slow')
+ @attr(type='gate')
def test_show_resource(self):
"""Getting details about created resource should be possible."""
resp, resource = self.client.get_resource(self.stack_identifier,
self.resource_name)
self.assertIsInstance(resource, dict)
+ self.assert_fields_in_dict(resource, 'resource_name', 'description',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'updated_time',
+ 'required_by', 'resource_status_reason',
+ 'physical_resource_id', 'resource_type')
self.assertEqual(self.resource_name, resource['logical_resource_id'])
self.assertEqual(self.resource_type, resource['resource_type'])
- @attr(type='slow')
+ @attr(type='gate')
def test_resource_metadata(self):
"""Getting metadata for created resource should be possible."""
resp, metadata = self.client.show_resource_metadata(
@@ -145,19 +162,25 @@
self.resource_name)
self.assertEqual('200', resp['status'])
self.assertIsInstance(metadata, dict)
- self.assertEqual(self.resource_name, metadata.get('Name', None))
+ self.assertEqual(['Tom', 'Stinky'], metadata.get('kittens', None))
- @attr(type='slow')
+ @attr(type='gate')
def test_list_events(self):
"""Getting list of created events for the stack should be possible."""
resp, events = self.client.list_events(self.stack_identifier)
self.assertEqual('200', resp['status'])
self.assertIsInstance(events, list)
+
+ for event in events:
+ self.assert_fields_in_dict(event, 'logical_resource_id', 'id',
+ 'resource_status_reason',
+ 'resource_status', 'event_time')
+
resource_statuses = map(lambda event: event['resource_status'], events)
self.assertIn('CREATE_IN_PROGRESS', resource_statuses)
self.assertIn('CREATE_COMPLETE', resource_statuses)
- @attr(type='slow')
+ @attr(type='gate')
def test_show_event(self):
"""Getting details about existing event should be possible."""
resp, events = self.client.list_resource_events(self.stack_identifier,
@@ -168,7 +191,12 @@
resp, event = self.client.show_event(self.stack_identifier,
self.resource_name, event_id)
self.assertEqual('200', resp['status'])
- self.assertEqual('CREATE_IN_PROGRESS', event['resource_status'])
+ self.assertIsInstance(event, dict)
+ self.assert_fields_in_dict(event, 'resource_name', 'event_time',
+ 'links', 'logical_resource_id',
+ 'resource_status', 'resource_status_reason',
+ 'physical_resource_id', 'id',
+ 'resource_properties', 'resource_type')
+ self.assertEqual(self.resource_name, event['resource_name'])
self.assertEqual('state changed', event['resource_status_reason'])
self.assertEqual(self.resource_name, event['logical_resource_id'])
- self.assertIsInstance(event, dict)
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 3c2a2d2..2ef629f 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -1,5 +1,3 @@
-# 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
@@ -18,18 +16,17 @@
from tempest.api.orchestration import base
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
from tempest.test import attr
-
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class ServerCfnInitTestJSON(base.BaseOrchestrationTest):
_interface = 'json'
- existing_keypair = (tempest.config.TempestConfig().
- orchestration.keypair_name is not None)
+ existing_keypair = CONF.orchestration.keypair_name is not None
template = """
HeatTemplateFormatVersion: '2012-12-12'
@@ -169,9 +166,9 @@
body['physical_resource_id'])
# Check that the user can authenticate with the generated password
- linux_client = RemoteClient(
- server, 'ec2-user', pkey=self.keypair['private_key'])
- self.assertTrue(linux_client.can_authenticate())
+ linux_client = RemoteClient(server, 'ec2-user',
+ pkey=self.keypair['private_key'])
+ linux_client.validate_authentication()
@attr(type='slow')
def test_stack_wait_condition_data(self):
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index 0b7883d..fc2dda8 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 2589632..6cbc872 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/api/telemetry/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/api/telemetry/__init__.py
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
new file mode 100644
index 0000000..1f661a6
--- /dev/null
+++ b/tempest/api/telemetry/base.py
@@ -0,0 +1,27 @@
+# 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
+import tempest.test
+
+CONF = config.CONF
+
+
+class BaseTelemetryTest(tempest.test.BaseTestCase):
+
+ """Base test case class for all Telemetry API tests."""
+
+ @classmethod
+ def setUpClass(cls):
+ super(BaseTelemetryTest, cls).setUpClass()
+ if not CONF.service_available.ceilometer:
+ raise cls.skipException("Ceilometer support is required")
diff --git a/tempest/api/utils.py b/tempest/api/utils.py
index be6bdba..c62dc8d 100644
--- a/tempest/api/utils.py
+++ b/tempest/api/utils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index 03e8469..32a355b 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -1,5 +1,3 @@
-# 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
@@ -22,7 +20,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..3211ef8 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD
# All Rights Reserved.
#
@@ -15,12 +13,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..5c311e1 100644
--- a/tempest/api/volume/admin/test_volume_hosts.py
+++ b/tempest/api/volume/admin/test_volume_hosts.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -19,7 +17,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..0ea999a 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,13 +13,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..99a0826 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,7 +18,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..5a1a2cd 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
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -23,7 +21,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..56ad227 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -22,7 +20,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..9274fce 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Huawei Technologies Co.,LTD
# All Rights Reserved.
#
@@ -15,12 +13,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 465f570..9c6eebe 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,9 +13,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
@@ -30,18 +27,16 @@
@classmethod
def setUpClass(cls):
+ cls.set_network_resources()
super(BaseVolumeTest, cls).setUpClass()
if not cls.config.service_available.cinder:
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.servers_client = cls.os.servers_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
@@ -49,12 +44,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()
@@ -79,7 +68,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')
@@ -113,27 +105,24 @@
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.snapshots_client = cls.os.snapshots_client
+ cls.volumes_client = cls.os.volumes_client
+ cls.volumes_extension_client = cls.os.volumes_extension_client
-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_extensions.py b/tempest/api/volume/test_extensions.py
new file mode 100644
index 0000000..deef8a1
--- /dev/null
+++ b/tempest/api/volume/test_extensions.py
@@ -0,0 +1,47 @@
+# 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.volume import base
+from tempest.openstack.common import log as logging
+from tempest.test import attr
+
+
+LOG = logging.getLogger(__name__)
+
+
+class ExtensionsTestJSON(base.BaseVolumeV1Test):
+ _interface = 'json'
+
+ @attr(type='gate')
+ def test_list_extensions(self):
+ # List of all extensions
+ resp, extensions = self.volumes_extension_client.list_extensions()
+ self.assertEqual(200, resp.status)
+ if len(self.config.volume_feature_enabled.api_extensions) == 0:
+ raise self.skipException('There are not any extensions configured')
+ extension_list = [extension.get('alias') for extension in extensions]
+ LOG.debug("Cinder extensions: %s" % ','.join(extension_list))
+ ext = self.config.volume_feature_enabled.api_extensions[0]
+ if ext == 'all':
+ self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+ elif ext:
+ self.assertIn(ext, map(lambda x: x['name'], extensions))
+ else:
+ raise self.skipException('There are not any extensions configured')
+
+
+class ExtensionsTestXML(ExtensionsTestJSON):
+ _interface = 'xml'
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
new file mode 100644
index 0000000..1493b37
--- /dev/null
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -0,0 +1,117 @@
+# 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.volume import base
+from tempest import test
+
+
+class SnapshotMetadataTest(base.BaseVolumeV1Test):
+ _interface = "json"
+
+ @classmethod
+ def setUpClass(cls):
+ super(SnapshotMetadataTest, cls).setUpClass()
+ cls.client = cls.snapshots_client
+ # Create a volume
+ cls.volume = cls.create_volume()
+ # Create a snapshot
+ cls.snapshot = cls.create_snapshot(volume_id=cls.volume['id'])
+ cls.snapshot_id = cls.snapshot['id']
+
+ def tearDown(self):
+ # Update the metadata to {}
+ self.client.update_snapshot_metadata(self.snapshot_id, {})
+ super(SnapshotMetadataTest, self).tearDown()
+
+ @test.attr(type='gate')
+ def test_create_get_delete_snapshot_metadata(self):
+ # Create metadata for the snapshot
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+ expected = {"key2": "value2",
+ "key3": "value3"}
+ resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the snapshot
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(metadata, body)
+ # Delete one item metadata of the snapshot
+ resp, body = self.client.delete_snapshot_metadata_item(
+ self.snapshot_id,
+ "key1")
+ self.assertEqual(200, resp.status)
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(expected, body)
+
+ @test.attr(type='gate')
+ def test_update_snapshot_metadata(self):
+ # Update metadata for the snapshot
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+ update = {"key3": "value3_update",
+ "key4": "value4"}
+ # Create metadata for the snapshot
+ resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the snapshot
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(metadata, body)
+ # Update metadata item
+ resp, body = self.client.update_snapshot_metadata(
+ self.snapshot_id,
+ update)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the snapshot
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(update, body)
+
+ @test.attr(type='gate')
+ def test_update_snapshot_metadata_item(self):
+ # Update metadata item for the snapshot
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+ update_item = {"key3": "value3_update"}
+ expect = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3_update"}
+ # Create metadata for the snapshot
+ resp, body = self.client.create_snapshot_metadata(self.snapshot_id,
+ metadata)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the snapshot
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(metadata, body)
+ # Update metadata item
+ resp, body = self.client.update_snapshot_metadata_item(
+ self.snapshot_id,
+ "key3",
+ update_item)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the snapshot
+ resp, body = self.client.get_snapshot_metadata(self.snapshot_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(expect, body)
+
+
+class SnapshotMetadataTestXML(SnapshotMetadataTest):
+ _interface = "xml"
diff --git a/tempest/api/volume/test_volume_metadata.py b/tempest/api/volume/test_volume_metadata.py
new file mode 100644
index 0000000..6d23c0a
--- /dev/null
+++ b/tempest/api/volume/test_volume_metadata.py
@@ -0,0 +1,122 @@
+# 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.volume import base
+from tempest import test
+
+
+class VolumeMetadataTest(base.BaseVolumeV1Test):
+ _interface = "json"
+
+ @classmethod
+ def setUpClass(cls):
+ super(VolumeMetadataTest, cls).setUpClass()
+ # Create a volume
+ cls.volume = cls.create_volume()
+ cls.volume_id = cls.volume['id']
+
+ @classmethod
+ def tearDownClass(cls):
+ super(VolumeMetadataTest, cls).tearDownClass()
+
+ def tearDown(self):
+ # Update the metadata to {}
+ self.volumes_client.update_volume_metadata(self.volume_id, {})
+ super(VolumeMetadataTest, self).tearDown()
+
+ @test.attr(type='gate')
+ def test_create_get_delete_volume_metadata(self):
+ # Create metadata for the volume
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+
+ rsp, body = self.volumes_client.create_volume_metadata(self.volume_id,
+ metadata)
+ self.assertEqual(200, rsp.status)
+ # Get the metadata of the volume
+ resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(metadata, body)
+ # Delete one item metadata of the volume
+ rsp, body = self.volumes_client.delete_volume_metadata_item(
+ self.volume_id,
+ "key1")
+ self.assertEqual(200, rsp.status)
+ resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.assertNotIn("key1", body)
+
+ @test.attr(type='gate')
+ def test_update_volume_metadata(self):
+ # Update metadata for the volume
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+
+ update = {"key4": "value4",
+ "key1": "value1_update"}
+
+ # Create metadata for the volume
+ resp, body = self.volumes_client.create_volume_metadata(
+ self.volume_id,
+ metadata)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the volume
+ resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(metadata, body)
+ # Update metadata
+ resp, body = self.volumes_client.update_volume_metadata(
+ self.volume_id,
+ update)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the volume
+ resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(update, body)
+
+ @test.attr(type='gate')
+ def test_update_volume_metadata_item(self):
+ # Update metadata item for the volume
+ metadata = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+ create_expect = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3"}
+ update_item = {"key3": "value3_update"}
+ expect = {"key1": "value1",
+ "key2": "value2",
+ "key3": "value3_update"}
+ # Create metadata for the volume
+ resp, body = self.volumes_client.create_volume_metadata(
+ self.volume_id,
+ metadata)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(create_expect, body)
+ # Update metadata item
+ resp, body = self.volumes_client.update_volume_metadata_item(
+ self.volume_id,
+ "key3",
+ update_item)
+ self.assertEqual(200, resp.status)
+ # Get the metadata of the volume
+ resp, body = self.volumes_client.get_volume_metadata(self.volume_id)
+ self.assertEqual(200, resp.status)
+ self.assertEqual(expect, body)
+
+
+class VolumeMetadataTestXML(VolumeMetadataTest):
+ _interface = "xml"
diff --git a/tempest/api/volume/test_volume_transfers.py b/tempest/api/volume/test_volume_transfers.py
index dacebf1..8710d82 100644
--- a/tempest/api/volume/test_volume_transfers.py
+++ b/tempest/api/volume/test_volume_transfers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,13 +13,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 +58,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 +87,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..e767ec0 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,14 +13,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 +29,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..79a4365 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -21,7 +19,7 @@
from tempest.test import services
-class VolumesGetTest(base.BaseVolumeTest):
+class VolumesGetTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
@@ -117,17 +115,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 +136,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 4dbc88a..049544d 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
@@ -15,16 +13,20 @@
# 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 operator
from tempest.api.volume import base
from tempest.common.utils import data_utils
from tempest.openstack.common import log as logging
from tempest.test import attr
+from testtools.matchers import ContainsAll
LOG = logging.getLogger(__name__)
+VOLUME_FIELDS = ('id', 'display_name')
-class VolumesListTest(base.BaseVolumeTest):
+
+class VolumesListTest(base.BaseVolumeV1Test):
"""
This test creates a number of 1G volumes. To run successfully,
@@ -36,7 +38,11 @@
_interface = 'json'
- def assertVolumesIn(self, fetched_list, expected_list):
+ def assertVolumesIn(self, fetched_list, expected_list, fields=None):
+ if fields:
+ expected_list = map(operator.itemgetter(*fields), expected_list)
+ fetched_list = map(operator.itemgetter(*fields), fetched_list)
+
missing_vols = [v for v in expected_list if v not in fetched_list]
if len(missing_vols) == 0:
return
@@ -57,19 +63,17 @@
# Create 3 test volumes
cls.volume_list = []
cls.volume_id_list = []
+ cls.metadata = {'Type': 'work'}
for i in range(3):
- v_name = data_utils.rand_name('volume')
- metadata = {'Type': 'work'}
try:
- resp, volume = cls.client.create_volume(size=1,
- display_name=v_name,
- metadata=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
@@ -78,7 +82,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):
@@ -88,13 +92,38 @@
cls.client.wait_for_resource_deletion(volid)
super(VolumesListTest, cls).tearDownClass()
+ def _list_by_param_value_and_assert(self, params, with_detail=False):
+ """
+ Perform list or list_details action with given params
+ and validates result.
+ """
+ if with_detail:
+ resp, fetched_vol_list = \
+ self.client.list_volumes_with_detail(params=params)
+ else:
+ resp, fetched_vol_list = self.client.list_volumes(params=params)
+
+ self.assertEqual(200, resp.status)
+ # Validating params of fetched volumes
+ for volume in fetched_vol_list:
+ for key in params:
+ msg = "Failed to list volumes %s by %s" % \
+ ('details' if with_detail else '', key)
+ if key == 'metadata':
+ self.assertThat(volume[key].items(),
+ ContainsAll(params[key].items()),
+ msg)
+ else:
+ self.assertEqual(params[key], volume[key], msg)
+
@attr(type='smoke')
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
resp, fetched_list = self.client.list_volumes()
self.assertEqual(200, resp.status)
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volume_list_with_details(self):
@@ -131,7 +160,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual('available', volume['status'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_status(self):
@@ -151,7 +181,8 @@
self.assertEqual(200, resp.status)
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
- self.assertVolumesIn(fetched_list, self.volume_list)
+ self.assertVolumesIn(fetched_list, self.volume_list,
+ fields=VOLUME_FIELDS)
@attr(type='gate')
def test_volumes_list_details_by_availability_zone(self):
@@ -164,6 +195,34 @@
self.assertEqual(zone, volume['availability_zone'])
self.assertVolumesIn(fetched_list, self.volume_list)
+ @attr(type='gate')
+ def test_volume_list_with_param_metadata(self):
+ # Test to list volumes when metadata param is given
+ params = {'metadata': self.metadata}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_volume_list_with_detail_param_metadata(self):
+ # Test to list volumes details when metadata param is given
+ params = {'metadata': self.metadata}
+ self._list_by_param_value_and_assert(params, with_detail=True)
+
+ @attr(type='gate')
+ def test_volume_list_param_display_name_and_status(self):
+ # Test to list volume when display name and status param is given
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'display_name': volume['display_name'],
+ 'status': 'available'}
+ self._list_by_param_value_and_assert(params)
+
+ @attr(type='gate')
+ def test_volume_list_with_detail_param_display_name_and_status(self):
+ # Test to list volume when name and status param is given
+ volume = self.volume_list[data_utils.rand_int_id(0, 2)]
+ params = {'display_name': volume['display_name'],
+ 'status': 'available'}
+ self._list_by_param_value_and_assert(params, with_detail=True)
+
class VolumeListTestXML(VolumesListTest):
_interface = 'xml'
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 928bd49..284c321 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -23,7 +21,7 @@
from tempest.test import attr
-class VolumesNegativeTest(base.BaseVolumeTest):
+class VolumesNegativeTest(base.BaseVolumeV1Test):
_interface = 'json'
@classmethod
@@ -32,21 +30,18 @@
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'])
- def test_volume_get_nonexistant_volume_id(self):
- # Should not be able to get a non-existant volume
+ def test_volume_get_nonexistent_volume_id(self):
+ # Should not be able to get a non-existent volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
str(uuid.uuid4()))
@attr(type=['negative', 'gate'])
- def test_volume_delete_nonexistant_volume_id(self):
- # Should not be able to delete a non-existant Volume
+ def test_volume_delete_nonexistent_volume_id(self):
+ # Should not be able to delete a non-existent Volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
str(uuid.uuid4()))
@@ -85,8 +80,8 @@
size='-1', display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_volume_type(self):
- # Should not be able to create volume with non-existant volume type
+ def test_create_volume_with_nonexistent_volume_type(self):
+ # Should not be able to create volume with non-existent volume type
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -94,8 +89,8 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_snapshot_id(self):
- # Should not be able to create volume with non-existant snapshot
+ def test_create_volume_with_nonexistent_snapshot_id(self):
+ # Should not be able to create volume with non-existent snapshot
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -103,8 +98,8 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_create_volume_with_nonexistant_source_volid(self):
- # Should not be able to create volume with non-existant source volume
+ def test_create_volume_with_nonexistent_source_volid(self):
+ # Should not be able to create volume with non-existent source volume
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.create_volume,
@@ -112,7 +107,7 @@
display_name=v_name, metadata=metadata)
@attr(type=['negative', 'gate'])
- def test_update_volume_with_nonexistant_volume_id(self):
+ def test_update_volume_with_nonexistent_volume_id(self):
v_name = data_utils.rand_name('Volume-')
metadata = {'Type': 'work'}
self.assertRaises(exceptions.NotFound, self.client.update_volume,
diff --git a/tempest/api/volume/test_volumes_snapshots.py b/tempest/api/volume/test_volumes_snapshots.py
index 99e8de7..487ada6 100644
--- a/tempest/api/volume/test_volumes_snapshots.py
+++ b/tempest/api/volume/test_volumes_snapshots.py
@@ -1,5 +1,3 @@
-# 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
@@ -20,7 +18,7 @@
LOG = logging.getLogger(__name__)
-class VolumesSnapshotTest(base.BaseVolumeTest):
+class VolumesSnapshotTest(base.BaseVolumeV1Test):
_interface = "json"
@classmethod
@@ -37,6 +35,27 @@
def tearDownClass(cls):
super(VolumesSnapshotTest, cls).tearDownClass()
+ def _list_by_param_values_and_assert(self, params, with_detail=False):
+ """
+ Perform list or list_details action with given params
+ and validates result.
+ """
+ if with_detail:
+ resp, fetched_snap_list = \
+ self.snapshots_client.\
+ list_snapshots_with_detail(params=params)
+ else:
+ resp, fetched_snap_list = \
+ self.snapshots_client.list_snapshots(params=params)
+
+ self.assertEqual(200, resp.status)
+ # Validating params of fetched snapshots
+ for snap in fetched_snap_list:
+ for key in params:
+ msg = "Failed to list snapshots %s by %s" % \
+ ('details' if with_detail else '', key)
+ self.assertEqual(params[key], snap[key], msg)
+
@attr(type='gate')
def test_snapshot_create_get_list_update_delete(self):
# Create a snapshot
@@ -83,6 +102,46 @@
self.snapshots.remove(snapshot)
@attr(type='gate')
+ def test_snapshots_list_with_params(self):
+ """list snapshots with params."""
+ # Create a snapshot
+ display_name = data_utils.rand_name('snap')
+ snapshot = self.create_snapshot(self.volume_origin['id'],
+ display_name=display_name)
+
+ # Verify list snapshots by display_name filter
+ params = {'display_name': snapshot['display_name']}
+ self._list_by_param_values_and_assert(params)
+
+ # Verify list snapshots by status filter
+ params = {'status': 'available'}
+ self._list_by_param_values_and_assert(params)
+
+ # Verify list snapshots by status and display name filter
+ params = {'status': 'available',
+ 'display_name': snapshot['display_name']}
+ self._list_by_param_values_and_assert(params)
+
+ @attr(type='gate')
+ def test_snapshots_list_details_with_params(self):
+ """list snapshot details with params."""
+ # Create a snapshot
+ display_name = data_utils.rand_name('snap')
+ snapshot = self.create_snapshot(self.volume_origin['id'],
+ display_name=display_name)
+
+ # Verify list snapshot details by display_name filter
+ params = {'display_name': snapshot['display_name']}
+ self._list_by_param_values_and_assert(params, with_detail=True)
+ # Verify list snapshot details by status filter
+ params = {'status': 'available'}
+ self._list_by_param_values_and_assert(params, with_detail=True)
+ # Verify list snapshot details by status and display name filter
+ params = {'status': 'available',
+ 'display_name': snapshot['display_name']}
+ self._list_by_param_values_and_assert(params, with_detail=True)
+
+ @attr(type='gate')
def test_volume_from_snapshot(self):
# Create a temporary snap using wrapper method from base, then
# create a snap based volume, check resp code and deletes it
diff --git a/tempest/api/volume/test_volumes_snapshots_negative.py b/tempest/api/volume/test_volumes_snapshots_negative.py
index 04a4774..b24b597 100644
--- a/tempest/api/volume/test_volumes_snapshots_negative.py
+++ b/tempest/api/volume/test_volumes_snapshots_negative.py
@@ -1,5 +1,3 @@
-# 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
@@ -20,7 +18,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..dfa2124 100644
--- a/tempest/cli/__init__.py
+++ b/tempest/cli/__init__.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -86,6 +84,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/output_parser.py b/tempest/cli/output_parser.py
index bb3368f..4edcd47 100644
--- a/tempest/cli/output_parser.py
+++ b/tempest/cli/output_parser.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
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..0b6ae22 100644
--- a/tempest/cli/simple_read_only/test_ceilometer.py
+++ b/tempest/cli/simple_read_only/test_ceilometer.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,17 +13,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo.config import cfg
-
-import tempest.cli
+from tempest import cli
+from tempest import config
from tempest.openstack.common import log as logging
-CONF = cfg.CONF
+CONF = config.CONF
LOG = logging.getLogger(__name__)
-class SimpleReadOnlyCeilometerClientTest(tempest.cli.ClientTestBase):
+class SimpleReadOnlyCeilometerClientTest(cli.ClientTestBase):
"""Basic, read-only tests for Ceilometer CLI client.
Checks return values and output of read-only commands.
@@ -36,7 +33,7 @@
@classmethod
def setUpClass(cls):
if (not CONF.service_available.ceilometer):
- msg = ("Skiping all Ceilometer cli tests because it is"
+ msg = ("Skipping all Ceilometer cli tests because it is "
"not available")
raise cls.skipException(msg)
super(SimpleReadOnlyCeilometerClientTest, cls).setUpClass()
@@ -49,3 +46,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_cinder.py b/tempest/cli/simple_read_only/test_cinder.py
index 25157a4..f71a2de 100644
--- a/tempest/cli/simple_read_only/test_cinder.py
+++ b/tempest/cli/simple_read_only/test_cinder.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/cli/simple_read_only/test_glance.py b/tempest/cli/simple_read_only/test_glance.py
index a5a229c..0e0f995 100644
--- a/tempest/cli/simple_read_only/test_glance.py
+++ b/tempest/cli/simple_read_only/test_glance.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
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..b45182b
--- /dev/null
+++ b/tempest/cli/simple_read_only/test_heat.py
@@ -0,0 +1,96 @@
+# 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/cli/simple_read_only/test_keystone.py b/tempest/cli/simple_read_only/test_keystone.py
index a7e7147..271a18c 100644
--- a/tempest/cli/simple_read_only/test_keystone.py
+++ b/tempest/cli/simple_read_only/test_keystone.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/cli/simple_read_only/test_neutron.py b/tempest/cli/simple_read_only/test_neutron.py
index 047b17d..ebf0dc4 100644
--- a/tempest/cli/simple_read_only/test_neutron.py
+++ b/tempest/cli/simple_read_only/test_neutron.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,18 +16,17 @@
import re
import subprocess
-from oslo.config import cfg
-
-import tempest.cli
+from tempest import cli
+from tempest import config
from tempest.openstack.common import log as logging
from tempest import test
-CONF = cfg.CONF
+CONF = config.CONF
LOG = logging.getLogger(__name__)
-class SimpleReadOnlyNeutronClientTest(tempest.cli.ClientTestBase):
+class SimpleReadOnlyNeutronClientTest(cli.ClientTestBase):
"""Basic, read-only tests for Neutron CLI client.
Checks return values and output of read-only commands.
@@ -40,83 +37,105 @@
@classmethod
def setUpClass(cls):
if (not CONF.service_available.neutron):
- msg = "Skiping all Neutron cli tests because it is not available"
+ msg = "Skipping all Neutron cli tests because it is not available"
raise cls.skipException(msg)
super(SimpleReadOnlyNeutronClientTest, cls).setUpClass()
+ @test.attr(type='smoke')
def test_neutron_fake_action(self):
self.assertRaises(subprocess.CalledProcessError,
self.neutron,
'this-does-not-exist')
+ @test.attr(type='smoke')
def test_neutron_net_list(self):
self.neutron('net-list')
+ @test.attr(type='smoke')
def test_neutron_ext_list(self):
ext = self.parser.listing(self.neutron('ext-list'))
self.assertTableStruct(ext, ['alias', 'name'])
+ @test.attr(type='smoke')
def test_neutron_dhcp_agent_list_hosting_net(self):
self.neutron('dhcp-agent-list-hosting-net',
params=CONF.compute.fixed_network_name)
+ @test.attr(type='smoke')
def test_neutron_agent_list(self):
agents = self.parser.listing(self.neutron('agent-list'))
field_names = ['id', 'agent_type', 'host', 'alive', 'admin_state_up']
self.assertTableStruct(agents, field_names)
+ @test.attr(type='smoke')
def test_neutron_floatingip_list(self):
self.neutron('floatingip-list')
@test.skip_because(bug="1240694")
+ @test.attr(type='smoke')
+ @test.requires_ext(extension='metering', service='network')
def test_neutron_meter_label_list(self):
self.neutron('meter-label-list')
@test.skip_because(bug="1240694")
+ @test.attr(type='smoke')
+ @test.requires_ext(extension='metering', service='network')
def test_neutron_meter_label_rule_list(self):
self.neutron('meter-label-rule-list')
def _test_neutron_lbaas_command(self, command):
try:
self.neutron(command)
- except tempest.cli.CommandFailed as e:
+ except cli.CommandFailed as e:
if '404 Not Found' not in e.stderr:
self.fail('%s: Unexpected failure.' % command)
+ @test.attr(type='smoke')
def test_neutron_lb_healthmonitor_list(self):
self._test_neutron_lbaas_command('lb-healthmonitor-list')
+ @test.attr(type='smoke')
def test_neutron_lb_member_list(self):
self._test_neutron_lbaas_command('lb-member-list')
+ @test.attr(type='smoke')
def test_neutron_lb_pool_list(self):
self._test_neutron_lbaas_command('lb-pool-list')
+ @test.attr(type='smoke')
def test_neutron_lb_vip_list(self):
self._test_neutron_lbaas_command('lb-vip-list')
+ @test.attr(type='smoke')
def test_neutron_net_external_list(self):
self.neutron('net-external-list')
+ @test.attr(type='smoke')
def test_neutron_port_list(self):
self.neutron('port-list')
+ @test.attr(type='smoke')
def test_neutron_quota_list(self):
self.neutron('quota-list')
+ @test.attr(type='smoke')
def test_neutron_router_list(self):
self.neutron('router-list')
+ @test.attr(type='smoke')
def test_neutron_security_group_list(self):
security_grp = self.parser.listing(self.neutron('security-group-list'))
self.assertTableStruct(security_grp, ['id', 'name', 'description'])
+ @test.attr(type='smoke')
def test_neutron_security_group_rule_list(self):
self.neutron('security-group-rule-list')
+ @test.attr(type='smoke')
def test_neutron_subnet_list(self):
self.neutron('subnet-list')
+ @test.attr(type='smoke')
def test_neutron_help(self):
help_text = self.neutron('help')
lines = help_text.split('\n')
@@ -134,13 +153,16 @@
'router-show', 'agent-update', 'help'))
self.assertFalse(wanted_commands - commands)
- # Optional arguments:
+ # Optional arguments:
+ @test.attr(type='smoke')
def test_neutron_version(self):
self.neutron('', flags='--version')
+ @test.attr(type='smoke')
def test_neutron_debug_net_list(self):
self.neutron('net-list', flags='--debug')
+ @test.attr(type='smoke')
def test_neutron_quiet_net_list(self):
self.neutron('net-list', flags='--quiet')
diff --git a/tempest/cli/simple_read_only/test_nova.py b/tempest/cli/simple_read_only/test_nova.py
index 1aa8f2c..822e531 100644
--- a/tempest/cli/simple_read_only/test_nova.py
+++ b/tempest/cli/simple_read_only/test_nova.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/cli/simple_read_only/test_nova_manage.py b/tempest/cli/simple_read_only/test_nova_manage.py
index 524db5d..a92e8da 100644
--- a/tempest/cli/simple_read_only/test_nova_manage.py
+++ b/tempest/cli/simple_read_only/test_nova_manage.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/clients.py b/tempest/clients.py
index ac79ce0..65b603b 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,6 +16,8 @@
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
+from tempest.services.baremetal.v1.client_json import BaremetalClientJSON
+from tempest.services.baremetal.v1.client_xml import BaremetalClientXML
from tempest.services import botoclients
from tempest.services.compute.json.aggregates_client import \
AggregatesClientJSON
@@ -50,33 +50,34 @@
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.instance_usage_audit_log_client import \
+ InstanceUsagesAuditLogV3ClientJSON
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.availability_zone_client import \
- AvailabilityZoneV3ClientXML
-from tempest.services.compute.v3.xml.extensions_client import \
- ExtensionsV3ClientXML
-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.servers_client import ServersV3ClientXML
-from tempest.services.compute.v3.xml.services_client import \
- ServicesV3ClientXML
-from tempest.services.compute.v3.xml.tenant_usages_client import \
- TenantUsagesV3ClientXML
+from tempest.services.compute.v3.json.version_client import \
+ VersionV3ClientJSON
from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
from tempest.services.compute.xml.availability_zone_client import \
AvailabilityZoneClientXML
@@ -87,6 +88,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 \
@@ -104,6 +106,7 @@
TenantUsagesClientXML
from tempest.services.compute.xml.volumes_extensions_client import \
VolumesExtensionsClientXML
+from tempest.services.data_processing.v1_1.client import DataProcessingClient
from tempest.services.identity.json.identity_client import IdentityClientJSON
from tempest.services.identity.json.identity_client import TokenClientJSON
from tempest.services.identity.v3.json.credentials_client import \
@@ -144,15 +147,20 @@
VolumeHostsClientJSON
from tempest.services.volume.json.admin.volume_types_client import \
VolumeTypesClientJSON
+from tempest.services.volume.json.extensions_client import \
+ ExtensionsClientJSON as VolumeExtensionClientJSON
from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
from tempest.services.volume.json.volumes_client import VolumesClientJSON
from tempest.services.volume.xml.admin.volume_hosts_client import \
VolumeHostsClientXML
from tempest.services.volume.xml.admin.volume_types_client import \
VolumeTypesClientXML
+from tempest.services.volume.xml.extensions_client import \
+ ExtensionsClientXML as VolumeExtensionClientXML
from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
from tempest.services.volume.xml.volumes_client import VolumesClientXML
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -173,13 +181,12 @@
:param password: Override of the password
:param tenant_name: Override of the tenant name
"""
- self.config = config.TempestConfig()
-
+ self.config = CONF
# If no creds are provided, we fall back on the defaults
# in the config file for the Compute API.
- self.username = username or self.config.identity.username
- self.password = password or self.config.identity.password
- self.tenant_name = tenant_name or self.config.identity.tenant_name
+ self.username = username or CONF.identity.username
+ self.password = password or CONF.identity.password
+ self.tenant_name = tenant_name or CONF.identity.tenant_name
if None in (self.username, self.password, self.tenant_name):
msg = ("Missing required credentials. "
@@ -188,15 +195,15 @@
{'u': username, 'p': password, 't': tenant_name})
raise exceptions.InvalidConfiguration(msg)
- self.auth_url = self.config.identity.uri
- self.auth_url_v3 = self.config.identity.uri_v3
+ self.auth_url = CONF.identity.uri
+ self.auth_url_v3 = CONF.identity.uri_v3
- client_args = (self.config, self.username, self.password,
+ client_args = (CONF, self.username, self.password,
self.auth_url, self.tenant_name)
if self.auth_url_v3:
auth_version = 'v3'
- client_args_v3_auth = (self.config, self.username,
+ client_args_v3_auth = (CONF, self.username,
self.password, self.auth_url_v3,
self.tenant_name, auth_version)
else:
@@ -206,14 +213,13 @@
if interface == 'xml':
self.certificates_client = CertificatesClientXML(*client_args)
+ self.baremetal_client = BaremetalClientXML(*client_args)
self.servers_client = ServersClientXML(*client_args)
- self.servers_v3_client = ServersV3ClientXML(*client_args)
self.limits_client = LimitsClientXML(*client_args)
self.images_client = ImagesClientXML(*client_args)
self.keypairs_client = KeyPairsClientXML(*client_args)
self.quotas_client = QuotasClientXML(*client_args)
self.flavors_client = FlavorsClientXML(*client_args)
- self.extensions_v3_client = ExtensionsV3ClientXML(*client_args)
self.extensions_client = ExtensionsClientXML(*client_args)
self.volumes_extensions_client = VolumesExtensionsClientXML(
*client_args)
@@ -223,26 +229,20 @@
self.volume_types_client = VolumeTypesClientXML(*client_args)
self.identity_client = IdentityClientXML(*client_args)
self.identity_v3_client = IdentityV3ClientXML(*client_args)
- self.token_client = TokenClientXML(self.config)
+ self.token_client = TokenClientXML(CONF)
self.security_groups_client = SecurityGroupsClientXML(
*client_args)
- self.interfaces_v3_client = InterfacesV3ClientXML(*client_args)
self.interfaces_client = InterfacesClientXML(*client_args)
self.endpoints_client = EndPointClientXML(*client_args)
self.fixed_ips_client = FixedIPsClientXML(*client_args)
- self.availability_zone_v3_client = AvailabilityZoneV3ClientXML(
- *client_args)
self.availability_zone_client = AvailabilityZoneClientXML(
*client_args)
- self.services_v3_client = ServicesV3ClientXML(*client_args)
self.service_client = ServiceClientXML(*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.hypervisor_v3_client = HypervisorV3ClientXML(*client_args)
+ self.hosts_client = HostsClientXML(*client_args)
self.hypervisor_client = HypervisorClientXML(*client_args)
self.token_v3_client = V3TokenClientXML(*client_args)
self.network_client = NetworkClientXML(*client_args)
@@ -250,6 +250,8 @@
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientXML(*client_args)
self.volume_hosts_client = VolumeHostsClientXML(*client_args)
+ self.volumes_extension_client = VolumeExtensionClientXML(
+ *client_args)
if client_args_v3_auth:
self.servers_client_v3_auth = ServersClientXML(
@@ -257,13 +259,20 @@
elif interface == 'json':
self.certificates_client = CertificatesClientJSON(*client_args)
+ self.certificates_v3_client = CertificatesV3ClientJSON(
+ *client_args)
+ self.baremetal_client = BaremetalClientJSON(*client_args)
self.servers_client = ServersClientJSON(*client_args)
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(
@@ -274,7 +283,7 @@
self.volume_types_client = VolumeTypesClientJSON(*client_args)
self.identity_client = IdentityClientJSON(*client_args)
self.identity_v3_client = IdentityV3ClientJSON(*client_args)
- self.token_client = TokenClientJSON(self.config)
+ self.token_client = TokenClientJSON(CONF)
self.security_groups_client = SecurityGroupsClientJSON(
*client_args)
self.interfaces_v3_client = InterfacesV3ClientJSON(*client_args)
@@ -287,12 +296,15 @@
*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.version_v3_client = VersionV3ClientJSON(*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)
@@ -300,7 +312,12 @@
self.credentials_client = CredentialsClientJSON(*client_args)
self.instance_usages_audit_log_client = \
InstanceUsagesAuditLogClientJSON(*client_args)
+ self.instance_usages_audit_log_v3_client = \
+ InstanceUsagesAuditLogV3ClientJSON(*client_args)
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(
@@ -310,9 +327,8 @@
raise exceptions.InvalidConfiguration(msg)
# common clients
- self.hosts_client = HostsClientJSON(*client_args)
self.account_client = AccountClient(*client_args)
- if self.config.service_available.glance:
+ if CONF.service_available.glance:
self.image_client = ImageClientJSON(*client_args)
self.image_client_v2 = ImageClientV2JSON(*client_args)
self.container_client = ContainerClient(*client_args)
@@ -323,6 +339,7 @@
self.custom_object_client = ObjectClientCustomizedHeader(*client_args)
self.custom_account_client = \
AccountClientCustomizedHeader(*client_args)
+ self.data_processing_client = DataProcessingClient(*client_args)
class AltManager(Manager):
@@ -333,10 +350,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AltManager, self).__init__(conf.identity.alt_username,
- conf.identity.alt_password,
- conf.identity.alt_tenant_name,
+ super(AltManager, self).__init__(CONF.identity.alt_username,
+ CONF.identity.alt_password,
+ CONF.identity.alt_tenant_name,
interface=interface)
@@ -348,10 +364,9 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
- super(AdminManager, self).__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.admin_tenant_name,
+ super(AdminManager, self).__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.admin_tenant_name,
interface=interface)
@@ -363,11 +378,10 @@
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(ComputeAdminManager, self)
- base.__init__(conf.compute_admin.username,
- conf.compute_admin.password,
- conf.compute_admin.tenant_name,
+ base.__init__(CONF.compute_admin.username,
+ CONF.compute_admin.password,
+ CONF.compute_admin.tenant_name,
interface=interface)
@@ -377,9 +391,8 @@
so that heat templates can create users
"""
def __init__(self, interface='json'):
- conf = config.TempestConfig()
base = super(OrchestrationManager, self)
- base.__init__(conf.identity.admin_username,
- conf.identity.admin_password,
- conf.identity.tenant_name,
+ base.__init__(CONF.identity.admin_username,
+ CONF.identity.admin_password,
+ CONF.identity.tenant_name,
interface=interface)
diff --git a/tempest/common/commands.py b/tempest/common/commands.py
index 4fc85b6..af7a692 100644
--- a/tempest/common/commands.py
+++ b/tempest/common/commands.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/common/custom_matchers.py b/tempest/common/custom_matchers.py
index 307d5db..a02c967 100644
--- a/tempest/common/custom_matchers.py
+++ b/tempest/common/custom_matchers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NTT Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -125,7 +123,7 @@
elif key == 'content-type' and not value:
return InvalidFormat(key, value)
elif key == 'x-trans-id' and \
- not re.match("^tx[0-9a-f]*-[0-9a-f]*$", value):
+ not re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*", value):
return InvalidFormat(key, value)
elif key == 'date' and not value:
return InvalidFormat(key, value)
diff --git a/tempest/common/debug.py b/tempest/common/debug.py
index 69c933c..8325d4d 100644
--- a/tempest/common/debug.py
+++ b/tempest/common/debug.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -19,13 +17,14 @@
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
tables = ['filter', 'nat', 'mangle']
def log_ip_ns():
- if not config.TempestConfig().debug.enable:
+ if not CONF.debug.enable:
return
LOG.info("Host Addr:\n" + commands.ip_addr_raw())
LOG.info("Host Route:\n" + commands.ip_route_raw())
diff --git a/tempest/common/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py
index 545703b..e1213db 100644
--- a/tempest/common/generate_sample_tempest.py
+++ b/tempest/common/generate_sample_tempest.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
@@ -18,7 +16,7 @@
import sys
-from tempest import config
+import tempest.config
from tempest.openstack.common.config import generator
# NOTE(mtreinish): This hack is needed because of how oslo config is used in
@@ -31,5 +29,7 @@
# the issue by manually loading the config file (which may or may not exist)
# which will populate all the options before running the generator.
-config.TempestConfig()
-generator.generate(sys.argv[1:])
+
+if __name__ == "__main__":
+ CONF = tempest.config.TempestConfigPrivate(False)
+ generator.generate(sys.argv[1:])
diff --git a/tempest/common/http.py b/tempest/common/http.py
index b70502c..b3793bc 100644
--- a/tempest/common/http.py
+++ b/tempest/common/http.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Citrix Systems, Inc.
# All Rights Reserved.
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 5dbb3a7..95d12c1 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -25,18 +23,20 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
class IsolatedCreds(object):
def __init__(self, name, tempest_client=True, interface='json',
- password='pass'):
+ password='pass', network_resources=None):
+ self.network_resources = network_resources
self.isolated_creds = {}
self.isolated_net_resources = {}
self.ports = []
self.name = name
- self.config = config.TempestConfig()
+ self.config = CONF
self.tempest_client = tempest_client
self.interface = interface
self.password = password
@@ -44,11 +44,11 @@
self._get_admin_clients())
def _get_official_admin_clients(self):
- username = self.config.identity.admin_username
- password = self.config.identity.admin_password
- tenant_name = self.config.identity.admin_tenant_name
- auth_url = self.config.identity.uri
- dscv = self.config.identity.disable_ssl_certificate_validation
+ username = CONF.identity.admin_username
+ password = CONF.identity.admin_password
+ tenant_name = CONF.identity.admin_tenant_name
+ auth_url = CONF.identity.uri
+ dscv = CONF.identity.disable_ssl_certificate_validation
identity_client = keystoneclient.Client(username=username,
password=password,
tenant_name=tenant_name,
@@ -164,7 +164,7 @@
role = None
try:
roles = self._list_roles()
- admin_role = self.config.identity.admin_role
+ admin_role = CONF.identity.admin_role
if self.tempest_client:
role = next(r for r in roles if r['name'] == admin_role)
else:
@@ -197,15 +197,33 @@
network = None
subnet = None
router = None
+ # Make sure settings
+ if self.network_resources:
+ if self.network_resources['router']:
+ if (not self.network_resources['subnet'] or
+ not self.network_resources['network']):
+ raise exceptions.InvalidConfiguration(
+ 'A router requires a subnet and network')
+ elif self.network_resources['subnet']:
+ if not self.network_resources['network']:
+ raise exceptions.InvalidConfiguration(
+ 'A subnet requires a network')
+ elif self.network_resources['dhcp']:
+ raise exceptions.InvalidConfiguration('DHCP requires a subnet')
+
data_utils.rand_name_root = data_utils.rand_name(self.name)
- network_name = data_utils.rand_name_root + "-network"
- network = self._create_network(network_name, tenant_id)
+ if not self.network_resources or self.network_resources['network']:
+ network_name = data_utils.rand_name_root + "-network"
+ network = self._create_network(network_name, tenant_id)
try:
- subnet_name = data_utils.rand_name_root + "-subnet"
- subnet = self._create_subnet(subnet_name, tenant_id, network['id'])
- router_name = data_utils.rand_name_root + "-router"
- router = self._create_router(router_name, tenant_id)
- self._add_router_interface(router['id'], subnet['id'])
+ if not self.network_resources or self.network_resources['subnet']:
+ subnet_name = data_utils.rand_name_root + "-subnet"
+ subnet = self._create_subnet(subnet_name, tenant_id,
+ network['id'])
+ if not self.network_resources or self.network_resources['router']:
+ router_name = data_utils.rand_name_root + "-router"
+ router = self._create_router(router_name, tenant_id)
+ self._add_router_interface(router['id'], subnet['id'])
except Exception:
if router:
self._clear_isolated_router(router['id'], router['name'])
@@ -229,14 +247,25 @@
if not self.tempest_client:
body = {'subnet': {'name': subnet_name, 'tenant_id': tenant_id,
'network_id': network_id, 'ip_version': 4}}
- base_cidr = netaddr.IPNetwork(self.config.network.tenant_network_cidr)
- mask_bits = self.config.network.tenant_network_mask_bits
+ if self.network_resources:
+ body['enable_dhcp'] = self.network_resources['dhcp']
+ base_cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
+ mask_bits = CONF.network.tenant_network_mask_bits
for subnet_cidr in base_cidr.subnet(mask_bits):
try:
if self.tempest_client:
- resp, resp_body = self.network_admin_client.create_subnet(
- network_id, str(subnet_cidr), name=subnet_name,
- tenant_id=tenant_id)
+ if self.network_resources:
+ resp, resp_body = self.network_admin_client.\
+ create_subnet(
+ network_id, str(subnet_cidr),
+ name=subnet_name,
+ tenant_id=tenant_id,
+ enable_dhcp=self.network_resources['dhcp'])
+ else:
+ resp, resp_body = self.network_admin_client.\
+ create_subnet(network_id, str(subnet_cidr),
+ name=subnet_name,
+ tenant_id=tenant_id)
else:
body['subnet']['cidr'] = str(subnet_cidr)
resp_body = self.network_admin_client.create_subnet(body)
@@ -252,7 +281,7 @@
def _create_router(self, router_name, tenant_id):
external_net_id = dict(
- network_id=self.config.network.public_network_id)
+ network_id=CONF.network.public_network_id)
if self.tempest_client:
resp, resp_body = self.network_admin_client.create_router(
router_name,
@@ -328,7 +357,7 @@
self.isolated_creds['primary'] = (user, tenant)
LOG.info("Acquired isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['primary'] = (
@@ -347,7 +376,7 @@
self.isolated_creds['admin'] = (user, tenant)
LOG.info("Acquired admin isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['admin'] = (
@@ -366,7 +395,7 @@
self.isolated_creds['alt'] = (user, tenant)
LOG.info("Acquired alt isolated creds:\n user: %s, tenant: %s"
% (username, tenant_name))
- if self.config.service_available.neutron:
+ if CONF.service_available.neutron:
network, subnet, router = self._create_network_resources(
self._get_tenant_id(tenant))
self.isolated_net_resources['alt'] = (
@@ -430,26 +459,27 @@
net_client = self.network_admin_client
for cred in self.isolated_net_resources:
network, subnet, router = self.isolated_net_resources.get(cred)
- try:
- if self.tempest_client:
- net_client.remove_router_interface_with_subnet_id(
- router['id'], subnet['id'])
- else:
- body = {'subnet_id': subnet['id']}
- net_client.remove_interface_router(router['id'], body)
- except exceptions.NotFound:
- LOG.warn('router with name: %s not found for delete' %
- router['name'])
- pass
- self._clear_isolated_router(router['id'], router['name'])
- # TODO(mlavalle) This method call will be removed once patch
- # https://review.openstack.org/#/c/46563/ merges in Neutron
- self._cleanup_ports(network['id'])
- self._clear_isolated_subnet(subnet['id'], subnet['name'])
- self._clear_isolated_network(network['id'], network['name'])
- LOG.info("Cleared isolated network resources: \n"
- + " network: %s, subnet: %s, router: %s"
- % (network['name'], subnet['name'], router['name']))
+ if self.network_resources.get('router'):
+ try:
+ if self.tempest_client:
+ net_client.remove_router_interface_with_subnet_id(
+ router['id'], subnet['id'])
+ else:
+ body = {'subnet_id': subnet['id']}
+ net_client.remove_interface_router(router['id'], body)
+ except exceptions.NotFound:
+ LOG.warn('router with name: %s not found for delete' %
+ router['name'])
+ pass
+ self._clear_isolated_router(router['id'], router['name'])
+ if self.network_resources.get('network'):
+ # TODO(mlavalle) This method call will be removed once patch
+ # https://review.openstack.org/#/c/46563/ merges in Neutron
+ self._cleanup_ports(network['id'])
+ if self.network_resources.get('subnet'):
+ self._clear_isolated_subnet(subnet['id'], subnet['name'])
+ if self.network_resources.get('network'):
+ self._clear_isolated_network(network['id'], network['name'])
def clear_isolated_creds(self):
if not self.isolated_creds:
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 9aca2ff..3efc710 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tempest/common/ssh.py b/tempest/common/ssh.py
index c397b7c..5eb7336 100644
--- a/tempest/common/ssh.py
+++ b/tempest/common/ssh.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -23,6 +21,7 @@
import warnings
from tempest import exceptions
+from tempest.openstack.common import log as logging
with warnings.catch_warnings():
@@ -30,6 +29,9 @@
import paramiko
+LOG = logging.getLogger(__name__)
+
+
class Client(object):
def __init__(self, host, username, password=None, timeout=300, pkey=None,
@@ -49,33 +51,44 @@
def _get_ssh_connection(self, sleep=1.5, backoff=1.01):
"""Returns an ssh connection to the specified host."""
- _timeout = True
bsleep = sleep
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(
paramiko.AutoAddPolicy())
_start_time = time.time()
-
- while not self._is_timed_out(_start_time):
+ if self.pkey is not None:
+ LOG.info("Creating ssh connection to '%s' as '%s'"
+ " with public key authentication",
+ self.host, self.username)
+ else:
+ LOG.info("Creating ssh connection to '%s' as '%s'"
+ " with password %s",
+ self.host, self.username, str(self.password))
+ attempts = 0
+ while True:
try:
ssh.connect(self.host, username=self.username,
password=self.password,
look_for_keys=self.look_for_keys,
key_filename=self.key_filename,
timeout=self.channel_timeout, pkey=self.pkey)
- _timeout = False
- break
+ LOG.info("ssh connection to %s@%s sucessfuly created",
+ self.username, self.host)
+ return ssh
except (socket.error,
- paramiko.AuthenticationException,
paramiko.SSHException):
+ attempts += 1
time.sleep(bsleep)
bsleep *= backoff
- continue
- if _timeout:
- raise exceptions.SSHTimeout(host=self.host,
- user=self.username,
- password=self.password)
- return ssh
+ if not self._is_timed_out(_start_time):
+ continue
+ else:
+ LOG.exception("Failed to establish authenticated ssh"
+ " connection to %s@%s after %d attempts",
+ self.username, self.host, attempts)
+ raise exceptions.SSHTimeout(host=self.host,
+ user=self.username,
+ password=self.password)
def _is_timed_out(self, start_time):
return (time.time() - self.timeout) > start_time
@@ -144,11 +157,6 @@
return ''.join(out_data)
def test_connection_auth(self):
- """Returns true if ssh can connect to server."""
- try:
- connection = self._get_ssh_connection()
- connection.close()
- except paramiko.AuthenticationException:
- return False
-
- return True
+ """Raises an exception when we can not connect to server via ssh."""
+ connection = self._get_ssh_connection()
+ connection.close()
diff --git a/tempest/common/tempest_fixtures.py b/tempest/common/tempest_fixtures.py
index 73c02e8..b33f354 100644
--- a/tempest/common/tempest_fixtures.py
+++ b/tempest/common/tempest_fixtures.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/common/utils/data_utils.py b/tempest/common/utils/data_utils.py
index 4f93e1c..2b2963c 100644
--- a/tempest/common/utils/data_utils.py
+++ b/tempest/common/utils/data_utils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -40,6 +38,21 @@
return random.randint(start, end)
+def rand_mac_address():
+ """Generate an Ethernet MAC address."""
+ # NOTE(vish): We would prefer to use 0xfe here to ensure that linux
+ # bridge mac addresses don't change, but it appears to
+ # conflict with libvirt, so we use the next highest octet
+ # that has the unicast and locally administered bits set
+ # properly: 0xfa.
+ # Discussion: https://bugs.launchpad.net/nova/+bug/921838
+ mac = [0xfa, 0x16, 0x3e,
+ random.randint(0x00, 0xff),
+ random.randint(0x00, 0xff),
+ random.randint(0x00, 0xff)]
+ return ':'.join(["%02x" % x for x in mac])
+
+
def build_url(host, port, api_version=None, path=None,
params=None, use_ssl=False):
"""Build the request URL from given host, port, path and parameters."""
diff --git a/tempest/common/utils/file_utils.py b/tempest/common/utils/file_utils.py
index b111e84..43083f4 100644
--- a/tempest/common/utils/file_utils.py
+++ b/tempest/common/utils/file_utils.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 0d0e794..5276d49 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -1,5 +1,3 @@
-# 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
@@ -17,19 +15,20 @@
from tempest.common.ssh import Client
from tempest.common import utils
-from tempest.config import TempestConfig
+from tempest import config
from tempest.exceptions import ServerUnreachable
-from tempest.exceptions import SSHTimeout
+
+CONF = config.CONF
class RemoteClient():
# NOTE(afazekas): It should always get an address instead of server
def __init__(self, server, username, password=None, pkey=None):
- ssh_timeout = TempestConfig().compute.ssh_timeout
- network = TempestConfig().compute.network_for_ssh
- ip_version = TempestConfig().compute.ip_version_for_ssh
- ssh_channel_timeout = TempestConfig().compute.ssh_channel_timeout
+ ssh_timeout = CONF.compute.ssh_timeout
+ network = CONF.compute.network_for_ssh
+ ip_version = CONF.compute.ip_version_for_ssh
+ ssh_channel_timeout = CONF.compute.ssh_channel_timeout
if isinstance(server, basestring):
ip_address = server
else:
@@ -40,16 +39,15 @@
break
else:
raise ServerUnreachable()
-
self.ssh_client = Client(ip_address, username, password, ssh_timeout,
pkey=pkey,
channel_timeout=ssh_channel_timeout)
- if not self.ssh_client.test_connection_auth():
- raise SSHTimeout()
- def can_authenticate(self):
- # Re-authenticate
- return self.ssh_client.test_connection_auth()
+ def validate_authentication(self):
+ """Validate ssh connection and authentication
+ This method raises an Exception when the validation fails.
+ """
+ self.ssh_client.test_connection_auth()
def hostname_equals_servername(self, expected_hostname):
# Get host name using command "hostname"
@@ -89,3 +87,11 @@
# usually to /dev/ttyS0
cmd = 'sudo sh -c "echo \\"%s\\" >/dev/console"' % message
return self.ssh_client.exec_command(cmd)
+
+ def ping_host(self, host):
+ cmd = 'ping -c1 -w1 %s' % host
+ return self.ssh_client.exec_command(cmd)
+
+ def get_mac_address(self):
+ cmd = "/sbin/ifconfig | awk '/HWaddr/ {print $5}'"
+ return self.ssh_client.exec_command(cmd)
diff --git a/tempest/common/utils/misc.py b/tempest/common/utils/misc.py
index 1099ff5..a0b0c0a 100644
--- a/tempest/common/utils/misc.py
+++ b/tempest/common/utils/misc.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/common/utils/test_utils.py b/tempest/common/utils/test_utils.py
new file mode 100644
index 0000000..eca716e
--- /dev/null
+++ b/tempest/common/utils/test_utils.py
@@ -0,0 +1,134 @@
+# Copyright 2013 Hewlett-Packard, 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.common.utils import misc
+from tempest import config
+from tempest.scenario import manager
+
+import json
+import re
+import string
+import unicodedata
+
+CONF = config.CONF
+
+
+@misc.singleton
+class ImageUtils(object):
+
+ default_ssh_user = 'root'
+
+ def __init__(self):
+ # Load configuration items
+ self.ssh_users = json.loads(CONF.input_scenario.ssh_user_regex)
+ self.non_ssh_image_pattern = \
+ CONF.input_scenario.non_ssh_image_regex
+ # Setup clients
+ ocm = manager.OfficialClientManager(CONF.identity.username,
+ CONF.identity.password,
+ CONF.identity.tenant_name)
+ self.client = ocm.compute_client
+
+ def ssh_user(self, image_id):
+ _image = self.client.images.get(image_id)
+ for regex, user in self.ssh_users:
+ # First match wins
+ if re.match(regex, _image.name) is not None:
+ return user
+ else:
+ return self.default_ssh_user
+
+ def _is_sshable_image(self, image):
+ return not re.search(pattern=self.non_ssh_image_pattern,
+ string=str(image.name))
+
+ def is_sshable_image(self, image_id):
+ _image = self.client.images.get(image_id)
+ return self._is_sshable_image(_image)
+
+ def _is_flavor_enough(self, flavor, image):
+ return image.minDisk <= flavor.disk
+
+ def is_flavor_enough(self, flavor_id, image_id):
+ _image = self.client.images.get(image_id)
+ _flavor = self.client.flavors.get(flavor_id)
+ return self._is_flavor_enough(_flavor, _image)
+
+
+@misc.singleton
+class InputScenarioUtils(object):
+
+ """
+ Example usage:
+
+ import testscenarios
+ (...)
+ load_tests = testscenarios.load_tests_apply_scenarios
+
+
+ class TestInputScenario(manager.OfficialClientTest):
+
+ scenario_utils = test_utils.InputScenarioUtils()
+ scenario_flavor = scenario_utils.scenario_flavors
+ scenario_image = scenario_utils.scenario_images
+ scenarios = testscenarios.multiply_scenarios(scenario_image,
+ scenario_flavor)
+
+ def test_create_server_metadata(self):
+ name = rand_name('instance')
+ _ = self.compute_client.servers.create(name=name,
+ flavor=self.flavor_ref,
+ image=self.image_ref)
+ """
+ validchars = "-_.{ascii}{digit}".format(ascii=string.ascii_letters,
+ digit=string.digits)
+
+ def __init__(self):
+ ocm = manager.OfficialClientManager(CONF.identity.username,
+ CONF.identity.password,
+ CONF.identity.tenant_name)
+ self.client = ocm.compute_client
+ self.image_pattern = CONF.input_scenario.image_regex
+ self.flavor_pattern = CONF.input_scenario.flavor_regex
+
+ def _normalize_name(self, name):
+ nname = unicodedata.normalize('NFKD', name).encode('ASCII', 'ignore')
+ nname = ''.join(c for c in nname if c in self.validchars)
+ return nname
+
+ @property
+ def scenario_images(self):
+ """
+ :return: a scenario with name and uuid of images
+ """
+ if not hasattr(self, '_scenario_images'):
+ images = self.client.images.list(detailed=False)
+ self._scenario_images = [
+ (self._normalize_name(i.name), dict(image_ref=i.id))
+ for i in images if re.search(self.image_pattern, str(i.name))
+ ]
+ return self._scenario_images
+
+ @property
+ def scenario_flavors(self):
+ """
+ :return: a scenario with name and uuid of flavors
+ """
+ if not hasattr(self, '_scenario_flavors'):
+ flavors = self.client.flavors.list(detailed=False)
+ self._scenario_flavors = [
+ (self._normalize_name(f.name), dict(flavor_ref=f.id))
+ for f in flavors if re.search(self.flavor_pattern, str(f.name))
+ ]
+ return self._scenario_flavors
diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py
index 497a297..dbeba8f 100644
--- a/tempest/common/waiters.py
+++ b/tempest/common/waiters.py
@@ -1,5 +1,3 @@
-# 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
@@ -19,7 +17,7 @@
from tempest import exceptions
from tempest.openstack.common import log as logging
-CONFIG = config.TempestConfig()
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -29,7 +27,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
@@ -55,7 +56,7 @@
# responses
if str(task_state) == "None":
# without state api extension 3 sec usually enough
- time.sleep(CONFIG.compute.ready_wait)
+ time.sleep(CONF.compute.ready_wait)
return
else:
return
@@ -75,10 +76,47 @@
timed_out = int(time.time()) - start_time >= timeout
if timed_out:
- message = ('Server %s failed to reach %s status within the '
- 'required time (%s s).' %
- (server_id, status, timeout))
+ expected_task_state = 'None' if ready_wait else 'n/a'
+ message = ('Server %(server_id)s failed to reach %(status)s '
+ 'status and task state "%(expected_task_state)s" '
+ 'within the required time (%(timeout)s s).' %
+ {'server_id': server_id,
+ 'status': status,
+ 'expected_task_state': expected_task_state,
+ 'timeout': timeout})
message += ' Current status: %s.' % server_status
+ message += ' Current task state: %s.' % task_state
raise exceptions.TimeoutException(message)
old_status = server_status
old_task_state = task_state
+
+
+def wait_for_image_status(client, image_id, status):
+ """Waits for an image to reach a given status.
+
+ The client should have a get_image(image_id) method to get the image.
+ The client should also have build_interval and build_timeout attributes.
+ """
+ resp, image = client.get_image(image_id)
+ start = int(time.time())
+
+ while image['status'] != status:
+ time.sleep(client.build_interval)
+ resp, image = client.get_image(image_id)
+ if image['status'] == 'ERROR':
+ raise exceptions.AddImageException(image_id=image_id)
+
+ # check the status again to avoid a false negative where we hit
+ # the timeout at the same time that the image reached the expected
+ # status
+ if image['status'] == status:
+ return
+
+ if int(time.time()) - start >= client.build_timeout:
+ message = ('Image %(image_id)s failed to reach %(status)s '
+ 'status within the required time (%(timeout)s s).' %
+ {'image_id': image_id,
+ 'status': status,
+ 'timeout': client.build_timeout})
+ message += ' Current status: %s.' % image['status']
+ raise exceptions.TimeoutException(message)
diff --git a/tempest/config.py b/tempest/config.py
index 3d9eba9..d529965 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -18,12 +16,9 @@
from __future__ import print_function
import os
-import sys
-
from oslo.config import cfg
-from tempest.common.utils.misc import singleton
from tempest.openstack.common import log as logging
@@ -81,7 +76,7 @@
secret=True),
cfg.StrOpt('admin_username',
default='admin',
- help="Administrative Username to use for"
+ help="Administrative Username to use for "
"Keystone API requests."),
cfg.StrOpt('admin_tenant_name',
default='admin',
@@ -93,6 +88,16 @@
secret=True),
]
+identity_feature_group = cfg.OptGroup(name='identity-feature-enabled',
+ title='Enabled Identity Features')
+
+IdentityFeatureGroup = [
+ cfg.BoolOpt('trust',
+ default=True,
+ help='Does the identity service have delegation and '
+ 'impersonation enabled')
+]
+
compute_group = cfg.OptGroup(name='compute',
title='Compute Service Options')
@@ -137,7 +142,7 @@
help="Timeout in seconds to wait for an instance to build."),
cfg.BoolOpt('run_ssh',
default=False,
- help="Does the test environment support snapshots?"),
+ help="Should the tests ssh to instances?"),
cfg.StrOpt('ssh_user',
default='root',
help="User name used to authenticate to an instance."),
@@ -380,6 +385,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"),
]
@@ -398,11 +406,11 @@
"one is used."),
cfg.IntOpt('container_sync_timeout',
default=120,
- help="Number of seconds to time on waiting for a container"
+ help="Number of seconds to time on waiting for a container "
"to container synchronization complete."),
cfg.IntOpt('container_sync_interval',
default=5,
- help="Number of seconds to wait while looping to check the"
+ help="Number of seconds to wait while looping to check the "
"status of a container to container synchronization"),
cfg.StrOpt('operator_role',
default='Member',
@@ -415,19 +423,11 @@
title='Enabled object-storage features')
ObjectStoreFeaturesGroup = [
- cfg.BoolOpt('container_quotas',
- default=True,
- help="Set to True if the Container Quota middleware "
- "is enabled"),
- cfg.BoolOpt('accounts_quotas',
- default=True,
- help="Set to True if the Account Quota middleware is enabled"),
- cfg.BoolOpt('crossdomain',
- default=True,
- help="Set to True if the Crossdomain middleware is enabled"),
- cfg.BoolOpt('tempurl',
- default=True,
- help="Set to True if the TempURL middleware is enabled"),
+ cfg.ListOpt('discoverable_apis',
+ default=['all'],
+ help="A list of the enabled optional discoverable apis. "
+ "A single entry, all, indicates that all of these "
+ "features are expected to be enabled"),
]
@@ -473,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")
@@ -486,6 +496,16 @@
]
+data_processing_group = cfg.OptGroup(name="data_processing",
+ title="Data Processing options")
+
+DataProcessingGroup = [
+ cfg.StrOpt('catalog_type',
+ default='data_processing',
+ help="Catalog type of the data processing service.")
+]
+
+
boto_group = cfg.OptGroup(name='boto',
title='EC2/S3 options')
BotoGroup = [
@@ -621,6 +641,12 @@
cfg.BoolOpt('horizon',
default=True,
help="Whether or not Horizon is expected to be available"),
+ cfg.BoolOpt('savanna',
+ default=False,
+ help="Whether or not Savanna is expected to be available"),
+ cfg.BoolOpt('ironic',
+ default=False,
+ help="Whether or not Ironic is expected to be available"),
]
debug_group = cfg.OptGroup(name="debug",
@@ -632,9 +658,40 @@
help="Enable diagnostic commands"),
]
+input_scenario_group = cfg.OptGroup(name="input-scenario",
+ title="Filters and values for"
+ " input scenarios")
-@singleton
-class TempestConfig:
+InputScenarioGroup = [
+ cfg.StrOpt('image_regex',
+ default='^cirros-0.3.1-x86_64-uec$',
+ help="Matching images become parameters for scenario tests"),
+ cfg.StrOpt('flavor_regex',
+ default='^m1.(micro|nano|tiny)$',
+ help="Matching flavors become parameters for scenario tests"),
+ cfg.StrOpt('non_ssh_image_regex',
+ default='^.*[Ww]in.*$',
+ help="SSH verification in tests is skipped"
+ "for matching images"),
+ cfg.StrOpt('ssh_user_regex',
+ default="[[\"^.*[Cc]irros.*$\", \"root\"]]",
+ help="List of user mapped to regex "
+ "to matching image names."),
+]
+
+
+baremetal_group = cfg.OptGroup(name='baremetal',
+ title='Baremetal provisioning service options')
+
+BaremetalGroup = [
+ cfg.StrOpt('catalog_type',
+ default='baremetal',
+ help="Catalog type of the baremetal provisioning service."),
+]
+
+
+# this should never be called outside of this class
+class TempestConfigPrivate(object):
"""Provides OpenStack configuration information."""
DEFAULT_CONFIG_DIR = os.path.join(
@@ -643,8 +700,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(TempestConfigPrivate, self).__init__()
config_files = []
failsafe_path = "/etc/tempest/" + self.DEFAULT_CONFIG_FILE
@@ -660,10 +718,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)
@@ -675,6 +732,8 @@
register_opt_group(cfg.CONF, compute_features_group,
ComputeFeaturesGroup)
register_opt_group(cfg.CONF, identity_group, IdentityGroup)
+ register_opt_group(cfg.CONF, identity_feature_group,
+ IdentityFeatureGroup)
register_opt_group(cfg.CONF, image_group, ImageGroup)
register_opt_group(cfg.CONF, image_feature_group, ImageFeaturesGroup)
register_opt_group(cfg.CONF, network_group, NetworkGroup)
@@ -687,7 +746,10 @@
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)
register_opt_group(cfg.CONF, boto_group, BotoGroup)
register_opt_group(cfg.CONF, compute_admin_group, ComputeAdminGroup)
register_opt_group(cfg.CONF, stress_group, StressGroup)
@@ -695,9 +757,12 @@
register_opt_group(cfg.CONF, service_available_group,
ServiceAvailableGroup)
register_opt_group(cfg.CONF, debug_group, DebugGroup)
+ register_opt_group(cfg.CONF, baremetal_group, BaremetalGroup)
+ register_opt_group(cfg.CONF, input_scenario_group, InputScenarioGroup)
self.compute = cfg.CONF.compute
self.compute_feature_enabled = cfg.CONF['compute-feature-enabled']
self.identity = cfg.CONF.identity
+ self.identity_feature_enabled = cfg.CONF['identity-feature-enabled']
self.images = cfg.CONF.image
self.image_feature_enabled = cfg.CONF['image-feature-enabled']
self.network = cfg.CONF.network
@@ -708,14 +773,31 @@
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
self.compute_admin = cfg.CONF['compute-admin']
self.stress = cfg.CONF.stress
self.scenario = cfg.CONF.scenario
self.service_available = cfg.CONF.service_available
self.debug = cfg.CONF.debug
+ self.baremetal = cfg.CONF.baremetal
+ self.input_scenario = cfg.CONF['input-scenario']
if not self.compute_admin.username:
self.compute_admin.username = self.identity.admin_username
self.compute_admin.password = self.identity.admin_password
self.compute_admin.tenant_name = self.identity.admin_tenant_name
+
+
+class TempestConfigProxy(object):
+ _config = None
+
+ def __getattr__(self, attr):
+ if not self._config:
+ self._config = TempestConfigPrivate()
+
+ return getattr(self._config, attr)
+
+
+CONF = TempestConfigProxy()
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index 0bab9c7..809037d 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 4c1c107..2e499a2 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -21,6 +19,7 @@
PYTHON_CLIENT_RE = re.compile('import (%s)client' % '|'.join(PYTHON_CLIENTS))
TEST_DEFINITION = re.compile(r'^\s*def test.*')
+SETUPCLASS_DEFINITION = re.compile(r'^\s*def setUpClass')
SCENARIO_DECORATOR = re.compile(r'\s*@.*services\(')
@@ -52,6 +51,14 @@
"T104: Scenario tests require a service decorator")
+def no_setupclass_for_unit_tests(physical_line, filename):
+ if 'tempest/tests' in filename:
+ if SETUPCLASS_DEFINITION.match(physical_line):
+ return (physical_line.find('def'),
+ "T105: setUpClass can not be used with unit tests")
+
+
def factory(register):
register(import_no_clients_in_api)
register(scenario_tests_need_service_tags)
+ register(no_setupclass_for_unit_tests)
diff --git a/tempest/manager.py b/tempest/manager.py
index e3aeb31..cba6ba5 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -15,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-import tempest.config
+from tempest import config
from tempest import exceptions
@@ -29,7 +27,7 @@
"""
def __init__(self):
- self.config = tempest.config.TempestConfig()
+ self.config = config.CONF
self.client_attr_names = []
# we do this everywhere, have it be part of the super class
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 0066a73..04882f3 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
@@ -24,16 +22,17 @@
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
-from tempest.common import ssh
from tempest.common.utils import data_utils
from tempest.common.utils.linux.remote_client import RemoteClient
from tempest import exceptions
@@ -75,6 +74,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,
@@ -123,6 +126,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:
@@ -206,9 +233,10 @@
def setUpClass(cls):
super(OfficialClientTest, cls).setUpClass()
cls.isolated_creds = isolated_creds.IsolatedCreds(
- __name__, tempest_client=False)
+ __name__, tempest_client=False,
+ network_resources=cls.network_resources)
- username, tenant_name, password = cls.credentials()
+ username, password, tenant_name = cls.credentials()
cls.manager = OfficialClientManager(username, password, tenant_name)
cls.compute_client = cls.manager.compute_client
@@ -216,19 +244,33 @@
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 = []
@classmethod
- def credentials(cls):
+ def _get_credentials(cls, get_creds, prefix):
if cls.config.compute.allow_tenant_isolation:
- return cls.isolated_creds.get_primary_creds()
+ username, tenant_name, password = get_creds()
+ else:
+ username = getattr(cls.config.identity, prefix + 'username')
+ password = getattr(cls.config.identity, prefix + 'password')
+ tenant_name = getattr(cls.config.identity, prefix + 'tenant_name')
+ return username, password, tenant_name
- username = cls.config.identity.username
- password = cls.config.identity.password
- tenant_name = cls.config.identity.tenant_name
- return username, tenant_name, password
+ @classmethod
+ def credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_primary_creds, '')
+
+ @classmethod
+ def alt_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_alt_creds, 'alt_')
+
+ @classmethod
+ def admin_credentials(cls):
+ return cls._get_credentials(cls.isolated_creds.get_admin_creds,
+ 'admin_')
@classmethod
def tearDownClass(cls):
@@ -248,7 +290,9 @@
thing.delete()
except Exception as e:
# If the resource is already missing, mission accomplished.
- if e.__class__.__name__ == 'NotFound':
+ # add status code as workaround for bug 1247568
+ if (e.__class__.__name__ == 'NotFound' or
+ hasattr(e, 'status_code') and e.status_code == 404):
continue
raise
@@ -343,9 +387,13 @@
raise
new_status = thing.status
- if new_status == error_status:
- message = "%s failed to get to expected status. \
- In %s state." % (thing, new_status)
+
+ # Some components are reporting error status in lower case
+ # so case sensitive comparisons can really mess things
+ # up.
+ if new_status.lower() == error_status.lower():
+ message = ("%s failed to get to expected status. "
+ "In %s state.") % (thing, new_status)
raise exceptions.BuildErrorException(message)
elif new_status == expected_status and expected_status is not None:
return True # All good.
@@ -356,8 +404,8 @@
check_status,
self.config.compute.build_timeout,
self.config.compute.build_interval):
- message = "Timed out waiting for thing %s \
- to become %s" % (thing_id, log_status)
+ message = ("Timed out waiting for thing %s "
+ "to become %s") % (thing_id, log_status)
raise exceptions.TimeoutException(message)
def _create_loginable_secgroup_rule_nova(self, client=None,
@@ -478,6 +526,13 @@
private_key = self.keypair.private_key
return RemoteClient(ip, username, pkey=private_key)
+ def _log_console_output(self, servers=None):
+ if not servers:
+ servers = self.compute_client.servers.list()
+ for server in servers:
+ LOG.debug('Console output for %s', server.id)
+ LOG.debug(server.get_console_output())
+
class NetworkScenarioTest(OfficialClientTest):
"""
@@ -604,12 +659,15 @@
self.set_resource(name, port)
return port
- def _create_floating_ip(self, server, external_network_id):
+ def _get_server_port_id(self, server):
result = self.network_client.list_ports(device_id=server.id)
ports = result.get('ports', [])
self.assertEqual(len(ports), 1,
"Unable to determine which port to target.")
- port_id = ports[0]['id']
+ return ports[0]['id']
+
+ def _create_floating_ip(self, server, external_network_id):
+ port_id = self._get_server_port_id(server)
body = dict(
floatingip=dict(
floating_network_id=external_network_id,
@@ -624,7 +682,21 @@
self.set_resource(data_utils.rand_name('floatingip-'), floating_ip)
return floating_ip
- def _ping_ip_address(self, ip_address):
+ def _associate_floating_ip(self, floating_ip, server):
+ port_id = self._get_server_port_id(server)
+ floating_ip.update(port_id=port_id)
+ self.assertEqual(port_id, floating_ip.port_id)
+ return floating_ip
+
+ def _disassociate_floating_ip(self, floating_ip):
+ """
+ :param floating_ip: type DeletableFloatingIp
+ """
+ floating_ip.update(port_id=None)
+ self.assertEqual(None, floating_ip.port_id)
+ return floating_ip
+
+ def _ping_ip_address(self, ip_address, should_succeed=True):
cmd = ['ping', '-c1', '-w1', ip_address]
def ping():
@@ -632,30 +704,38 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.wait()
- if proc.returncode == 0:
- return True
+ return (proc.returncode == 0) == should_succeed
return tempest.test.call_until_true(
ping, self.config.compute.ping_timeout, 1)
- def _is_reachable_via_ssh(self, ip_address, username, private_key,
- timeout):
- ssh_client = ssh.Client(ip_address, username,
- pkey=private_key,
- timeout=timeout)
- return ssh_client.test_connection_auth()
+ def _check_vm_connectivity(self, ip_address,
+ username=None,
+ private_key=None,
+ should_connect=True):
+ """
+ :param ip_address: server to test against
+ :param username: server's ssh username
+ :param private_key: server's ssh private key to be used
+ :param should_connect: True/False indicates positive/negative test
+ positive - attempt ping and ssh
+ negative - attempt ping and fail if succeed
- def _check_vm_connectivity(self, ip_address, username, private_key):
- self.assertTrue(self._ping_ip_address(ip_address),
- "Timed out waiting for %s to become "
- "reachable" % ip_address)
- self.assertTrue(self._is_reachable_via_ssh(
- ip_address,
- username,
- private_key,
- timeout=self.config.compute.ssh_timeout),
- 'Auth failure in connecting to %s@%s via ssh' %
- (username, ip_address))
+ :raises: AssertError if the result of the connectivity check does
+ not match the value of the should_connect param
+ """
+ if should_connect:
+ msg = "Timed out waiting for %s to become reachable" % ip_address
+ else:
+ msg = "ip address %s is reachable" % ip_address
+ self.assertTrue(self._ping_ip_address(ip_address,
+ should_succeed=should_connect),
+ msg=msg)
+ if should_connect:
+ # no need to check ssh for negative connectivity
+ linux_client = self.get_remote_client(ip_address, username,
+ private_key)
+ linux_client.validate_authentication()
def _create_security_group_nova(self, client=None,
namestart='secgroup-smoke-',
@@ -822,6 +902,12 @@
return rules
+ def _ssh_to_server(self, server, private_key):
+ ssh_login = self.config.compute.image_ssh_user
+ return self.get_remote_client(server,
+ username=ssh_login,
+ private_key=private_key)
+
def _show_quota_network(self, tenant_id):
quota = self.network_client.show_quota(tenant_id)
return quota['quota']['network']
@@ -834,6 +920,60 @@
quota = self.network_client.show_quota(tenant_id)
return quota['quota']['port']
+ def _get_router(self, tenant_id):
+ """Retrieve a router for the given tenant id.
+
+ If a public router has been configured, it will be returned.
+
+ If a public router has not been configured, but a public
+ network has, a tenant router will be created and returned that
+ routes traffic to the public network.
+ """
+ router_id = self.config.network.public_router_id
+ network_id = self.config.network.public_network_id
+ if router_id:
+ result = self.network_client.show_router(router_id)
+ return net_common.AttributeDict(**result['router'])
+ elif network_id:
+ router = self._create_router(tenant_id)
+ router.add_gateway(network_id)
+ return router
+ else:
+ raise Exception("Neither of 'public_router_id' or "
+ "'public_network_id' has been defined.")
+
+ def _create_router(self, tenant_id, namestart='router-smoke-'):
+ name = data_utils.rand_name(namestart)
+ body = dict(
+ router=dict(
+ name=name,
+ admin_state_up=True,
+ tenant_id=tenant_id,
+ ),
+ )
+ result = self.network_client.create_router(body=body)
+ router = net_common.DeletableRouter(client=self.network_client,
+ **result['router'])
+ self.assertEqual(router.name, name)
+ self.set_resource(name, router)
+ return router
+
+ def _create_networks(self, tenant_id=None):
+ """Create a network with a subnet connected to a router.
+
+ :returns: network, subnet, router
+ """
+ if tenant_id is None:
+ tenant_id = self.tenant_id
+ network = self._create_network(tenant_id)
+ router = self._get_router(tenant_id)
+ subnet = self._create_subnet(network)
+ subnet.add_to_router(router.id)
+ self.networks.append(network)
+ self.subnets.append(subnet)
+ self.routers.append(router)
+ return network, subnet, router
+
class OrchestrationScenarioTest(OfficialClientTest):
"""
@@ -851,7 +991,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/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py
index 90ef3a0..be7f955 100644
--- a/tempest/scenario/orchestration/test_autoscaling.py
+++ b/tempest/scenario/orchestration/test_autoscaling.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py
new file mode 100644
index 0000000..3ae9567
--- /dev/null
+++ b/tempest/scenario/test_aggregates_basic_ops.py
@@ -0,0 +1,133 @@
+# 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 import tempest_fixtures as fixtures
+from tempest.common.utils.data_utils import rand_name
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest import test
+
+
+LOG = logging.getLogger(__name__)
+
+
+class TestAggregatesBasicOps(manager.OfficialClientTest):
+ """
+ Creates an aggregate within an availability zone
+ Adds a host to the aggregate
+ Checks aggregate details
+ Updates aggregate's name
+ Removes host from aggregate
+ Deletes aggregate
+ """
+ @classmethod
+ def credentials(cls):
+ return cls.admin_credentials()
+
+ def _create_aggregate(self, aggregate_name, availability_zone=None):
+ aggregate = self.compute_client.aggregates.create(aggregate_name,
+ availability_zone)
+ self.assertEqual(aggregate.name, aggregate_name)
+ self.assertEqual(aggregate.availability_zone, availability_zone)
+ self.set_resource(aggregate.id, aggregate)
+ LOG.debug("Aggregate %s created." % (aggregate.name))
+ return aggregate
+
+ def _delete_aggregate(self, aggregate):
+ self.compute_client.aggregates.delete(aggregate.id)
+ self.remove_resource(aggregate.id)
+ LOG.debug("Aggregate %s deleted. " % (aggregate.name))
+
+ def _get_host_name(self):
+ hosts = self.compute_client.hosts.list()
+ self.assertTrue(len(hosts) >= 1)
+ hostname = hosts[0].host_name
+ return hostname
+
+ def _add_host(self, aggregate_name, host):
+ aggregate = self.compute_client.aggregates.add_host(aggregate_name,
+ host)
+ self.assertIn(host, aggregate.hosts)
+ LOG.debug("Host %s added to Aggregate %s." % (host, aggregate.name))
+
+ def _remove_host(self, aggregate_name, host):
+ aggregate = self.compute_client.aggregates.remove_host(aggregate_name,
+ host)
+ self.assertNotIn(host, aggregate.hosts)
+ LOG.debug("Host %s removed to Aggregate %s." % (host, aggregate.name))
+
+ def _check_aggregate_details(self, aggregate, aggregate_name, azone,
+ hosts, metadata):
+ aggregate = self.compute_client.aggregates.get(aggregate.id)
+ self.assertEqual(aggregate_name, aggregate.name)
+ self.assertEqual(azone, aggregate.availability_zone)
+ self.assertEqual(aggregate.hosts, hosts)
+ for meta_key in metadata.keys():
+ self.assertIn(meta_key, aggregate.metadata)
+ self.assertEqual(metadata[meta_key], aggregate.metadata[meta_key])
+ LOG.debug("Aggregate %s details match." % aggregate.name)
+
+ def _set_aggregate_metadata(self, aggregate, meta):
+ aggregate = self.compute_client.aggregates.set_metadata(aggregate.id,
+ meta)
+
+ for key, value in meta.items():
+ self.assertEqual(meta[key], aggregate.metadata[key])
+ LOG.debug("Aggregate %s metadata updated successfully." %
+ aggregate.name)
+
+ def _update_aggregate(self, aggregate, aggregate_name,
+ availability_zone):
+ values = {}
+ if aggregate_name:
+ values.update({'name': aggregate_name})
+ if availability_zone:
+ values.update({'availability_zone': availability_zone})
+ if values.keys():
+ aggregate = self.compute_client.aggregates.update(aggregate.id,
+ values)
+ for key, values in values.items():
+ self.assertEqual(getattr(aggregate, key), values)
+ return aggregate
+
+ @test.services('compute')
+ def test_aggregate_basic_ops(self):
+ self.useFixture(fixtures.LockFixture('availability_zone'))
+ az = 'foo_zone'
+ aggregate_name = rand_name('aggregate-scenario')
+ aggregate = self._create_aggregate(aggregate_name, az)
+
+ metadata = {'meta_key': 'meta_value'}
+ self._set_aggregate_metadata(aggregate, metadata)
+
+ host = self._get_host_name()
+ self._add_host(aggregate, host)
+ self._check_aggregate_details(aggregate, aggregate_name, az, [host],
+ metadata)
+
+ aggregate_name = rand_name('renamed-aggregate-scenario')
+ aggregate = self._update_aggregate(aggregate, aggregate_name, None)
+
+ additional_metadata = {'foo': 'bar'}
+ self._set_aggregate_metadata(aggregate, additional_metadata)
+
+ metadata.update(additional_metadata)
+ self._check_aggregate_details(aggregate, aggregate.name, az, [host],
+ metadata)
+
+ self._remove_host(aggregate, host)
+ self._delete_aggregate(aggregate)
diff --git a/tempest/scenario/test_cross_tenant_connectivity.py b/tempest/scenario/test_cross_tenant_connectivity.py
new file mode 100644
index 0000000..6fd10be
--- /dev/null
+++ b/tempest/scenario/test_cross_tenant_connectivity.py
@@ -0,0 +1,491 @@
+# Copyright 2013 Red Hat, Inc.
+# 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 import debug
+from tempest.common.utils import data_utils
+from tempest import exceptions
+from tempest.openstack.common import log as logging
+from tempest.scenario import manager
+from tempest.scenario.manager import OfficialClientManager
+from tempest.test import attr
+from tempest.test import call_until_true
+from tempest.test import services
+
+LOG = logging.getLogger(__name__)
+
+
+class TestNetworkCrossTenant(manager.NetworkScenarioTest):
+
+ """
+ This test suite assumes that Nova has been configured to
+ boot VM's with Neutron-managed networking, and attempts to
+ verify cross tenant connectivity as follows
+
+ ssh:
+ in order to overcome "ip namespace", each tenant has an "access point"
+ VM with floating-ip open to incoming ssh connection allowing network
+ commands (ping/ssh) to be executed from within the
+ tenant-network-namespace
+ Tempest host performs key-based authentication to the ssh server via
+ floating IP address
+
+ connectivity test is done by pinging destination server via source server
+ ssh connection.
+ success - ping returns
+ failure - ping_timeout reached
+
+ setup:
+ for each tenant (demo and alt):
+ 1. create a network&subnet
+ 2. create a router (if public router isn't configured)
+ 3. connect tenant network to public network via router
+ 4. create an access point:
+ a. a security group open to incoming ssh connection
+ b. a VM with a floating ip
+ 5. create a general empty security group (same as "default", but
+ without rules allowing in-tenant traffic)
+ 6. for demo tenant - create another server to test in-tenant
+ connections
+
+ tests:
+ 1. _verify_network_details
+ 2. _verify_mac_addr: for each access point verify that
+ (subnet, fix_ip, mac address) are as defined in the port list
+ 3. _test_in_tenant_block: test that in-tenant traffic is disabled
+ without rules allowing it
+ 4. _test_in_tenant_allow: test that in-tenant traffic is enabled
+ once an appropriate rule has been created
+ 5. _test_cross_tenant_block: test that cross-tenant traffic is disabled
+ without a rule allowing it on destination tenant
+ 6. _test_cross_tenant_allow:
+ * test that cross-tenant traffic is enabled once an appropriate
+ rule has been created on destination tenant.
+ * test that reverse traffic is still blocked
+ * test than revesre traffic is enabled once an appropriate rule has
+ been created on source tenant
+
+ assumptions:
+ 1. alt_tenant/user existed and is different from demo_tenant/user
+ 2. Public network is defined and reachable from the Tempest host
+ 3. Public router can either be:
+ * defined, in which case all tenants networks can connect directly
+ to it, and cross tenant check will be done on the private IP of the
+ destination tenant
+ or
+ * not defined (empty string), in which case each tanant will have
+ its own router connected to the public network
+ """
+
+ class TenantProperties():
+ '''
+ helper class to save tenant details
+ id
+ credentials
+ network
+ subnet
+ security groups
+ servers
+ access point
+ '''
+
+ def __init__(self, tenant_id, tenant_user, tenant_pass, tenant_name):
+ self.manager = OfficialClientManager(
+ tenant_user,
+ tenant_pass,
+ tenant_name
+ )
+ self.tenant_id = tenant_id
+ self.tenant_name = tenant_name
+ self.tenant_user = tenant_user
+ self.tenant_pass = tenant_pass
+ self.network = None
+ self.subnet = None
+ self.router = None
+ self.security_groups = {}
+ self.servers = list()
+
+ def _set_network(self, network, subnet, router):
+ self.network = network
+ self.subnet = subnet
+ self.router = router
+
+ def _get_tenant_credentials(self):
+ return self.tenant_user, self.tenant_pass, self.tenant_name
+
+ @classmethod
+ def check_preconditions(cls):
+ super(TestNetworkCrossTenant, cls).check_preconditions()
+ if (cls.alt_tenant_id is None) or (cls.tenant_id is cls.alt_tenant_id):
+ msg = 'No alt_tenant defined'
+ cls.enabled = False
+ raise cls.skipException(msg)
+ cfg = cls.config.network
+ if not (cfg.tenant_networks_reachable or cfg.public_network_id):
+ msg = ('Either tenant_networks_reachable must be "true", or '
+ 'public_network_id must be defined.')
+ cls.enabled = False
+ raise cls.skipException(msg)
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestNetworkCrossTenant, cls).setUpClass()
+ alt_creds = cls.alt_credentials()
+ cls.alt_tenant_id = cls.manager._get_identity_client(
+ *alt_creds
+ ).tenant_id
+ cls.check_preconditions()
+ # TODO(mnewby) Consider looking up entities as needed instead
+ # of storing them as collections on the class.
+ cls.keypairs = {}
+ cls.security_groups = {}
+ cls.networks = []
+ cls.subnets = []
+ cls.routers = []
+ cls.servers = []
+ cls.floating_ips = {}
+ cls.tenants = {}
+ cls.demo_tenant = cls.TenantProperties(
+ cls.tenant_id,
+ *cls.credentials()
+ )
+ cls.alt_tenant = cls.TenantProperties(
+ cls.alt_tenant_id,
+ *alt_creds
+ )
+ for tenant in [cls.demo_tenant, cls.alt_tenant]:
+ cls.tenants[tenant.tenant_id] = tenant
+ if not cls.config.network.public_router_id:
+ cls.floating_ip_access = True
+ else:
+ cls.floating_ip_access = False
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestNetworkCrossTenant, cls).tearDownClass()
+
+ def _create_tenant_keypairs(self, tenant_id):
+ self.keypairs[tenant_id] = self.create_keypair(
+ name=data_utils.rand_name('keypair-smoke-'))
+
+ def _create_tenant_security_groups(self, tenant):
+ self.security_groups.setdefault(self.tenant_id, [])
+ access_sg = self._create_empty_security_group(
+ namestart='secgroup_access-',
+ tenant_id=tenant.tenant_id
+ )
+ # don't use default secgroup since it allows in-tenant traffic
+ def_sg = self._create_empty_security_group(
+ namestart='secgroup_general-',
+ tenant_id=tenant.tenant_id
+ )
+ tenant.security_groups.update(access=access_sg, default=def_sg)
+ ssh_rule = dict(
+ protocol='tcp',
+ port_range_min=22,
+ port_range_max=22,
+ direction='ingress',
+ )
+ self._create_security_group_rule(secgroup=access_sg,
+ **ssh_rule
+ )
+
+ def _verify_network_details(self, tenant):
+ # Checks that we see the newly created network/subnet/router via
+ # checking the result of list_[networks,routers,subnets]
+ # Check that (router, subnet) couple exist in port_list
+ seen_nets = self._list_networks()
+ seen_names = [n['name'] for n in seen_nets]
+ seen_ids = [n['id'] for n in seen_nets]
+
+ self.assertIn(tenant.network.name, seen_names)
+ self.assertIn(tenant.network.id, seen_ids)
+
+ seen_subnets = [(n['id'], n['cidr'], n['network_id'])
+ for n in self._list_subnets()]
+ mysubnet = (tenant.subnet.id, tenant.subnet.cidr, tenant.network.id)
+ self.assertIn(mysubnet, seen_subnets)
+
+ seen_routers = self._list_routers()
+ seen_router_ids = [n['id'] for n in seen_routers]
+ seen_router_names = [n['name'] for n in seen_routers]
+
+ self.assertIn(tenant.router.name, seen_router_names)
+ self.assertIn(tenant.router.id, seen_router_ids)
+
+ myport = (tenant.router.id, tenant.subnet.id)
+ router_ports = [(i['device_id'], i['fixed_ips'][0]['subnet_id']) for i
+ in self.network_client.list_ports()['ports']
+ if i['device_owner'] == 'network:router_interface']
+
+ self.assertIn(myport, router_ports)
+
+ def _create_server(self, name, tenant, security_groups=None):
+ """
+ creates a server and assigns to security group
+ """
+ self._set_compute_context(tenant)
+ if security_groups is None:
+ security_groups = [tenant.security_groups['default'].name]
+ create_kwargs = {
+ 'nics': [
+ {'net-id': tenant.network.id},
+ ],
+ 'key_name': self.keypairs[tenant.tenant_id].name,
+ 'security_groups': security_groups,
+ 'tenant_id': tenant.tenant_id
+ }
+ server = self.create_server(name=name, create_kwargs=create_kwargs)
+ return server
+
+ def _create_tenant_servers(self, tenant, num=1):
+ for i in range(num):
+ name = 'server-{tenant}-gen-{num}-'.format(
+ tenant=tenant.tenant_name,
+ num=i
+ )
+ name = data_utils.rand_name(name)
+ server = self._create_server(name, tenant)
+ self.servers.append(server)
+ tenant.servers.append(server)
+
+ def _set_access_point(self, tenant):
+ """
+ creates a server in a secgroup with rule allowing external ssh
+ in order to access tenant internal network
+ workaround ip namespace
+ """
+ secgroups = [sg.name for sg in tenant.security_groups.values()]
+ name = 'server-{tenant}-access_point-'.format(tenant=tenant.tenant_name
+ )
+ name = data_utils.rand_name(name)
+ server = self._create_server(name, tenant,
+ security_groups=secgroups)
+ self.servers.append(server)
+ tenant.access_point = server
+ self._assign_floating_ips(server)
+
+ def _assign_floating_ips(self, server):
+ public_network_id = self.config.network.public_network_id
+ floating_ip = self._create_floating_ip(server, public_network_id)
+ self.floating_ips.setdefault(server, floating_ip)
+
+ def _create_tenant_network(self, tenant):
+ tenant._set_network(*self._create_networks(tenant.tenant_id))
+
+ def _set_compute_context(self, tenant):
+ self.compute_client = tenant.manager.compute_client
+ return self.compute_client
+
+ def _deploy_tenant(self, tenant_or_id):
+ """
+ creates:
+ network
+ subnet
+ router (if public not defined)
+ access security group
+ access-point server
+ for demo_tenant:
+ creates general server to test against
+ """
+ if not isinstance(tenant_or_id, self.TenantProperties):
+ tenant = self.tenants[tenant_or_id]
+ tenant_id = tenant_or_id
+ else:
+ tenant = tenant_or_id
+ tenant_id = tenant.tenant_id
+ self._set_compute_context(tenant)
+ self._create_tenant_keypairs(tenant_id)
+ self._create_tenant_network(tenant)
+ self._create_tenant_security_groups(tenant)
+ if tenant is self.demo_tenant:
+ self._create_tenant_servers(tenant, num=1)
+ self._set_access_point(tenant)
+
+ def _get_server_ip(self, server, floating=False):
+ '''
+ returns the ip (floating/internal) of a server
+ '''
+ if floating:
+ return self.floating_ips[server].floating_ip_address
+ else:
+ network_name = self.tenants[server.tenant_id].network.name
+ return server.networks[network_name][0]
+
+ def _connect_to_access_point(self, tenant):
+ """
+ create ssh connection to tenant access point
+ """
+ access_point_ssh = \
+ self.floating_ips[tenant.access_point].floating_ip_address
+ private_key = self.keypairs[tenant.tenant_id].private_key
+ access_point_ssh = self._ssh_to_server(access_point_ssh,
+ private_key=private_key)
+ return access_point_ssh
+
+ def _test_remote_connectivity(self, source, dest, should_succeed=True):
+ """
+ check ping server via source ssh connection
+
+ :param source: RemoteClient: an ssh connection from which to ping
+ :param dest: and IP to ping against
+ :param should_succeed: boolean should ping succeed or not
+ :returns: boolean -- should_succeed == ping
+ :returns: ping is false if ping failed
+ """
+ def ping_remote():
+ try:
+ source.ping_host(dest)
+ except exceptions.SSHExecCommandFailed as ex:
+ LOG.debug(ex)
+ return not should_succeed
+ return should_succeed
+
+ return call_until_true(ping_remote,
+ self.config.compute.ping_timeout,
+ 1)
+
+ def _check_connectivity(self, access_point, ip, should_succeed=True):
+ if should_succeed:
+ msg = "Timed out waiting for %s to become reachable" % ip
+ else:
+ # todo(yfried): remove this line when bug 1252620 is fixed
+ return True
+ msg = "%s is reachable" % ip
+ try:
+ self.assertTrue(self._test_remote_connectivity(access_point, ip,
+ should_succeed),
+ msg)
+ except Exception:
+ debug.log_ip_ns()
+ raise
+
+ def _test_in_tenant_block(self, tenant):
+ access_point_ssh = self._connect_to_access_point(tenant)
+ for server in tenant.servers:
+ self._check_connectivity(access_point=access_point_ssh,
+ ip=self._get_server_ip(server),
+ should_succeed=False)
+
+ def _test_in_tenant_allow(self, tenant):
+ ruleset = dict(
+ protocol='icmp',
+ remote_group_id=tenant.security_groups['default'].id,
+ direction='ingress'
+ )
+ rule = self._create_security_group_rule(
+ secgroup=tenant.security_groups['default'],
+ **ruleset
+ )
+ access_point_ssh = self._connect_to_access_point(tenant)
+ for server in tenant.servers:
+ self._check_connectivity(access_point=access_point_ssh,
+ ip=self._get_server_ip(server))
+ rule.delete()
+
+ def _test_cross_tenant_block(self, source_tenant, dest_tenant):
+ '''
+ if public router isn't defined, then dest_tenant access is via
+ floating-ip
+ '''
+ access_point_ssh = self._connect_to_access_point(source_tenant)
+ ip = self._get_server_ip(dest_tenant.access_point,
+ floating=self.floating_ip_access)
+ self._check_connectivity(access_point=access_point_ssh, ip=ip,
+ should_succeed=False)
+
+ def _test_cross_tenant_allow(self, source_tenant, dest_tenant):
+ '''
+ check for each direction:
+ creating rule for tenant incoming traffic enables only 1way traffic
+ '''
+ ruleset = dict(
+ protocol='icmp',
+ direction='ingress'
+ )
+ rule_s2d = self._create_security_group_rule(
+ secgroup=dest_tenant.security_groups['default'],
+ **ruleset
+ )
+ try:
+ access_point_ssh = self._connect_to_access_point(source_tenant)
+ ip = self._get_server_ip(dest_tenant.access_point,
+ floating=self.floating_ip_access)
+ self._check_connectivity(access_point_ssh, ip)
+
+ # test that reverse traffic is still blocked
+ self._test_cross_tenant_block(dest_tenant, source_tenant)
+
+ # allow reverse traffic and check
+ rule_d2s = self._create_security_group_rule(
+ secgroup=source_tenant.security_groups['default'],
+ **ruleset
+ )
+ try:
+ access_point_ssh_2 = self._connect_to_access_point(dest_tenant)
+ ip = self._get_server_ip(source_tenant.access_point,
+ floating=self.floating_ip_access)
+ self._check_connectivity(access_point_ssh_2, ip)
+
+ # clean_rules
+ rule_s2d.delete()
+ rule_d2s.delete()
+
+ except Exception as e:
+ rule_d2s.delete()
+ raise e
+
+ except Exception as e:
+ rule_s2d.delete()
+ raise e
+
+ def _verify_mac_addr(self, tenant):
+ """
+ verify that VM (tenant's access point) has the same ip,mac as listed in
+ port list
+ """
+ access_point_ssh = self._connect_to_access_point(tenant)
+ mac_addr = access_point_ssh.get_mac_address()
+ mac_addr = mac_addr.strip().lower()
+ port_list = self.network_client.list_ports()['ports']
+ port_detail_list = [
+ (port['fixed_ips'][0]['subnet_id'],
+ port['fixed_ips'][0]['ip_address'],
+ port['mac_address'].lower()) for port in port_list
+ ]
+ server_ip = self._get_server_ip(tenant.access_point)
+ subnet_id = tenant.subnet.id
+ self.assertIn((subnet_id, server_ip, mac_addr), port_detail_list)
+
+ @attr(type='smoke')
+ @services('compute', 'network')
+ def test_cross_tenant_traffic(self):
+ try:
+ for tenant_id in self.tenants.keys():
+ self._deploy_tenant(tenant_id)
+ self._verify_network_details(self.tenants[tenant_id])
+ self._verify_mac_addr(self.tenants[tenant_id])
+
+ # in-tenant check
+ self._test_in_tenant_block(self.demo_tenant)
+ self._test_in_tenant_allow(self.demo_tenant)
+
+ # cross tenant check
+ source_tenant = self.demo_tenant
+ dest_tenant = self.alt_tenant
+ self._test_cross_tenant_block(source_tenant, dest_tenant)
+ self._test_cross_tenant_allow(source_tenant, dest_tenant)
+ except Exception:
+ self._log_console_output(servers=self.servers)
+ raise
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index 1081a3e..98efcfb 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -34,6 +32,7 @@
@classmethod
def setUpClass(cls):
+ cls.set_network_resources()
super(TestDashboardBasicOps, cls).setUpClass()
if not cls.config.service_available.horizon:
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index 7f8d3e4..25e2dab 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -36,6 +34,11 @@
"""
+ @classmethod
+ def setUpClass(cls):
+ cls.set_network_resources()
+ super(TestLargeOpsScenario, cls).setUpClass()
+
def _wait_for_server_status(self, status):
for server in self.servers:
self.status_timeout(
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index 9703f11..26a4dc0 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -131,7 +129,12 @@
self.server.add_floating_ip(self.floating_ip)
def ssh_to_server(self):
- self.linux_client = self.get_remote_client(self.floating_ip.ip)
+ try:
+ self.linux_client = self.get_remote_client(self.floating_ip.ip)
+ except Exception:
+ LOG.exception('ssh to server failed')
+ self._log_console_output()
+ raise
def check_partitions(self):
partitions = self.linux_client.get_partitions()
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index bfded53..eaca1fd 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
@@ -16,15 +14,16 @@
# License for the specific language governing permissions and limitations
# under the License.
-from tempest.api.network import common as net_common
from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
+
from tempest.test import attr
from tempest.test import services
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -46,6 +45,13 @@
ssh server hosted at the IP address. This check guarantees
that the IP address is associated with the target VM.
+ - detach the floating-ip from the VM and verify that it becomes
+ unreachable
+
+ - associate detached floating ip to a new VM and verify connectivity.
+ VMs are created with unique keypair so connectivity also asserts that
+ floating IP is associated with the new VM instead of the old one
+
# TODO(mnewby) - Need to implement the following:
- the Tempest host can ssh into the VM via the IP address and
successfully execute the following:
@@ -94,8 +100,6 @@
"""
- CONF = config.TempestConfig()
-
@classmethod
def check_preconditions(cls):
super(TestNetworkBasicOps, cls).check_preconditions()
@@ -112,70 +116,17 @@
cls.check_preconditions()
# TODO(mnewby) Consider looking up entities as needed instead
# of storing them as collections on the class.
- cls.keypairs = {}
cls.security_groups = {}
cls.networks = []
cls.subnets = []
cls.routers = []
- cls.servers = []
+ cls.servers = {}
cls.floating_ips = {}
- def _get_router(self, tenant_id):
- """Retrieve a router for the given tenant id.
-
- If a public router has been configured, it will be returned.
-
- If a public router has not been configured, but a public
- network has, a tenant router will be created and returned that
- routes traffic to the public network.
-
- """
- router_id = self.config.network.public_router_id
- network_id = self.config.network.public_network_id
- if router_id:
- result = self.network_client.show_router(router_id)
- return net_common.AttributeDict(**result['router'])
- elif network_id:
- router = self._create_router(tenant_id)
- router.add_gateway(network_id)
- return router
- else:
- raise Exception("Neither of 'public_router_id' or "
- "'public_network_id' has been defined.")
-
- def _create_router(self, tenant_id, namestart='router-smoke-'):
- name = data_utils.rand_name(namestart)
- body = dict(
- router=dict(
- name=name,
- admin_state_up=True,
- tenant_id=tenant_id,
- ),
- )
- result = self.network_client.create_router(body=body)
- router = net_common.DeletableRouter(client=self.network_client,
- **result['router'])
- self.assertEqual(router.name, name)
- self.set_resource(name, router)
- return router
-
- def _create_keypairs(self):
- self.keypairs[self.tenant_id] = self.create_keypair(
- name=data_utils.rand_name('keypair-smoke-'))
-
def _create_security_groups(self):
self.security_groups[self.tenant_id] =\
self._create_security_group_neutron(tenant_id=self.tenant_id)
- def _create_networks(self):
- network = self._create_network(self.tenant_id)
- router = self._get_router(self.tenant_id)
- subnet = self._create_subnet(network)
- subnet.add_to_router(router.id)
- self.networks.append(network)
- self.subnets.append(subnet)
- self.routers.append(router)
-
def _check_networks(self):
# Checks that we see the newly created network/subnet/router via
# checking the result of list_[networks,routers,subnets]
@@ -201,71 +152,98 @@
def _create_server(self, name, network):
tenant_id = network.tenant_id
- keypair_name = self.keypairs[tenant_id].name
+ keypair = self.create_keypair(name='keypair-%s' % name)
security_groups = [self.security_groups[tenant_id].name]
create_kwargs = {
'nics': [
{'net-id': network.id},
],
- 'key_name': keypair_name,
+ 'key_name': keypair.name,
'security_groups': security_groups,
}
server = self.create_server(name=name, create_kwargs=create_kwargs)
+ self.servers[server] = keypair
return server
def _create_servers(self):
for i, network in enumerate(self.networks):
name = data_utils.rand_name('server-smoke-%d-' % i)
- server = self._create_server(name, network)
- self.servers.append(server)
+ self._create_server(name, network)
def _check_tenant_network_connectivity(self):
- if not self.config.network.tenant_networks_reachable:
+ if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
- for server in self.servers:
- for net_name, ip_addresses in server.networks.iteritems():
- for ip_address in ip_addresses:
- self._check_vm_connectivity(ip_address, ssh_login,
- private_key)
+ ssh_login = CONF.compute.image_ssh_user
+ try:
+ for server, key in self.servers.items():
+ for net_name, ip_addresses in server.networks.iteritems():
+ for ip_address in ip_addresses:
+ self._check_vm_connectivity(ip_address, ssh_login,
+ key.private_key)
+ except Exception:
+ LOG.exception('Tenant connectivity check failed')
+ self._log_console_output(
+ servers=[server for server, _key in self.servers])
+ debug.log_ip_ns()
+ raise
- def _assign_floating_ips(self):
- public_network_id = self.config.network.public_network_id
- for server in self.servers:
+ def _create_and_associate_floating_ips(self):
+ public_network_id = CONF.network.public_network_id
+ for server in self.servers.keys():
floating_ip = self._create_floating_ip(server, public_network_id)
- self.floating_ips.setdefault(server, [])
- self.floating_ips[server].append(floating_ip)
+ self.floating_ips[floating_ip] = server
- def _check_public_network_connectivity(self):
+ def _check_public_network_connectivity(self, should_connect=True):
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
- ssh_login = self.config.compute.image_ssh_user
- private_key = self.keypairs[self.tenant_id].private_key
+ ssh_login = CONF.compute.image_ssh_user
+ LOG.debug('checking network connections')
try:
- for server, floating_ips in self.floating_ips.iteritems():
- for floating_ip in floating_ips:
- ip_address = floating_ip.floating_ip_address
- self._check_vm_connectivity(ip_address,
- ssh_login,
- private_key)
- except Exception as exc:
- LOG.exception(exc)
+ for floating_ip, server in self.floating_ips.iteritems():
+ ip_address = floating_ip.floating_ip_address
+ private_key = None
+ if should_connect:
+ private_key = self.servers[server].private_key
+ self._check_vm_connectivity(ip_address,
+ ssh_login,
+ private_key,
+ should_connect=should_connect)
+ except Exception:
+ LOG.exception('Public network connectivity check failed')
+ self._log_console_output(
+ servers=[server for server, _key in self.servers])
debug.log_ip_ns()
- raise exc
+ raise
+
+ def _disassociate_floating_ips(self):
+ for floating_ip, server in self.floating_ips.iteritems():
+ self._disassociate_floating_ip(floating_ip)
+ self.floating_ips[floating_ip] = None
+
+ def _reassociate_floating_ips(self):
+ network = self.networks[0]
+ for floating_ip in self.floating_ips.keys():
+ name = data_utils.rand_name('new_server-smoke-')
+ # create a new server for the floating ip
+ server = self._create_server(name, network)
+ self._associate_floating_ip(floating_ip, server)
+ self.floating_ips[floating_ip] = server
@attr(type='smoke')
@services('compute', 'network')
def test_network_basic_ops(self):
- self._create_keypairs()
self._create_security_groups()
self._create_networks()
self._check_networks()
self._create_servers()
- self._assign_floating_ips()
- self._check_public_network_connectivity()
+ self._create_and_associate_floating_ips()
self._check_tenant_network_connectivity()
+ self._check_public_network_connectivity(should_connect=True)
+ self._disassociate_floating_ips()
+ self._check_public_network_connectivity(should_connect=False)
+ self._reassociate_floating_ips()
+ self._check_public_network_connectivity(should_connect=True)
diff --git a/tempest/scenario/test_network_quotas.py b/tempest/scenario/test_network_quotas.py
deleted file mode 100644
index cb7aa0b..0000000
--- a/tempest/scenario/test_network_quotas.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# 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 neutronclient.common import exceptions as exc
-
-from tempest.scenario.manager import NetworkScenarioTest
-from tempest.test import services
-
-
-class TestNetworkQuotaBasic(NetworkScenarioTest):
- """
- This test suite contains tests that each loop trying to grab a
- particular resource until a quota limit is hit.
- For sanity, there is a maximum number of iterations - if this is hit
- the test fails. Covers network, subnet, port.
- """
-
- @classmethod
- def check_preconditions(cls):
- super(TestNetworkQuotaBasic, cls).check_preconditions()
-
- @classmethod
- def setUpClass(cls):
- super(TestNetworkQuotaBasic, cls).setUpClass()
- cls.check_preconditions()
- cls.networks = []
- cls.subnets = []
- cls.ports = []
-
- @services('network')
- def test_create_network_until_quota_hit(self):
- hit_limit = False
- networknum = self._get_tenant_own_network_num(self.tenant_id)
- max = self._show_quota_network(self.tenant_id) - networknum
- for n in xrange(max):
- try:
- self.networks.append(
- self._create_network(self.tenant_id,
- namestart='network-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- break
- self.assertFalse(hit_limit, "Failed: Hit quota limit !")
-
- try:
- self.networks.append(
- self._create_network(self.tenant_id,
- namestart='network-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- self.assertTrue(hit_limit, "Failed: Did not hit quota limit !")
-
- @services('network')
- def test_create_subnet_until_quota_hit(self):
- if not self.networks:
- self.networks.append(
- self._create_network(self.tenant_id,
- namestart='network-quotatest-'))
- hit_limit = False
- subnetnum = self._get_tenant_own_subnet_num(self.tenant_id)
- max = self._show_quota_subnet(self.tenant_id) - subnetnum
- for n in xrange(max):
- try:
- self.subnets.append(
- self._create_subnet(self.networks[0],
- namestart='subnet-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- break
- self.assertFalse(hit_limit, "Failed: Hit quota limit !")
-
- try:
- self.subnets.append(
- self._create_subnet(self.networks[0],
- namestart='subnet-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- self.assertTrue(hit_limit, "Failed: Did not hit quota limit !")
-
- @services('network')
- def test_create_ports_until_quota_hit(self):
- if not self.networks:
- self.networks.append(
- self._create_network(self.tenant_id,
- namestart='network-quotatest-'))
- hit_limit = False
- portnum = self._get_tenant_own_port_num(self.tenant_id)
- max = self._show_quota_port(self.tenant_id) - portnum
- for n in xrange(max):
- try:
- self.ports.append(
- self._create_port(self.networks[0],
- namestart='port-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- break
- self.assertFalse(hit_limit, "Failed: Hit quota limit !")
-
- try:
- self.ports.append(
- self._create_port(self.networks[0],
- namestart='port-quotatest-'))
- except exc.NeutronClientException as e:
- if (e.status_code != 409):
- raise
- hit_limit = True
- self.assertTrue(hit_limit, "Failed: Did not hit quota limit !")
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index 112c8a2..45c24ca 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -33,6 +31,7 @@
@classmethod
def setUpClass(cls):
+ cls.set_network_resources()
super(TestServerAdvancedOps, cls).setUpClass()
if not cls.config.compute_feature_enabled.resize:
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 1e1a310..8779518 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,12 +14,21 @@
# under the License.
from tempest.common.utils import data_utils
+from tempest.common.utils import test_utils
from tempest.openstack.common import log as logging
from tempest.scenario import manager
from tempest.test import services
+import testscenarios
+
LOG = logging.getLogger(__name__)
+# NOTE(andreaf) - nose does not honour the load_tests protocol
+# however it's test discovery regex will match anything
+# which includes _tests. So nose would require some further
+# investigation to be supported with this
+load_tests = testscenarios.load_tests_apply_scenarios
+
class TestServerBasicOps(manager.OfficialClientTest):
@@ -37,6 +44,37 @@
* Terminate the instance
"""
+ scenario_utils = test_utils.InputScenarioUtils()
+ scenario_flavor = scenario_utils.scenario_flavors
+ scenario_image = scenario_utils.scenario_images
+
+ scenarios = testscenarios.multiply_scenarios(scenario_image,
+ scenario_flavor)
+
+ def setUp(self):
+ super(TestServerBasicOps, self).setUp()
+ # Setup image and flavor the test instance
+ # Support both configured and injected values
+ if not hasattr(self, 'image_ref'):
+ self.image_ref = self.config.compute.image_ref
+ if not hasattr(self, 'flavor_ref'):
+ self.flavor_ref = self.config.compute.flavor_ref
+ self.image_utils = test_utils.ImageUtils()
+ if not self.image_utils.is_flavor_enough(self.flavor_ref,
+ self.image_ref):
+ raise self.skipException(
+ '{image} does not fit in {flavor}'.format(
+ image=self.image_ref, flavor=self.flavor_ref
+ )
+ )
+ self.run_ssh = self.config.compute.run_ssh and \
+ self.image_utils.is_sshable_image(self.image_ref)
+ self.ssh_user = self.image_utils.ssh_user(self.image_ref)
+ LOG.debug('Starting test for i:{image}, f:{flavor}. '
+ 'Run ssh: {ssh}, user: {ssh_user}'.format(
+ image=self.image_ref, flavor=self.flavor_ref,
+ ssh=self.run_ssh, ssh_user=self.ssh_user))
+
def add_keypair(self):
self.keypair = self.create_keypair()
@@ -53,10 +91,13 @@
self._create_loginable_secgroup_rule_nova(secgroup_id=self.secgroup.id)
def boot_instance(self):
+ # Create server with image and flavor from input scenario
create_kwargs = {
'key_name': self.keypair.id
}
- instance = self.create_server(create_kwargs=create_kwargs)
+ instance = self.create_server(image=self.image_ref,
+ flavor=self.flavor_ref,
+ create_kwargs=create_kwargs)
self.set_resource('instance', instance)
def pause_server(self):
@@ -100,6 +141,24 @@
instance.delete()
self.remove_resource('instance')
+ def verify_ssh(self):
+ if self.run_ssh:
+ # Obtain a floating IP
+ floating_ip = self.compute_client.floating_ips.create()
+ # Attach a floating IP
+ instance = self.get_resource('instance')
+ instance.add_floating_ip(floating_ip)
+ # Check ssh
+ try:
+ self.get_remote_client(
+ server_or_ip=floating_ip.ip,
+ username=self.image_utils.ssh_user(self.image_ref),
+ private_key=self.keypair.private)
+ except Exception:
+ LOG.exception('ssh to server failed')
+ self._log_console_output()
+ raise
+
@services('compute', 'network')
def test_server_basicops(self):
self.add_keypair()
@@ -109,4 +168,5 @@
self.unpause_server()
self.suspend_server()
self.resume_server()
+ self.verify_ssh()
self.terminate_instance()
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 00139f0..5ff8642 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
@@ -15,10 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest.openstack.common import log
from tempest.scenario import manager
from tempest.test import services
+LOG = log.getLogger(__name__)
+
+
class TestSnapshotPattern(manager.OfficialClientTest):
"""
This test is for snapshotting an instance and booting with it.
@@ -40,7 +42,11 @@
self.keypair = self.create_keypair()
def _ssh_to_server(self, server_or_ip):
- linux_client = self.get_remote_client(server_or_ip)
+ try:
+ linux_client = self.get_remote_client(server_or_ip)
+ except Exception:
+ LOG.exception()
+ self._log_console_output()
return linux_client.ssh_client
def _write_timestamp(self, server_or_ip):
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index 5eac55c..84c7096 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py
new file mode 100644
index 0000000..5892e1e
--- /dev/null
+++ b/tempest/scenario/test_swift_basic_ops.py
@@ -0,0 +1,100 @@
+# 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):
+ cls.set_network_resources()
+ 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/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index fa9a228..c4f8ced 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -1,5 +1,3 @@
-# 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
@@ -13,10 +11,15 @@
# under the License.
from tempest.common.utils import data_utils
+from tempest.openstack.common import log
from tempest.scenario import manager
+import tempest.test
from tempest.test import services
+LOG = log.getLogger(__name__)
+
+
class TestVolumeBootPattern(manager.OfficialClientTest):
"""
@@ -96,8 +99,14 @@
network_name_for_ssh = self.config.compute.network_for_ssh
ip = server.networks[network_name_for_ssh][0]
- client = self.get_remote_client(ip,
- private_key=keypair.private_key)
+ try:
+ client = self.get_remote_client(
+ ip,
+ private_key=keypair.private_key)
+ except Exception:
+ LOG.exception('ssh to server failed')
+ self._log_console_output()
+ raise
return client.ssh_client
def _get_content(self, ssh_client):
@@ -117,6 +126,7 @@
actual = self._get_content(ssh_client)
self.assertEqual(expected, actual)
+ @tempest.test.skip_because(bug="1270608")
@services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
diff --git a/tempest/services/__init__.py b/tempest/services/__init__.py
index e210926..e7bec60 100644
--- a/tempest/services/__init__.py
+++ b/tempest/services/__init__.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/baremetal/__init__.py
similarity index 100%
rename from tempest/services/compute/v3/xml/__init__.py
rename to tempest/services/baremetal/__init__.py
diff --git a/tempest/services/baremetal/base.py b/tempest/services/baremetal/base.py
new file mode 100644
index 0000000..74d023a
--- /dev/null
+++ b/tempest/services/baremetal/base.py
@@ -0,0 +1,195 @@
+# 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 functools
+import json
+
+import six
+
+from tempest.common import rest_client
+
+
+def handle_errors(f):
+ """A decorator that allows to ignore certain types of errors."""
+
+ @functools.wraps(f)
+ def wrapper(*args, **kwargs):
+ param_name = 'ignore_errors'
+ ignored_errors = kwargs.get(param_name, tuple())
+
+ if param_name in kwargs:
+ del kwargs[param_name]
+
+ try:
+ return f(*args, **kwargs)
+ except ignored_errors:
+ # Silently ignore errors
+ pass
+
+ return wrapper
+
+
+class BaremetalClient(rest_client.RestClient):
+ """
+ Base Tempest REST client for Ironic API.
+
+ """
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(BaremetalClient, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.baremetal.catalog_type
+ self.uri_prefix = ''
+
+ def serialize(self, object_type, object_dict):
+ """Serialize an Ironic object."""
+
+ raise NotImplementedError
+
+ def deserialize(self, object_str):
+ """Deserialize an Ironic object."""
+
+ raise NotImplementedError
+
+ def _get_uri(self, resource_name, uuid=None, permanent=False):
+ """
+ Get URI for a specific resource or object.
+
+ :param resource_name: The name of the REST resource, e.g., 'nodes'.
+ :param uuid: The unique identifier of an object in UUID format.
+ :return: Relative URI for the resource or object.
+
+ """
+ prefix = self.uri_prefix if not permanent else ''
+
+ return '{pref}/{res}{uuid}'.format(pref=prefix,
+ res=resource_name,
+ uuid='/%s' % uuid if uuid else '')
+
+ def _make_patch(self, allowed_attributes, **kw):
+ """
+ Create a JSON patch according to RFC 6902.
+
+ :param allowed_attributes: An iterable object that contains a set of
+ allowed attributes for an object.
+ :param **kw: Attributes and new values for them.
+ :return: A JSON path that sets values of the specified attributes to
+ the new ones.
+
+ """
+ def get_change(kw, path='/'):
+ for name, value in six.iteritems(kw):
+ if isinstance(value, dict):
+ for ch in get_change(value, path + '%s/' % name):
+ yield ch
+ else:
+ yield {'path': path + name,
+ 'value': value,
+ 'op': 'replace'}
+
+ patch = [ch for ch in get_change(kw)
+ if ch['path'].lstrip('/') in allowed_attributes]
+
+ return patch
+
+ def _list_request(self, resource, permanent=False):
+ """
+ Get the list of objects of the specified type.
+
+ :param resource: The name of the REST resource, e.g., 'nodes'.
+ :return: A tuple with the server response and deserialized JSON list
+ of objects
+
+ """
+ uri = self._get_uri(resource, permanent=permanent)
+
+ resp, body = self.get(uri, self.headers)
+
+ return resp, self.deserialize(body)
+
+ def _show_request(self, resource, uuid, permanent=False):
+ """
+ Gets a specific object of the specified type.
+
+ :param uuid: Unique identifier of the object in UUID format.
+ :return: Serialized object as a dictionary.
+
+ """
+ uri = self._get_uri(resource, uuid=uuid, permanent=permanent)
+ resp, body = self.get(uri, self.headers)
+
+ return resp, self.deserialize(body)
+
+ def _create_request(self, resource, object_type, object_dict):
+ """
+ Create an object of the specified type.
+
+ :param resource: The name of the REST resource, e.g., 'nodes'.
+ :param object_dict: A Python dict that represents an object of the
+ specified type.
+ :return: A tuple with the server response and the deserialized created
+ object.
+
+ """
+ body = self.serialize(object_type, object_dict)
+ uri = self._get_uri(resource)
+
+ resp, body = self.post(uri, headers=self.headers, body=body)
+
+ return resp, self.deserialize(body)
+
+ def _delete_request(self, resource, uuid):
+ """
+ Delete specified object.
+
+ :param resource: The name of the REST resource, e.g., 'nodes'.
+ :param uuid: The unique identifier of an object in UUID format.
+ :return: A tuple with the server response and the response body.
+
+ """
+ uri = self._get_uri(resource, uuid)
+
+ resp, body = self.delete(uri, self.headers)
+ return resp, body
+
+ def _patch_request(self, resource, uuid, patch_object):
+ """
+ Update specified object with JSON-patch.
+
+ :param resource: The name of the REST resource, e.g., 'nodes'.
+ :param uuid: The unique identifier of an object in UUID format.
+ :return: A tuple with the server response and the serialized patched
+ object.
+
+ """
+ uri = self._get_uri(resource, uuid)
+ patch_body = json.dumps(patch_object)
+
+ resp, body = self.patch(uri, headers=self.headers, body=patch_body)
+ return resp, self.deserialize(body)
+
+ @handle_errors
+ def get_api_description(self):
+ """Retrieves all versions of the Ironic API."""
+
+ return self._list_request('', permanent=True)
+
+ @handle_errors
+ def get_version_description(self, version='v1'):
+ """
+ Retrieves the desctription of the API.
+
+ :param version: The version of the API. Default: 'v1'.
+ :return: Serialized description of API resources.
+
+ """
+ return self._list_request(version, permanent=True)
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/baremetal/v1/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/services/baremetal/v1/__init__.py
diff --git a/tempest/services/baremetal/v1/base_v1.py b/tempest/services/baremetal/v1/base_v1.py
new file mode 100644
index 0000000..5e90cd6
--- /dev/null
+++ b/tempest/services/baremetal/v1/base_v1.py
@@ -0,0 +1,207 @@
+# 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.services.baremetal import base
+
+
+class BaremetalClientV1(base.BaremetalClient):
+ """
+ Base Tempest REST client for Ironic API v1.
+
+ Specific implementations must implement serialize and deserialize
+ methods in order to send requests to Ironic.
+
+ """
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(BaremetalClientV1, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.version = '1'
+ self.uri_prefix = 'v%s' % self.version
+
+ @base.handle_errors
+ def list_nodes(self):
+ """List all existing nodes."""
+ return self._list_request('nodes')
+
+ @base.handle_errors
+ def list_chassis(self):
+ """List all existing chassis."""
+ return self._list_request('chassis')
+
+ @base.handle_errors
+ def list_ports(self):
+ """List all existing ports."""
+ return self._list_request('ports')
+
+ @base.handle_errors
+ def show_node(self, uuid):
+ """
+ Gets a specific node.
+
+ :param uuid: Unique identifier of the node in UUID format.
+ :return: Serialized node as a dictionary.
+
+ """
+ return self._show_request('nodes', uuid)
+
+ @base.handle_errors
+ def show_chassis(self, uuid):
+ """
+ Gets a specific chassis.
+
+ :param uuid: Unique identifier of the chassis in UUID format.
+ :return: Serialized chassis as a dictionary.
+
+ """
+ return self._show_request('chassis', uuid)
+
+ @base.handle_errors
+ def show_port(self, uuid):
+ """
+ Gets a specific port.
+
+ :param uuid: Unique identifier of the port in UUID format.
+ :return: Serialized port as a dictionary.
+
+ """
+ return self._show_request('ports', uuid)
+
+ @base.handle_errors
+ def create_node(self, chassis_id, **kwargs):
+ """
+ Create a baremetal node with the specified parameters.
+
+ :param cpu_arch: CPU architecture of the node. Default: x86_64.
+ :param cpu_num: Number of CPUs. Default: 8.
+ :param storage: Disk size. Default: 1024.
+ :param memory: Available RAM. Default: 4096.
+ :param driver: Driver name. Default: "fake"
+ :return: A tuple with the server response and the created node.
+
+ """
+ node = {'chassis_uuid': chassis_id,
+ 'properties': {'cpu_arch': kwargs.get('cpu_arch', 'x86_64'),
+ 'cpu_num': kwargs.get('cpu_num', 8),
+ 'storage': kwargs.get('storage', 1024),
+ 'memory': kwargs.get('memory', 4096)},
+ 'driver': kwargs.get('driver', 'fake')}
+
+ return self._create_request('nodes', 'node', node)
+
+ @base.handle_errors
+ def create_chassis(self, **kwargs):
+ """
+ Create a chassis with the specified parameters.
+
+ :param description: The description of the chassis.
+ Default: test-chassis
+ :return: A tuple with the server response and the created chassis.
+
+ """
+ chassis = {'description': kwargs.get('description', 'test-chassis')}
+
+ return self._create_request('chassis', 'chassis', chassis)
+
+ @base.handle_errors
+ def create_port(self, node_id, **kwargs):
+ """
+ Create a port with the specified parameters.
+
+ :param node_id: The ID of the node which owns the port.
+ :param address: MAC address of the port. Default: 01:23:45:67:89:0A.
+ :return: A tuple with the server response and the created port.
+
+ """
+ port = {'address': kwargs.get('address', '01:23:45:67:89:0A'),
+ 'node_uuid': node_id}
+
+ return self._create_request('ports', 'port', port)
+
+ @base.handle_errors
+ def delete_node(self, uuid):
+ """
+ Deletes a node having the specified UUID.
+
+ :param uuid: The unique identifier of the node.
+ :return: A tuple with the server response and the response body.
+
+ """
+ return self._delete_request('nodes', uuid)
+
+ @base.handle_errors
+ def delete_chassis(self, uuid):
+ """
+ Deletes a chassis having the specified UUID.
+
+ :param uuid: The unique identifier of the chassis.
+ :return: A tuple with the server response and the response body.
+
+ """
+ return self._delete_request('chassis', uuid)
+
+ @base.handle_errors
+ def delete_port(self, uuid):
+ """
+ Deletes a port having the specified UUID.
+
+ :param uuid: The unique identifier of the port.
+ :return: A tuple with the server response and the response body.
+
+ """
+ return self._delete_request('ports', uuid)
+
+ @base.handle_errors
+ def update_node(self, uuid, **kwargs):
+ """
+ Update the specified node.
+
+ :param uuid: The unique identifier of the node.
+ :return: A tuple with the server response and the updated node.
+
+ """
+ node_attributes = ('properties/cpu_arch',
+ 'properties/cpu_num',
+ 'properties/storage',
+ 'properties/memory',
+ 'driver')
+
+ patch = self._make_patch(node_attributes, **kwargs)
+
+ return self._patch_request('nodes', uuid, patch)
+
+ @base.handle_errors
+ def update_chassis(self, uuid, **kwargs):
+ """
+ Update the specified chassis.
+
+ :param uuid: The unique identifier of the chassis.
+ :return: A tuple with the server response and the updated chassis.
+
+ """
+ chassis_attributes = ('description',)
+ patch = self._make_patch(chassis_attributes, **kwargs)
+
+ return self._patch_request('chassis', uuid, patch)
+
+ @base.handle_errors
+ def update_port(self, uuid, **kwargs):
+ """
+ Update the specified port.
+
+ :param uuid: The unique identifier of the port.
+ :return: A tuple with the server response and the updated port.
+
+ """
+ port_attributes = ('address',)
+ patch = self._make_patch(port_attributes, **kwargs)
+
+ return self._patch_request('ports', uuid, patch)
diff --git a/tempest/services/baremetal/v1/client_json.py b/tempest/services/baremetal/v1/client_json.py
new file mode 100644
index 0000000..f1708af
--- /dev/null
+++ b/tempest/services/baremetal/v1/client_json.py
@@ -0,0 +1,26 @@
+# 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.services.baremetal.v1 import base_v1
+
+
+class BaremetalClientJSON(base_v1.BaremetalClientV1):
+ """Tempest REST client for Ironic JSON API v1."""
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(BaremetalClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+
+ self.serialize = lambda obj_type, obj_body: json.dumps(obj_body)
+ self.deserialize = json.loads
diff --git a/tempest/services/baremetal/v1/client_xml.py b/tempest/services/baremetal/v1/client_xml.py
new file mode 100644
index 0000000..4c214fe
--- /dev/null
+++ b/tempest/services/baremetal/v1/client_xml.py
@@ -0,0 +1,55 @@
+# 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 import rest_client
+from tempest.services.baremetal.v1 import base_v1 as base
+from tempest.services.compute.xml import common as xml
+
+
+class BaremetalClientXML(rest_client.RestClientXML, base.BaremetalClientV1):
+ """Tempest REST client for Ironic XML API v1."""
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(BaremetalClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+
+ self.serialize = self.json_to_xml
+ self.deserialize = xml.xml_to_json
+
+ def json_to_xml(self, object_type, object_dict):
+ """
+ Brainlessly converts a specification of an object to XML string.
+
+ :param object_type: Kind of the object.
+ :param object_dict: Specification of the object attributes as a dict.
+ :return: An XML string that corresponds to the specification.
+
+ """
+ root = xml.Element(object_type)
+
+ for attr_name, value in object_dict:
+ # Handle nested dictionaries
+ if isinstance(value, dict):
+ value = self.json_to_xml(attr_name, value)
+
+ root.append(xml.Element(attr_name, value))
+
+ return str(xml.Document(root))
+
+ def _patch_request(self, resource_name, uuid, patch_object):
+ """Changes Content-Type header to application/json for jsonpatch."""
+
+ self.headers['Content-Type'] = 'application/json'
+ try:
+ super(self)._patch_request(self, resource_name, uuid, patch_object)
+ finally:
+ self.headers['Content-Type'] = 'application/xml'
diff --git a/tempest/services/botoclients.py b/tempest/services/botoclients.py
index 0b4b3b9..a1e1b5c 100644
--- a/tempest/services/botoclients.py
+++ b/tempest/services/botoclients.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
index b7c6bf1..d9e73de 100644
--- a/tempest/services/compute/json/aggregates_client.py
+++ b/tempest/services/compute/json/aggregates_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
index b11871b..49664c7 100644
--- a/tempest/services/compute/json/availability_zone_client.py
+++ b/tempest/services/compute/json/availability_zone_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/certificates_client.py b/tempest/services/compute/json/certificates_client.py
index 9fdce17..f4d31ed 100644
--- a/tempest/services/compute/json/certificates_client.py
+++ b/tempest/services/compute/json/certificates_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index ce46a9b..ae68261 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/json/extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -31,9 +29,14 @@
url = 'extensions'
resp, body = self.get(url)
body = json.loads(body)
- return resp, body
+ return resp, body['extensions']
def is_enabled(self, extension):
_, extensions = self.list_extensions()
exts = extensions['extensions']
return any([e for e in exts if e['name'] == extension])
+
+ def get_extension(self, extension_alias):
+ resp, body = self.get('extensions/%s' % extension_alias)
+ body = json.loads(body)
+ return resp, body['extension']
diff --git a/tempest/services/compute/json/fixed_ips_client.py b/tempest/services/compute/json/fixed_ips_client.py
index 4ef7c4c..31754ca 100644
--- a/tempest/services/compute/json/fixed_ips_client.py
+++ b/tempest/services/compute/json/fixed_ips_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 00d6f8a..300a0de 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 8349263..1235dd1 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index f51879d..23cb7e9 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
index fba5acb..c8ac951 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/json/hypervisor_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/images_client.py b/tempest/services/compute/json/images_client.py
index 5f17894..d64d8d7 100644
--- a/tempest/services/compute/json/images_client.py
+++ b/tempest/services/compute/json/images_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -16,10 +14,10 @@
# under the License.
import json
-import time
import urllib
from tempest.common.rest_client import RestClient
+from tempest.common import waiters
from tempest import exceptions
@@ -82,18 +80,7 @@
def wait_for_image_status(self, image_id, status):
"""Waits for an image to reach a given status."""
- resp, image = self.get_image(image_id)
- start = int(time.time())
-
- while image['status'] != status:
- time.sleep(self.build_interval)
- resp, image = self.get_image(image_id)
-
- if image['status'] == 'ERROR':
- raise exceptions.AddImageException(image_id=image_id)
-
- if int(time.time()) - start >= self.build_timeout:
- raise exceptions.TimeoutException
+ waiters.wait_for_image_status(self, image_id, status)
def list_image_metadata(self, image_id):
"""Lists all metadata items for an image."""
diff --git a/tempest/services/compute/json/instance_usage_audit_log_client.py b/tempest/services/compute/json/instance_usage_audit_log_client.py
index 07ce1bb..97062cb 100644
--- a/tempest/services/compute/json/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/json/instance_usage_audit_log_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 5e1900c..efd92d2 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/limits_client.py b/tempest/services/compute/json/limits_client.py
index 3e53e3e..525c12f 100644
--- a/tempest/services/compute/json/limits_client.py
+++ b/tempest/services/compute/json/limits_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/quotas_client.py b/tempest/services/compute/json/quotas_client.py
index a910dec..b6ec9b8 100644
--- a/tempest/services/compute/json/quotas_client.py
+++ b/tempest/services/compute/json/quotas_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 NTT Data
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index 1f01437..8a44626 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -63,6 +61,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/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index eb1a0c3..0b9ca0e 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
@@ -397,9 +395,9 @@
'os-virtual-interfaces']))
return resp, json.loads(body)
- def rescue_server(self, server_id, adminPass=None):
+ def rescue_server(self, server_id, **kwargs):
"""Rescue the provided server."""
- return self.action(server_id, 'rescue', None, adminPass=adminPass)
+ return self.action(server_id, 'rescue', None, **kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server."""
diff --git a/tempest/services/compute/json/services_client.py b/tempest/services/compute/json/services_client.py
index 4db7596..7829e5a 100644
--- a/tempest/services/compute/json/services_client.py
+++ b/tempest/services/compute/json/services_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tempest/services/compute/json/tenant_usages_client.py b/tempest/services/compute/json/tenant_usages_client.py
index 4dd6964..a263767 100644
--- a/tempest/services/compute/json/tenant_usages_client.py
+++ b/tempest/services/compute/json/tenant_usages_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/json/volumes_extensions_client.py b/tempest/services/compute/json/volumes_extensions_client.py
index d9906fd..aa49be5 100644
--- a/tempest/services/compute/json/volumes_extensions_client.py
+++ b/tempest/services/compute/json/volumes_extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
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..d63be02
--- /dev/null
+++ b/tempest/services/compute/v3/json/aggregates_client.py
@@ -0,0 +1,109 @@
+# 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/availability_zone_client.py b/tempest/services/compute/v3/json/availability_zone_client.py
index 9a3fe8b..97ff21c 100644
--- a/tempest/services/compute/v3/json/availability_zone_client.py
+++ b/tempest/services/compute/v3/json/availability_zone_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/json/certificates_client.py b/tempest/services/compute/v3/json/certificates_client.py
new file mode 100644
index 0000000..7c21290
--- /dev/null
+++ b/tempest/services/compute/v3/json/certificates_client.py
@@ -0,0 +1,40 @@
+# 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.
+
+import json
+
+from tempest.common.rest_client import RestClient
+
+
+class CertificatesV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(CertificatesV3ClientJSON, self).__init__(config, username,
+ password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def get_certificate(self, id):
+ url = "os-certificates/%s" % (id)
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['certificate']
+
+ def create_certificate(self):
+ """create certificates."""
+ url = "os-certificates"
+ resp, body = self.post(url, None, self.headers)
+ body = json.loads(body)
+ return resp, body['certificate']
diff --git a/tempest/services/compute/v3/json/extensions_client.py b/tempest/services/compute/v3/json/extensions_client.py
index 60c0217..c508d2f 100644
--- a/tempest/services/compute/v3/json/extensions_client.py
+++ b/tempest/services/compute/v3/json/extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -32,9 +30,14 @@
url = 'extensions'
resp, body = self.get(url)
body = json.loads(body)
- return resp, body
+ return resp, body['extensions']
def is_enabled(self, extension):
_, extensions = self.list_extensions()
exts = extensions['extensions']
return any([e for e in exts if e['name'] == extension])
+
+ def get_extension(self, extension_alias):
+ resp, body = self.get('extensions/%s' % extension_alias)
+ body = json.loads(body)
+ return resp, body['extension']
diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py
index 00d6f8a..f8c762c 100644
--- a/tempest/services/compute/v3/json/flavors_client.py
+++ b/tempest/services/compute/v3/json/flavors_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -21,12 +19,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'
@@ -61,13 +59,13 @@
'id': flavor_id,
}
if kwargs.get('ephemeral'):
- post_body['OS-FLV-EXT-DATA:ephemeral'] = kwargs.get('ephemeral')
+ post_body['ephemeral'] = kwargs.get('ephemeral')
if kwargs.get('swap'):
post_body['swap'] = kwargs.get('swap')
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 +89,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 +117,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 +130,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 +143,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..669bf59
--- /dev/null
+++ b/tempest/services/compute/v3/json/hosts_client.py
@@ -0,0 +1,80 @@
+# 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/hypervisor_client.py b/tempest/services/compute/v3/json/hypervisor_client.py
index fa1255a..d78cc5e 100644
--- a/tempest/services/compute/v3/json/hypervisor_client.py
+++ b/tempest/services/compute/v3/json/hypervisor_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/json/instance_usage_audit_log_client.py b/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
new file mode 100644
index 0000000..c5fba48
--- /dev/null
+++ b/tempest/services/compute/v3/json/instance_usage_audit_log_client.py
@@ -0,0 +1,35 @@
+# Copyright 2013 IBM 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
+
+
+class InstanceUsagesAuditLogV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(InstanceUsagesAuditLogV3ClientJSON, self).__init__(
+ config, username, password, auth_url, tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def list_instance_usage_audit_logs(self, time_before=None):
+ if time_before:
+ url = 'os-instance-usage-audit-log?before=%s' % time_before
+ else:
+ url = 'os-instance-usage-audit-log'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body["instance_usage_audit_log"]
diff --git a/tempest/services/compute/v3/json/keypairs_client.py b/tempest/services/compute/v3/json/keypairs_client.py
new file mode 100644
index 0000000..26018ae
--- /dev/null
+++ b/tempest/services/compute/v3/json/keypairs_client.py
@@ -0,0 +1,54 @@
+# 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 json
+
+from tempest.common.rest_client import RestClient
+
+
+class KeyPairsV3ClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ 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("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,
+ # servers, etc. A bug?
+ # For now we shall adhere to the spec, but the spec for keypairs
+ # is yet to be found
+ return resp, body['keypairs']
+
+ def get_keypair(self, key_name):
+ resp, body = self.get("keypairs/%s" % str(key_name))
+ body = json.loads(body)
+ return resp, body['keypair']
+
+ def create_keypair(self, name, pub_key=None):
+ post_body = {'keypair': {'name': name}}
+ if pub_key:
+ post_body['keypair']['public_key'] = pub_key
+ post_body = json.dumps(post_body)
+ 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("keypairs/%s" % str(key_name))
diff --git a/tempest/services/compute/v3/json/limits_client.py b/tempest/services/compute/v3/json/limits_client.py
deleted file mode 100644
index 3e53e3e..0000000
--- a/tempest/services/compute/v3/json/limits_client.py
+++ /dev/null
@@ -1,40 +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.
-
-import json
-from tempest.common.rest_client import RestClient
-
-
-class LimitsClientJSON(RestClient):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(LimitsClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
-
- def get_absolute_limits(self):
- resp, body = self.get("limits")
- body = json.loads(body)
- return resp, body['limits']['absolute']
-
- def get_specific_absolute_limit(self, absolute_limit):
- resp, body = self.get("limits")
- body = json.loads(body)
- if absolute_limit not in body['limits']['absolute']:
- return None
- else:
- return body['limits']['absolute'][absolute_limit]
diff --git a/tempest/services/compute/v3/json/quotas_client.py b/tempest/services/compute/v3/json/quotas_client.py
index a910dec..0f0fd00 100644
--- a/tempest/services/compute/v3/json/quotas_client.py
+++ b/tempest/services/compute/v3/json/quotas_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 NTT Data
# All Rights Reserved.
#
@@ -20,12 +18,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 +42,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 +54,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 +75,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..ef282fa 100644
--- a/tempest/services/compute/v3/json/servers_client.py
+++ b/tempest/services/compute/v3/json/servers_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# Copyright 2013 IBM Corp
@@ -45,8 +43,6 @@
admin_password: Sets the initial root password.
key_name: Key name of keypair that was created earlier.
meta: A dictionary of values to be used as metadata.
- personality: A list of dictionaries for files to be injected into
- the server.
security_groups: A list of security group dicts.
networks: A list of network dicts with UUID and fixed_ip.
user_data: User data for instance.
@@ -64,18 +60,20 @@
'flavor_ref': flavor_ref
}
- for option in ['personality', 'admin_password', 'key_name',
- 'security_groups', 'networks',
+ for option in ['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'),
('os-disk-config:disk_config', 'disk_config'),
('os-multiple-create:return_reservation_id',
- 'return_reservation_id')]:
+ 'return_reservation_id')]:
if isinstance(option, tuple):
post_param = option[0]
key = option[1]
@@ -91,8 +89,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,
@@ -101,7 +99,6 @@
Updates the properties of an existing server.
server_id: The id of an existing server.
name: The name of the server.
- personality: A list of files to be injected into the server.
access_ip_v4: The IPv4 access address for the server.
access_ip_v6: The IPv6 access address for the server.
"""
@@ -115,10 +112,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
@@ -161,10 +158,12 @@
body = json.loads(body)
return resp, body
- def wait_for_server_status(self, server_id, status, extra_timeout=0):
+ def wait_for_server_status(self, server_id, status, extra_timeout=0,
+ raise_on_error=True):
"""Waits for a server to reach a given status."""
return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout)
+ extra_timeout=extra_timeout,
+ raise_on_error=raise_on_error)
def wait_for_server_termination(self, server_id, ignore_error=False):
"""Waits for server to reach termination."""
@@ -205,6 +204,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,
@@ -337,33 +343,40 @@
return self.action(server_id, 'unlock', None, **kwargs)
def suspend_server(self, server_id, **kwargs):
- """Suspends the provded server."""
+ """Suspends the provided server."""
return self.action(server_id, 'suspend', None, **kwargs)
def resume_server(self, server_id, **kwargs):
- """Un-suspends the provded server."""
+ """Un-suspends the provided server."""
return self.action(server_id, 'resume', None, **kwargs)
def pause_server(self, server_id, **kwargs):
- """Pauses the provded server."""
+ """Pauses the provided server."""
return self.action(server_id, 'pause', None, **kwargs)
def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provded server."""
+ """Un-pauses the provided server."""
return self.action(server_id, 'unpause', None, **kwargs)
def reset_state(self, server_id, state='error'):
"""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)
- def rescue_server(self, server_id, admin_password=None):
+ def rescue_server(self, server_id, **kwargs):
"""Rescue the provided server."""
- return self.action(server_id, 'rescue', None,
- admin_password=admin_password)
+ return self.action(server_id, 'rescue', None, **kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server."""
@@ -388,3 +401,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/json/services_client.py b/tempest/services/compute/v3/json/services_client.py
index 41564e5..e0c1c3c 100644
--- a/tempest/services/compute/v3/json/services_client.py
+++ b/tempest/services/compute/v3/json/services_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tempest/services/compute/v3/json/tenant_usages_client.py b/tempest/services/compute/v3/json/tenant_usages_client.py
index 298f363..ff0251d 100644
--- a/tempest/services/compute/v3/json/tenant_usages_client.py
+++ b/tempest/services/compute/v3/json/tenant_usages_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/json/version_client.py b/tempest/services/compute/v3/json/version_client.py
new file mode 100644
index 0000000..1773af5
--- /dev/null
+++ b/tempest/services/compute/v3/json/version_client.py
@@ -0,0 +1,32 @@
+# Copyright 2014 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 import rest_client
+
+
+class VersionV3ClientJSON(rest_client.RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(VersionV3ClientJSON, self).__init__(config, username,
+ password, auth_url,
+ tenant_name)
+ self.service = self.config.compute.catalog_v3_type
+
+ def get_version(self):
+ resp, body = self.get('')
+ body = json.loads(body)
+ return resp, body['version']
diff --git a/tempest/services/compute/v3/xml/availability_zone_client.py b/tempest/services/compute/v3/xml/availability_zone_client.py
deleted file mode 100644
index 35fb2b1..0000000
--- a/tempest/services/compute/v3/xml/availability_zone_client.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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.services.compute.xml.common import xml_to_json
-
-
-class AvailabilityZoneV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(AvailabilityZoneV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- return [xml_to_json(x) for x in node]
-
- def get_availability_zone_list(self):
- resp, body = self.get('os-availability-zone', self.headers)
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
-
- def get_availability_zone_list_detail(self):
- resp, body = self.get('os-availability-zone/detail', self.headers)
- availability_zone = self._parse_array(etree.fromstring(body))
- return resp, availability_zone
diff --git a/tempest/services/compute/v3/xml/flavors_client.py b/tempest/services/compute/v3/xml/flavors_client.py
deleted file mode 100644
index a1c74d9..0000000
--- a/tempest/services/compute/v3/xml/flavors_client.py
+++ /dev/null
@@ -1,220 +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.
-
-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 Text
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
-
-
-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"
-
-
-class FlavorsClientXML(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
-
- def _format_flavor(self, f):
- flavor = {'links': []}
- for k, v in f.items():
- if k == 'id':
- flavor['id'] = v
- continue
-
- if k == 'link':
- 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'
- v = True if v == 'True' else False
-
- if k == 'extra_specs':
- k = 'OS-FLV-WITH-EXT-SPECS:extra_specs'
- flavor[k] = dict(v)
- continue
-
- try:
- v = int(v)
- except ValueError:
- try:
- v = float(v)
- except ValueError:
- pass
-
- flavor[k] = v
-
- return flavor
-
- def _parse_array(self, node):
- return [self._format_flavor(xml_to_json(x)) for x in node]
-
- def _list_flavors(self, url, params):
- if params:
- url += "?%s" % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- flavors = self._parse_array(etree.fromstring(body))
- return resp, flavors
-
- def list_flavors(self, params=None):
- url = 'flavors'
- return self._list_flavors(url, params)
-
- def list_flavors_with_detail(self, params=None):
- url = 'flavors/detail'
- return self._list_flavors(url, params)
-
- def get_flavor_details(self, flavor_id):
- resp, body = self.get("flavors/%s" % str(flavor_id), self.headers)
- body = xml_to_json(etree.fromstring(body))
- flavor = self._format_flavor(body)
- return resp, flavor
-
- def create_flavor(self, name, ram, vcpus, disk, flavor_id, **kwargs):
- """Creates a new flavor or instance type."""
- flavor = Element("flavor",
- xmlns=XMLNS_11,
- ram=ram,
- vcpus=vcpus,
- disk=disk,
- id=flavor_id,
- name=name)
- if kwargs.get('rxtx'):
- flavor.add_attr('rxtx_factor', kwargs.get('rxtx'))
- 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'))
- if kwargs.get('is_public'):
- flavor.add_attr('os-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)
- resp, body = self.post('flavors', str(Document(flavor)), self.headers)
- body = xml_to_json(etree.fromstring(body))
- flavor = self._format_flavor(body)
- return resp, flavor
-
- def delete_flavor(self, flavor_id):
- """Deletes the given flavor."""
- return self.delete("flavors/%s" % str(flavor_id), self.headers)
-
- def is_resource_deleted(self, id):
- # Did not use get_flavor_details(id) for verification as it gives
- # 200 ok even for deleted id. LP #981263
- # we can remove the loop here and use get by ID when bug gets sortedout
- resp, flavors = self.list_flavors_with_detail()
- for flavor in flavors:
- if flavor['id'] == id:
- return False
- return True
-
- def set_flavor_extra_spec(self, flavor_id, specs):
- """Sets extra Specs to the mentioned flavor."""
- 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,
- 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,
- 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' %
- (str(flavor_id), key), self.headers)
- body = {}
- element = etree.fromstring(xml_body)
- key = element.get('key')
- body[key] = xml_to_json(element)
- return resp, body
-
- def update_flavor_extra_spec(self, flavor_id, key, **kwargs):
- """Update extra Specs details of the mentioned flavor and key."""
- doc = Document()
- for (k, v) in kwargs.items():
- element = Element(k)
- doc.append(element)
- value = Text(v)
- element.append(value)
-
- resp, body = self.put('flavors/%s/os-extra_specs/%s' %
- (flavor_id, key),
- str(doc), self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, {key: body}
-
- 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))
-
- 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),
- self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def add_flavor_access(self, flavor_id, tenant_id):
- """Add flavor access for the specified tenant."""
- doc = Document()
- server = Element("addTenantAccess")
- doc.append(server)
- server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id),
- str(doc), self.headers)
- body = self._parse_array_access(etree.fromstring(body))
- return resp, body
-
- def remove_flavor_access(self, flavor_id, tenant_id):
- """Remove flavor access from the specified tenant."""
- doc = Document()
- server = Element("removeTenantAccess")
- doc.append(server)
- server.add_attr("tenant", tenant_id)
- resp, body = self.post('flavors/%s/action' % str(flavor_id),
- str(doc), self.headers)
- body = self._parse_array_access(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/hypervisor_client.py b/tempest/services/compute/v3/xml/hypervisor_client.py
deleted file mode 100644
index ce0207d..0000000
--- a/tempest/services/compute/v3/xml/hypervisor_client.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2013 IBM 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.services.compute.xml.common import xml_to_json
-
-
-class HypervisorV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(HypervisorV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- return [xml_to_json(x) for x in node]
-
- def get_hypervisor_list(self):
- """List hypervisors information."""
- resp, body = self.get('os-hypervisors', self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail', self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_show_details(self, hyper_id):
- """Display the details of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s' % hyper_id,
- self.headers)
- hypervisor = xml_to_json(etree.fromstring(body))
- return resp, hypervisor
-
- def get_hypervisor_servers(self, hyper_name):
- """List instances belonging to the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/servers' % hyper_name,
- self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
-
- def get_hypervisor_stats(self):
- """Get hypervisor statistics over all compute nodes."""
- resp, body = self.get('os-hypervisors/statistics', self.headers)
- stats = xml_to_json(etree.fromstring(body))
- return resp, stats
-
- def get_hypervisor_uptime(self, hyper_id):
- """Display the uptime of the specified hypervisor."""
- resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id,
- self.headers)
- uptime = xml_to_json(etree.fromstring(body))
- return resp, uptime
-
- def search_hypervisor(self, hyper_name):
- """Search specified hypervisor."""
- resp, body = self.get('os-hypervisors/search?query=%s' % hyper_name,
- self.headers)
- hypervisors = self._parse_array(etree.fromstring(body))
- return resp, hypervisors
diff --git a/tempest/services/compute/v3/xml/interfaces_client.py b/tempest/services/compute/v3/xml/interfaces_client.py
deleted file mode 100644
index 870c130..0000000
--- a/tempest/services/compute/v3/xml/interfaces_client.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# 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.
-
-import time
-
-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 InterfacesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(InterfacesV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _process_xml_interface(self, node):
- iface = xml_to_json(node)
- # NOTE(danms): if multiple addresses per interface is ever required,
- # xml_to_json will need to be fixed or replaced in this case
- iface['fixed_ips'] = [dict(iface['fixed_ips']['fixed_ip'].items())]
- return iface
-
- def list_interfaces(self, server):
- resp, body = self.get('servers/%s/os-attach-interfaces' % server,
- self.headers)
- node = etree.fromstring(body)
- interfaces = [self._process_xml_interface(x)
- for x in node.getchildren()]
- return resp, interfaces
-
- def create_interface(self, server, port_id=None, network_id=None,
- fixed_ip=None):
- doc = Document()
- iface = Element('interface_attachment')
- if port_id:
- _port_id = Element('port_id')
- _port_id.append(Text(port_id))
- iface.append(_port_id)
- if network_id:
- _network_id = Element('net_id')
- _network_id.append(Text(network_id))
- iface.append(_network_id)
- if fixed_ip:
- _fixed_ips = Element('fixed_ips')
- _fixed_ip = Element('fixed_ip')
- _ip_address = Element('ip_address')
- _ip_address.append(Text(fixed_ip))
- _fixed_ip.append(_ip_address)
- _fixed_ips.append(_fixed_ip)
- iface.append(_fixed_ips)
- doc.append(iface)
- resp, body = self.post('servers/%s/os-attach-interfaces' % server,
- headers=self.headers,
- body=str(doc))
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def show_interface(self, server, port_id):
- resp, body =\
- self.get('servers/%s/os-attach-interfaces/%s' % (server, port_id),
- self.headers)
- body = self._process_xml_interface(etree.fromstring(body))
- return resp, body
-
- def delete_interface(self, server, port_id):
- resp, body =\
- self.delete('servers/%s/os-attach-interfaces/%s' % (server,
- port_id))
- return resp, body
-
- def wait_for_interface_status(self, server, port_id, status):
- """Waits for a interface to reach a given status."""
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
- start = int(time.time())
-
- while(interface_status != status):
- time.sleep(self.build_interval)
- resp, body = self.show_interface(server, port_id)
- interface_status = body['port_state']
-
- timed_out = int(time.time()) - start >= self.build_timeout
-
- if interface_status != status and timed_out:
- message = ('Interface %s failed to reach %s status within '
- 'the required time (%s s).' %
- (port_id, status, self.build_timeout))
- raise exceptions.TimeoutException(message)
- return resp, body
diff --git a/tempest/services/compute/v3/xml/limits_client.py b/tempest/services/compute/v3/xml/limits_client.py
deleted file mode 100644
index 704de52..0000000
--- a/tempest/services/compute/v3/xml/limits_client.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 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 lxml import objectify
-
-from tempest.common.rest_client import RestClientXML
-
-NS = "{http://docs.openstack.org/common/api/v1.0}"
-
-
-class LimitsClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(LimitsClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_type
-
- def get_absolute_limits(self):
- resp, body = self.get("limits", self.headers)
- body = objectify.fromstring(body)
- lim = NS + 'absolute'
- ret = {}
-
- for el in body[lim].iterchildren():
- attributes = el.attrib
- ret[attributes['name']] = attributes['value']
- return resp, ret
-
- def get_specific_absolute_limit(self, absolute_limit):
- resp, body = self.get("limits", self.headers)
- body = objectify.fromstring(body)
- lim = NS + 'absolute'
- ret = {}
-
- for el in body[lim].iterchildren():
- attributes = el.attrib
- ret[attributes['name']] = attributes['value']
- if absolute_limit not in ret:
- return None
- else:
- return ret[absolute_limit]
diff --git a/tempest/services/compute/v3/xml/quotas_client.py b/tempest/services/compute/v3/xml/quotas_client.py
deleted file mode 100644
index ef5362c..0000000
--- a/tempest/services/compute/v3/xml/quotas_client.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 NTT Data
-# 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.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
-
-
-class QuotasClientXML(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
-
- def _format_quota(self, q):
- quota = {}
- for k, v in q.items():
- try:
- v = int(v)
- except ValueError:
- pass
-
- quota[k] = v
-
- return quota
-
- def _parse_array(self, node):
- return [self._format_quota(xml_to_json(x)) for x in node]
-
- def get_quota_set(self, tenant_id):
- """List the quota set for a tenant."""
-
- url = 'os-quota-sets/%s' % str(tenant_id)
- resp, body = self.get(url, self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- return resp, body
-
- def get_default_quota_set(self, tenant_id):
- """List the default quota set for a tenant."""
-
- url = 'os-quota-sets/%s/defaults' % str(tenant_id)
- resp, body = self.get(url, self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- 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_groups=None):
- """
- Updates the tenant's quota limits for one or more resources
- """
- post_body = Element("quota_set",
- xmlns=XMLNS_11)
-
- 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)
-
- if ram is not None:
- post_body.add_attr('ram', ram)
-
- if floating_ips is not None:
- post_body.add_attr('floating_ips', floating_ips)
-
- if fixed_ips is not None:
- post_body.add_attr('fixed_ips', fixed_ips)
-
- if key_pairs is not None:
- post_body.add_attr('key_pairs', key_pairs)
-
- if instances is not None:
- post_body.add_attr('instances', instances)
-
- 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)
-
- resp, body = self.put('os-quota-sets/%s' % str(tenant_id),
- str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- body = self._format_quota(body)
- return resp, body
diff --git a/tempest/services/compute/v3/xml/servers_client.py b/tempest/services/compute/v3/xml/servers_client.py
deleted file mode 100644
index 7af4161..0000000
--- a/tempest/services/compute/v3/xml/servers_client.py
+++ /dev/null
@@ -1,623 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
-# Copyright 2012 IBM Corp.
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# 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 time
-import urllib
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.common import waiters
-from tempest import exceptions
-from tempest.openstack.common import log as logging
-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
-from tempest.services.compute.xml.common import XMLNS_V3
-
-
-LOG = logging.getLogger(__name__)
-
-
-def _translate_ip_xml_json(ip):
- """
- Convert the address version to int.
- """
- ip = dict(ip)
- version = ip.get('version')
- if version:
- ip['version'] = int(version)
- if ip.get('type'):
- ip['type'] = ip.get('type')
- if ip.get('mac_addr'):
- ip['mac_addr'] = ip.get('mac_addr')
- return ip
-
-
-def _translate_network_xml_to_json(network):
- return [_translate_ip_xml_json(ip.attrib)
- for ip in network.findall('{%s}ip' % XMLNS_V3)]
-
-
-def _translate_addresses_xml_to_json(xml_addresses):
- return dict((network.attrib['id'], _translate_network_xml_to_json(network))
- for network in xml_addresses.findall('{%s}network' % XMLNS_V3))
-
-
-def _translate_server_xml_to_json(xml_dom):
- """Convert server XML to server JSON.
-
- The addresses collection does not convert well by the dumb xml_to_json.
- This method does some pre and post-processing to deal with that.
-
- Translate XML addresses subtree to JSON.
-
- Having xml_doc similar to
- <api:server xmlns:api="http://docs.openstack.org/compute/api/v3">
- <api:addresses>
- <api:network id="foo_novanetwork">
- <api:ip version="4" addr="192.168.0.4"/>
- </api:network>
- <api:network id="bar_novanetwork">
- <api:ip version="4" addr="10.1.0.4"/>
- <api:ip version="6" addr="2001:0:0:1:2:3:4:5"/>
- </api:network>
- </api:addresses>
- </api:server>
-
- the _translate_server_xml_to_json(etree.fromstring(xml_doc)) should produce
- something like
-
- {'addresses': {'bar_novanetwork': [{'addr': '10.1.0.4', 'version': 4},
- {'addr': '2001:0:0:1:2:3:4:5',
- 'version': 6}],
- 'foo_novanetwork': [{'addr': '192.168.0.4', 'version': 4}]}}
- """
- nsmap = {'api': XMLNS_V3}
- addresses = xml_dom.xpath('/api:server/api:addresses', namespaces=nsmap)
- if addresses:
- if len(addresses) > 1:
- raise ValueError('Expected only single `addresses` element.')
- json_addresses = _translate_addresses_xml_to_json(addresses[0])
- json = xml_to_json(xml_dom)
- json['addresses'] = json_addresses
- else:
- json = xml_to_json(xml_dom)
- disk_config = ('{http://docs.openstack.org'
- '/compute/ext/disk_config/api/v3}disk_config')
- terminated_at = ('{http://docs.openstack.org/'
- 'compute/ext/os-server-usage/api/v3}terminated_at')
- launched_at = ('{http://docs.openstack.org'
- '/compute/ext/os-server-usage/api/v3}launched_at')
- power_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}power_state')
- availability_zone = ('{http://docs.openstack.org'
- '/compute/ext/extended_availability_zone/api/v3}'
- 'availability_zone')
- vm_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}vm_state')
- task_state = ('{http://docs.openstack.org'
- '/compute/ext/extended_status/api/v3}task_state')
- if disk_config in json:
- json['os-disk-config:disk_config'] = json.pop(disk_config)
- if terminated_at in json:
- json['os-server-usage:terminated_at'] = json.pop(terminated_at)
- if launched_at in json:
- json['os-server-usage:launched_at'] = json.pop(launched_at)
- if power_state in json:
- json['os-extended-status:power_state'] = json.pop(power_state)
- if availability_zone in json:
- json['os-extended-availability-zone:availability_zone'] = json.pop(
- availability_zone)
- if vm_state in json:
- 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)
- return json
-
-
-class ServersV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url,
- tenant_name=None, auth_version='v2'):
- super(ServersV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name,
- auth_version=auth_version)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_key_value(self, node):
- """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
- data = {}
- for node in node.getchildren():
- data[node.get('key')] = node.text
- return data
-
- def _parse_links(self, node, json):
- del json['link']
- json['links'] = []
- for linknode in node.findall('{http://www.w3.org/2005/Atom}link'):
- json['links'].append(xml_to_json(linknode))
-
- def _parse_server(self, body):
- json = _translate_server_xml_to_json(body)
-
- if 'metadata' in json and json['metadata']:
- # NOTE(danms): if there was metadata, we need to re-parse
- # that as a special type
- metadata_tag = body.find('{%s}metadata' % XMLNS_V3)
- json["metadata"] = self._parse_key_value(metadata_tag)
- if 'link' in json:
- self._parse_links(body, json)
- for sub in ['image', 'flavor']:
- if sub in json and 'link' in json[sub]:
- self._parse_links(body, json[sub])
- return json
-
- def _parse_xml_virtual_interfaces(self, xml_dom):
- """
- Return server's virtual interfaces XML as JSON.
- """
- data = {"virtual_interfaces": []}
- for iface in xml_dom.getchildren():
- data["virtual_interfaces"].append(
- {"id": iface.get("id"),
- "mac_address": iface.get("mac_address")})
- return data
-
- def get_server(self, server_id):
- """Returns the details of an existing server."""
- resp, body = self.get("servers/%s" % str(server_id), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def lock_server(self, server_id, **kwargs):
- """Locks the given server."""
- return self.action(server_id, 'lock', None, **kwargs)
-
- def unlock_server(self, server_id, **kwargs):
- """Unlocks the given server."""
- return self.action(server_id, 'unlock', None, **kwargs)
-
- def suspend_server(self, server_id, **kwargs):
- """Suspends the provided server."""
- return self.action(server_id, 'suspend', None, **kwargs)
-
- def resume_server(self, server_id, **kwargs):
- """Un-suspends the provided server."""
- return self.action(server_id, 'resume', None, **kwargs)
-
- def pause_server(self, server_id, **kwargs):
- """Pauses the provided server."""
- return self.action(server_id, 'pause', None, **kwargs)
-
- def unpause_server(self, server_id, **kwargs):
- """Un-pauses the provided server."""
- return self.action(server_id, 'unpause', None, **kwargs)
-
- def reset_state(self, server_id, state='error'):
- """Resets the state of a server to active/error."""
- return self.action(server_id, 'reset_state', None, state=state)
-
- def delete_server(self, server_id):
- """Deletes the given server."""
- return self.delete("servers/%s" % str(server_id))
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
- def list_servers(self, params=None):
- url = 'servers'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- servers = self._parse_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def list_servers_with_detail(self, params=None):
- url = 'servers/detail'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- servers = self._parse_array(etree.fromstring(body))
- return resp, {"servers": servers}
-
- def update_server(self, server_id, name=None, meta=None, access_ip_v4=None,
- access_ip_v6=None, disk_config=None):
- doc = Document()
- server = Element("server")
- doc.append(server)
-
- if name is not None:
- server.add_attr("name", name)
- if access_ip_v4 is not None:
- server.add_attr("access_ip_v4", access_ip_v4)
- if access_ip_v6 is not None:
- server.add_attr("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")
- server.add_attr("os-disk-config:disk_config", disk_config)
- if meta is not None:
- metadata = Element("metadata")
- server.append(metadata)
- for k, v in meta:
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- resp, body = self.put('servers/%s' % str(server_id),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def create_server(self, name, image_ref, flavor_ref, **kwargs):
- """
- Creates an instance of a server.
- name (Required): The name of the server.
- image_ref (Required): Reference to the image used to build the server.
- flavor_ref (Required): The flavor used to build the server.
- Following optional keyword arguments are accepted:
- admin_password: Sets the initial root password.
- key_name: Key name of keypair that was created earlier.
- meta: A dictionary of values to be used as metadata.
- personality: A list of dictionaries for files to be injected into
- the server.
- security_groups: A list of security group dicts.
- networks: A list of network dicts with UUID and fixed_ip.
- user_data: User data for instance.
- availability_zone: Availability zone in which to launch instance.
- access_ip_v4: The IPv4 access address for the server.
- access_ip_v6: The IPv6 access address for the server.
- min_count: Count of minimum number of instances to launch.
- max_count: Count of maximum number of instances to launch.
- disk_config: Determines if user or admin controls disk configuration.
- 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",
- ("os-user-data:user_data",
- 'user_data',
- 'xmlns:os-user-data',
- "http://docs.openstack.org/compute/ext/userdata/api/v3"),
- ("os-availability-zone:availability_zone",
- 'availability_zone',
- 'xmlns:os-availability-zone',
- "http://docs.openstack.org/compute/ext/"
- "availabilityzone/api/v3"),
- ("os-multiple-create:min_count",
- 'min_count',
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-multiple-create:max_count",
- 'max_count',
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-multiple-create:return_reservation_id",
- "return_reservation_id",
- 'xmlns:os-multiple-create',
- "http://docs.openstack.org/compute/ext/"
- "multiplecreate/api/v3"),
- ("os-disk-config:disk_config",
- "disk_config",
- "xmlns:os-disk-config",
- "http://docs.openstack.org/"
- "compute/ext/disk_config/api/v3")]
-
- for attr in attrs:
- if isinstance(attr, tuple):
- post_param = attr[0]
- key = attr[1]
- value = kwargs.get(key)
- if value is not None:
- server.add_attr(attr[2], attr[3])
- server.add_attr(post_param, value)
- else:
- post_param = attr
- key = attr
- value = kwargs.get(key)
- if value is not None:
- server.add_attr(post_param, value)
-
- if 'security_groups' in kwargs:
- secgroups = Element("security_groups")
- server.append(secgroups)
- for secgroup in kwargs['security_groups']:
- s = Element("security_group", name=secgroup['name'])
- secgroups.append(s)
-
- if 'networks' in kwargs:
- networks = Element("networks")
- server.append(networks)
- for network in kwargs['networks']:
- s = Element("network", uuid=network['uuid'],
- fixed_ip=network['fixed_ip'])
- networks.append(s)
-
- if 'meta' in kwargs:
- metadata = Element("metadata")
- server.append(metadata)
- for k, v in kwargs['meta'].items():
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- if 'personality' in kwargs:
- personality = Element('personality')
- server.append(personality)
- for k in kwargs['personality']:
- temp = Element('file', path=k['path'])
- temp.append(Text(k['contents']))
- personality.append(temp)
-
- resp, body = self.post('servers', str(Document(server)), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def wait_for_server_status(self, server_id, status, extra_timeout=0):
- """Waits for a server to reach a given status."""
- return waiters.wait_for_server_status(self, server_id, status,
- extra_timeout=extra_timeout)
-
- def wait_for_server_termination(self, server_id, ignore_error=False):
- """Waits for server to reach termination."""
- start_time = int(time.time())
- while True:
- try:
- resp, body = self.get_server(server_id)
- except exceptions.NotFound:
- return
-
- server_status = body['status']
- if server_status == 'ERROR' and not ignore_error:
- raise exceptions.BuildErrorException
-
- if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
-
- time.sleep(self.build_interval)
-
- def _parse_network(self, node):
- addrs = []
- for child in node.getchildren():
- addrs.append({'version': int(child.get('version')),
- 'addr': child.get('addr')})
- return {node.get('id'): addrs}
-
- def list_addresses(self, server_id):
- """Lists all addresses for a server."""
- resp, body = self.get("servers/%s/ips" % str(server_id), self.headers)
-
- networks = {}
- xml_list = etree.fromstring(body)
- for child in xml_list.getchildren():
- network = self._parse_network(child)
- networks.update(**network)
-
- return resp, networks
-
- def list_addresses_by_network(self, server_id, network_id):
- """Lists all addresses of a specific network type for a server."""
- resp, body = self.get("servers/%s/ips/%s" % (str(server_id),
- network_id),
- self.headers)
- network = self._parse_network(etree.fromstring(body))
-
- return resp, network
-
- def action(self, server_id, action_name, response_key, **kwargs):
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = XMLNS_V3
- doc = Document((Element(action_name, **kwargs)))
- resp, body = self.post("servers/%s/action" % server_id,
- str(doc), self.headers)
- if response_key is not None:
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def change_password(self, server_id, password):
- return self.action(server_id, "change_password", None,
- admin_password=password)
-
- def reboot(self, server_id, reboot_type):
- return self.action(server_id, "reboot", None, type=reboot_type)
-
- def rebuild(self, server_id, image_ref, **kwargs):
- kwargs['image_ref'] = image_ref
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:os-disk-config'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v3"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- if 'xmlns' not in kwargs:
- kwargs['xmlns'] = XMLNS_V3
-
- attrs = kwargs.copy()
- if 'metadata' in attrs:
- del attrs['metadata']
- rebuild = Element("rebuild",
- **attrs)
-
- if 'metadata' in kwargs:
- metadata = Element("metadata")
- rebuild.append(metadata)
- for k, v in kwargs['metadata'].items():
- meta = Element("meta", key=k)
- meta.append(Text(v))
- metadata.append(meta)
-
- resp, body = self.post('servers/%s/action' % server_id,
- str(Document(rebuild)), self.headers)
- server = self._parse_server(etree.fromstring(body))
- return resp, server
-
- def resize(self, server_id, flavor_ref, **kwargs):
- if 'disk_config' in kwargs:
- kwargs['os-disk-config:disk_config'] = kwargs['disk_config']
- del kwargs['disk_config']
- kwargs['xmlns:os-disk-config'] = "http://docs.openstack.org/"\
- "compute/ext/disk_config/api/v3"
- kwargs['xmlns:atom'] = "http://www.w3.org/2005/Atom"
- kwargs['flavor_ref'] = flavor_ref
- return self.action(server_id, 'resize', None, **kwargs)
-
- def confirm_resize(self, server_id, **kwargs):
- return self.action(server_id, 'confirm_resize', None, **kwargs)
-
- def revert_resize(self, server_id, **kwargs):
- return self.action(server_id, 'revert_resize', None, **kwargs)
-
- def stop(self, server_id, **kwargs):
- return self.action(server_id, 'stop', None, **kwargs)
-
- def start(self, server_id, **kwargs):
- return self.action(server_id, 'start', None, **kwargs)
-
- def create_image(self, server_id, name, meta=None):
- """Creates an image of the original server."""
- post_body = Element('create_image', name=name)
-
- if meta:
- metadata = Element('metadata')
- post_body.append(metadata)
- for k, v in meta.items():
- data = Element('meta', key=k)
- data.append(Text(v))
- metadata.append(data)
- resp, body = self.post('servers/%s/action' % str(server_id),
- str(Document(post_body)), self.headers)
- return resp, body
-
- def live_migrate_server(self, server_id, dest_host, use_block_migration):
- """This should be called with administrator privileges ."""
-
- req_body = Element("migrate_live",
- xmlns=XMLNS_V3,
- disk_over_commit=False,
- block_migration=use_block_migration,
- host=dest_host)
-
- resp, body = self.post("servers/%s/action" % str(server_id),
- str(Document(req_body)), self.headers)
- return resp, body
-
- def list_server_metadata(self, server_id):
- resp, body = self.get("servers/%s/metadata" % str(server_id),
- self.headers)
- body = self._parse_key_value(etree.fromstring(body))
- return resp, body
-
- def set_server_metadata(self, server_id, meta, no_metadata_field=False):
- doc = Document()
- if not no_metadata_field:
- metadata = Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = Element("meta", key=k)
- meta_element.append(Text(v))
- metadata.append(meta_element)
- resp, body = self.put('servers/%s/metadata' % str(server_id),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def update_server_metadata(self, server_id, meta):
- doc = Document()
- metadata = Element("metadata")
- doc.append(metadata)
- for k, v in meta.items():
- meta_element = Element("meta", key=k)
- meta_element.append(Text(v))
- metadata.append(meta_element)
- resp, body = self.post("/servers/%s/metadata" % str(server_id),
- str(doc), headers=self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def get_server_metadata_item(self, server_id, key):
- resp, body = self.get("servers/%s/metadata/%s" % (str(server_id), key),
- headers=self.headers)
- return resp, dict([(etree.fromstring(body).attrib['key'],
- xml_to_json(etree.fromstring(body)))])
-
- def set_server_metadata_item(self, server_id, key, meta):
- doc = Document()
- for k, v in meta.items():
- meta_element = Element("meta", key=k)
- meta_element.append(Text(v))
- doc.append(meta_element)
- resp, body = self.put('servers/%s/metadata/%s' % (str(server_id), key),
- str(doc), self.headers)
- return resp, xml_to_json(etree.fromstring(body))
-
- def delete_server_metadata_item(self, server_id, key):
- resp, body = self.delete("servers/%s/metadata/%s" %
- (str(server_id), key))
- return resp, body
-
- def get_console_output(self, server_id, length):
- return self.action(server_id, 'get_console_output', 'output',
- length=length)
-
- def rescue_server(self, server_id, admin_password=None):
- """Rescue the provided server."""
- return self.action(server_id, 'rescue', None,
- admin_password=admin_password)
-
- def unrescue_server(self, server_id):
- """Unrescue the provided server."""
- return self.action(server_id, 'unrescue', None)
-
- def attach_volume(self, server_id, volume_id, device='/dev/vdz'):
- return self.action(server_id, "attach", None, volume_id=volume_id,
- device=device)
-
- def detach_volume(self, server_id, volume_id):
- return self.action(server_id, "detach", None, volume_id=volume_id)
-
- def get_server_diagnostics(self, server_id):
- """Get the usage data for a server."""
- resp, body = self.get("servers/%s/os-server-diagnostics" % server_id,
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def list_instance_actions(self, server_id):
- """List the provided server action."""
- resp, body = self.get("servers/%s/os-instance-actions" % server_id,
- self.headers)
- body = self._parse_array(etree.fromstring(body))
- return resp, body
-
- def get_instance_action(self, server_id, request_id):
- """Returns the action details of the provided server."""
- resp, body = self.get("servers/%s/os-instance-actions/%s" %
- (server_id, request_id), self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/services_client.py b/tempest/services/compute/v3/xml/services_client.py
deleted file mode 100644
index 855641b..0000000
--- a/tempest/services/compute/v3/xml/services_client.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
-# Copyright 2013 NEC Corporation
-# 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.
-
-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 ServicesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(ServicesV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def list_services(self, params=None):
- url = 'os-services'
- 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 enable_service(self, host_name, binary):
- """
- Enable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/enable', str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
-
- def disable_service(self, host_name, binary):
- """
- Disable service on a host
- host_name: Name of host
- binary: Service binary
- """
- post_body = Element("service")
- post_body.add_attr('binary', binary)
- post_body.add_attr('host', host_name)
-
- resp, body = self.put('os-services/disable', str(Document(post_body)),
- self.headers)
- body = xml_to_json(etree.fromstring(body))
- return resp, body
diff --git a/tempest/services/compute/v3/xml/tenant_usages_client.py b/tempest/services/compute/v3/xml/tenant_usages_client.py
deleted file mode 100644
index 790bd5c..0000000
--- a/tempest/services/compute/v3/xml/tenant_usages_client.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# 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 urllib
-
-from lxml import etree
-
-from tempest.common.rest_client import RestClientXML
-from tempest.services.compute.xml.common import xml_to_json
-
-
-class TenantUsagesV3ClientXML(RestClientXML):
-
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(TenantUsagesV3ClientXML, self).__init__(config, username,
- password, auth_url,
- tenant_name)
- self.service = self.config.compute.catalog_v3_type
-
- def _parse_array(self, node):
- json = xml_to_json(node)
- return json
-
- def list_tenant_usages(self, params=None):
- url = 'os-simple-tenant-usage'
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage['tenant_usage']
-
- def get_tenant_usage(self, tenant_id, params=None):
- url = 'os-simple-tenant-usage/%s' % tenant_id
- if params:
- url += '?%s' % urllib.urlencode(params)
-
- resp, body = self.get(url, self.headers)
- tenant_usage = self._parse_array(etree.fromstring(body))
- return resp, tenant_usage
diff --git a/tempest/services/compute/xml/aggregates_client.py b/tempest/services/compute/xml/aggregates_client.py
index 5faaff5..164a963 100644
--- a/tempest/services/compute/xml/aggregates_client.py
+++ b/tempest/services/compute/xml/aggregates_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/availability_zone_client.py b/tempest/services/compute/xml/availability_zone_client.py
index ae93774..4024d29 100644
--- a/tempest/services/compute/xml/availability_zone_client.py
+++ b/tempest/services/compute/xml/availability_zone_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/certificates_client.py b/tempest/services/compute/xml/certificates_client.py
index 7523352..682f8de 100644
--- a/tempest/services/compute/xml/certificates_client.py
+++ b/tempest/services/compute/xml/certificates_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/common.py b/tempest/services/compute/xml/common.py
index 860dd5b..9c562b7 100644
--- a/tempest/services/compute/xml/common.py
+++ b/tempest/services/compute/xml/common.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
@@ -99,7 +97,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 +121,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, plurals)
+ else:
+ json[tag] = xml_to_json(child, plurals)
return json
diff --git a/tempest/services/compute/xml/extensions_client.py b/tempest/services/compute/xml/extensions_client.py
index 1395b5a..b2ab9da 100644
--- a/tempest/services/compute/xml/extensions_client.py
+++ b/tempest/services/compute/xml/extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -37,9 +35,14 @@
url = 'extensions'
resp, body = self.get(url, self.headers)
body = self._parse_array(etree.fromstring(body))
- return resp, {'extensions': body}
+ return resp, body
def is_enabled(self, extension):
_, extensions = self.list_extensions()
exts = extensions['extensions']
return any([e for e in exts if e['name'] == extension])
+
+ def get_extension(self, extension_alias):
+ resp, body = self.get('extensions/%s' % extension_alias, self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
diff --git a/tempest/services/compute/xml/fixed_ips_client.py b/tempest/services/compute/xml/fixed_ips_client.py
index bf2de38..53482c1 100644
--- a/tempest/services/compute/xml/fixed_ips_client.py
+++ b/tempest/services/compute/xml/fixed_ips_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/flavors_client.py b/tempest/services/compute/xml/flavors_client.py
index a1c74d9..b7e63e6 100644
--- a/tempest/services/compute/xml/flavors_client.py
+++ b/tempest/services/compute/xml/flavors_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/floating_ips_client.py b/tempest/services/compute/xml/floating_ips_client.py
index 2fffaa2..de78b1e 100644
--- a/tempest/services/compute/xml/floating_ips_client.py
+++ b/tempest/services/compute/xml/floating_ips_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
index f7d7b0a..e7931a3 100644
--- a/tempest/services/compute/xml/hosts_client.py
+++ b/tempest/services/compute/xml/hosts_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -47,18 +45,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/hypervisor_client.py b/tempest/services/compute/xml/hypervisor_client.py
index c10fed9..e988a36 100644
--- a/tempest/services/compute/xml/hypervisor_client.py
+++ b/tempest/services/compute/xml/hypervisor_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/images_client.py b/tempest/services/compute/xml/images_client.py
index b17ae78..6c5a14c 100644
--- a/tempest/services/compute/xml/images_client.py
+++ b/tempest/services/compute/xml/images_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
@@ -15,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-import time
import urllib
from lxml import etree
from tempest.common.rest_client import RestClientXML
+from tempest.common import waiters
from tempest import exceptions
from tempest.services.compute.xml.common import Document
from tempest.services.compute.xml.common import Element
@@ -140,17 +138,7 @@
def wait_for_image_status(self, image_id, status):
"""Waits for an image to reach a given status."""
- resp, image = self.get_image(image_id)
- start = int(time.time())
-
- while image['status'] != status:
- time.sleep(self.build_interval)
- resp, image = self.get_image(image_id)
- if image['status'] == 'ERROR':
- raise exceptions.AddImageException(image_id=image_id)
-
- if int(time.time()) - start >= self.build_timeout:
- raise exceptions.TimeoutException
+ waiters.wait_for_image_status(self, image_id, status)
def _metadata_body(self, meta):
post_body = Element('metadata')
diff --git a/tempest/services/compute/xml/instance_usage_audit_log_client.py b/tempest/services/compute/xml/instance_usage_audit_log_client.py
index 175997b..473ecd1 100644
--- a/tempest/services/compute/xml/instance_usage_audit_log_client.py
+++ b/tempest/services/compute/xml/instance_usage_audit_log_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/keypairs_client.py b/tempest/services/compute/xml/keypairs_client.py
index 0157245..57c4dda 100644
--- a/tempest/services/compute/xml/keypairs_client.py
+++ b/tempest/services/compute/xml/keypairs_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/limits_client.py b/tempest/services/compute/xml/limits_client.py
index 704de52..785d546 100644
--- a/tempest/services/compute/xml/limits_client.py
+++ b/tempest/services/compute/xml/limits_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/quotas_client.py b/tempest/services/compute/xml/quotas_client.py
index ef5362c..f157dfb 100644
--- a/tempest/services/compute/xml/quotas_client.py
+++ b/tempest/services/compute/xml/quotas_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 NTT Data
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/security_groups_client.py b/tempest/services/compute/xml/security_groups_client.py
index 5d86790..498922b 100644
--- a/tempest/services/compute/xml/security_groups_client.py
+++ b/tempest/services/compute/xml/security_groups_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
@@ -79,6 +77,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/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 68f6cf0..63492b7 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
@@ -595,9 +593,9 @@
virt_int = self._parse_xml_virtual_interfaces(etree.fromstring(body))
return resp, virt_int
- def rescue_server(self, server_id, adminPass=None):
+ def rescue_server(self, server_id, **kwargs):
"""Rescue the provided server."""
- return self.action(server_id, 'rescue', None, adminPass=adminPass)
+ return self.action(server_id, 'rescue', None, **kwargs)
def unrescue_server(self, server_id):
"""Unrescue the provided server."""
diff --git a/tempest/services/compute/xml/services_client.py b/tempest/services/compute/xml/services_client.py
index ac304e2..8ef0aa8 100644
--- a/tempest/services/compute/xml/services_client.py
+++ b/tempest/services/compute/xml/services_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tempest/services/compute/xml/tenant_usages_client.py b/tempest/services/compute/xml/tenant_usages_client.py
index cb92324..dfa4a9f 100644
--- a/tempest/services/compute/xml/tenant_usages_client.py
+++ b/tempest/services/compute/xml/tenant_usages_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 NEC Corporation
# All Rights Reserved.
#
diff --git a/tempest/services/compute/xml/volumes_extensions_client.py b/tempest/services/compute/xml/volumes_extensions_client.py
index 4cdc4f0..cb6cefc 100644
--- a/tempest/services/compute/xml/volumes_extensions_client.py
+++ b/tempest/services/compute/xml/volumes_extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/data_processing/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/services/data_processing/__init__.py
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/services/data_processing/v1_1/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/services/data_processing/v1_1/__init__.py
diff --git a/tempest/services/data_processing/v1_1/client.py b/tempest/services/data_processing/v1_1/client.py
new file mode 100644
index 0000000..bd147e8
--- /dev/null
+++ b/tempest/services/data_processing/v1_1/client.py
@@ -0,0 +1,77 @@
+# Copyright (c) 2013 Mirantis Inc.
+#
+# 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 import rest_client
+
+
+class DataProcessingClient(rest_client.RestClient):
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(DataProcessingClient, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.data_processing.catalog_type
+
+ @classmethod
+ def _request_and_parse(cls, req_fun, uri, res_name, *args, **kwargs):
+ """Make a request using specified req_fun and parse response.
+
+ It returns pair: resp and parsed resource(s) body.
+ """
+
+ resp, body = req_fun(uri, headers={
+ 'Content-Type': 'application/json'
+ }, *args, **kwargs)
+ body = json.loads(body)
+ return resp, body[res_name]
+
+ def list_node_group_templates(self):
+ """List all node group templates for a user."""
+
+ uri = 'node-group-templates'
+ return self._request_and_parse(self.get, uri, 'node_group_templates')
+
+ def get_node_group_template(self, tmpl_id):
+ """Returns the details of a single node group template."""
+
+ uri = "node-group-templates/%s" % tmpl_id
+ return self._request_and_parse(self.get, uri, 'node_group_template')
+
+ def create_node_group_template(self, name, plugin_name, hadoop_version,
+ node_processes, flavor_id,
+ node_configs=None, **kwargs):
+ """Creates node group template with specified params.
+
+ It supports passing additional params using kwargs and returns created
+ object.
+ """
+ uri = "node-group-templates"
+ body = kwargs.copy()
+ body.update({
+ 'name': name,
+ 'plugin_name': plugin_name,
+ 'hadoop_version': hadoop_version,
+ 'node_processes': node_processes,
+ 'flavor_id': flavor_id,
+ 'node_configs': node_configs or dict(),
+ })
+ return self._request_and_parse(self.post, uri, 'node_group_template',
+ body=json.dumps(body))
+
+ def delete_node_group_template(self, tmpl_id):
+ """Deletes the specified node group template by id."""
+
+ uri = "node-group-templates/%s" % tmpl_id
+ return self.delete(uri)
diff --git a/tempest/services/identity/json/identity_client.py b/tempest/services/identity/json/identity_client.py
index 94045b8..a0411dc 100644
--- a/tempest/services/identity/json/identity_client.py
+++ b/tempest/services/identity/json/identity_client.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index c3f788a..dccb9a0 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index cf26d0a..124f498 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index ec99d37..c89fbcc 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -274,11 +272,50 @@
body = json.loads(body)
return resp, body['group']
+ def get_group(self, group_id):
+ """Get group details."""
+ resp, body = self.get('groups/%s' % group_id, self.headers)
+ body = json.loads(body)
+ return resp, body['group']
+
+ def update_group(self, group_id, **kwargs):
+ """Updates a group."""
+ resp, body = self.get_group(group_id)
+ name = kwargs.get('name', body['name'])
+ description = kwargs.get('description', body['description'])
+ post_body = {
+ 'name': name,
+ 'description': description
+ }
+ post_body = json.dumps({'group': post_body})
+ resp, body = self.patch('groups/%s' % group_id, post_body,
+ self.headers)
+ body = json.loads(body)
+ return resp, body['group']
+
def delete_group(self, group_id):
"""Delete a group."""
resp, body = self.delete('groups/%s' % str(group_id))
return resp, body
+ def add_group_user(self, group_id, user_id):
+ """Add user into group."""
+ resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
+ None, self.headers)
+ return resp, body
+
+ def list_group_users(self, group_id):
+ """List users in group."""
+ resp, body = self.get('groups/%s/users' % group_id, self.headers)
+ body = json.loads(body)
+ return resp, body['users']
+
+ def delete_group_user(self, group_id, user_id):
+ """Delete user in group."""
+ resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
+ self.headers)
+ return resp, body
+
def assign_user_role_on_project(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
@@ -359,6 +396,66 @@
(domain_id, group_id, role_id))
return resp, body
+ def create_trust(self, trustor_user_id, trustee_user_id, project_id,
+ role_names, impersonation, expires_at):
+ """Creates a trust."""
+ roles = [{'name': n} for n in role_names]
+ post_body = {
+ 'trustor_user_id': trustor_user_id,
+ 'trustee_user_id': trustee_user_id,
+ 'project_id': project_id,
+ 'impersonation': impersonation,
+ 'roles': roles,
+ 'expires_at': expires_at
+ }
+ post_body = json.dumps({'trust': post_body})
+ resp, body = self.post('OS-TRUST/trusts', post_body, self.headers)
+ body = json.loads(body)
+ return resp, body['trust']
+
+ def delete_trust(self, trust_id):
+ """Deletes a trust."""
+ resp, body = self.delete("OS-TRUST/trusts/%s" % trust_id)
+ return resp, body
+
+ def get_trusts(self, trustor_user_id=None, trustee_user_id=None):
+ """GET trusts."""
+ if trustor_user_id:
+ resp, body = self.get("OS-TRUST/trusts?trustor_user_id=%s"
+ % trustor_user_id)
+ elif trustee_user_id:
+ resp, body = self.get("OS-TRUST/trusts?trustee_user_id=%s"
+ % trustee_user_id)
+ else:
+ resp, body = self.get("OS-TRUST/trusts")
+ body = json.loads(body)
+ return resp, body['trusts']
+
+ def get_trust(self, trust_id):
+ """GET trust."""
+ resp, body = self.get("OS-TRUST/trusts/%s" % trust_id)
+ body = json.loads(body)
+ return resp, body['trust']
+
+ def get_trust_roles(self, trust_id):
+ """GET roles delegated by a trust."""
+ resp, body = self.get("OS-TRUST/trusts/%s/roles" % trust_id)
+ body = json.loads(body)
+ return resp, body['roles']
+
+ def get_trust_role(self, trust_id, role_id):
+ """GET role delegated by a trust."""
+ resp, body = self.get("OS-TRUST/trusts/%s/roles/%s"
+ % (trust_id, role_id))
+ body = json.loads(body)
+ return resp, body['role']
+
+ def check_trust_role(self, trust_id, role_id):
+ """HEAD Check if role is delegated by a trust."""
+ resp, body = self.head("OS-TRUST/trusts/%s/roles/%s"
+ % (trust_id, role_id))
+ return resp, body
+
class V3TokenClientJSON(RestClient):
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 27404c4..9ce6d5b 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index dde572e..e60e7e3 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/xml/credentials_client.py b/tempest/services/identity/v3/xml/credentials_client.py
index dc0ade1..4344db1 100644
--- a/tempest/services/identity/v3/xml/credentials_client.py
+++ b/tempest/services/identity/v3/xml/credentials_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/xml/endpoints_client.py b/tempest/services/identity/v3/xml/endpoints_client.py
index e211cee..bd23674 100644
--- a/tempest/services/identity/v3/xml/endpoints_client.py
+++ b/tempest/services/identity/v3/xml/endpoints_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index 3fffc1f..579ddb8 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
@@ -52,6 +50,14 @@
array.append(xml_to_json(child))
return array
+ def _parse_group_users(self, node):
+ array = []
+ for child in node.getchildren():
+ tag_list = child.tag.split('}', 1)
+ if tag_list[1] == "user":
+ array.append(xml_to_json(child))
+ return array
+
def _parse_roles(self, node):
array = []
for child in node.getchildren():
@@ -318,11 +324,50 @@
body = self._parse_body(etree.fromstring(body))
return resp, body
+ def get_group(self, group_id):
+ """Get group details."""
+ resp, body = self.get('groups/%s' % group_id, self.headers)
+ body = self._parse_body(etree.fromstring(body))
+ return resp, body
+
+ def update_group(self, group_id, **kwargs):
+ """Updates a group."""
+ resp, body = self.get_group(group_id)
+ name = kwargs.get('name', body['name'])
+ description = kwargs.get('description', body['description'])
+ post_body = Element("group",
+ xmlns=XMLNS,
+ name=name,
+ description=description)
+ resp, body = self.patch('groups/%s' % group_id,
+ str(Document(post_body)),
+ self.headers)
+ body = self._parse_body(etree.fromstring(body))
+ return resp, body
+
def delete_group(self, group_id):
"""Delete a group."""
resp, body = self.delete('groups/%s' % group_id, self.headers)
return resp, body
+ def add_group_user(self, group_id, user_id):
+ """Add user into group."""
+ resp, body = self.put('groups/%s/users/%s' % (group_id, user_id),
+ '', self.headers)
+ return resp, body
+
+ def list_group_users(self, group_id):
+ """List users in group."""
+ resp, body = self.get('groups/%s/users' % group_id, self.headers)
+ body = self._parse_group_users(etree.fromstring(body))
+ return resp, body
+
+ def delete_group_user(self, group_id, user_id):
+ """Delete user in group."""
+ resp, body = self.delete('groups/%s/users/%s' % (group_id, user_id),
+ self.headers)
+ return resp, body
+
def assign_user_role_on_project(self, project_id, user_id, role_id):
"""Add roles to a user on a project."""
resp, body = self.put('projects/%s/users/%s/roles/%s' %
diff --git a/tempest/services/identity/v3/xml/policy_client.py b/tempest/services/identity/v3/xml/policy_client.py
index 0f07728..7317728 100644
--- a/tempest/services/identity/v3/xml/policy_client.py
+++ b/tempest/services/identity/v3/xml/policy_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/v3/xml/service_client.py b/tempest/services/identity/v3/xml/service_client.py
index 306245b..a142b06 100644
--- a/tempest/services/identity/v3/xml/service_client.py
+++ b/tempest/services/identity/v3/xml/service_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/identity/xml/identity_client.py b/tempest/services/identity/xml/identity_client.py
index 9c0a72c..6e819d8 100644
--- a/tempest/services/identity/xml/identity_client.py
+++ b/tempest/services/identity/xml/identity_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/image/v1/json/image_client.py b/tempest/services/image/v1/json/image_client.py
index 9f5a405..aa6abd0 100644
--- a/tempest/services/image/v1/json/image_client.py
+++ b/tempest/services/image/v1/json/image_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
@@ -36,7 +34,8 @@
super(ImageClientJSON, self).__init__(config, username, password,
auth_url, tenant_name)
self.service = self.config.images.catalog_type
- self.http = self._get_http()
+ if config.service_available.glance:
+ self.http = self._get_http()
def _image_meta_from_headers(self, headers):
meta = {'properties': {}}
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 3d37267..3a79695 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
@@ -31,7 +29,8 @@
super(ImageClientV2JSON, self).__init__(config, username, password,
auth_url, tenant_name)
self.service = self.config.images.catalog_type
- self.http = self._get_http()
+ if config.service_available.glance:
+ self.http = self._get_http()
def _get_http(self):
token, endpoint = self.keystone_auth(self.user, self.password,
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index c6bd423..8cb74a9 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -1,5 +1,3 @@
-# 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
@@ -15,9 +13,10 @@
import json
from tempest.common.rest_client import RestClient
+from tempest.services.network import network_client_base
-class NetworkClientJSON(RestClient):
+class NetworkClientJSON(network_client_base.NetworkClientBase):
"""
Tempest REST client for Neutron. Uses v2 of the Neutron API, since the
@@ -32,25 +31,28 @@
quotas
"""
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(NetworkClientJSON, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.network.catalog_type
- self.version = '2.0'
- self.uri_prefix = "v%s" % (self.version)
+ def get_rest_client(self, config, username,
+ password, auth_url, tenant_name=None):
+ return RestClient(config, username, password, auth_url, tenant_name)
- def list_networks(self):
- uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
+ def deserialize_single(self, body):
+ return json.loads(body)
+
+ def deserialize_list(self, body):
+ res = json.loads(body)
+ # expecting response in form
+ # {'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
body = json.dumps(post_body)
uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -61,21 +63,10 @@
post_body = {'networks': network_list}
body = json.dumps(post_body)
uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_network(self, uuid):
- uri = '%s/networks/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_network(self, uuid):
- uri = '%s/networks/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def create_subnet(self, net_uuid, cidr, ip_version=4, **kwargs):
post_body = {'subnet': kwargs}
post_body['subnet']['ip_version'] = ip_version
@@ -83,24 +74,7 @@
post_body['subnet']['cidr'] = cidr
body = json.dumps(post_body)
uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def delete_subnet(self, uuid):
- uri = '%s/subnets/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def list_subnets(self):
- uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def show_subnet(self, uuid):
- uri = '%s/subnets/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -114,28 +88,7 @@
post_body['port'][key] = val
body = json.dumps(post_body)
uri = '%s/ports' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def delete_port(self, port_id):
- uri = '%s/ports/%s' % (self.uri_prefix, port_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def list_ports(self, **filters):
- uri = '%s/ports' % (self.uri_prefix)
- filter_items = ["%s=%s" % (k, v) for (k, v) in filters.iteritems()]
- querystring = "&".join(filter_items)
- if querystring:
- uri = "%s?%s" % (uri, querystring)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def show_port(self, port_id):
- uri = '%s/ports/%s' % (self.uri_prefix, port_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -143,27 +96,15 @@
put_body = {'quota': kwargs}
body = json.dumps(put_body)
uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
- resp, body = self.put(uri, body, self.headers)
- body = json.loads(body)
- return resp, body['quota']
-
- def show_quotas(self, tenant_id):
- uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body['quota']
def reset_quotas(self, tenant_id):
uri = '%s/quotas/%s' % (self.uri_prefix, tenant_id)
- resp, body = self.delete(uri, self.headers)
+ resp, body = self.delete(uri)
return resp, body
- def list_quotas(self):
- uri = '%s/quotas' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body['quotas']
-
def update_subnet(self, subnet_id, new_name):
put_body = {
'subnet': {
@@ -172,7 +113,7 @@
}
body = json.dumps(put_body)
uri = '%s/subnets/%s' % (self.uri_prefix, subnet_id)
- resp, body = self.put(uri, body=body, headers=self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -184,7 +125,7 @@
}
body = json.dumps(put_body)
uri = '%s/ports/%s' % (self.uri_prefix, port_id)
- resp, body = self.put(uri, body=body, headers=self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -196,13 +137,7 @@
}
body = json.dumps(put_body)
uri = '%s/networks/%s' % (self.uri_prefix, network_id)
- resp, body = self.put(uri, body=body, headers=self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_routers(self):
- uri = '%s/routers' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -212,24 +147,13 @@
post_body['router']['admin_state_up'] = admin_state_up
body = json.dumps(post_body)
uri = '%s/routers' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def delete_router(self, router_id):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def show_router(self, router_id):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
def _update_router(self, router_id, set_enable_snat, **kwargs):
uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
update_body = {}
update_body['name'] = kwargs.get('name', body['router']['name'])
@@ -242,7 +166,7 @@
'external_gateway_info', body['router']['external_gateway_info'])
update_body = dict(router=update_body)
update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body, self.headers)
+ resp, body = self.put(uri, update_body)
body = json.loads(body)
return resp, body
@@ -268,7 +192,7 @@
router_id)
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body, self.headers)
+ resp, body = self.put(uri, update_body)
body = json.loads(body)
return resp, body
@@ -277,7 +201,7 @@
router_id)
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body, self.headers)
+ resp, body = self.put(uri, update_body)
body = json.loads(body)
return resp, body
@@ -286,7 +210,7 @@
router_id)
update_body = {"subnet_id": subnet_id}
update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body, self.headers)
+ resp, body = self.put(uri, update_body)
body = json.loads(body)
return resp, body
@@ -295,7 +219,7 @@
router_id)
update_body = {"port_id": port_id}
update_body = json.dumps(update_body)
- resp, body = self.put(uri, update_body, self.headers)
+ resp, body = self.put(uri, update_body)
body = json.loads(body)
return resp, body
@@ -305,21 +229,10 @@
post_body['floatingip']['floating_network_id'] = ext_network_id
body = json.dumps(post_body)
uri = '%s/floatingips' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body=body)
body = json.loads(body)
return resp, body
- def list_security_groups(self):
- uri = '%s/security-groups' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_security_group(self, secgroup_id):
- uri = '%s/security-groups/%s' % (self.uri_prefix, secgroup_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def create_security_group(self, name, **kwargs):
post_body = {
'security_group': {
@@ -330,45 +243,16 @@
post_body['security_group'][str(key)] = value
body = json.dumps(post_body)
uri = '%s/security-groups' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_floating_ip(self, floating_ip_id):
- uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def show_security_group(self, secgroup_id):
- uri = '%s/security-groups/%s' % (self.uri_prefix, secgroup_id)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_floating_ips(self):
- uri = '%s/floatingips' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_security_group_rules(self):
- uri = '%s/security-group-rules' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_floating_ip(self, floating_ip_id):
- uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def update_floating_ip(self, floating_ip_id, **kwargs):
post_body = {
'floatingip': kwargs}
body = json.dumps(post_body)
uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- resp, body = self.put(uri, headers=self.headers, body=body)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -384,7 +268,7 @@
post_body['security_group_rule'][str(key)] = value
body = json.dumps(post_body)
uri = '%s/security-group-rules' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -392,18 +276,7 @@
post_body = {'subnets': subnet_list}
body = json.dumps(post_body)
uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def delete_security_group_rule(self, rule_id):
- uri = '%s/security-group-rules/%s' % (self.uri_prefix, rule_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def show_security_group_rule(self, rule_id):
- uri = '%s/security-group-rules/%s' % (self.uri_prefix, rule_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -411,13 +284,7 @@
post_body = {'ports': port_list}
body = json.dumps(post_body)
uri = '%s/ports' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def list_vips(self):
- uri = '%s/lb/vips' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -433,41 +300,10 @@
}
body = json.dumps(post_body)
uri = '%s/lb/vips' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
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, headers=self.headers, body=body)
- body = json.loads(body)
- return resp, body
-
- def show_vip(self, uuid):
- uri = '%s/lb/vips/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_vip(self, uuid):
- uri = '%s/lb/vips/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def delete_pool(self, uuid):
- uri = '%s/lb/pools/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def update_vip(self, vip_id, new_name):
put_body = {
"vip": {
@@ -476,37 +312,7 @@
}
body = json.dumps(put_body)
uri = '%s/lb/vips/%s' % (self.uri_prefix, vip_id)
- resp, body = self.put(uri, body=body, headers=self.headers)
- 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, headers=self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_pools(self):
- uri = '%s/lb/pools' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def show_pool(self, uuid):
- uri = '%s/lb/pools/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_members(self):
- uri = '%s/lb/members' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -520,21 +326,10 @@
}
body = json.dumps(post_body)
uri = '%s/lb/members' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_member(self, uuid):
- uri = '%s/lb/members/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_member(self, uuid):
- uri = '%s/lb/members/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def update_member(self, admin_state_up, member_id):
put_body = {
"member": {
@@ -543,13 +338,7 @@
}
body = json.dumps(put_body)
uri = '%s/lb/members/%s' % (self.uri_prefix, member_id)
- resp, body = self.put(uri, body=body, headers=self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_health_monitors(self):
- uri = '%s/lb/health_monitors' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -564,21 +353,10 @@
}
body = json.dumps(post_body)
uri = '%s/lb/health_monitors' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_health_monitor(self, uuid):
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_health_monitor(self, uuid):
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def update_health_monitor(self, admin_state_up, uuid):
put_body = {
"health_monitor": {
@@ -587,7 +365,7 @@
}
body = json.dumps(put_body)
uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, uuid)
- resp, body = self.put(uri, body=body, headers=self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
@@ -601,7 +379,7 @@
body = json.dumps(post_body)
uri = '%s/lb/pools/%s/health_monitors' % (self.uri_prefix,
pool_id)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
@@ -609,28 +387,10 @@
pool_id):
uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
health_monitor_id)
- resp, body = self.delete(uri, headers=self.headers)
+ resp, body = self.delete(uri)
return resp, body
- def list_extensions(self):
- uri = '%s/extensions' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def show_extension_details(self, ext_alias):
- uri = '%s/extensions/%s' % (self.uri_prefix, ext_alias)
- resp, body = self.get(uri, headers=self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_vpn_services(self):
- uri = '%s/vpn/vpnservices' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def create_vpn_service(self, subnet_id, router_id, **kwargs):
+ def create_vpnservice(self, subnet_id, router_id, **kwargs):
post_body = {
"vpnservice": {
"subnet_id": subnet_id,
@@ -641,22 +401,11 @@
post_body['vpnservice'][key] = val
body = json.dumps(post_body)
uri = '%s/vpn/vpnservices' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_vpn_service(self, uuid):
- uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_vpn_service(self, uuid):
- uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def update_vpn_service(self, uuid, description):
+ def update_vpnservice(self, uuid, description):
put_body = {
"vpnservice": {
"description": description
@@ -664,65 +413,59 @@
}
body = json.dumps(put_body)
uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
- resp, body = self.put(uri, body=body, headers=self.headers)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
return resp, body
- def list_agents(self):
- uri = '%s/agents' % self.uri_prefix
- resp, body = self.get(uri, self.headers)
+ def update_agent(self, agent_id, agent_info):
+ """
+ :param agent_info: Agent update information.
+ E.g {"admin_state_up": True}
+ """
+ uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
+ agent = {"agent": agent_info}
+ body = json.dumps(agent)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
def list_routers_on_l3_agent(self, agent_id):
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
return resp, body
def list_l3_agents_hosting_router(self, router_id):
uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def list_service_providers(self):
- uri = '%s/service-providers' % self.uri_prefix
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
return resp, body
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, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
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, self.headers)
+ resp, body = self.get(uri)
body = json.loads(body)
return resp, body
def remove_network_from_dhcp_agent(self, agent_id, network_id):
uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
network_id)
- resp, body = self.delete(uri, self.headers)
+ resp, body = self.delete(uri)
return resp, body
- def list_ike_policies(self):
- uri = '%s/vpn/ikepolicies' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def create_ike_policy(self, name, **kwargs):
+ def create_ikepolicy(self, name, **kwargs):
post_body = {
"ikepolicy": {
"name": name,
@@ -732,25 +475,40 @@
post_body['ikepolicy'][key] = val
body = json.dumps(post_body)
uri = '%s/vpn/ikepolicies' % (self.uri_prefix)
- resp, body = self.post(uri, headers=self.headers, body=body)
+ resp, body = self.post(uri, body)
body = json.loads(body)
return resp, body
- def show_ike_policy(self, uuid):
- uri = '%s/vpn/ikepolicies/%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- body = json.loads(body)
- return resp, body
-
- def delete_ike_policy(self, uuid):
- uri = '%s/vpn/ikepolicies/%s' % (self.uri_prefix, uuid)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def update_ike_policy(self, uuid, **kwargs):
+ def update_ikepolicy(self, uuid, **kwargs):
put_body = {'ikepolicy': kwargs}
body = json.dumps(put_body)
uri = '%s/vpn/ikepolicies/%s' % (self.uri_prefix, uuid)
- resp, body = self.put(uri, body=body, headers=self.headers)
+ resp, body = self.put(uri, body)
+ body = json.loads(body)
+ return resp, body
+
+ def update_extra_routes(self, router_id, nexthop, destination):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ put_body = {
+ 'router': {
+ 'routes': [{'nexthop': nexthop,
+ "destination": destination}]
+ }
+ }
+ body = json.dumps(put_body)
+ resp, body = self.put(uri, body)
+ body = json.loads(body)
+ return resp, body
+
+ def delete_extra_routes(self, router_id):
+ uri = '%s/routers/%s' % (self.uri_prefix, router_id)
+ null_routes = None
+ put_body = {
+ 'router': {
+ 'routes': null_routes
+ }
+ }
+ body = json.dumps(put_body)
+ resp, body = self.put(uri, body)
body = json.loads(body)
return resp, body
diff --git a/tempest/services/network/network_client_base.py b/tempest/services/network/network_client_base.py
new file mode 100644
index 0000000..57b0ebb
--- /dev/null
+++ b/tempest/services/network/network_client_base.py
@@ -0,0 +1,158 @@
+# 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
+
+# the following map is used to construct proper URI
+# for the given neutron resource
+service_resource_prefix_map = {
+ 'networks': '',
+ 'subnets': '',
+ 'ports': '',
+ 'pools': 'lb',
+ 'vips': 'lb',
+ 'health_monitors': 'lb',
+ 'members': 'lb',
+ 'vpnservices': 'vpn',
+ 'ikepolicies': 'vpn'
+}
+
+# The following list represents resource names that do not require
+# changing underscore to a hyphen
+hyphen_exceptions = ["health_monitors"]
+
+# map from resource name to a plural name
+# needed only for those which can't be constructed as name + 's'
+resource_plural_map = {
+ 'security_groups': 'security_groups',
+ 'security_group_rules': 'security_group_rules',
+ 'ikepolicy': 'ikepolicies',
+ 'floating_ip': 'floatingips',
+ 'quotas': 'quotas'
+}
+
+
+class NetworkClientBase(object):
+ def __init__(self, config, username, password,
+ auth_url, tenant_name=None):
+ self.rest_client = self.get_rest_client(
+ config, username, password, auth_url, tenant_name)
+ self.rest_client.service = self.rest_client.config.network.catalog_type
+ self.version = '2.0'
+ self.uri_prefix = "v%s" % (self.version)
+
+ def get_rest_client(self, config, username, password,
+ auth_url, tenant_name):
+ raise NotImplementedError
+
+ def post(self, uri, body, headers=None):
+ headers = headers or self.rest_client.headers
+ return self.rest_client.post(uri, body, headers)
+
+ def put(self, uri, body, headers=None):
+ headers = headers or self.rest_client.headers
+ return self.rest_client.put(uri, body, headers)
+
+ def get(self, uri, headers=None):
+ headers = headers or self.rest_client.headers
+ return self.rest_client.get(uri, headers)
+
+ def delete(self, uri, headers=None):
+ headers = headers or self.rest_client.headers
+ return self.rest_client.delete(uri, headers)
+
+ def deserialize_list(self, body):
+ raise NotImplementedError
+
+ def deserialize_single(self, body):
+ raise NotImplementedError
+
+ def get_uri(self, plural_name):
+ # get service prefix from resource name
+ service_prefix = service_resource_prefix_map.get(
+ plural_name)
+ if plural_name not in hyphen_exceptions:
+ plural_name = plural_name.replace("_", "-")
+ if service_prefix:
+ uri = '%s/%s/%s' % (self.uri_prefix, service_prefix,
+ plural_name)
+ else:
+ uri = '%s/%s' % (self.uri_prefix, plural_name)
+ return uri
+
+ def pluralize(self, resource_name):
+ # get plural from map or just add 's'
+ return resource_plural_map.get(resource_name, resource_name + 's')
+
+ def _lister(self, plural_name):
+ def _list(**filters):
+ uri = self.get_uri(plural_name)
+ if filters:
+ uri += '?' + urllib.urlencode(filters)
+ resp, body = self.get(uri)
+ result = {plural_name: self.deserialize_list(body)}
+ return resp, result
+
+ return _list
+
+ def _deleter(self, resource_name):
+ def _delete(resource_id):
+ plural = self.pluralize(resource_name)
+ uri = '%s/%s' % (self.get_uri(plural), resource_id)
+ return self.delete(uri)
+
+ return _delete
+
+ def _shower(self, resource_name):
+ def _show(resource_id):
+ plural = self.pluralize(resource_name)
+ uri = '%s/%s' % (self.get_uri(plural), resource_id)
+ resp, body = self.get(uri)
+ body = self.deserialize_single(body)
+ return resp, body
+
+ 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_", "create_", "update_"]
+ method_functors = [self._lister,
+ self._deleter,
+ self._shower,
+ self._creater,
+ self._updater]
+ for index, prefix in enumerate(method_prefixes):
+ prefix_len = len(prefix)
+ if name[:prefix_len] == prefix:
+ return method_functors[index](name[prefix_len:])
+ raise AttributeError(name)
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
old mode 100755
new mode 100644
index e11d4c1..ebb2d00
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -1,5 +1,3 @@
-# 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
@@ -19,31 +17,44 @@
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(RestClientXML):
+class NetworkClientXML(client_base.NetworkClientBase):
- def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(NetworkClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.network.catalog_type
- self.version = '2.0'
- self.uri_prefix = "v%s" % (self.version)
+ # list of plurals used for xml serialization
+ PLURALS = ['dns_nameservers', 'host_routes', 'allocation_pools',
+ 'fixed_ips', 'extensions']
- def list_networks(self):
- uri = '%s/networks' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- networks = self._parse_array(etree.fromstring(body))
- networks = {"networks": networks}
- return resp, networks
+ 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 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")
p2 = Element("name", name)
post_body.append(p2)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -55,21 +66,11 @@
p2 = Element("name", names[i])
p1.append(p2)
post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- networks = self._parse_array(etree.fromstring(body))
+ resp, body = self.post(uri, str(Document(post_body)))
+ networks = parse_array(etree.fromstring(body))
networks = {"networks": networks}
return resp, networks
- def delete_network(self, uuid):
- uri = '%s/networks/%s' % (self.uri_prefix, str(uuid))
- return self.delete(uri, self.headers)
-
- def show_network(self, uuid):
- uri = '%s/networks/%s' % (self.uri_prefix, str(uuid))
- resp, body = self.get(uri, self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
def create_subnet(self, net_uuid, cidr):
uri = '%s/subnets' % (self.uri_prefix)
subnet = Element("subnet")
@@ -79,24 +80,7 @@
subnet.append(p2)
subnet.append(p3)
subnet.append(p4)
- resp, body = self.post(uri, str(Document(subnet)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_subnet(self, subnet_id):
- uri = '%s/subnets/%s' % (self.uri_prefix, str(subnet_id))
- return self.delete(uri, self.headers)
-
- def list_subnets(self):
- uri = '%s/subnets' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- subnets = self._parse_array(etree.fromstring(body))
- subnets = {"subnets": subnets}
- return resp, subnets
-
- def show_subnet(self, uuid):
- uri = '%s/subnets/%s' % (self.uri_prefix, str(uuid))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -108,30 +92,7 @@
for key, val in kwargs.items():
key = Element(key, val)
port.append(key)
- resp, body = self.post(uri, str(Document(port)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_port(self, port_id):
- uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
- return self.delete(uri, self.headers)
-
- def _parse_array(self, node):
- array = []
- for child in node.getchildren():
- array.append(xml_to_json(child))
- return array
-
- def list_ports(self):
- url = '%s/ports' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- ports = self._parse_array(etree.fromstring(body))
- ports = {"ports": ports}
- return resp, ports
-
- def show_port(self, port_id):
- uri = '%s/ports/%s' % (self.uri_prefix, str(port_id))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -140,7 +101,7 @@
port = Element("port")
p2 = Element("name", name)
port.append(p2)
- resp, body = self.put(uri, str(Document(port)), self.headers)
+ resp, body = self.put(uri, str(Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -149,7 +110,7 @@
subnet = Element("subnet")
p2 = Element("name", name)
subnet.append(p2)
- resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ resp, body = self.put(uri, str(Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -158,7 +119,7 @@
network = Element("network")
p2 = Element("name", name)
network.append(p2)
- resp, body = self.put(uri, str(Document(network)), self.headers)
+ resp, body = self.put(uri, str(Document(network)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -167,34 +128,10 @@
post_body = Element("security_group")
p2 = Element("name", name)
post_body.append(p2)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def list_security_groups(self):
- url = '%s/security-groups' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- secgroups = self._parse_array(etree.fromstring(body))
- secgroups = {"security_groups": secgroups}
- return resp, secgroups
-
- def delete_security_group(self, secgroup_id):
- uri = '%s/security-groups/%s' % (self.uri_prefix, str(secgroup_id))
- return self.delete(uri, self.headers)
-
- def show_security_group(self, secgroup_id):
- uri = '%s/security-groups/%s' % (self.uri_prefix, str(secgroup_id))
- resp, body = self.get(uri, self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_security_group_rules(self):
- url = '%s/security-group-rules' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- rules = self._parse_array(etree.fromstring(body))
- rules = {"security_group_rules": rules}
- return resp, rules
-
def create_security_group_rule(self, secgroup_id,
direction='ingress', **kwargs):
uri = '%s/security-group-rules' % (self.uri_prefix)
@@ -206,17 +143,7 @@
for key, val in kwargs.items():
key = Element(key, val)
rule.append(key)
- resp, body = self.post(uri, str(Document(rule)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_security_group_rule(self, rule_id):
- uri = '%s/security-group-rules/%s' % (self.uri_prefix, str(rule_id))
- return self.delete(uri, self.headers)
-
- def show_security_group_rule(self, rule_id):
- uri = '%s/security-group-rules/%s' % (self.uri_prefix, str(rule_id))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(rule)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -230,8 +157,8 @@
p2 = Element(k, kv)
p1.append(p2)
post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- subnets = self._parse_array(etree.fromstring(body))
+ resp, body = self.post(uri, str(Document(post_body)))
+ subnets = parse_array(etree.fromstring(body))
subnets = {"subnets": subnets}
return resp, subnets
@@ -245,18 +172,11 @@
p2 = Element(k, kv)
p1.append(p2)
post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- ports = self._parse_array(etree.fromstring(body))
+ resp, body = self.post(uri, str(Document(post_body)))
+ ports = parse_array(etree.fromstring(body))
ports = {"ports": ports}
return resp, ports
- def list_vips(self):
- url = '%s/lb/vips' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- vips = self._parse_array(etree.fromstring(body))
- vips = {"vips": vips}
- return resp, vips
-
def create_vip(self, name, protocol, protocol_port, subnet_id, pool_id):
uri = '%s/lb/vips' % (self.uri_prefix)
post_body = Element("vip")
@@ -270,17 +190,7 @@
post_body.append(p3)
post_body.append(p4)
post_body.append(p5)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_vip(self, vip_id):
- uri = '%s/lb/vips/%s' % (self.uri_prefix, str(vip_id))
- return self.delete(uri, self.headers)
-
- def show_vip(self, vip_id):
- uri = '%s/lb/vips/%s' % (self.uri_prefix, str(vip_id))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -289,56 +199,10 @@
put_body = Element("vip")
p2 = Element("name", new_name)
put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)), self.headers)
+ resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def list_pools(self):
- url = '%s/lb/pools' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- pools = self._parse_array(etree.fromstring(body))
- pools = {"pools": pools}
- return resp, pools
-
- 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)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_pool(self, pool_id):
- uri = '%s/lb/pools/%s' % (self.uri_prefix, str(pool_id))
- return self.delete(uri, self.headers)
-
- def show_pool(self, pool_id):
- uri = '%s/lb/pools/%s' % (self.uri_prefix, str(pool_id))
- resp, body = self.get(uri, self.headers)
- 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)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_members(self):
- url = '%s/lb/members' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- members = self._parse_array(etree.fromstring(body))
- members = {"members": members}
- return resp, members
-
def create_member(self, address, protocol_port, pool_id):
uri = '%s/lb/members' % (self.uri_prefix)
post_body = Element("member")
@@ -348,17 +212,7 @@
post_body.append(p1)
post_body.append(p2)
post_body.append(p3)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_member(self, member_id):
- uri = '%s/lb/members/%s' % (self.uri_prefix, str(member_id))
- return self.delete(uri, self.headers)
-
- def show_member(self, member_id):
- uri = '%s/lb/members/%s' % (self.uri_prefix, str(member_id))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -367,17 +221,10 @@
put_body = Element("member")
p2 = Element("admin_state_up", admin_state_up)
put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)), self.headers)
+ resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def list_health_monitors(self):
- uri = '%s/lb/health_monitors' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- body = self._parse_array(etree.fromstring(body))
- body = {"health_monitors": body}
- return resp, body
-
def create_health_monitor(self, delay, max_retries, Type, timeout):
uri = '%s/lb/health_monitors' % (self.uri_prefix)
post_body = Element("health_monitor")
@@ -389,17 +236,7 @@
post_body.append(p2)
post_body.append(p3)
post_body.append(p4)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_health_monitor(self, uuid):
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, str(uuid))
- return self.delete(uri, self.headers)
-
- def show_health_monitor(self, uuid):
- uri = '%s/lb/health_monitors/%s' % (self.uri_prefix, str(uuid))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -408,7 +245,7 @@
put_body = Element("health_monitor")
p2 = Element("admin_state_up", admin_state_up)
put_body.append(p2)
- resp, body = self.put(uri, str(Document(put_body)), self.headers)
+ resp, body = self.put(uri, str(Document(put_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -419,7 +256,7 @@
post_body = Element("health_monitor")
p1 = Element("id", health_monitor_id,)
post_body.append(p1)
- resp, body = self.post(uri, str(Document(post_body)), self.headers)
+ resp, body = self.post(uri, str(Document(post_body)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -427,18 +264,11 @@
pool_id):
uri = '%s/lb/pools/%s/health_monitors/%s' % (self.uri_prefix, pool_id,
health_monitor_id)
- return self.delete(uri, self.headers)
-
- def list_extensions(self):
- url = '%s/extensions' % (self.uri_prefix)
- resp, body = self.get(url, self.headers)
- extensions = self._parse_array(etree.fromstring(body))
- extensions = {"extensions": extensions}
- return resp, extensions
+ return self.delete(uri)
def show_extension_details(self, ext_alias):
uri = '%s/extensions/%s' % (self.uri_prefix, str(ext_alias))
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -447,18 +277,7 @@
router = Element("router")
router.append(Element("name", name))
deep_dict_to_xml(router, kwargs)
- resp, body = self.post(uri, str(Document(router)), self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def delete_router(self, router_id):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
- def show_router(self, router_id):
- uri = '%s/routers/%s' % (self.uri_prefix, router_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.post(uri, str(Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -467,7 +286,7 @@
router = Element("router")
for element, content in kwargs.iteritems():
router.append(Element(element, content))
- resp, body = self.put(uri, str(Document(router)), self.headers)
+ resp, body = self.put(uri, str(Document(router)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -475,7 +294,7 @@
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
subnet = Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ resp, body = self.put(uri, str(Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -483,7 +302,7 @@
uri = '%s/routers/%s/add_router_interface' % (self.uri_prefix,
router_id)
port = Element("port_id", port_id)
- resp, body = self.put(uri, str(Document(port)), self.headers)
+ resp, body = self.put(uri, str(Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -491,7 +310,7 @@
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
subnet = Element("subnet_id", subnet_id)
- resp, body = self.put(uri, str(Document(subnet)), self.headers)
+ resp, body = self.put(uri, str(Document(subnet)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -499,7 +318,7 @@
uri = '%s/routers/%s/remove_router_interface' % (self.uri_prefix,
router_id)
port = Element("port_id", port_id)
- resp, body = self.put(uri, str(Document(port)), self.headers)
+ resp, body = self.put(uri, str(Document(port)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
@@ -509,28 +328,10 @@
floatingip.append(Element("floating_network_id", ext_network_id))
for element, content in kwargs.iteritems():
floatingip.append(Element(element, content))
- resp, body = self.post(uri, str(Document(floatingip)), self.headers)
+ resp, body = self.post(uri, str(Document(floatingip)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def show_floating_ip(self, floating_ip_id):
- uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- resp, body = self.get(uri, self.headers)
- body = _root_tag_fetcher_and_xml_to_json_parse(body)
- return resp, body
-
- def list_floating_ips(self):
- uri = '%s/floatingips' % (self.uri_prefix)
- resp, body = self.get(uri, self.headers)
- floatingips = self._parse_array(etree.fromstring(body))
- floatingips = {"floatingips": floatingips}
- return resp, floatingips
-
- def delete_floating_ip(self, floating_ip_id):
- uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
- resp, body = self.delete(uri, self.headers)
- return resp, body
-
def update_floating_ip(self, floating_ip_id, **kwargs):
uri = '%s/floatingips/%s' % (self.uri_prefix, floating_ip_id)
floatingip = Element('floatingip')
@@ -543,61 +344,57 @@
floatingip.append(xml_elem)
else:
floatingip.append(Element(element, content))
- resp, body = self.put(uri, str(Document(floatingip)), self.headers)
+ resp, body = self.put(uri, str(Document(floatingip)))
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_router_interfaces(self, uuid):
uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
- resp, body = self.get(uri, self.headers)
- ports = self._parse_array(etree.fromstring(body))
+ resp, body = self.get(uri)
+ ports = parse_array(etree.fromstring(body), self.PLURALS)
ports = {"ports": ports}
return resp, ports
- def list_agents(self):
- uri = '%s/agents' % self.uri_prefix
- resp, body = self.get(uri, self.headers)
- agents = self._parse_array(etree.fromstring(body))
- agents = {'agents': agents}
- return resp, agents
+ def update_agent(self, agent_id, agent_info):
+ uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
+ agent = Element('agent')
+ for (key, value) in agent_info.items():
+ p = Element(key, value)
+ agent.append(p)
+ resp, body = self.put(uri, str(Document(agent)))
+ body = _root_tag_fetcher_and_xml_to_json_parse(body)
+ return resp, body
def list_routers_on_l3_agent(self, agent_id):
uri = '%s/agents/%s/l3-routers' % (self.uri_prefix, agent_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
def list_l3_agents_hosting_router(self, router_id):
uri = '%s/routers/%s/l3-agents' % (self.uri_prefix, router_id)
- resp, body = self.get(uri, self.headers)
+ resp, body = self.get(uri)
body = _root_tag_fetcher_and_xml_to_json_parse(body)
return resp, body
- def list_service_providers(self):
- uri = '%s/service-providers' % self.uri_prefix
- resp, body = self.get(uri, self.headers)
- providers = self._parse_array(etree.fromstring(body))
- body = {'service_providers': providers}
- return resp, body
-
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, self.headers)
- agents = self._parse_array(etree.fromstring(body))
+ resp, body = self.get(uri)
+ 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, self.headers)
- networks = self._parse_array(etree.fromstring(body))
+ resp, body = self.get(uri)
+ networks = parse_array(etree.fromstring(body))
body = {'networks': networks}
return resp, body
def remove_network_from_dhcp_agent(self, agent_id, network_id):
uri = '%s/agents/%s/dhcp-networks/%s' % (self.uri_prefix, agent_id,
network_id)
- resp, body = self.delete(uri, self.headers)
+ resp, body = self.delete(uri)
return resp, body
@@ -606,7 +403,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/account_client.py b/tempest/services/object_storage/account_client.py
index 94b55c3..e796f9b 100644
--- a/tempest/services/object_storage/account_client.py
+++ b/tempest/services/object_storage/account_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index 166c945..15185bc 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 9e0adff..1304a03 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -134,14 +132,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/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index e896e0d..20f1b06 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 IBM Corp.
# All Rights Reserved.
#
@@ -102,6 +100,20 @@
body = json.loads(body)
return resp, body['stack']
+ def suspend_stack(self, stack_identifier):
+ """Suspend a stack."""
+ url = 'stacks/%s/actions' % stack_identifier
+ body = {'suspend': None}
+ resp, body = self.post(url, json.dumps(body), self.headers)
+ return resp, body
+
+ def resume_stack(self, stack_identifier):
+ """Resume a stack."""
+ url = 'stacks/%s/actions' % stack_identifier
+ body = {'resume': None}
+ resp, body = self.post(url, json.dumps(body), self.headers)
+ return resp, body
+
def list_resources(self, stack_identifier):
"""Returns the details of a single resource."""
url = "stacks/%s/resources" % stack_identifier
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index fc28ada..c9a522a 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 44ad785..4ab9b70 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
new file mode 100644
index 0000000..bdd5f1e
--- /dev/null
+++ b/tempest/services/volume/json/extensions_client.py
@@ -0,0 +1,32 @@
+# 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 json
+
+from tempest.common.rest_client import RestClient
+
+
+class ExtensionsClientJSON(RestClient):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ExtensionsClientJSON, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.volume.catalog_type
+
+ def list_extensions(self):
+ url = 'extensions'
+ resp, body = self.get(url)
+ body = json.loads(body)
+ return resp, body['extensions']
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index 5d980eb..1a34898 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -1,5 +1,3 @@
-# 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
@@ -44,7 +42,7 @@
body = json.loads(body)
return resp, body['snapshots']
- def list_snapshot_with_detail(self, params=None):
+ def list_snapshots_with_detail(self, params=None):
"""List the details of all snapshots."""
url = 'snapshots/detail'
if params:
@@ -149,3 +147,40 @@
url = 'snapshots/%s/action' % str(snapshot_id)
resp, body = self.post(url, post_body, self.headers)
return resp, body
+
+ def create_snapshot_metadata(self, snapshot_id, metadata):
+ """Create metadata for the snapshot."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "snapshots/%s/metadata" % str(snapshot_id)
+ resp, body = self.post(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def get_snapshot_metadata(self, snapshot_id):
+ """Get metadata of the snapshot."""
+ url = "snapshots/%s/metadata" % str(snapshot_id)
+ resp, body = self.get(url, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_snapshot_metadata(self, snapshot_id, metadata):
+ """Update metadata for the snapshot."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "snapshots/%s/metadata" % str(snapshot_id)
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
+ """Update metadata item for the snapshot."""
+ put_body = json.dumps({'meta': meta_item})
+ url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['meta']
+
+ def delete_snapshot_metadata_item(self, snapshot_id, id):
+ """Delete metadata item for the snapshot."""
+ url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
+ resp, body = self.delete(url, self.headers)
+ return resp, body
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 967dc09..c99501b 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -263,3 +261,40 @@
resp, body = self.post('volumes/%s/action' % volume_id, post_body,
self.headers)
return resp, body
+
+ def create_volume_metadata(self, volume_id, metadata):
+ """Create metadata for the volume."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.post(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def get_volume_metadata(self, volume_id):
+ """Get metadata of the volume."""
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.get(url, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_volume_metadata(self, volume_id, metadata):
+ """Update metadata for the volume."""
+ put_body = json.dumps({'metadata': metadata})
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['metadata']
+
+ def update_volume_metadata_item(self, volume_id, id, meta_item):
+ """Update metadata item for the volume."""
+ put_body = json.dumps({'meta': meta_item})
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ resp, body = self.put(url, put_body, self.headers)
+ body = json.loads(body)
+ return resp, body['meta']
+
+ def delete_volume_metadata_item(self, volume_id, id):
+ """Delete metadata item for the volume."""
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ resp, body = self.delete(url, self.headers)
+ return resp, body
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
index 59ce933..31e529f 100644
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ b/tempest/services/volume/xml/admin/volume_hosts_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2013 Openstack Foundation.
# All Rights Reserved.
#
diff --git a/tempest/services/volume/xml/admin/volume_types_client.py b/tempest/services/volume/xml/admin/volume_types_client.py
index 42e7b9a..12e70d4 100644
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ b/tempest/services/volume/xml/admin/volume_types_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
diff --git a/tempest/services/compute/v3/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
similarity index 68%
rename from tempest/services/compute/v3/xml/extensions_client.py
rename to tempest/services/volume/xml/extensions_client.py
index e03251c..30997bb 100644
--- a/tempest/services/compute/v3/xml/extensions_client.py
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -20,12 +18,12 @@
from tempest.services.compute.xml.common import xml_to_json
-class ExtensionsV3ClientXML(RestClientXML):
+class ExtensionsClientXML(RestClientXML):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(ExtensionsV3ClientXML, self).__init__(config, username, password,
- auth_url, tenant_name)
- self.service = self.config.compute.catalog_v3_type
+ super(ExtensionsClientXML, self).__init__(config, username, password,
+ auth_url, tenant_name)
+ self.service = self.config.volume.catalog_type
def _parse_array(self, node):
array = []
@@ -37,9 +35,4 @@
url = 'extensions'
resp, body = self.get(url, self.headers)
body = self._parse_array(etree.fromstring(body))
- return resp, {'extensions': body}
-
- def is_enabled(self, extension):
- _, extensions = self.list_extensions()
- exts = extensions['extensions']
- return any([e for e in exts if e['name'] == extension])
+ return resp, body
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 5d59b07..ea2ea27 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -1,5 +1,3 @@
-# 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
@@ -22,6 +20,7 @@
from tempest.openstack.common import log as logging
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
from tempest.services.compute.xml.common import XMLNS_11
@@ -170,3 +169,57 @@
if body:
body = xml_to_json(etree.fromstring(body))
return resp, body
+
+ def _metadata_body(self, meta):
+ post_body = Element('metadata')
+ for k, v in meta.items():
+ data = Element('meta', key=k)
+ data.append(Text(v))
+ post_body.append(data)
+ return post_body
+
+ def _parse_key_value(self, node):
+ """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
+ data = {}
+ for node in node.getchildren():
+ data[node.get('key')] = node.text
+ return data
+
+ def create_snapshot_metadata(self, snapshot_id, metadata):
+ """Create metadata for the snapshot."""
+ post_body = self._metadata_body(metadata)
+ resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
+ str(Document(post_body)),
+ self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def get_snapshot_metadata(self, snapshot_id):
+ """Get metadata of the snapshot."""
+ url = "snapshots/%s/metadata" % str(snapshot_id)
+ resp, body = self.get(url, self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def update_snapshot_metadata(self, snapshot_id, metadata):
+ """Update metadata for the snapshot."""
+ put_body = self._metadata_body(metadata)
+ url = "snapshots/%s/metadata" % str(snapshot_id)
+ resp, body = self.put(url, str(Document(put_body)), self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
+ """Update metadata item for the snapshot."""
+ for k, v in meta_item.items():
+ put_body = Element('meta', key=k)
+ put_body.append(Text(v))
+ url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
+ resp, body = self.put(url, str(Document(put_body)), self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def delete_snapshot_metadata_item(self, snapshot_id, id):
+ """Delete metadata item for the snapshot."""
+ url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
+ return self.delete(url)
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 1fc63e9..37370b1 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-#
# Copyright 2012 IBM Corp.
# All Rights Reserved.
#
@@ -356,3 +354,57 @@
if body:
body = xml_to_json(etree.fromstring(body))
return resp, body
+
+ def _metadata_body(self, meta):
+ post_body = Element('metadata')
+ for k, v in meta.items():
+ data = Element('meta', key=k)
+ data.append(Text(v))
+ post_body.append(data)
+ return post_body
+
+ def _parse_key_value(self, node):
+ """Parse <foo key='key'>value</foo> data into {'key': 'value'}."""
+ data = {}
+ for node in node.getchildren():
+ data[node.get('key')] = node.text
+ return data
+
+ def create_volume_metadata(self, volume_id, metadata):
+ """Create metadata for the volume."""
+ post_body = self._metadata_body(metadata)
+ resp, body = self.post('volumes/%s/metadata' % volume_id,
+ str(Document(post_body)),
+ self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def get_volume_metadata(self, volume_id):
+ """Get metadata of the volume."""
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.get(url, self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def update_volume_metadata(self, volume_id, metadata):
+ """Update metadata for the volume."""
+ put_body = self._metadata_body(metadata)
+ url = "volumes/%s/metadata" % str(volume_id)
+ resp, body = self.put(url, str(Document(put_body)), self.headers)
+ body = self._parse_key_value(etree.fromstring(body))
+ return resp, body
+
+ def update_volume_metadata_item(self, volume_id, id, meta_item):
+ """Update metadata item for the volume."""
+ for k, v in meta_item.items():
+ put_body = Element('meta', key=k)
+ put_body.append(Text(v))
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ resp, body = self.put(url, str(Document(put_body)), self.headers)
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
+
+ def delete_volume_metadata_item(self, volume_id, id):
+ """Delete metadata item for the volume."""
+ url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
+ return self.delete(url)
diff --git a/tempest/stress/__init__.py b/tempest/stress/__init__.py
index 1caf74a..e69de29 100644
--- a/tempest/stress/__init__.py
+++ b/tempest/stress/__init__.py
@@ -1,13 +0,0 @@
-# Copyright 2013 Quanta Research Cambridge, Inc.
-#
-# 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.
diff --git a/tempest/stress/actions/__init__.py b/tempest/stress/actions/__init__.py
index 1caf74a..e69de29 100644
--- a/tempest/stress/actions/__init__.py
+++ b/tempest/stress/actions/__init__.py
@@ -1,13 +0,0 @@
-# Copyright 2013 Quanta Research Cambridge, Inc.
-#
-# 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.
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 74a9739..28de771 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/stress/actions/unit_test.py b/tempest/stress/actions/unit_test.py
index 5ab5573..8bd2f22 100644
--- a/tempest/stress/actions/unit_test.py
+++ b/tempest/stress/actions/unit_test.py
@@ -1,5 +1,3 @@
-# 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
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 1bd9485..b46de35 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tempest/stress/etc/ssh_floating.json b/tempest/stress/etc/ssh_floating.json
index 0cb6776..e03fd4f 100644
--- a/tempest/stress/etc/ssh_floating.json
+++ b/tempest/stress/etc/ssh_floating.json
@@ -8,7 +8,7 @@
"new_floating": true,
"verify": ["check_icmp_echo", "check_port_ssh"],
"check_timeout": 120,
- "check_inerval": 1,
+ "check_interval": 1,
"wait_after_vm_create": true,
"wait_for_disassociate": true,
"reboot": false}
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 067b994..61fb58f 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Quanta Research Cambridge, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tempest/stress/stressaction.py b/tempest/stress/stressaction.py
index 61e46fa..f6770ab 100644
--- a/tempest/stress/stressaction.py
+++ b/tempest/stress/stressaction.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# (c) Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/test.py b/tempest/test.py
index ceb2c80..61d1311 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -33,6 +31,8 @@
LOG = logging.getLogger(__name__)
+CONF = config.CONF
+
# All the successful HTTP status codes from RFC 2616
HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
@@ -110,15 +110,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
@@ -146,12 +155,13 @@
"""A function that will check the list of enabled extensions from config
"""
- configs = config.TempestConfig()
+ configs = CONF
config_dict = {
'compute': configs.compute_feature_enabled.api_extensions,
'compute_v3': configs.compute_feature_enabled.api_v3_extensions,
'volume': configs.volume_feature_enabled.api_extensions,
'network': configs.network_feature_enabled.api_extensions,
+ 'object': configs.object_storage_feature_enabled.discoverable_apis,
}
if config_dict[service][0] == 'all':
return True
@@ -214,10 +224,12 @@
testtools.testcase.WithAttributes,
testresources.ResourcedTestCase):
- config = config.TempestConfig()
+ config = CONF
setUpClassCalled = False
+ network_resources = {}
+
@classmethod
def setUpClass(cls):
if hasattr(super(BaseTestCase, cls), 'setUpClass'):
@@ -265,7 +277,8 @@
"""
Returns an Openstack client manager
"""
- cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)
+ cls.isolated_creds = isolated_creds.IsolatedCreds(
+ cls.__name__, network_resources=cls.network_resources)
force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
if (cls.config.compute.allow_tenant_isolation or
@@ -307,6 +320,27 @@
cls.config.identity.uri
)
+ @classmethod
+ def set_network_resources(self, network=False, router=False, subnet=False,
+ dhcp=False):
+ """Specify which network resources should be created
+
+ @param network
+ @param router
+ @param subnet
+ @param dhcp
+ """
+ # network resources should be set only once from callers
+ # in order to ensure that even if it's called multiple times in
+ # a chain of overloaded methods, the attribute is set only
+ # in the leaf class
+ if not self.network_resources:
+ self.network_resources = {
+ 'network': network,
+ 'router': router,
+ 'subnet': subnet,
+ 'dhcp': dhcp}
+
def call_until_true(func, duration, sleep_for):
"""
diff --git a/tempest/services/compute/v3/xml/__init__.py b/tempest/test_discover/__init__.py
similarity index 100%
copy from tempest/services/compute/v3/xml/__init__.py
copy to tempest/test_discover/__init__.py
diff --git a/tempest/test_discover/test_discover.py b/tempest/test_discover/test_discover.py
new file mode 100644
index 0000000..87fdbdc
--- /dev/null
+++ b/tempest/test_discover/test_discover.py
@@ -0,0 +1,30 @@
+# 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 os
+import unittest
+
+
+def load_tests(loader, tests, pattern):
+ suite = unittest.TestSuite()
+ base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
+ base_path = os.path.split(base_path)[0]
+ for test_dir in ['./tempest/api', './tempest/cli', './tempest/scenario',
+ './tempest/thirdparty']:
+ if not pattern:
+ suite.addTests(loader.discover(test_dir, top_level_dir=base_path))
+ else:
+ suite.addTests(loader.discover(test_dir, pattern=pattern,
+ top_level_dir=base_path))
+ return suite
diff --git a/tempest/tests/base.py b/tempest/tests/base.py
index ba83cf4..3654f64 100644
--- a/tempest/tests/base.py
+++ b/tempest/tests/base.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/tests/fake_config.py b/tempest/tests/fake_config.py
new file mode 100644
index 0000000..a50aaeb
--- /dev/null
+++ b/tempest/tests/fake_config.py
@@ -0,0 +1,26 @@
+# 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.
+
+
+class FakeConfig(object):
+
+ class fake_compute(object):
+ build_interval = 10
+ build_timeout = 10
+
+ class fake_identity(object):
+ disable_ssl_certificate_validation = True
+
+ compute = fake_compute()
+ identity = fake_identity()
diff --git a/tempest/tests/fake_http.py b/tempest/tests/fake_http.py
new file mode 100644
index 0000000..ac5f765
--- /dev/null
+++ b/tempest/tests/fake_http.py
@@ -0,0 +1,46 @@
+# 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 httplib2
+
+
+class fake_httplib2(object):
+
+ def __init__(self, return_type=None):
+ self.return_type = return_type
+
+ def request(self, uri, method="GET", body=None, headers=None,
+ redirections=5, connection_type=None):
+ if not self.return_type:
+ fake_headers = httplib2.Response(headers)
+ return_obj = {
+ 'uri': uri,
+ 'method': method,
+ 'body': body,
+ 'headers': headers
+ }
+ return (fake_headers, return_obj)
+ # return (headers, return_obj)
+ elif isinstance(self.return_type, int):
+ body = "fake_body"
+ header_info = {
+ 'content-type': 'text/plain',
+ 'status': str(self.return_type),
+ 'content-length': len(body)
+ }
+ resp_header = httplib2.Response(header_info)
+ return (resp_header, body)
+ else:
+ msg = "unsupported return type %s" % self.return_type
+ raise TypeError(msg)
diff --git a/tempest/tests/files/failing-tests b/tempest/tests/files/failing-tests
index 0ec5421..78efc93 100644
--- a/tempest/tests/files/failing-tests
+++ b/tempest/tests/files/failing-tests
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/tests/files/passing-tests b/tempest/tests/files/passing-tests
index 2f5b7c9..a55cb1b 100644
--- a/tempest/tests/files/passing-tests
+++ b/tempest/tests/files/passing-tests
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/tests/stress/test_stress.py b/tempest/tests/stress/test_stress.py
index 4d7de9d..c76abde 100644
--- a/tempest/tests/stress/test_stress.py
+++ b/tempest/tests/stress/test_stress.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Deutsche Telekom AG
# All Rights Reserved.
#
diff --git a/tempest/tests/stress/test_stressaction.py b/tempest/tests/stress/test_stressaction.py
index 3d2901e..1a1bb67 100644
--- a/tempest/tests/stress/test_stressaction.py
+++ b/tempest/tests/stress/test_stressaction.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 Deutsche Telekom AG
# All Rights Reserved.
#
diff --git a/tempest/tests/test_list_tests.py b/tempest/tests/test_list_tests.py
index ab0d114..157fc5f 100644
--- a/tempest/tests/test_list_tests.py
+++ b/tempest/tests/test_list_tests.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
new file mode 100644
index 0000000..acb9000
--- /dev/null
+++ b/tempest/tests/test_rest_client.py
@@ -0,0 +1,90 @@
+# 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 httplib2
+
+from tempest.common import rest_client
+from tempest import exceptions
+from tempest.openstack.common.fixture import mockpatch
+from tempest.tests import base
+from tempest.tests import fake_config
+from tempest.tests import fake_http
+
+
+class BaseRestClientTestClass(base.TestCase):
+
+ def _set_token(self):
+ self.rest_client.token = 'fake token'
+
+ def setUp(self):
+ super(BaseRestClientTestClass, self).setUp()
+ self.rest_client = rest_client.RestClient(fake_config.FakeConfig(),
+ 'fake_user', 'fake_pass',
+ 'http://fake_url/v2.0')
+ self.stubs.Set(httplib2.Http, 'request', self.fake_http.request)
+ self.useFixture(mockpatch.PatchObject(self.rest_client, '_set_auth',
+ side_effect=self._set_token()))
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ '_log_response'))
+
+
+class TestRestClientHTTPMethods(BaseRestClientTestClass):
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2()
+ super(TestRestClientHTTPMethods, self).setUp()
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ '_error_checker'))
+
+ def test_post(self):
+ __, return_dict = self.rest_client.post('fake_endpoint', {},
+ {})
+ self.assertEqual('POST', return_dict['method'])
+
+ def test_get(self):
+ __, return_dict = self.rest_client.get('fake_endpoint')
+ self.assertEqual('GET', return_dict['method'])
+
+ def test_delete(self):
+ __, return_dict = self.rest_client.delete('fake_endpoint')
+ self.assertEqual('DELETE', return_dict['method'])
+
+ def test_patch(self):
+ __, return_dict = self.rest_client.patch('fake_endpoint', {},
+ {})
+ self.assertEqual('PATCH', return_dict['method'])
+
+ def test_put(self):
+ __, return_dict = self.rest_client.put('fake_endpoint', {},
+ {})
+ self.assertEqual('PUT', return_dict['method'])
+
+ def test_head(self):
+ self.useFixture(mockpatch.PatchObject(self.rest_client,
+ 'response_checker'))
+ __, return_dict = self.rest_client.head('fake_endpoint')
+ self.assertEqual('HEAD', return_dict['method'])
+
+ def test_copy(self):
+ __, return_dict = self.rest_client.copy('fake_endpoint')
+ self.assertEqual('COPY', return_dict['method'])
+
+
+class TestRestClientNotFoundHandling(BaseRestClientTestClass):
+ def setUp(self):
+ self.fake_http = fake_http.fake_httplib2(404)
+ super(TestRestClientNotFoundHandling, self).setUp()
+
+ def test_post(self):
+ self.assertRaises(exceptions.NotFound, self.rest_client.post,
+ 'fake_endpoint', {}, {})
diff --git a/tempest/tests/test_wrappers.py b/tempest/tests/test_wrappers.py
index dbf1809..dd0ea61 100644
--- a/tempest/tests/test_wrappers.py
+++ b/tempest/tests/test_wrappers.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -56,7 +54,7 @@
# version or an sdist to work. so make the test directory a git repo
# too.
subprocess.call(['git', 'init'])
- exit_code = subprocess.call('sh pretty_tox.sh tests.passing',
+ exit_code = subprocess.call('bash pretty_tox.sh tests.passing',
shell=True, stdout=DEVNULL, stderr=DEVNULL)
self.assertEqual(exit_code, 0)
@@ -71,7 +69,7 @@
# version or an sdist to work. so make the test directory a git repo
# too.
subprocess.call(['git', 'init'])
- exit_code = subprocess.call('sh pretty_tox.sh', shell=True,
+ exit_code = subprocess.call('bash pretty_tox.sh', shell=True,
stdout=DEVNULL, stderr=DEVNULL)
self.assertEqual(exit_code, 1)
@@ -82,7 +80,7 @@
# Change directory, run wrapper and check result
self.addCleanup(os.chdir, os.path.abspath(os.curdir))
os.chdir(self.directory)
- exit_code = subprocess.call('sh pretty_tox_serial.sh tests.passing',
+ exit_code = subprocess.call('bash pretty_tox_serial.sh tests.passing',
shell=True, stdout=DEVNULL, stderr=DEVNULL)
self.assertEqual(exit_code, 0)
@@ -93,6 +91,6 @@
# Change directory, run wrapper and check result
self.addCleanup(os.chdir, os.path.abspath(os.curdir))
os.chdir(self.directory)
- exit_code = subprocess.call('sh pretty_tox_serial.sh', shell=True,
+ exit_code = subprocess.call('bash pretty_tox_serial.sh', shell=True,
stdout=DEVNULL, stderr=DEVNULL)
self.assertEqual(exit_code, 1)
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index 5ae21c8..d484d94 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -29,7 +27,7 @@
import tempest.clients
from tempest.common.utils.file_utils import have_effective_read_access
-import tempest.config
+from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
import tempest.test
@@ -37,6 +35,7 @@
from tempest.thirdparty.boto.utils.wait import state_wait
from tempest.thirdparty.boto.utils.wait import wait_exception
+CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -50,11 +49,10 @@
def all_read(*args):
return all(map(have_effective_read_access, args))
- config = tempest.config.TempestConfig()
- materials_path = config.boto.s3_materials_path
- ami_path = materials_path + os.sep + config.boto.ami_manifest
- aki_path = materials_path + os.sep + config.boto.aki_manifest
- ari_path = materials_path + os.sep + config.boto.ari_manifest
+ materials_path = CONF.boto.s3_materials_path
+ ami_path = materials_path + os.sep + CONF.boto.ami_manifest
+ aki_path = materials_path + os.sep + CONF.boto.aki_manifest
+ ari_path = materials_path + os.sep + CONF.boto.ari_manifest
A_I_IMAGES_READY = all_read(ami_path, aki_path, ari_path)
boto_logger = logging.getLogger('boto')
@@ -70,7 +68,7 @@
raise Exception("Unknown (Authentication?) Error")
openstack = tempest.clients.Manager()
try:
- if urlparse.urlparse(config.boto.ec2_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.ec2_url).hostname is None:
raise Exception("Failed to get hostname from the ec2_url")
ec2client = openstack.ec2api_client
try:
@@ -87,7 +85,7 @@
EC2_CAN_CONNECT_ERROR = str(exc)
try:
- if urlparse.urlparse(config.boto.s3_url).hostname is None:
+ if urlparse.urlparse(CONF.boto.s3_url).hostname is None:
raise Exception("Failed to get hostname from the s3_url")
s3client = openstack.s3_client
try:
@@ -245,20 +243,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 +426,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 +461,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 +495,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 +504,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/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index 9ded9da..8a08cc2 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index 41db709..b4c1827 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py
index b4949c8..3c3c74d 100644
--- a/tempest/thirdparty/boto/test_ec2_network.py
+++ b/tempest/thirdparty/boto/test_ec2_network.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py
index e8c6466..75dd254 100644
--- a/tempest/thirdparty/boto/test_ec2_security_groups.py
+++ b/tempest/thirdparty/boto/test_ec2_security_groups.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_ec2_volumes.py b/tempest/thirdparty/boto/test_ec2_volumes.py
index faff3ca..3e7e2de 100644
--- a/tempest/thirdparty/boto/test_ec2_volumes.py
+++ b/tempest/thirdparty/boto/test_ec2_volumes.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index 56ee9e3..f8948fd 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py
index 2e7525a..4b7d9dd 100644
--- a/tempest/thirdparty/boto/test_s3_ec2_images.py
+++ b/tempest/thirdparty/boto/test_s3_ec2_images.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py
index 57ec34a..f355899 100644
--- a/tempest/thirdparty/boto/test_s3_objects.py
+++ b/tempest/thirdparty/boto/test_s3_objects.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/utils/s3.py b/tempest/thirdparty/boto/utils/s3.py
index 56e1191..ff5e332 100644
--- a/tempest/thirdparty/boto/utils/s3.py
+++ b/tempest/thirdparty/boto/utils/s3.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py
index 1cd847b..eed0a92 100644
--- a/tempest/thirdparty/boto/utils/wait.py
+++ b/tempest/thirdparty/boto/utils/wait.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
@@ -21,17 +19,12 @@
import boto.exception
from testtools import TestCase
-import tempest.config
+from tempest import config
from tempest.openstack.common import log as logging
+CONF = config.CONF
LOG = logging.getLogger(__name__)
-_boto_config = tempest.config.TempestConfig().boto
-
-default_timeout = _boto_config.build_timeout
-
-default_check_interval = _boto_config.build_interval
-
def state_wait(lfunction, final_set=set(), valid_set=None):
# TODO(afazekas): evaluate using ABC here
@@ -50,12 +43,12 @@
if valid_set is not None and status not in valid_set:
return status
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("State change timeout exceeded!"
'(%ds) While waiting'
'for %s at "%s"' %
(dtime, final_set, status))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
old_status = status
status = lfunction()
@@ -73,12 +66,12 @@
text)
return result
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException('Pattern find timeout exceeded!'
'(%ds) While waiting for'
'"%s" pattern in "%s"' %
(dtime, regexp, text))
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
def wait_no_exception(lfunction, exc_class=None, exc_matcher=None):
@@ -104,10 +97,10 @@
raise exc
# Let the other exceptions propagate
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# NOTE(afazekas): EC2/boto normally raise exception instead of empty list
@@ -122,9 +115,9 @@
time.time() - start_time)
return exc
dtime = time.time() - start_time
- if dtime > default_timeout:
+ if dtime > CONF.boto.build_timeout:
raise TestCase.failureException("Wait timeout exceeded! (%ds)" %
dtime)
- time.sleep(default_check_interval)
+ time.sleep(CONF.boto.build_interval)
# TODO(afazekas): consider strategy design pattern..
diff --git a/test-requirements.txt b/test-requirements.txt
index 9486244..d7340f3 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -6,3 +6,4 @@
oslo.sphinx
mox>=0.5.3
mock>=1.0
+coverage>=3.6
diff --git a/tools/check_logs.py b/tools/check_logs.py
index 6d4436e..f3204e3 100755
--- a/tools/check_logs.py
+++ b/tools/check_logs.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Red Hat, Inc.
# All Rights Reserved.
@@ -27,11 +26,13 @@
is_neutron = os.environ.get('DEVSTACK_GATE_NEUTRON', "0") == "1"
+is_grenade = (os.environ.get('DEVSTACK_GATE_GRENADE', "0") == "1" or
+ os.environ.get('DEVSTACK_GATE_GRENADE_FORWARD', "0") == "1")
dump_all_errors = is_neutron
def process_files(file_specs, url_specs, whitelists):
- regexp = re.compile(r"^.*(ERROR|CRITICAL).*\[.*\-.*\]")
+ regexp = re.compile(r"^.* (ERROR|CRITICAL) .*\[.*\-.*\]")
had_errors = False
for (name, filename) in file_specs:
whitelist = whitelists.get(name, [])
@@ -125,6 +126,9 @@
if is_neutron:
print("Currently not failing neutron builds with errors")
return 0
+ if is_grenade:
+ print("Currently not failing grenade runs with errors")
+ return 0
print("FAILED")
return 1
else:
diff --git a/tools/colorizer.py b/tools/colorizer.py
index 76a3bd3..a3a0616 100755
--- a/tools/colorizer.py
+++ b/tools/colorizer.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013, Nebula, Inc.
# Copyright 2010 United States Government as represented by the
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/find_stack_traces.py b/tools/find_stack_traces.py
index 52a5a66..c905976 100755
--- a/tools/find_stack_traces.py
+++ b/tools/find_stack_traces.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 IBM Corp.
# All Rights Reserved.
diff --git a/tools/install_venv.py b/tools/install_venv.py
index 84d0fd9..a7fb5ee 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.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.
# All Rights Reserved.
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/tools/pretty_tox.sh b/tools/pretty_tox.sh
index a5a6076..07c35a0 100755
--- a/tools/pretty_tox.sh
+++ b/tools/pretty_tox.sh
@@ -1,4 +1,6 @@
-#!/bin/sh
+#!/usr/bin/env bash
+
+set -o pipefail
TESTRARGS=$1
python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit2pyunit
diff --git a/tools/pretty_tox_serial.sh b/tools/pretty_tox_serial.sh
index 45f05bd..42ce760 100755
--- a/tools/pretty_tox_serial.sh
+++ b/tools/pretty_tox_serial.sh
@@ -1,4 +1,6 @@
-#!/bin/sh
+#!/usr/bin/env bash
+
+set -o pipefail
TESTRARGS=$@
diff --git a/tools/skip_tracker.py b/tools/skip_tracker.py
index 0ae3323..50f33eb 100755
--- a/tools/skip_tracker.py
+++ b/tools/skip_tracker.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
diff --git a/tools/tempest_auto_config.py b/tools/tempest_auto_config.py
index fe9f5af..9aeb077 100644
--- a/tools/tempest_auto_config.py
+++ b/tools/tempest_auto_config.py
@@ -1,5 +1,3 @@
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
-
# Copyright 2012 OpenStack Foundation
# All Rights Reserved.
#
diff --git a/tools/verify_tempest_config.py b/tools/verify_tempest_config.py
index 347659d..f56b475 100755
--- a/tools/verify_tempest_config.py
+++ b/tools/verify_tempest_config.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 IBM Corp.
#
@@ -21,7 +20,7 @@
from tempest import config
-CONF = config.TempestConfig()
+CONF = config.CONF
#Dicts matching extension names to config options
NOVA_EXTENSIONS = {
diff --git a/tox.ini b/tox.ini
index 9389cf4..88f2537 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,55 +4,58 @@
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
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:py33]
+setenv = OS_TEST_PATH=./tempest/tests
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
[testenv:py27]
+setenv = OS_TEST_PATH=./tempest/tests
commands = python setup.py test --slowest --testr-arg='tempest\.tests {posargs}'
+[testenv:cover]
+setenv = OS_TEST_PATH=./tempest/tests
+commands = python setup.py testr --coverage --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 =
- sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
+ bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
[testenv:testr-full]
-sitepackages = True
commands =
- sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}'
+ 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 =
- sh tools/pretty_tox_serial.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}'
+ 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
@@ -77,20 +80,17 @@
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 =
- sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
+ 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.
commands =
- sh tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}'
+ 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