Merge "Update QoS scenario test"
diff --git a/.zuul.yaml b/.zuul.yaml
index cc1b61f..8c6072a 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -3,7 +3,7 @@
parent: devstack-tempest
abstract: true
description: |
- Perform setup common to all Neutron tempest tests
+ Perform setup common to all Neutron tempest tests
roles:
- zuul: openstack-dev/devstack
required-projects:
@@ -16,7 +16,7 @@
tox_envlist: all
devstack_localrc:
TEMPEST_PLUGINS: /opt/stack/neutron-tempest-plugin
- NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-mac-address-regenerate,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details"
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,filter-validation,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-mac-address-regenerate,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details
devstack_plugins:
neutron: git://git.openstack.org/openstack/neutron.git
neutron-tempest-plugin: git://git.openstack.org/openstack/neutron-tempest-plugin.git
@@ -38,7 +38,7 @@
# NOTE(slaweq): We can get rid of this hardcoded absolute path when
# devstack-tempest job will be switched to use lib/neutron instead of
# lib/neutron-legacy
- "/$NEUTRON_CORE_PLUGIN_CONF":
+ /$NEUTRON_CORE_PLUGIN_CONF:
ml2:
type_drivers: flat,geneve,vlan,gre,local,vxlan
ml2_type_vlan:
@@ -53,11 +53,11 @@
$NEUTRON_DHCP_CONF:
agent:
availability_zone: nova
- "/etc/neutron/api-paste.ini":
- "composite:neutronapi_v2_0":
- use: "call:neutron.auth:pipeline_factory"
- noauth: "cors request_id catch_errors osprofiler extensions neutronapiapp_v2_0"
- keystone: "cors request_id catch_errors osprofiler authtoken keystonecontext extensions neutronapiapp_v2_0"
+ /etc/neutron/api-paste.ini:
+ composite:neutronapi_v2_0:
+ use: call:neutron.auth:pipeline_factory
+ noauth: cors request_id catch_errors osprofiler extensions neutronapiapp_v2_0
+ keystone: cors request_id catch_errors osprofiler authtoken keystonecontext extensions neutronapiapp_v2_0
test-config:
$TEMPEST_CONFIG:
neutron_plugin_options:
@@ -65,7 +65,7 @@
agent_availability_zone: nova
image_is_advanced: true
available_type_drivers: flat,geneve,vlan,gre,local,vxlan
- irrelevant-files:
+ irrelevant-files: &tempest-irrelevant-files
- ^(test-|)requirements.txt$
- ^releasenotes/.*$
- ^doc/.*$
@@ -88,7 +88,7 @@
# NOTE(slaweq): We can get rid of this hardcoded absolute path when
# devstack-tempest job will be switched to use lib/neutron instead of
# lib/neutron-legacy
- "/$NEUTRON_CORE_PLUGIN_CONF":
+ /$NEUTRON_CORE_PLUGIN_CONF:
AGENT:
tunnel_types: gre,vxlan
network_log:
@@ -104,24 +104,37 @@
# TODO(slaweq): find a way to put this list of extensions in
# neutron repository and keep it different per branch,
# then it could be removed from here
- NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details"
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details
+
+- job:
+ name: neutron-tempest-plugin-api-rocky
+ parent: neutron-tempest-plugin-api
+ override-checkout: stable/rocky
+ vars:
+ branch_override: stable/rocky
+ devstack_localrc:
+ # TODO(slaweq): find a way to put this list of extensions in
+ # neutron repository and keep it different per branch,
+ # then it could be removed from here
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-mac-address-regenerate,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details
- job:
name: neutron-tempest-plugin-scenario
parent: neutron-tempest-plugin
abstract: true
description: |
- Perform setup common to all tempest scenario test jobs.
+ Perform setup common to all tempest scenario test jobs.
vars:
tempest_test_regex: ^neutron_tempest_plugin\.scenario
devstack_localrc:
- PHYSICAL_NETWORK: default
- DOWNLOAD_DEFAULT_IMAGES: false
- IMAGE_URLS: "http://cloud-images.ubuntu.com/releases/16.04/release-20180622/ubuntu-16.04-server-cloudimg-amd64-disk1.img,"
- DEFAULT_INSTANCE_TYPE: ds512M
- DEFAULT_INSTANCE_USER: ubuntu
- BUILD_TIMEOUT: 784
- LIBVIRT_TYPE: kvm
+ PHYSICAL_NETWORK: default
+ DOWNLOAD_DEFAULT_IMAGES: false
+ IMAGE_URLS: "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img,http://cloud-images.ubuntu.com/releases/16.04/release-20180622/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
+ DEFAULT_IMAGE_NAME: cirros-0.3.4-i386-disk
+ ADVANCED_IMAGE_NAME: ubuntu-16.04-server-cloudimg-amd64-disk1
+ ADVANCED_INSTANCE_TYPE: ds512M
+ ADVANCED_INSTANCE_USER: ubuntu
+ BUILD_TIMEOUT: 784
devstack_services:
cinder: true
@@ -131,8 +144,8 @@
timeout: 10000
vars:
devstack_localrc:
- Q_AGENT: linuxbridge
- NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details"
+ Q_AGENT: linuxbridge
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,filter-validation,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details
devstack_local_conf:
post-config:
$NEUTRON_CONF:
@@ -143,7 +156,7 @@
# NOTE(slaweq): We can get rid of this hardcoded absolute path when
# devstack-tempest job will be switched to use lib/neutron instead of
# lib/neutron-legacy
- "/$NEUTRON_CORE_PLUGIN_CONF":
+ /$NEUTRON_CORE_PLUGIN_CONF:
ml2:
type_drivers: flat,vlan,local,vxlan
test-config:
@@ -158,31 +171,141 @@
vars:
branch_override: stable/queens
devstack_localrc:
- NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details"
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details
+
+- job:
+ name: neutron-tempest-plugin-scenario-linuxbridge-rocky
+ parent: neutron-tempest-plugin-scenario-linuxbridge
+ override-checkout: stable/rocky
+ vars:
+ branch_override: stable/rocky
+ devstack_localrc:
+ NETWORK_API_EXTENSIONS: address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-domain-ports,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details
- job:
name: neutron-tempest-plugin-dvr-multinode-scenario
- parent: legacy-dsvm-base-multinode
- run: playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
- post-run: playbooks/neutron-tempest-plugin-dvr-multinode-scenario/post.yaml
- nodeset: legacy-ubuntu-xenial-2-node
- timeout: 10800
+ parent: tempest-multinode-full
+ description: |
+ Perform setup for Neutron tempest tests in multinode with DVR scenario
+ roles:
+ - zuul: openstack-dev/devstack
required-projects:
- openstack-infra/devstack-gate
- openstack/neutron
- openstack/neutron-tempest-plugin
- openstack/tempest
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^releasenotes/.*$
- - ^doc/.*$
- - ^setup.cfg$
- - ^.*\.rst$
- - ^neutron/locale/.*$
- - ^neutron/tests/unit/.*$
- - ^tools/.*$
- - ^tox.ini$
+ pre-run: playbooks/dvr-multinode-scenario-pre-run.yaml
voting: false
+ vars:
+ tempest_concurrency: 4
+ tox_envlist: all
+ tempest_test_regex: ^neutron_tempest_plugin\.scenario
+ devstack_localrc:
+ TEMPEST_PLUGINS: /opt/stack/neutron-tempest-plugin
+ NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-integration,dvr,empty-string-filtering,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,fip-port-details,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-segment,standard-attr-timestamp,standard-attr-tag,subnet_allocation,trunk,trunk-details"
+ PHYSICAL_NETWORK: default
+ DOWNLOAD_DEFAULT_IMAGES: false
+ IMAGE_URLS: "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img,http://cloud-images.ubuntu.com/releases/16.04/release-20180622/ubuntu-16.04-server-cloudimg-amd64-disk1.img"
+ DEFAULT_IMAGE_NAME: cirros-0.3.4-i386-disk
+ ADVANCED_IMAGE_NAME: ubuntu-16.04-server-cloudimg-amd64-disk1
+ ADVANCED_INSTANCE_TYPE: ds512M
+ ADVANCED_INSTANCE_USER: ubuntu
+ BUILD_TIMEOUT: 784
+ devstack_plugins:
+ neutron: git://git.openstack.org/openstack/neutron.git
+ neutron-tempest-plugin: git://git.openstack.org/openstack/neutron-tempest-plugin.git
+ devstack_services:
+ tls-proxy: false
+ tempest: true
+ neutron-dns: true
+ neutron-qos: true
+ neutron-segments: true
+ neutron-trunk: true
+ neutron-log: true
+ cinder: true
+ devstack_local_conf:
+ post-config:
+ $NEUTRON_CONF:
+ quotas:
+ quota_router: 100
+ quota_floatingip: 500
+ quota_security_group: 100
+ quota_security_group_rule: 1000
+ DEFAULT:
+ router_distributed: True
+ # NOTE(slaweq): We can get rid of this hardcoded absolute path when
+ # devstack-tempest job will be switched to use lib/neutron instead of
+ # lib/neutron-legacy
+ "/$NEUTRON_CORE_PLUGIN_CONF":
+ ml2:
+ type_drivers: flat,geneve,vlan,gre,local,vxlan
+ mechanism_drivers: openvswitch,l2population
+ ml2_type_vlan:
+ network_vlan_ranges: foo:1:10
+ ml2_type_vxlan:
+ vni_ranges: 1:2000
+ ml2_type_gre:
+ tunnel_id_ranges: 1:1000
+ agent:
+ enable_distributed_routing: True
+ l2_population: True
+ tunnel_types: vxlan,gre
+ ovs:
+ tunnel_bridge: br-tun
+ bridge_mappings: public:br-ex
+ $NEUTRON_L3_CONF:
+ DEFAULT:
+ agent_mode: dvr_snat
+ agent:
+ availability_zone: nova
+ $NEUTRON_DHCP_CONF:
+ agent:
+ availability_zone: nova
+ "/etc/neutron/api-paste.ini":
+ "composite:neutronapi_v2_0":
+ use: "call:neutron.auth:pipeline_factory"
+ noauth: "cors request_id catch_errors osprofiler extensions neutronapiapp_v2_0"
+ keystone: "cors request_id catch_errors osprofiler authtoken keystonecontext extensions neutronapiapp_v2_0"
+ test-config:
+ $TEMPEST_CONFIG:
+ neutron_plugin_options:
+ provider_vlans: foo,
+ agent_availability_zone: nova
+ image_is_advanced: true
+ available_type_drivers: flat,geneve,vlan,gre,local,vxlan
+ l3_agent_mode: dvr_snat
+ group-vars:
+ subnode:
+ devstack_services:
+ tls-proxy: false
+ q-agt: true
+ q-l3: true
+ q-meta: true
+ neutron-qos: true
+ neutron-trunk: true
+ neutron-log: true
+ devstack_local_conf:
+ post-config:
+ $NEUTRON_CONF:
+ DEFAULT:
+ router_distributed: True
+ # NOTE(slaweq): We can get rid of this hardcoded absolute path when
+ # devstack-tempest job will be switched to use lib/neutron instead of
+ # lib/neutron-legacy
+ "/$NEUTRON_CORE_PLUGIN_CONF":
+ agent:
+ enable_distributed_routing: True
+ l2_population: True
+ tunnel_types: vxlan,gre
+ ovs:
+ tunnel_bridge: br-tun
+ bridge_mappings: public:br-ex
+ $NEUTRON_L3_CONF:
+ DEFAULT:
+ agent_mode: dvr_snat
+ agent:
+ availability_zone: nova
+ irrelevant-files: *tempest-irrelevant-files
- job:
name: neutron-tempest-plugin-dvr-multinode-scenario-queens
@@ -192,6 +315,13 @@
branch_override: stable/queens
- job:
+ name: neutron-tempest-plugin-dvr-multinode-scenario-rocky
+ parent: neutron-tempest-plugin-dvr-multinode-scenario
+ override-checkout: stable/rocky
+ vars:
+ branch_override: stable/rocky
+
+- job:
name: neutron-tempest-plugin-designate-scenario
parent: neutron-tempest-plugin-scenario
description: Neutron designate integration scenario
@@ -202,19 +332,20 @@
timeout: 3600
vars:
devstack_localrc:
- TEMPEST_PLUGINS: '"/opt/stack/designate-tempest-plugin
- /opt/stack/neutron-tempest-plugin"'
+ TEMPEST_PLUGINS: '"/opt/stack/designate-tempest-plugin /opt/stack/neutron-tempest-plugin"'
DESIGNATE_BACKEND_DRIVER: bind9
+ DOWNLOAD_DEFAULT_IMAGES: false
+ IMAGE_URLS: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-i386-disk.img,
+ # In this job advanced image is not needed, so it's name should be
+ # empty
+ ADVANCED_IMAGE_NAME: ""
devstack_plugins:
designate: git://git.openstack.org/openstack/designate.git
devstack_services:
cinder: false
designate: true
tempest_test_regex: ^neutron_tempest_plugin\.scenario\.test_dns_integration
- irrelevant-files:
- - ^(test-|)requirements.txt$
- - ^releasenotes/.*$
- - ^setup.cfg$
+ irrelevant-files: *tempest-irrelevant-files
- job:
name: neutron-tempest-plugin-designate-scenario-queens
@@ -223,6 +354,13 @@
vars:
branch_override: stable/queens
+- job:
+ name: neutron-tempest-plugin-designate-scenario-rocky
+ parent: neutron-tempest-plugin-designate-scenario
+ override-checkout: stable/rocky
+ vars:
+ branch_override: stable/rocky
+
- project-template:
name: neutron-tempest-plugin-jobs
check:
@@ -250,7 +388,23 @@
jobs:
- neutron-tempest-plugin-api-queens
+- project-template:
+ name: neutron-tempest-plugin-jobs-rocky
+ check:
+ jobs:
+ - neutron-tempest-plugin-api-rocky
+ - neutron-tempest-plugin-designate-scenario-rocky
+ - neutron-tempest-plugin-dvr-multinode-scenario-rocky
+ - neutron-tempest-plugin-scenario-linuxbridge-rocky
+ gate:
+ jobs:
+ - neutron-tempest-plugin-api-rocky
+
- project:
templates:
- neutron-tempest-plugin-jobs
- neutron-tempest-plugin-jobs-queens
+ - neutron-tempest-plugin-jobs-rocky
+ - check-requirements
+ - tempest-plugin-jobs
+ - release-notes-jobs-python3
diff --git a/README.rst b/README.rst
index b3883b8..3d8a49b 100644
--- a/README.rst
+++ b/README.rst
@@ -10,3 +10,4 @@
* Documentation: https://docs.openstack.org/neutron/latest/
* Source: https://git.openstack.org/cgit/openstack/neutron-tempest-plugin
* Bugs: https://bugs.launchpad.net/neutron
+* Release notes: https://docs.openstack.org/releasenotes/neutron-tempest-plugin/
diff --git a/devstack/customize_image.sh b/devstack/customize_image.sh
new file mode 100644
index 0000000..669c761
--- /dev/null
+++ b/devstack/customize_image.sh
@@ -0,0 +1,158 @@
+# This script include functions that allow guest image files customization
+# before uploading them to OpenStack image service
+
+# ensure we don't re-source this in the same environment
+[[ -z "$_NEUTRON_TEMPEST_PLUGIN_CUSTOMIZE_IMAGE" ]] || return 0
+declare -r -g _NEUTRON_TEMPEST_PLUGIN_CUSTOMIZE_IMAGE=1
+
+source "${NEUTRON_TEMPEST_PLUGIN_DIR}/functions.sh"
+
+# By default enable guest image customization. It will be automatically skipped
+# for cirros images
+CUSTOMIZE_IMAGE=${CUSTOMIZE_IMAGE:-True}
+
+# Image customization is performed using virt-customize
+# using direct backend by default
+LIBGUESTFS_BACKEND=${LIBGUESTFS_BACKEND:-direct}
+
+# Disable KVM hardware accelleration by default
+LIBGUESTFS_BACKEND_SETTINGS=${LIBGUESTFS_BACKEND_SETTINGS:-force_tcg}
+
+# Install tools required for customizing guest image files
+function install_customize_image_tools {
+ local do_customize=$(trueorfalse True CUSTOMIZE_IMAGE)
+ if [ ${do_customize} == True ]; then
+ # Make sure virt-customize is installed
+ install_package libguestfs-tools
+ fi
+}
+
+# Wraps upload_image function to eventually customize image file before
+# uploading it via "openstack image create" command
+save_function upload_image overridden_upload_image
+function upload_image {
+ local image_url=$1
+
+ # Fork a subshell to have environment restored at the end of this function
+ (
+ # Check user configuration
+ local customize_image=$(trueorfalse True CUSTOMIZE_IMAGE)
+ if [ ${customize_image} == True ]; then
+ # Temporarly wraps openstack command with openstack_image_create
+ # function
+ function openstack {
+ IMAGE_URL=${image_url} upload_custom_image "$@"
+ }
+ fi
+
+ # Execute original upload_image function
+ overridden_upload_image "$@"
+ )
+}
+
+# Wraps "openstack image create" command to customize image file before
+# uploading it to OpenstackImage service.
+# Called only when ${CUSTOMIZE_IMAGE} is True
+function upload_custom_image {
+ # Copy command arguments for later use
+ local args=( "$@" )
+
+ # Look for image create sub-command:
+ # skip any argument before "image" and "create" words
+ local i=0
+ local subcommands=()
+ for subcommand in image create; do
+ for (( ; i < ${#args[@]}; )) {
+ local arg=${args[i]}
+ (( ++i ))
+ if [ "${arg}" == "${subcommand}" ]; then
+ subcommands+=( "${arg}" )
+ break
+ fi
+ }
+ done
+
+ if [ "${subcommands[*]}" == "image create" ]; then
+ # create image subcommand has been detected
+
+ # Put here temporary files to be delete before exiting from this
+ # function
+ local temp_dir=$(mktemp -d)
+ chmod 777 "${temp_dir}"
+
+ # Parse openstack image create subcommand arguments
+ local image_url="${IMAGE_URL}"
+ local image_file=
+ local disk_format=auto
+ local container_format=bare
+
+ for (( ; i < ${#args[@]}; )) {
+ local arg=${args[$i]}
+ (( ++i ))
+
+ if [[ "${arg}" == --* ]]; then
+ # Handle --<option_name>=<option_value> syntax
+ local option_fields=(${arg//=/ })
+ local option_name=${option_fields[0]}
+ local option_value=${option_fields[1]:-}
+
+ case "${option_name}" in
+
+ --container-format) # Found container format
+ container_format=${option_value:-${args[ (( i++ )) ]}}
+ ;;
+
+ --disk-format) # Found disk format
+ disk_format=${option_value:-${args[ (( i++ )) ]}}
+ ;;
+
+ --file) # Found image file name
+ image_file=${option_value:-${args[ (( i++ )) ]}}
+ ;;
+ esac
+ fi
+ }
+
+ if [ "${image_file}" == "" ]; then
+ # Copy image file from stdin to a temporary file
+ image_file=${temp_dir}/$(basename "${image_url}")
+ cat > "${image_file}"
+
+ # Add option to load image from file
+ args+=( --file "${image_file}" )
+ fi
+
+ # Make image file readable and writable by qemu user
+ sudo chmod 666 "${image_file}"
+
+ # Customize image file
+ TEMP_DIR=${temp_dir} \
+ DISK_FORMAT=${disk_format} \
+ customize_image "${image_file}"
+ fi
+
+ # Upload custom image file
+ overridden_openstack "${args[@]}" || local error=$?
+
+ # Finally delete temporary files
+ sudo rm -fR "${temp_dir}" || true
+
+ return ${error:-0}
+}
+
+function overridden_openstack {
+ "$(which openstack)" "$@"
+}
+
+# Execute customization commands on a VM with attached guest image file.
+# Called only when ${CUSTOMIZE_IMAGE} is True
+function customize_image {
+ local image_file=$1
+ local top_dir=$(dirname "${NEUTRON_TEMPEST_PLUGIN_DIR}")
+ (
+ export TEMP_DIR DISK_FORMAT RC_DIR
+ if [[ "$(basename ${image_file})" == ubuntu-* ]]; then
+ "${top_dir}/tools/customize_ubuntu_image" "${image_file}"
+ fi
+ )
+}
diff --git a/devstack/functions.sh b/devstack/functions.sh
new file mode 100644
index 0000000..8d8a4bf
--- /dev/null
+++ b/devstack/functions.sh
@@ -0,0 +1,87 @@
+# Generic use functions
+
+# ensure we don't re-source this in the same environment
+[[ -z "$_NEUTRON_TEMPEST_PLUGIN_FUNCTIONS" ]] || return 0
+declare -r -g _NEUTRON_TEMPEST_PLUGIN_FUNCTIONS=1
+
+# Create a function copying the code from an existing one
+function save_function {
+ local old_name=$1
+ local new_name=$2
+
+ # Saving the same function again after redefining it could produce a
+ # recorsive function in case for example this plugin is sourced twice
+ if type -t "${new_name}"; then
+ # Prevent copying the same function twice
+ return 0
+ fi
+
+ # Save xtrace setting
+ _XTRACE_FUNCTIONS=$(set +o | grep xtrace)
+ set +o xtrace
+
+ # Get code of the original function
+ local old_code=$(declare -f ${old_name})
+ # Produce code for the new function
+ local new_code="${new_name}${old_code#${old_name}}"
+ # Define the new function
+ eval "${new_code}"
+
+ # Restore xtrace
+ $_XTRACE_FUNCTIONS
+}
+
+#Add advanced image config to tempest.conf
+function configure_advanced_image {
+ local advanced_image_uuid
+
+ if ! is_service_enabled glance; then
+ # if glance is not enabled, there is no image for to configure
+ return 0
+ fi
+
+ if [[ -z "$ADVANCED_IMAGE_NAME" ]]; then
+ # if name of advanced image is not provided, there is no image to
+ # configure
+ return 0
+ fi
+
+ while read -r IMAGE_NAME IMAGE_UUID; do
+ if [ "$IMAGE_NAME" = "$ADVANCED_IMAGE_NAME" ]; then
+ advanced_image_uuid="$IMAGE_UUID"
+ break
+ fi
+ done < <(openstack image list --property status=active | awk -F'|' '!/^(+--)|ID|aki|ari/ { print $3,$2 }')
+
+ if [[ -z "$advanced_image_uuid" ]]; then
+ echo "No image with name $ADVANCED_IMAGE_NAME found."
+ return 1
+ fi
+
+ iniset $TEMPEST_CONFIG neutron_plugin_options advanced_image_ref $advanced_image_uuid
+ iniset $TEMPEST_CONFIG neutron_plugin_options advanced_image_ssh_user $ADVANCED_INSTANCE_USER
+}
+
+
+function configure_flavor_for_advanced_image {
+ local flavor_ref
+
+ if ! is_service_enabled nova; then
+ # if nova is not enabled, there is no flavor to configure
+ return 0
+ fi
+
+ if [[ -z "$ADVANCED_INSTANCE_TYPE" ]]; then
+ # if name of flavor for advanced image is not provided, there is no
+ # flavor to configure
+ return 0
+ fi
+
+ flavor_ref=$(openstack flavor show $ADVANCED_INSTANCE_TYPE -f value -c id)
+ if [[ -z "$flavor_ref" ]]; then
+ echo "Found no valid flavors to use for $ADVANCED_IMAGE_NAME !"
+ echo "Fallback to use $DEFAULT_INSTANCE_TYPE"
+ flavor_ref=$(iniget $TEMPEST_CONFIG compute flavor_ref)
+ fi
+ iniset $TEMPEST_CONFIG neutron_plugin_options advanced_image_flavor_ref $flavor_ref
+}
diff --git a/devstack/plugin.sh b/devstack/plugin.sh
index a2009ea..25cfba6 100644
--- a/devstack/plugin.sh
+++ b/devstack/plugin.sh
@@ -1,6 +1,12 @@
+# Directory where this plugin.sh file is
+NEUTRON_TEMPEST_PLUGIN_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+
+source "${NEUTRON_TEMPEST_PLUGIN_DIR}/customize_image.sh"
+
# install_neutron_tempest_plugin
function install_neutron_tempest_plugin {
setup_dev_lib "neutron-tempest-plugin"
+ install_customize_image_tools
}
if [[ "$1" == "stack" ]]; then
@@ -9,5 +15,9 @@
echo_summary "Installing neutron-tempest-plugin"
install_neutron_tempest_plugin
;;
+ test-config)
+ echo_summary "Configuring neutron-tempest-plugin tempest options"
+ configure_advanced_image
+ configure_flavor_for_advanced_image
esac
fi
diff --git a/devstack/settings b/devstack/settings
index 614376f..6804a47 100644
--- a/devstack/settings
+++ b/devstack/settings
@@ -1,3 +1,7 @@
GITREPO["neutron-tempest-plugin"]=${NEUTRON_TEMPEST_REPO:-${GIT_BASE}/openstack/neutron-tempest-plugin.git}
GITDIR["neutron-tempest-plugin"]=$DEST/neutron-tempest-plugin
GITBRANCH["neutron-tempest-plugin"]=master
+
+ADVANCED_IMAGE_NAME=${ADVANCED_IMAGE_NAME:-""}
+ADVANCED_INSTANCE_TYPE=${ADVANCED_INSTANCE_TYPE:-$DEFAULT_INSTANCE_TYPE}
+ADVANCED_INSTANCE_USER=${ADVANCED_INSTANCE_USER:-$DEFAULT_INSTANCE_USER}
diff --git a/neutron_tempest_plugin/api/admin/test_agent_availability_zone.py b/neutron_tempest_plugin/api/admin/test_agent_availability_zone.py
index 245715f..c69c63d 100644
--- a/neutron_tempest_plugin/api/admin/test_agent_availability_zone.py
+++ b/neutron_tempest_plugin/api/admin/test_agent_availability_zone.py
@@ -40,9 +40,10 @@
@testtools.skipUnless(CONF.neutron_plugin_options.agent_availability_zone,
"Need a single availability_zone assumption.")
def test_agents_availability_zone(self):
- """
- Test list agents availability_zone, only L3 and DHCP agent support
- availability_zone, default availability_zone is "nova".
+ """Test list agents availability_zone
+
+ Only L3 and DHCP agent support availability_zone, default
+ availability_zone is "nova".
"""
body = self.admin_client.list_agents()
agents = body['agents']
diff --git a/neutron_tempest_plugin/api/admin/test_agent_management.py b/neutron_tempest_plugin/api/admin/test_agent_management.py
index 72cba62..ad0368a 100644
--- a/neutron_tempest_plugin/api/admin/test_agent_management.py
+++ b/neutron_tempest_plugin/api/admin/test_agent_management.py
@@ -81,9 +81,7 @@
self.assertEqual(updated_description, description)
def _restore_agent(self, dyn_agent):
- """
- Restore the agent description after update test.
- """
+ """Restore the agent description after update test."""
description = dyn_agent['description']
origin_agent = {'description': description}
self.admin_client.update_agent(agent_id=dyn_agent['id'],
diff --git a/neutron_tempest_plugin/api/admin/test_external_network_extension.py b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
index cd4635c..a713492 100644
--- a/neutron_tempest_plugin/api/admin/test_external_network_extension.py
+++ b/neutron_tempest_plugin/api/admin/test_external_network_extension.py
@@ -162,14 +162,12 @@
target_tenant=self.admin_client.tenant_id)
self.create_subnet(net, client=self.admin_client, enable_dhcp=False)
with testtools.ExpectedException(lib_exc.NotFound):
- self.client2.create_floatingip(
- floating_network_id=net['id'])
+ self.create_floatingip(net['id'], client=self.client2)
self.admin_client.create_rbac_policy(
object_type='network', object_id=net['id'],
action='access_as_external',
target_tenant=self.client2.tenant_id)
- self.client2.create_floatingip(
- floating_network_id=net['id'])
+ self.create_floatingip(net['id'], client=self.client2)
@decorators.idempotent_id('476be1e0-f72e-47dc-9a14-4435926bbe82')
def test_policy_allows_tenant_to_attach_ext_gw(self):
diff --git a/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py b/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
index 3607060..1efe516 100644
--- a/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
+++ b/neutron_tempest_plugin/api/admin/test_floating_ips_admin_actions.py
@@ -32,7 +32,7 @@
def resource_setup(cls):
super(FloatingIPAdminTestJSON, cls).resource_setup()
cls.ext_net_id = CONF.network.public_network_id
- cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
+ cls.floating_ip = cls.create_floatingip()
cls.alt_client = cls.os_alt.network_client
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
@@ -44,10 +44,7 @@
@decorators.attr(type='negative')
@decorators.idempotent_id('11116ee9-4e99-5b15-b8e1-aa7df92ca589')
def test_associate_floating_ip_with_port_from_another_project(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
+ floating_ip = self.create_floatingip()
project_id = self.create_project()['id']
port = self.admin_client.create_port(network_id=self.network['id'],
@@ -65,20 +62,17 @@
# other tests may end up stealing the IP before we can use it
# since it's on the external network so we need to retry if it's
# in use.
- for i in range(100):
+ for _ in range(100):
fip = self.get_unused_ip(self.ext_net_id, ip_version=4)
try:
- body = self.admin_client.create_floatingip(
- floating_network_id=self.ext_net_id,
- floating_ip_address=fip)
+ created_floating_ip = self.create_floatingip(
+ floating_ip_address=fip,
+ client=self.admin_client)
break
except lib_exc.Conflict:
pass
else:
self.fail("Could not get an unused IP after 100 attempts")
- created_floating_ip = body['floatingip']
- self.addCleanup(self.admin_client.delete_floatingip,
- created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
self.assertEqual(created_floating_ip['floating_ip_address'], fip)
diff --git a/neutron_tempest_plugin/api/admin/test_quotas_negative.py b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
index 7d699d1..cd64e5c 100644
--- a/neutron_tempest_plugin/api/admin/test_quotas_negative.py
+++ b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
@@ -167,11 +167,7 @@
new_quotas = {'floatingip': 1}
self._setup_quotas(tenant_id, **new_quotas)
- ext_net_id = CONF.network.public_network_id
- fip_args = {'tenant_id': tenant_id,
- 'floating_network_id': ext_net_id}
- fip = self.admin_client.create_floatingip(**fip_args)['floatingip']
- self.addCleanup(self.admin_client.delete_floatingip, fip['id'])
+ self.create_floatingip(client=self.admin_client, tenant_id=tenant_id)
- self.assertRaises(lib_exc.Conflict,
- self.admin_client.create_floatingip, **fip_args)
+ self.assertRaises(lib_exc.Conflict, self.create_floatingip,
+ client=self.admin_client, tenant_id=tenant_id)
diff --git a/neutron_tempest_plugin/api/admin/test_routers_dvr.py b/neutron_tempest_plugin/api/admin/test_routers_dvr.py
index 644bc38..8d80ba6 100644
--- a/neutron_tempest_plugin/api/admin/test_routers_dvr.py
+++ b/neutron_tempest_plugin/api/admin/test_routers_dvr.py
@@ -44,7 +44,8 @@
@decorators.idempotent_id('08a2a0a8-f1e4-4b34-8e30-e522e836c44e')
def test_distributed_router_creation(self):
- """
+ """Test distributed router creation
+
Test uses administrative credentials to creates a
DVR (Distributed Virtual Routing) router using the
distributed=True.
@@ -61,7 +62,8 @@
@decorators.idempotent_id('8a0a72b4-7290-4677-afeb-b4ffe37bc352')
def test_centralized_router_creation(self):
- """
+ """Test centralized router creation
+
Test uses administrative credentials to creates a
CVR (Centralized Virtual Routing) router using the
distributed=False.
@@ -84,7 +86,8 @@
@decorators.idempotent_id('acd43596-c1fb-439d-ada8-31ad48ae3c2e')
def test_centralized_router_update_to_dvr(self):
- """
+ """Test centralized to DVR router update
+
Test uses administrative credentials to creates a
CVR (Centralized Virtual Routing) router using the
distributed=False.Then it will "update" the router
diff --git a/neutron_tempest_plugin/api/admin/test_routers_ha.py b/neutron_tempest_plugin/api/admin/test_routers_ha.py
index b8227bd..b717a10 100644
--- a/neutron_tempest_plugin/api/admin/test_routers_ha.py
+++ b/neutron_tempest_plugin/api/admin/test_routers_ha.py
@@ -40,7 +40,8 @@
@decorators.idempotent_id('8abc177d-14f1-4018-9f01-589b299cbee1')
def test_ha_router_creation(self):
- """
+ """Test HA router creation
+
Test uses administrative credentials to create a
HA (High Availability) router using the ha=True.
@@ -53,7 +54,8 @@
@decorators.idempotent_id('97b5f7ef-2192-4fa3-901e-979cd5c1097a')
def test_legacy_router_creation(self):
- """
+ """Test legacy router creation
+
Test uses administrative credentials to create a
SF (Single Failure) router using the ha=False.
@@ -63,12 +65,13 @@
as opposed to a "High Availability Router"
"""
name = data_utils.rand_name('router')
- router = self.create_admin_router(name, ha=False)
+ router = self._create_admin_router(name, ha=False)
self.assertFalse(router['ha'])
@decorators.idempotent_id('5a6bfe82-5b23-45a4-b027-5160997d4753')
def test_legacy_router_update_to_ha(self):
- """
+ """Test legacy to HA router update
+
Test uses administrative credentials to create a
SF (Single Failure) router using the ha=False.
Then it will "update" the router ha attribute to True
diff --git a/neutron_tempest_plugin/api/admin/test_tag.py b/neutron_tempest_plugin/api/admin/test_tag.py
index 05db644..fdcb6a1 100644
--- a/neutron_tempest_plugin/api/admin/test_tag.py
+++ b/neutron_tempest_plugin/api/admin/test_tag.py
@@ -15,7 +15,6 @@
from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.api import base
-from neutron_tempest_plugin import config
class TagTestJSON(base.BaseAdminNetworkTest):
@@ -177,9 +176,7 @@
@classmethod
@utils.requires_ext(extension="router", service="network")
def _create_resource(cls):
- cls.ext_net_id = config.CONF.network.public_network_id
- floatingip = cls.create_floatingip(cls.ext_net_id)
- return floatingip['id']
+ return cls.create_floatingip()['id']
@decorators.attr(type='smoke')
@decorators.idempotent_id('53f6c2bf-e272-4e9e-b9a9-b165eb7be807')
@@ -212,13 +209,7 @@
def _create_resource(cls):
network = cls.create_network()
parent_port = cls.create_port(network)
- trunk = cls.client.create_trunk(parent_port['id'], None)
- return trunk['trunk']['id']
-
- @classmethod
- def resource_cleanup(cls):
- cls.client.delete_trunk(cls.res_id)
- super(TagTrunkTestJSON, cls).resource_cleanup()
+ return cls.create_trunk(parent_port)['id']
@decorators.attr(type='smoke')
@decorators.idempotent_id('4c63708b-c4c3-407c-8101-7a9593882f5f')
@@ -424,9 +415,7 @@
@classmethod
@utils.requires_ext(extension="router", service="network")
def _create_resource(cls):
- cls.ext_net_id = config.CONF.network.public_network_id
- floatingip = cls.create_floatingip(cls.ext_net_id)
- return floatingip['id']
+ return cls.create_floatingip()['id']
def _list_resource(self, filters):
res = self.client.list_floatingips(**filters)
@@ -467,14 +456,7 @@
def _create_resource(cls):
network = cls.create_network()
parent_port = cls.create_port(network)
- trunk = cls.client.create_trunk(parent_port['id'], None)
- return trunk['trunk']['id']
-
- @classmethod
- def resource_cleanup(cls):
- for res_id in cls.res_ids:
- cls.client.delete_trunk(res_id)
- super(TagFilterTrunkTestJSON, cls).resource_cleanup()
+ return cls.create_trunk(parent_port)['id']
def _list_resource(self, filters):
res = self.client.list_trunks(**filters)
diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py
index 966b30d..c4bc71d 100644
--- a/neutron_tempest_plugin/api/base.py
+++ b/neutron_tempest_plugin/api/base.py
@@ -34,8 +34,7 @@
class BaseNetworkTest(test.BaseTestCase):
- """
- Base class for the Neutron tests that use the Tempest Neutron REST client
+ """Base class for Neutron tests that use the Tempest Neutron REST client
Per the Neutron API Guide, API v1.x was removed from the source code tree
(docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html)
@@ -63,6 +62,8 @@
# Derive from BaseAdminNetworkTest class to have this initialized
admin_client = None
+ external_network_id = CONF.network.public_network_id
+
@classmethod
def get_client_manager(cls, credential_type=None, roles=None,
force_new=None):
@@ -124,6 +125,7 @@
cls.subnetpools = []
cls.admin_subnetpools = []
cls.security_groups = []
+ cls.admin_security_groups = []
cls.projects = []
cls.log_objects = []
cls.reserved_subnet_cidrs = set()
@@ -139,8 +141,8 @@
# Clean up floating IPs
for floating_ip in cls.floating_ips:
- cls._try_delete_resource(cls.client.delete_floatingip,
- floating_ip['id'])
+ cls._try_delete_resource(cls.delete_floatingip, floating_ip)
+
# Clean up routers
for router in cls.routers:
cls._try_delete_resource(cls.delete_router,
@@ -191,6 +193,12 @@
cls._try_delete_resource(cls.client.delete_security_group,
secgroup['id'])
+ # Clean up admin security groups
+ for secgroup in cls.admin_security_groups:
+ cls._try_delete_resource(
+ cls.admin_client.delete_security_group,
+ secgroup['id'])
+
for subnetpool in cls.subnetpools:
cls._try_delete_resource(cls.client.delete_subnetpool,
subnetpool['id'])
@@ -577,15 +585,56 @@
*args, **kwargs)
@classmethod
- def create_floatingip(cls, external_network_id):
- """Wrapper utility that returns a test floating IP."""
- body = cls.client.create_floatingip(
- floating_network_id=external_network_id)
- fip = body['floatingip']
+ def create_floatingip(cls, external_network_id=None, port=None,
+ client=None, **kwargs):
+ """Creates a floating IP.
+
+ Create a floating IP and schedule it for later deletion.
+ If a client is passed, then it is used for deleting the IP too.
+
+ :param external_network_id: network ID where to create
+ By default this is 'CONF.network.public_network_id'.
+
+ :param port: port to bind floating IP to
+ This is translated to 'port_id=port['id']'
+ By default it is None.
+
+ :param client: network client to be used for creating and cleaning up
+ the floating IP.
+
+ :param **kwargs: additional creation parameters to be forwarded to
+ networking server.
+ """
+
+ client = client or cls.client
+ external_network_id = (external_network_id or
+ cls.external_network_id)
+
+ if port:
+ kwargs['port_id'] = port['id']
+
+ fip = client.create_floatingip(external_network_id,
+ **kwargs)['floatingip']
+
+ # save client to be used later in cls.delete_floatingip
+ # for final cleanup
+ fip['client'] = client
cls.floating_ips.append(fip)
return fip
@classmethod
+ def delete_floatingip(cls, floating_ip, client=None):
+ """Delete floating IP
+
+ :param client: Client to be used
+ If client is not given it will use the client used to create
+ the floating IP, or cls.client if unknown.
+ """
+
+ client = client or floating_ip.get('client') or cls.client
+ client.delete_floatingip(floating_ip['id'])
+
+ @classmethod
def create_router_interface(cls, router_id, subnet_id):
"""Wrapper utility that returns a router interface."""
interface = cls.client.add_router_interface_with_subnet_id(
@@ -660,6 +709,12 @@
name=test_project,
description=test_description)['project']
cls.projects.append(project)
+ # Create a project will create a default security group.
+ # We make these security groups into admin_security_groups.
+ sgs_list = cls.admin_client.list_security_groups(
+ tenant_id=project['id'])['security_groups']
+ for sg in sgs_list:
+ cls.admin_security_groups.append(sg)
return project
@classmethod
@@ -1124,11 +1179,14 @@
expected_resources[:-1],
self._extract_resources(body))
- def _test_list_validation_filters(self):
- validation_args = {
- 'unknown_filter': 'value',
- }
- body = self.list_method(**validation_args)
- resources = self._extract_resources(body)
- for resource in resources:
- self.assertIn(resource['name'], self.resource_names)
+ @tutils.requires_ext(extension="filter-validation", service="network")
+ def _test_list_validation_filters(
+ self, validation_args, filter_is_valid=True):
+ if not filter_is_valid:
+ self.assertRaises(lib_exc.BadRequest, self.list_method,
+ **validation_args)
+ else:
+ body = self.list_method(**validation_args)
+ resources = self._extract_resources(body)
+ for resource in resources:
+ self.assertIn(resource['name'], self.resource_names)
diff --git a/neutron_tempest_plugin/api/clients.py b/neutron_tempest_plugin/api/clients.py
index ee0289c..407e694 100644
--- a/neutron_tempest_plugin/api/clients.py
+++ b/neutron_tempest_plugin/api/clients.py
@@ -29,9 +29,7 @@
class Manager(manager.Manager):
- """
- Top level manager for OpenStack tempest clients
- """
+ """Top level manager for OpenStack tempest clients"""
default_params = {
'disable_ssl_certificate_validation':
CONF.identity.disable_ssl_certificate_validation,
diff --git a/neutron_tempest_plugin/api/test_allowed_address_pair.py b/neutron_tempest_plugin/api/test_allowed_address_pair.py
index f34cc5b..0137ff2 100644
--- a/neutron_tempest_plugin/api/test_allowed_address_pair.py
+++ b/neutron_tempest_plugin/api/test_allowed_address_pair.py
@@ -20,7 +20,8 @@
class AllowedAddressPairTestJSON(base.BaseNetworkTest):
- """
+ """AllowedAddressPairTestJSON class
+
Tests the Neutron Allowed Address Pair API extension using the Tempest
REST client. The following API operations are tested with this extension:
diff --git a/neutron_tempest_plugin/api/test_auto_allocated_topology.py b/neutron_tempest_plugin/api/test_auto_allocated_topology.py
index 0baa2a8..4d70bfc 100644
--- a/neutron_tempest_plugin/api/test_auto_allocated_topology.py
+++ b/neutron_tempest_plugin/api/test_auto_allocated_topology.py
@@ -21,8 +21,8 @@
class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
+ """Tests Get-Me-A-Network
- """
Tests the Get-Me-A-Network operations in the Neutron API
using the REST client for Neutron.
"""
diff --git a/neutron_tempest_plugin/api/test_dhcp_ipv6.py b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
index 0fab75c..4f2e576 100644
--- a/neutron_tempest_plugin/api/test_dhcp_ipv6.py
+++ b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
@@ -82,7 +82,9 @@
@decorators.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af')
def test_dhcp_stateful_fixedips_outrange(self):
- """When port gets IP address from fixed IP range it
+ """Test DHCP Stateful fixed IPs out of range
+
+ When port gets IP address from fixed IP range it
shall be checked if it's from subnets range.
"""
kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful',
diff --git a/neutron_tempest_plugin/api/test_extra_dhcp_options.py b/neutron_tempest_plugin/api/test_extra_dhcp_options.py
index e5f73b2..cb4dba8 100644
--- a/neutron_tempest_plugin/api/test_extra_dhcp_options.py
+++ b/neutron_tempest_plugin/api/test_extra_dhcp_options.py
@@ -20,8 +20,8 @@
class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest):
+ """Test Extra DHCP Options
- """
Tests the following operations with the Extra DHCP Options Neutron API
extension:
diff --git a/neutron_tempest_plugin/api/test_flavors_extensions.py b/neutron_tempest_plugin/api/test_flavors_extensions.py
index 30f1eb6..42eb7b1 100644
--- a/neutron_tempest_plugin/api/test_flavors_extensions.py
+++ b/neutron_tempest_plugin/api/test_flavors_extensions.py
@@ -19,8 +19,8 @@
class TestFlavorsJson(base.BaseAdminNetworkTest):
+ """Test Flavors
- """
Tests the following operations in the Neutron API using the REST client for
Neutron:
diff --git a/neutron_tempest_plugin/api/test_floating_ips.py b/neutron_tempest_plugin/api/test_floating_ips.py
index 9f5778f..ea3d22e 100644
--- a/neutron_tempest_plugin/api/test_floating_ips.py
+++ b/neutron_tempest_plugin/api/test_floating_ips.py
@@ -48,11 +48,7 @@
# originally the floating IP had no attributes other than its
# association, so an update with an empty body was a signal to
# clear the association. This test ensures we maintain that behavior.
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0])
self.assertEqual(self.ports[0]['id'], body['port_id'])
body = self.client.update_floatingip(body['id'])['floatingip']
self.assertFalse(body['port_id'])
@@ -61,12 +57,7 @@
@utils.requires_ext(extension="standard-attr-description",
service="network")
def test_create_update_floatingip_description(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0], description='d1')
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual('d1', body['description'])
@@ -84,12 +75,7 @@
service="network")
def test_floatingip_update_extra_attributes_port_id_not_changed(self):
port_id = self.ports[1]['id']
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=port_id,
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port_id=port_id, description='d1')
self.assertEqual('d1', body['description'])
body = self.client.show_floatingip(body['id'])['floatingip']
self.assertEqual(port_id, body['port_id'])
@@ -112,12 +98,7 @@
@utils.requires_ext(extension="fip-port-details", service="network")
def test_create_update_floatingip_port_details(self):
- body = self.client.create_floatingip(
- floating_network_id=self.ext_net_id,
- port_id=self.ports[0]['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=self.ports[0], description='d1')
self._assert_port_details(self.ports[0], body)
body = self.client.show_floatingip(body['id'])['floatingip']
self._assert_port_details(self.ports[0], body)
diff --git a/neutron_tempest_plugin/api/test_floating_ips_negative.py b/neutron_tempest_plugin/api/test_floating_ips_negative.py
index 453af71..c8b8cb4 100644
--- a/neutron_tempest_plugin/api/test_floating_ips_negative.py
+++ b/neutron_tempest_plugin/api/test_floating_ips_negative.py
@@ -53,14 +53,8 @@
self.addCleanup(self.client.update_router, self.router['id'],
external_gateway_info={})
port = self.create_port(net)
- body1 = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip1 = body1['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip1['id'])
- body2 = self.client.create_floatingip(
- floating_network_id=self.ext_net_id)
- floating_ip2 = body2['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip2['id'])
+ floating_ip1 = self.create_floatingip()
+ floating_ip2 = self.create_floatingip()
self.client.update_floatingip(floating_ip1['id'],
port_id=port['id'])
self.assertRaises(lib_exc.Conflict, self.client.update_floatingip,
diff --git a/neutron_tempest_plugin/api/test_metering_extensions.py b/neutron_tempest_plugin/api/test_metering_extensions.py
index 745a8d0..ceeb2b6 100644
--- a/neutron_tempest_plugin/api/test_metering_extensions.py
+++ b/neutron_tempest_plugin/api/test_metering_extensions.py
@@ -23,8 +23,8 @@
class MeteringTestJSON(base.BaseAdminNetworkTest):
+ """Test Metering
- """
Tests the following operations in the Neutron API using the REST client for
Neutron:
diff --git a/neutron_tempest_plugin/api/test_network_ip_availability.py b/neutron_tempest_plugin/api/test_network_ip_availability.py
index 10aee2e..1cdfc7e 100644
--- a/neutron_tempest_plugin/api/test_network_ip_availability.py
+++ b/neutron_tempest_plugin/api/test_network_ip_availability.py
@@ -37,8 +37,8 @@
class NetworksIpAvailabilityTest(base.BaseAdminNetworkTest):
+ """Tests Networks IP Availability
- """
Tests the following operations in the Neutron API using the REST client for
Neutron:
diff --git a/neutron_tempest_plugin/api/test_networks.py b/neutron_tempest_plugin/api/test_networks.py
index c4b3596..f9d52ba 100644
--- a/neutron_tempest_plugin/api/test_networks.py
+++ b/neutron_tempest_plugin/api/test_networks.py
@@ -22,8 +22,8 @@
class NetworksTestJSON(base.BaseNetworkTest):
+ """Test Networks
- """
Tests the following operations in the Neutron API using the REST client for
Neutron:
@@ -209,7 +209,8 @@
def test_list_no_pagination_limit_0(self):
self._test_list_no_pagination_limit_0()
- @decorators.skip_because(bug="1749820")
@decorators.idempotent_id('3574ec9b-a8b8-43e3-9c11-98f5875df6a9')
def test_list_validation_filters(self):
- self._test_list_validation_filters()
+ self._test_list_validation_filters(self.list_kwargs)
+ self._test_list_validation_filters({
+ 'unknown_filter': 'value'}, filter_is_valid=False)
diff --git a/neutron_tempest_plugin/api/test_qos.py b/neutron_tempest_plugin/api/test_qos.py
index 2bf99bf..1b88a7a 100644
--- a/neutron_tempest_plugin/api/test_qos.py
+++ b/neutron_tempest_plugin/api/test_qos.py
@@ -1053,17 +1053,6 @@
policy_id=policy['id'],
direction=self.DIRECTION_EGRESS, min_kbps=201)
- @decorators.idempotent_id('d6fce764-e511-4fa6-9f86-f4b41cf142cf')
- def test_rule_create_fail_for_direction_ingress(self):
- policy = self.create_qos_policy(name='test-policy',
- description='test policy',
- shared=False)
- self.assertRaises(exceptions.BadRequest,
- self.admin_client.create_minimum_bandwidth_rule,
- policy_id=policy['id'],
- direction=self.DIRECTION_INGRESS,
- min_kbps=201)
-
@decorators.idempotent_id('a49a6988-2568-47d2-931e-2dbc858943b3')
def test_rule_update(self):
policy = self.create_qos_policy(name='test-policy',
diff --git a/neutron_tempest_plugin/api/test_revisions.py b/neutron_tempest_plugin/api/test_revisions.py
index eb32560..b03285d 100644
--- a/neutron_tempest_plugin/api/test_revisions.py
+++ b/neutron_tempest_plugin/api/test_revisions.py
@@ -309,7 +309,7 @@
@decorators.idempotent_id('9de71ebc-f5df-4cd0-80bc-60299fce3ce9')
@utils.requires_ext(extension="router", service="network")
@utils.requires_ext(extension="standard-attr-description",
- service="network")
+ service="network")
def test_update_floatingip_bumps_revision(self):
ext_id = config.CONF.network.public_network_id
net = self.create_network()
@@ -325,12 +325,7 @@
subnet['id'])
port = self.create_port(net)
self.addCleanup(self.client.delete_port, port['id'])
- body = self.client.create_floatingip(
- floating_network_id=ext_id,
- port_id=port['id'],
- description='d1'
- )['floatingip']
- self.floating_ips.append(body)
+ body = self.create_floatingip(port=port, description='d1')
self.assertIn('revision_number', body)
b2 = self.client.update_floatingip(body['id'], description='d2')
self.assertGreater(b2['floatingip']['revision_number'],
diff --git a/neutron_tempest_plugin/api/test_subnetpools.py b/neutron_tempest_plugin/api/test_subnetpools.py
index 8adbc4c..9d927cf 100644
--- a/neutron_tempest_plugin/api/test_subnetpools.py
+++ b/neutron_tempest_plugin/api/test_subnetpools.py
@@ -58,7 +58,8 @@
new_prefix = u'10.11.15.0/24'
larger_prefix = u'10.11.0.0/16'
- """
+ """Test Subnet Pools
+
Tests the following operations in the Neutron API using the REST client for
Neutron:
@@ -327,9 +328,7 @@
@decorators.idempotent_id('4c6963c2-f54c-4347-b288-75d18421c4c4')
@utils.requires_ext(extension='default-subnetpools', service='network')
def test_tenant_create_non_default_subnetpool(self):
- """
- Test creates a subnetpool, the "is_default" attribute is False.
- """
+ """Test creates a subnetpool, the "is_default" attribute is False."""
created_subnetpool = self._create_subnetpool()
self.assertFalse(created_subnetpool['is_default'])
@@ -414,7 +413,8 @@
def test_list_no_pagination_limit_0(self):
self._test_list_no_pagination_limit_0()
- @decorators.skip_because(bug="1749820")
@decorators.idempotent_id('27feb3f8-40f4-4e50-8cd2-7d0096a98682')
def test_list_validation_filters(self):
- self._test_list_validation_filters()
+ self._test_list_validation_filters(self.list_kwargs)
+ self._test_list_validation_filters({
+ 'unknown_filter': 'value'}, filter_is_valid=False)
diff --git a/neutron_tempest_plugin/api/test_subnets.py b/neutron_tempest_plugin/api/test_subnets.py
index b7a1b21..b8842ab 100644
--- a/neutron_tempest_plugin/api/test_subnets.py
+++ b/neutron_tempest_plugin/api/test_subnets.py
@@ -64,7 +64,8 @@
def test_list_no_pagination_limit_0(self):
self._test_list_no_pagination_limit_0()
- @decorators.skip_because(bug="1749820")
@decorators.idempotent_id('c0f9280b-9d81-4728-a967-6be22659d4c8')
def test_list_validation_filters(self):
- self._test_list_validation_filters()
+ self._test_list_validation_filters(self.list_kwargs)
+ self._test_list_validation_filters({
+ 'unknown_filter': 'value'}, filter_is_valid=False)
diff --git a/neutron_tempest_plugin/api/test_timestamp.py b/neutron_tempest_plugin/api/test_timestamp.py
index 186d21f..f5888f9 100644
--- a/neutron_tempest_plugin/api/test_timestamp.py
+++ b/neutron_tempest_plugin/api/test_timestamp.py
@@ -247,14 +247,14 @@
@decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
def test_create_floatingip_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
# Verifies body contains timestamp fields
self.assertIsNotNone(fip['created_at'])
self.assertIsNotNone(fip['updated_at'])
@decorators.idempotent_id('a3ac215a-61ac-13f9-9d3c-57c51f11afa1')
def test_update_floatingip_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
origin_updated_at = fip['updated_at']
update_body = {'description': 'new'}
body = self.client.update_floatingip(fip['id'], **update_body)
@@ -266,7 +266,7 @@
@decorators.idempotent_id('32a6a086-e1ef-413b-b13a-0cfe13ef051e')
def test_show_floatingip_attribute_with_timestamp(self):
- fip = self.create_floatingip(self.ext_net_id)
+ fip = self.create_floatingip()
body = self.client.show_floatingip(fip['id'])
show_fip = body['floatingip']
# verify the timestamp from creation and showed is same
diff --git a/neutron_tempest_plugin/api/test_trunk.py b/neutron_tempest_plugin/api/test_trunk.py
index 1a000fd..823a95d 100644
--- a/neutron_tempest_plugin/api/test_trunk.py
+++ b/neutron_tempest_plugin/api/test_trunk.py
@@ -14,7 +14,6 @@
from tempest.common import utils
from tempest.lib.common.utils import data_utils
-from tempest.lib.common.utils import test_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
@@ -22,18 +21,7 @@
from neutron_tempest_plugin import config
-def trunks_cleanup(client, trunks):
- for trunk in trunks:
- # NOTE(armax): deleting a trunk with subports is permitted, however
- # for testing purposes it is safer to be explicit and clean all the
- # resources associated with the trunk beforehand.
- subports = test_utils.call_and_ignore_notfound_exc(
- client.get_subports, trunk['id'])
- if subports:
- client.remove_subports(
- trunk['id'], subports['sub_ports'])
- test_utils.call_and_ignore_notfound_exc(
- client.delete_trunk, trunk['id'])
+CONF = config.CONF
class TrunkTestJSONBase(base.BaseAdminNetworkTest):
@@ -41,51 +29,51 @@
required_extensions = ['trunk']
def setUp(self):
+ base.BaseAdminNetworkTest.setUp(self)
+ # This avoids problems due to user quotas
+ self.resource_setup()
self.addCleanup(self.resource_cleanup)
- super(TrunkTestJSONBase, self).setUp()
-
- @classmethod
- def resource_setup(cls):
- super(TrunkTestJSONBase, cls).resource_setup()
- cls.trunks = []
-
- @classmethod
- def resource_cleanup(cls):
- trunks_cleanup(cls.client, cls.trunks)
- super(TrunkTestJSONBase, cls).resource_cleanup()
@classmethod
def is_type_driver_enabled(cls, type_driver):
return (type_driver in
- config.CONF.neutron_plugin_options.available_type_drivers)
+ CONF.neutron_plugin_options.available_type_drivers)
- def _create_trunk_with_network_and_parent(
- self, subports, parent_network_type=None, **kwargs):
+ @classmethod
+ def _create_trunk_with_network_and_parent(cls, subports=None,
+ parent_network_type=None,
+ **kwargs):
client = None
network_kwargs = {}
if parent_network_type:
- client = self.admin_client
+ client = cls.admin_client
network_kwargs = {"provider:network_type": parent_network_type,
- "tenant_id": self.client.tenant_id}
- network = self.create_network(client=client, **network_kwargs)
- parent_port = self.create_port(network)
- trunk = self.client.create_trunk(parent_port['id'], subports, **kwargs)
- self.trunks.append(trunk['trunk'])
- return trunk
+ "tenant_id": cls.client.tenant_id}
+ network = cls.create_network(client=client, **network_kwargs)
+ parent_port = cls.create_port(network)
+ return cls.create_trunk(parent_port, subports, **kwargs)
- def _show_trunk(self, trunk_id):
- return self.client.show_trunk(trunk_id)
+ @classmethod
+ def _show_trunk(cls, trunk):
+ client = trunk.get('client') or cls.client
+ return client.show_trunk(trunk['id'])['trunk']
- def _list_trunks(self):
- return self.client.list_trunks()
+ @classmethod
+ def _update_trunk(cls, trunk, **kwargs):
+ client = trunk.get('client') or cls.client
+ return client.update_trunk(trunk['id'], **kwargs)['trunk']
+
+ @classmethod
+ def _list_trunks(cls):
+ return cls.client.list_trunks()['trunks']
class TrunkTestJSON(TrunkTestJSONBase):
def _test_create_trunk(self, subports):
trunk = self._create_trunk_with_network_and_parent(subports)
- observed_trunk = self._show_trunk(trunk['trunk']['id'])
- self.assertEqual(trunk, observed_trunk)
+ observed_trunk = self._show_trunk(trunk)
+ self.assertEqual(trunk, dict(observed_trunk, client=trunk['client']))
@decorators.idempotent_id('e1a6355c-4768-41f3-9bf8-0f1d192bd501')
def test_create_trunk_empty_subports_list(self):
@@ -97,79 +85,69 @@
@decorators.idempotent_id('7de46c22-e2b6-4959-ac5a-0e624632ab32')
def test_create_show_delete_trunk(self):
- trunk = self._create_trunk_with_network_and_parent(None)
- trunk_id = trunk['trunk']['id']
- parent_port_id = trunk['trunk']['port_id']
- res = self._show_trunk(trunk_id)
- self.assertEqual(trunk_id, res['trunk']['id'])
- self.assertEqual(parent_port_id, res['trunk']['port_id'])
- self.client.delete_trunk(trunk_id)
- self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk_id)
+ trunk = self._create_trunk_with_network_and_parent()
+ observed_trunk = self._show_trunk(trunk)
+ self.assertEqual(trunk, dict(observed_trunk, client=trunk['client']))
+ self.delete_trunk(trunk)
+ self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk)
@decorators.idempotent_id('8d83a6ca-662d-45b8-8062-d513077296aa')
@utils.requires_ext(extension="project-id", service="network")
def test_show_trunk_has_project_id(self):
- trunk = self._create_trunk_with_network_and_parent(None)
- body = self._show_trunk(trunk['trunk']['id'])
- show_trunk = body['trunk']
- self.assertIn('project_id', show_trunk)
- self.assertIn('tenant_id', show_trunk)
- self.assertEqual(self.client.tenant_id, show_trunk['project_id'])
- self.assertEqual(self.client.tenant_id, show_trunk['tenant_id'])
+ trunk = self._create_trunk_with_network_and_parent()
+ observed_trunk = self._show_trunk(trunk)
+ for key in ['project_id', 'tenant_id']:
+ self.assertIn(key, observed_trunk)
+ self.assertEqual(self.client.tenant_id, observed_trunk[key])
@decorators.idempotent_id('4ce46c22-a2b6-4659-bc5a-0ef2463cab32')
def test_create_update_trunk(self):
- trunk = self._create_trunk_with_network_and_parent(None)
- rev = trunk['trunk']['revision_number']
- trunk_id = trunk['trunk']['id']
- res = self._show_trunk(trunk_id)
- self.assertTrue(res['trunk']['admin_state_up'])
- self.assertEqual(rev, res['trunk']['revision_number'])
- self.assertEqual("", res['trunk']['name'])
- self.assertEqual("", res['trunk']['description'])
- res = self.client.update_trunk(
- trunk_id, name='foo', admin_state_up=False)
- self.assertFalse(res['trunk']['admin_state_up'])
- self.assertEqual("foo", res['trunk']['name'])
- self.assertGreater(res['trunk']['revision_number'], rev)
- # enable the trunk so that it can be managed
- self.client.update_trunk(trunk_id, admin_state_up=True)
+ trunk = self._create_trunk_with_network_and_parent()
+ observed_trunk = self._show_trunk(trunk)
+ self.assertTrue(observed_trunk['admin_state_up'])
+ self.assertEqual(trunk['revision_number'],
+ observed_trunk['revision_number'])
+ self.assertEqual("", observed_trunk['name'])
+ self.assertEqual("", observed_trunk['description'])
+ updated_trunk = self._update_trunk(trunk, name='foo',
+ admin_state_up=False)
+ self.assertFalse(updated_trunk['admin_state_up'])
+ self.assertEqual("foo", updated_trunk['name'])
+ self.assertGreater(updated_trunk['revision_number'],
+ trunk['revision_number'])
@decorators.idempotent_id('5ff46c22-a2b6-5559-bc5a-0ef2463cab32')
def test_create_update_trunk_with_description(self):
trunk = self._create_trunk_with_network_and_parent(
- None, description="foo description")
- trunk_id = trunk['trunk']['id']
- self.assertEqual("foo description", trunk['trunk']['description'])
- trunk = self.client.update_trunk(trunk_id, description='')
- self.assertEqual('', trunk['trunk']['description'])
+ description="foo description")
+ self.assertEqual("foo description", trunk['description'])
+ updated_trunk = self._update_trunk(trunk, description='')
+ self.assertEqual('', updated_trunk['description'])
@decorators.idempotent_id('73365f73-bed6-42cd-960b-ec04e0c99d85')
def test_list_trunks(self):
- trunk1 = self._create_trunk_with_network_and_parent(None)
- trunk2 = self._create_trunk_with_network_and_parent(None)
- expected_trunks = {trunk1['trunk']['id']: trunk1['trunk'],
- trunk2['trunk']['id']: trunk2['trunk']}
- trunk_list = self._list_trunks()['trunks']
- matched_trunks = [x for x in trunk_list if x['id'] in expected_trunks]
- self.assertEqual(2, len(matched_trunks))
- for trunk in matched_trunks:
- self.assertEqual(expected_trunks[trunk['id']], trunk)
+ trunk1 = self._create_trunk_with_network_and_parent()
+ trunk2 = self._create_trunk_with_network_and_parent()
+ expected_trunks = {trunk1['id']: trunk1,
+ trunk2['id']: trunk2}
+ observed_trunks = {trunk['id']: dict(trunk, client=self.client)
+ for trunk in self._list_trunks()
+ if trunk['id'] in expected_trunks}
+ self.assertEqual(expected_trunks, observed_trunks)
@decorators.idempotent_id('bb5fcead-09b5-484a-bbe6-46d1e06d6cc0')
- def test_add_subport(self):
- trunk = self._create_trunk_with_network_and_parent([])
+ def test_add_subports(self):
+ trunk = self._create_trunk_with_network_and_parent()
network = self.create_network()
port = self.create_port(network)
subports = [{'port_id': port['id'],
'segmentation_type': 'vlan',
'segmentation_id': 2}]
- self.client.add_subports(trunk['trunk']['id'], subports)
- trunk = self._show_trunk(trunk['trunk']['id'])
- observed_subports = trunk['trunk']['sub_ports']
- self.assertEqual(1, len(observed_subports))
- created_subport = observed_subports[0]
- self.assertEqual(subports[0], created_subport)
+ added_subports = self.client.add_subports(trunk['id'],
+ subports)['sub_ports']
+ self.assertEqual(subports, added_subports)
+ observed_trunk = self._show_trunk(trunk)
+ self.assertEqual(subports, observed_trunk['sub_ports'])
@decorators.idempotent_id('ee5fcead-1abf-483a-bce6-43d1e06d6aa0')
def test_delete_trunk_with_subport_is_allowed(self):
@@ -179,38 +157,27 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}]
trunk = self._create_trunk_with_network_and_parent(subports)
- self.client.delete_trunk(trunk['trunk']['id'])
+ self.client.delete_trunk(trunk['id'])
@decorators.idempotent_id('96eea398-a03c-4c3e-a99e-864392c2ca53')
def test_remove_subport(self):
- subport_parent1 = self.create_port(self.create_network())
- subport_parent2 = self.create_port(self.create_network())
- subports = [{'port_id': subport_parent1['id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 2},
- {'port_id': subport_parent2['id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 4}]
- trunk = self._create_trunk_with_network_and_parent(subports)
- removed_subport = trunk['trunk']['sub_ports'][0]
- expected_subport = None
-
- for subport in subports:
- if subport['port_id'] != removed_subport['port_id']:
- expected_subport = subport
- break
+ subport1 = {'port_id': self.create_port(self.create_network())['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2}
+ subport2 = {'port_id': self.create_port(self.create_network())['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 4}
+ trunk = self._create_trunk_with_network_and_parent([subport1,
+ subport2])
# Remove the subport and validate PUT response
- res = self.client.remove_subports(trunk['trunk']['id'],
- [removed_subport])
- self.assertEqual(1, len(res['sub_ports']))
- self.assertEqual(expected_subport, res['sub_ports'][0])
+ subports_after_remove = self.client.remove_subports(
+ trunk['id'], [subport2])['sub_ports']
+ self.assertEqual([subport1], subports_after_remove)
# Validate the results of a subport list
- trunk = self._show_trunk(trunk['trunk']['id'])
- observed_subports = trunk['trunk']['sub_ports']
- self.assertEqual(1, len(observed_subports))
- self.assertEqual(expected_subport, observed_subports[0])
+ observed_trunk = self._show_trunk(trunk)
+ self.assertEqual([subport1], observed_trunk['sub_ports'])
@decorators.idempotent_id('bb5fcaad-09b5-484a-dde6-4cd1ea6d6ff0')
def test_get_subports(self):
@@ -220,9 +187,8 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}]
trunk = self._create_trunk_with_network_and_parent(subports)
- trunk = self.client.get_subports(trunk['trunk']['id'])
- observed_subports = trunk['sub_ports']
- self.assertEqual(1, len(observed_subports))
+ observed_subports = self.client.get_subports(trunk['id'])['sub_ports']
+ self.assertEqual(subports, observed_subports)
class TrunkTestInheritJSONBase(TrunkTestJSONBase):
@@ -233,41 +199,43 @@
def skip_checks(cls):
super(TrunkTestInheritJSONBase, cls).skip_checks()
if ("vlan" not in
- config.CONF.neutron_plugin_options.available_type_drivers):
+ CONF.neutron_plugin_options.available_type_drivers):
raise cls.skipException("VLAN type_driver is not enabled")
- if not config.CONF.neutron_plugin_options.provider_vlans:
+ if not CONF.neutron_plugin_options.provider_vlans:
raise cls.skipException("No provider VLAN networks available")
def create_provider_network(self):
- foo_net = config.CONF.neutron_plugin_options.provider_vlans[0]
+ foo_net = CONF.neutron_plugin_options.provider_vlans[0]
return self.create_network(name=data_utils.rand_name('vlan-net'),
provider_network_type='vlan',
provider_physical_network=foo_net)
@decorators.idempotent_id('0f05d98e-41f5-4629-dada-9aee269c9602')
def test_add_subport(self):
- trunk_network = self.create_provider_network()
- trunk_port = self.create_port(trunk_network)
- subport_networks = [
- self.create_provider_network(),
- self.create_provider_network(),
- ]
- subport1 = self.create_port(subport_networks[0])
- subport2 = self.create_port(subport_networks[1])
+ parent_network = self.create_provider_network()
+ parent_port = self.create_port(parent_network)
+ subport_network1 = self.create_provider_network()
+ segmentation_id1 = subport_network1['provider:segmentation_id']
+ subport_network2 = self.create_provider_network()
+ segmentation_id2 = subport_network2['provider:segmentation_id']
+ subport1 = self.create_port(subport_network1)
+ subport2 = self.create_port(subport_network2)
subports = [{'port_id': subport1['id'],
- 'segmentation_type': 'inherit',
- 'segmentation_id': subport1['id']},
+ 'segmentation_type': 'inherit'},
{'port_id': subport2['id'],
- 'segmentation_type': 'inherit',
- 'segmentation_id': subport2['id']}]
- trunk = self.client.create_trunk(trunk_port['id'], subports)['trunk']
- self.trunks.append(trunk)
+ 'segmentation_type': 'inherit'}]
+
+ trunk = self.create_trunk(parent_port, subports)
+
+ expected_subports = [{'port_id': subport1['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': segmentation_id1},
+ {'port_id': subport2['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': segmentation_id2}]
+
# Validate that subport got segmentation details from the network
- for i in range(2):
- self.assertEqual(subport_networks[i]['provider:network_type'],
- trunk['sub_ports'][i]['segmentation_type'])
- self.assertEqual(subport_networks[i]['provider:segmentation_id'],
- trunk['sub_ports'][i]['segmentation_id'])
+ self.assertEqual(expected_subports, trunk['sub_ports'])
class TrunkTestMtusJSONBase(TrunkTestJSONBase):
@@ -306,19 +274,16 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}]
- trunk = self.client.create_trunk(self.larger_mtu_port['id'], subports)
- self.trunks.append(trunk['trunk'])
+ self.create_trunk(self.larger_mtu_port, subports)
@decorators.idempotent_id('2004c5c6-e557-4c43-8100-c820ad4953e8')
- def test_add_subport_with_mtu_smaller_than_trunk(self):
+ def test_add_subport_with_mtu_greater_than_subport(self):
subports = [{'port_id': self.smaller_mtu_port['id'],
'segmentation_type': 'vlan',
'segmentation_id': 2}]
- trunk = self.client.create_trunk(self.larger_mtu_port['id'], None)
- self.trunks.append(trunk['trunk'])
-
- self.client.add_subports(trunk['trunk']['id'], subports)
+ trunk = self.create_trunk(self.larger_mtu_port)
+ self.client.add_subports(trunk['id'], subports)
@decorators.idempotent_id('22725101-f4bc-4e00-84ec-4e02cd7e0500')
def test_create_trunk_with_mtu_equal_to_subport(self):
@@ -326,9 +291,7 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}]
- trunk = self.client.create_trunk(self.smaller_mtu_port_2['id'],
- subports)
- self.trunks.append(trunk['trunk'])
+ self.create_trunk(self.smaller_mtu_port_2, subports)
@decorators.idempotent_id('175b05ae-66ad-44c7-857a-a12d16f1058f')
def test_add_subport_with_mtu_equal_to_trunk(self):
@@ -336,10 +299,8 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}]
- trunk = self.client.create_trunk(self.smaller_mtu_port_2['id'], None)
- self.trunks.append(trunk['trunk'])
-
- self.client.add_subports(trunk['trunk']['id'], subports)
+ trunk = self.create_trunk(self.smaller_mtu_port_2)
+ self.client.add_subports(trunk['id'], subports)
class TrunksSearchCriteriaTest(base.BaseSearchCriteriaTest):
@@ -350,17 +311,10 @@
@classmethod
def resource_setup(cls):
super(TrunksSearchCriteriaTest, cls).resource_setup()
- cls.trunks = []
net = cls.create_network(network_name='trunk-search-test-net')
for name in cls.resource_names:
parent_port = cls.create_port(net)
- trunk = cls.client.create_trunk(parent_port['id'], [], name=name)
- cls.trunks.append(trunk['trunk'])
-
- @classmethod
- def resource_cleanup(cls):
- trunks_cleanup(cls.client, cls.trunks)
- super(TrunksSearchCriteriaTest, cls).resource_cleanup()
+ cls.create_trunk(parent_port, name=name)
@decorators.idempotent_id('fab73df4-960a-4ae3-87d3-60992b8d3e2d')
def test_list_sorts_asc(self):
diff --git a/neutron_tempest_plugin/api/test_trunk_details.py b/neutron_tempest_plugin/api/test_trunk_details.py
index 972f216..bc8a2ea 100644
--- a/neutron_tempest_plugin/api/test_trunk_details.py
+++ b/neutron_tempest_plugin/api/test_trunk_details.py
@@ -23,14 +23,13 @@
@decorators.idempotent_id('f0bed24f-d36a-498b-b4e7-0d66e3fb7308')
def test_port_resource_trunk_details_no_subports(self):
- trunk = self._create_trunk_with_network_and_parent([])
- port = self.client.show_port(trunk['trunk']['port_id'])
+ trunk = self._create_trunk_with_network_and_parent()
+ parent_port = self.client.show_port(trunk['port_id'])['port']
+ observed_trunk_details = parent_port.get('trunk_details')
expected_trunk_details = {'sub_ports': [],
- 'trunk_id': trunk['trunk']['id']}
- observed_trunk_details = port['port'].get('trunk_details')
+ 'trunk_id': trunk['id']}
self.assertIsNotNone(observed_trunk_details)
- self.assertEqual(expected_trunk_details,
- observed_trunk_details)
+ self.assertEqual(expected_trunk_details, observed_trunk_details)
@decorators.idempotent_id('544bcaf2-86fb-4930-93ab-ece1c3cc33df')
def test_port_resource_trunk_details_with_subport(self):
@@ -40,19 +39,19 @@
'segmentation_type': 'vlan',
'segmentation_id': 2}
trunk = self._create_trunk_with_network_and_parent([subport_data])
- subport_data['mac_address'] = subport['mac_address']
- parent_port = self.client.show_port(trunk['trunk']['port_id'])
- expected_trunk_details = {'sub_ports': [subport_data],
- 'trunk_id': trunk['trunk']['id']}
- observed_trunk_details = parent_port['port'].get('trunk_details')
+ parent_port = self.client.show_port(trunk['port_id'])['port']
+ observed_trunk_details = parent_port.get('trunk_details')
+ expected_subport_data = dict(subport_data,
+ mac_address=subport['mac_address'])
+ expected_trunk_details = {'sub_ports': [expected_subport_data],
+ 'trunk_id': trunk['id']}
self.assertIsNotNone(observed_trunk_details)
- self.assertEqual(expected_trunk_details,
- observed_trunk_details)
+ self.assertEqual(expected_trunk_details, observed_trunk_details)
@decorators.idempotent_id('fe6d865f-1d5c-432e-b65d-904157172f24')
def test_port_resource_empty_trunk_details(self):
network = self.create_network()
port = self.create_port(network)
- port = self.client.show_port(port['id'])
- observed_trunk_details = port['port'].get('trunk_details')
+ observed_port = self.client.show_port(port['id'])['port']
+ observed_trunk_details = observed_port.get('trunk_details')
self.assertIsNone(observed_trunk_details)
diff --git a/neutron_tempest_plugin/api/test_trunk_negative.py b/neutron_tempest_plugin/api/test_trunk_negative.py
index 4d7ead1..85beb4e 100644
--- a/neutron_tempest_plugin/api/test_trunk_negative.py
+++ b/neutron_tempest_plugin/api/test_trunk_negative.py
@@ -19,6 +19,9 @@
import testtools
from neutron_tempest_plugin.api import test_trunk
+from neutron_tempest_plugin import config
+
+CONF = config.CONF
class TrunkTestJSON(test_trunk.TrunkTestJSONBase):
@@ -43,9 +46,9 @@
@decorators.attr(type='negative')
@decorators.idempotent_id('a5c5200a-72a0-43c5-a11a-52f808490344')
def test_create_subport_nonexistent_port_id(self):
- trunk = self._create_trunk_with_network_and_parent([])
+ trunk = self._create_trunk_with_network_and_parent()
self.assertRaises(lib_exc.NotFound, self.client.add_subports,
- trunk['trunk']['id'],
+ trunk['id'],
[{'port_id': uuidutils.generate_uuid(),
'segmentation_type': 'vlan',
'segmentation_id': 2}])
@@ -64,11 +67,11 @@
@decorators.attr(type='negative')
@decorators.idempotent_id('7e0f99ab-fe37-408b-a889-9e44ef300084')
def test_create_subport_missing_segmentation_id(self):
- trunk = self._create_trunk_with_network_and_parent([])
+ trunk = self._create_trunk_with_network_and_parent()
subport_network = self.create_network()
parent_port = self.create_port(subport_network)
self.assertRaises(lib_exc.BadRequest, self.client.add_subports,
- trunk['trunk']['id'],
+ trunk['id'],
[{'port_id': parent_port['id'],
'segmentation_type': 'vlan'}])
@@ -109,41 +112,43 @@
if not self.is_type_driver_enabled('vxlan'):
msg = "Vxlan type driver must be enabled for this test."
raise self.skipException(msg)
+ if not CONF.neutron_plugin_options.provider_vlans:
+ raise self.skipException("No provider VLAN networks available")
trunk = self._create_trunk_with_network_and_parent(
- subports=[], parent_network_type='vxlan')
+ parent_network_type='vxlan')
subport_network = self.create_network()
- parent_port = self.create_port(subport_network)
+ subport = self.create_port(subport_network)
self.assertRaises(lib_exc.BadRequest, self.client.add_subports,
- trunk['trunk']['id'],
- [{'port_id': parent_port['id'],
+ trunk['id'],
+ [{'port_id': subport['id'],
'segmentation_type': 'inherit',
'segmentation_id': -1}])
@decorators.attr(type='negative')
@decorators.idempotent_id('40aed9be-e976-47d0-a555-bde2c7e74e57')
def test_create_trunk_duplicate_subport_segmentation_ids(self):
- trunk = self._create_trunk_with_network_and_parent([])
+ trunk = self._create_trunk_with_network_and_parent()
subport_network1 = self.create_network()
subport_network2 = self.create_network()
- parent_port1 = self.create_port(subport_network1)
- parent_port2 = self.create_port(subport_network2)
+ subport1 = self.create_port(subport_network1)
+ subport2 = self.create_port(subport_network2)
self.assertRaises(lib_exc.BadRequest, self.client.create_trunk,
- trunk['trunk']['id'],
- [{'port_id': parent_port1['id'],
+ trunk['id'],
+ [{'port_id': subport1['id'],
'segmentation_id': 2,
'segmentation_type': 'vlan'},
- {'port_id': parent_port2['id'],
+ {'port_id': subport2['id'],
'segmentation_id': 2,
'segmentation_type': 'vlan'}])
@decorators.attr(type='negative')
@decorators.idempotent_id('6f132ccc-1380-42d8-9c44-50411612bd01')
- def test_add_subport_port_id_uses_trunk_port_id(self):
- trunk = self._create_trunk_with_network_and_parent(None)
+ def test_add_subport_port_id_uses_parent_port_id(self):
+ trunk = self._create_trunk_with_network_and_parent()
self.assertRaises(lib_exc.Conflict, self.client.add_subports,
- trunk['trunk']['id'],
- [{'port_id': trunk['trunk']['port_id'],
+ trunk['id'],
+ [{'port_id': trunk['port_id'],
'segmentation_type': 'vlan',
'segmentation_id': 2}])
@@ -151,67 +156,54 @@
@decorators.idempotent_id('7f132ccc-1380-42d8-9c44-50411612bd01')
def test_add_subport_port_id_disabled_trunk(self):
trunk = self._create_trunk_with_network_and_parent(
- None, admin_state_up=False)
- self.assertRaises(lib_exc.Conflict,
- self.client.add_subports,
- trunk['trunk']['id'],
- [{'port_id': trunk['trunk']['port_id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 2}])
- self.client.update_trunk(
- trunk['trunk']['id'], admin_state_up=True)
+ admin_state_up=False)
+ self.assertRaises(lib_exc.Conflict, self.client.add_subports,
+ trunk['id'], [{'port_id': trunk['port_id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2}])
@decorators.attr(type='negative')
@decorators.idempotent_id('8f132ccc-1380-42d8-9c44-50411612bd01')
def test_remove_subport_port_id_disabled_trunk(self):
trunk = self._create_trunk_with_network_and_parent(
- None, admin_state_up=False)
- self.assertRaises(lib_exc.Conflict,
- self.client.remove_subports,
- trunk['trunk']['id'],
- [{'port_id': trunk['trunk']['port_id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 2}])
- self.client.update_trunk(
- trunk['trunk']['id'], admin_state_up=True)
+ admin_state_up=False)
+ self.assertRaises(lib_exc.Conflict, self.client.remove_subports,
+ trunk['id'], [{'port_id': trunk['port_id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2}])
@decorators.attr(type='negative')
@decorators.idempotent_id('9f132ccc-1380-42d8-9c44-50411612bd01')
def test_delete_trunk_disabled_trunk(self):
trunk = self._create_trunk_with_network_and_parent(
- None, admin_state_up=False)
- self.assertRaises(lib_exc.Conflict,
- self.client.delete_trunk,
- trunk['trunk']['id'])
- self.client.update_trunk(
- trunk['trunk']['id'], admin_state_up=True)
+ admin_state_up=False)
+ self.assertRaises(lib_exc.Conflict, self.client.delete_trunk,
+ trunk['id'])
@decorators.attr(type='negative')
@decorators.idempotent_id('00cb40bb-1593-44c8-808c-72b47e64252f')
def test_add_subport_duplicate_segmentation_details(self):
- trunk = self._create_trunk_with_network_and_parent(None)
+ trunk = self._create_trunk_with_network_and_parent()
network = self.create_network()
- parent_port1 = self.create_port(network)
- parent_port2 = self.create_port(network)
- self.client.add_subports(trunk['trunk']['id'],
- [{'port_id': parent_port1['id'],
+ subport1 = self.create_port(network)
+ subport2 = self.create_port(network)
+ self.client.add_subports(trunk['id'],
+ [{'port_id': subport1['id'],
'segmentation_type': 'vlan',
'segmentation_id': 2}])
self.assertRaises(lib_exc.Conflict, self.client.add_subports,
- trunk['trunk']['id'],
- [{'port_id': parent_port2['id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 2}])
+ trunk['id'], [{'port_id': subport2['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2}])
@decorators.attr(type='negative')
@decorators.idempotent_id('4eac8c25-83ee-4051-9620-34774f565730')
def test_add_subport_passing_dict(self):
- trunk = self._create_trunk_with_network_and_parent(None)
+ trunk = self._create_trunk_with_network_and_parent()
self.assertRaises(lib_exc.BadRequest, self.client.add_subports,
- trunk['trunk']['id'],
- {'port_id': trunk['trunk']['port_id'],
- 'segmentation_type': 'vlan',
- 'segmentation_id': 2})
+ trunk['id'], {'port_id': trunk['port_id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2})
@decorators.attr(type='negative')
@decorators.idempotent_id('17ca7dd7-96a8-445a-941e-53c0c86c2fe2')
@@ -223,7 +215,7 @@
'segmentation_id': 2}
trunk = self._create_trunk_with_network_and_parent([subport_data])
self.assertRaises(lib_exc.BadRequest, self.client.remove_subports,
- trunk['trunk']['id'], subport_data)
+ trunk['id'], subport_data)
@decorators.attr(type='negative')
@decorators.idempotent_id('aaca7dd7-96b8-445a-931e-63f0d86d2fe2')
@@ -233,16 +225,16 @@
subport_data = {'port_id': parent_port['id'],
'segmentation_type': 'vlan',
'segmentation_id': 2}
- trunk = self._create_trunk_with_network_and_parent([])
+ trunk = self._create_trunk_with_network_and_parent()
self.assertRaises(lib_exc.NotFound, self.client.remove_subports,
- trunk['trunk']['id'], [subport_data])
+ trunk['id'], [subport_data])
@decorators.attr(type='negative')
@decorators.idempotent_id('6c9c5126-4f61-11e6-8248-40a8f063c891')
def test_delete_port_in_use_by_trunk(self):
- trunk = self._create_trunk_with_network_and_parent(None)
+ trunk = self._create_trunk_with_network_and_parent()
self.assertRaises(lib_exc.Conflict, self.client.delete_port,
- trunk['trunk']['port_id'])
+ trunk['port_id'])
@decorators.attr(type='negative')
@decorators.idempotent_id('343a03d0-4f7c-11e6-97fa-40a8f063c891')
diff --git a/neutron_tempest_plugin/common/ssh.py b/neutron_tempest_plugin/common/ssh.py
index 99f731c..4829db2 100644
--- a/neutron_tempest_plugin/common/ssh.py
+++ b/neutron_tempest_plugin/common/ssh.py
@@ -13,9 +13,12 @@
# under the License.
import os
+import time
from oslo_log import log
+import paramiko
from tempest.lib.common import ssh
+from tempest.lib import exceptions
from neutron_tempest_plugin import config
@@ -26,6 +29,8 @@
class Client(ssh.Client):
+ default_ssh_lang = 'en_US.UTF-8'
+
timeout = CONF.validation.ssh_timeout
proxy_jump_host = CONF.neutron_plugin_options.ssh_proxy_jump_host
@@ -112,3 +117,141 @@
host=host, username=username, password=password,
look_for_keys=look_for_keys, key_filename=key_file,
port=port, proxy_client=None, **kwargs)
+
+ # attribute used to keep reference to opened client connection
+ _client = None
+
+ def connect(self, *args, **kwargs):
+ """Creates paramiko.SSHClient and connect it to remote SSH server
+
+ In case this method is called more times it returns the same client
+ and no new SSH connection is created until close method is called.
+
+ :returns: paramiko.Client connected to remote server.
+
+ :raises tempest.lib.exceptions.SSHTimeout: in case it fails to connect
+ to remote server.
+ """
+ client = self._client
+ if client is None:
+ client = super(Client, self)._get_ssh_connection(
+ *args, **kwargs)
+ self._client = client
+
+ return client
+
+ # This overrides superclass protected method to make sure exec_command
+ # method is going to reuse the same SSH client and connection if called
+ # more times
+ _get_ssh_connection = connect
+
+ def close(self):
+ """Closes connection to SSH server and cleanup resources."""
+ client = self._client
+ if client is not None:
+ client.close()
+ self._client = None
+
+ def open_session(self):
+ """Gets connection to SSH server and open a new paramiko.Channel
+
+ :returns: new paramiko.Channel
+ """
+
+ client = self.connect()
+
+ try:
+ return client.get_transport().open_session()
+ except paramiko.SSHException:
+ # the request is rejected, the session ends prematurely or
+ # there is a timeout opening a channel
+ LOG.exception("Unable to open SSH session")
+ raise exceptions.SSHTimeout(host=self.host,
+ user=self.username,
+ password=self.password)
+
+ def execute_script(self, script, become_root=False,
+ combine_stderr=True, shell='sh -eux'):
+ """Connect to remote machine and executes script.
+
+ Implementation note: it passes script lines to shell interpreter via
+ STDIN. Therefore script line number could be not available to some
+ script interpreters for debugging porposes.
+
+ :param script: script lines to be executed.
+
+ :param become_root: executes interpreter as root with sudo.
+
+ :param combine_stderr (bool): whenever to redirect STDERR to STDOUT so
+ that output from both streams are returned together. True by default.
+
+ :param shell: command line used to launch script interpreter. By
+ default it executes Bash with -eux options enabled. This means that
+ any command returning non-zero exist status or any any undefined
+ variable would interrupt script execution with an error and every
+ command executed by the script is going to be traced to STDERR.
+
+ :returns output written by script to STDOUT.
+
+ :raises tempest.lib.exceptions.SSHTimeout: in case it fails to connect
+ to remote server or it fails to open a channel.
+
+ :raises tempest.lib.exceptions.SSHExecCommandFailed: in case command
+ script exits with non zero exit status.
+ """
+
+ channel = self.open_session()
+ with channel:
+
+ # Combine STOUT and STDERR to have to handle with only one stream
+ channel.set_combine_stderr(combine_stderr)
+
+ # Set default environment
+ channel.update_environment({
+ # Language and encoding
+ 'LC_ALL': os.environ.get('LC_ALL') or self.default_ssh_lang,
+ 'LANG': os.environ.get('LANG') or self.default_ssh_lang
+ })
+
+ if become_root:
+ shell = 'sudo ' + shell
+ # Spawn a Bash
+ channel.exec_command(shell)
+
+ lines_iterator = iter(script.splitlines())
+ output_data = b''
+ error_data = b''
+
+ while not channel.exit_status_ready():
+ # Drain incoming data buffers
+ while channel.recv_ready():
+ output_data += channel.recv(self.buf_size)
+ while channel.recv_stderr_ready():
+ error_data += channel.recv_stderr(self.buf_size)
+
+ if channel.send_ready():
+ try:
+ line = next(lines_iterator)
+ except StopIteration:
+ # Finalize Bash script execution
+ channel.shutdown_write()
+ else:
+ # Send script to Bash STDIN line by line
+ channel.send((line + '\n').encode('utf-8'))
+ else:
+ time.sleep(.1)
+
+ # Get exit status and drain incoming data buffers
+ exit_status = channel.recv_exit_status()
+ while channel.recv_ready():
+ output_data += channel.recv(self.buf_size)
+ while channel.recv_stderr_ready():
+ error_data += channel.recv_stderr(self.buf_size)
+
+ if exit_status != 0:
+ raise exceptions.SSHExecCommandFailed(
+ command='bash', exit_status=exit_status,
+ stderr=error_data.decode('utf-8'),
+ stdout=output_data.decode('utf-8'))
+
+ return output_data.decode('utf-8')
diff --git a/neutron_tempest_plugin/common/utils.py b/neutron_tempest_plugin/common/utils.py
index c42d984..fa7bb8b 100644
--- a/neutron_tempest_plugin/common/utils.py
+++ b/neutron_tempest_plugin/common/utils.py
@@ -54,8 +54,8 @@
def wait_until_true(predicate, timeout=60, sleep=1, exception=None):
- """
- Wait until callable predicate is evaluated as True
+ """Wait until callable predicate is evaluated as True
+
:param predicate: Callable deciding whether waiting should continue.
Best practice is to instantiate predicate with functools.partial()
:param timeout: Timeout in seconds how long should function wait.
@@ -69,7 +69,7 @@
eventlet.sleep(sleep)
except eventlet.Timeout:
if exception is not None:
- #pylint: disable=raising-bad-type
+ # pylint: disable=raising-bad-type
raise exception
raise WaitTimeout("Timed out after %d seconds" % timeout)
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index e15748d..030a126 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -29,10 +29,6 @@
default=[],
help='List of network types available to neutron, '
'e.g. vxlan,vlan,gre.'),
- cfg.BoolOpt('image_is_advanced',
- default=False,
- help='Image that supports features that cirros does not, like'
- ' Ubuntu or CentOS supporting advanced features'),
cfg.StrOpt('agent_availability_zone',
help='The availability zone for all agents in the deployment. '
'Configure this only when the single value is used by '
@@ -75,6 +71,26 @@
cfg.IntOpt('ssh_proxy_jump_port',
default=22,
help='Port used to connect to "ssh_proxy_jump_host".'),
+
+ # Options for special, "advanced" image like e.g. Ubuntu. Such image can be
+ # used in tests which require some more advanced tool than available in
+ # Cirros
+ cfg.StrOpt('advanced_image_ref',
+ default=None,
+ help='Valid advanced image uuid to be used in tests. '
+ 'It is an image that supports features that Cirros '
+ 'does not, like Ubuntu or CentOS supporting advanced '
+ 'features.'),
+ cfg.StrOpt('advanced_image_flavor_ref',
+ default=None,
+ help='Valid flavor to use with advanced image in tests. '
+ 'This is required if advanced image has to be used in '
+ 'tests.'),
+ cfg.StrOpt('advanced_image_ssh_user',
+ default=None,
+ help='Name of ssh user to use with advanced image in tests. '
+ 'This is required if advanced image has to be used in '
+ 'tests.'),
]
# TODO(amuller): Redo configuration options registration as part of the planned
diff --git a/neutron_tempest_plugin/scenario/admin/test_floatingip.py b/neutron_tempest_plugin/scenario/admin/test_floatingip.py
index e58be83..1af5502 100644
--- a/neutron_tempest_plugin/scenario/admin/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/admin/test_floatingip.py
@@ -85,18 +85,19 @@
network_id=self.network['id'],
device_id=server['server']['id']
)['ports'][0]
- fips.append(self.create_and_associate_floatingip(
- port['id'], client=self.os_admin.network_client))
+ fip = self.create_floatingip(port=port,
+ client=self.os_admin.network_client)
+ fips.append(fip)
server_ssh_clients.append(ssh.Client(
fips[i]['floating_ip_address'], CONF.validation.image_ssh_user,
pkey=self.keypair['private_key']))
- self.addCleanup(self.os_admin.network_client.delete_floatingip,
- fips[i]['id'])
return server_ssh_clients, fips
@decorators.idempotent_id('6bba729b-3fb6-494b-9e1e-82bbd89a1045')
def test_two_vms_fips(self):
- """This test verifies the ability of two instances
+ """Test two VMs floating IPs
+
+ This test verifies the ability of two instances
that were created in the same compute node and same availability zone
to reach each other.
"""
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 3adaa1e..a2c5c72 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -14,6 +14,7 @@
# under the License.
import subprocess
+from debtcollector import removals
import netaddr
from neutron_lib.api import validators
from neutron_lib import constants as neutron_lib_constants
@@ -39,6 +40,7 @@
def create_server(self, flavor_ref, image_ref, key_name, networks,
**kwargs):
"""Create a server using tempest lib
+
All the parameters are the ones used in Compute API
* - Kwargs that require admin privileges
@@ -133,8 +135,7 @@
@classmethod
def create_pingable_secgroup_rule(cls, secgroup_id=None,
client=None):
- """This rule is intended to permit inbound ping
- """
+ """This rule is intended to permit inbound ping"""
rule_list = [{'protocol': 'icmp',
'direction': 'ingress',
@@ -158,14 +159,12 @@
cls.routers.append(router)
return router
+ @removals.remove(version='Stein',
+ message="Please use create_floatingip method instead of "
+ "create_and_associate_floatingip.")
def create_and_associate_floatingip(self, port_id, client=None):
client = client or self.os_primary.network_client
- fip = client.create_floatingip(
- CONF.network.public_network_id,
- port_id=port_id)['floatingip']
- if client is self.os_primary.network_client:
- self.floating_ips.append(fip)
- return fip
+ return self.create_floatingip(port_id=port_id, client=client)
def create_interface(cls, server_id, port_id, client=None):
client = client or cls.os_primary.interfaces_client
@@ -215,7 +214,7 @@
self.port = self.client.list_ports(network_id=self.network['id'],
device_id=self.server[
'server']['id'])['ports'][0]
- self.fip = self.create_and_associate_floatingip(self.port['id'])
+ self.fip = self.create_floatingip(port=self.port)
def check_connectivity(self, host, ssh_user, ssh_key, servers=None):
ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
diff --git a/neutron_tempest_plugin/scenario/test_dns_integration.py b/neutron_tempest_plugin/scenario/test_dns_integration.py
index 923f013..20062c1 100644
--- a/neutron_tempest_plugin/scenario/test_dns_integration.py
+++ b/neutron_tempest_plugin/scenario/test_dns_integration.py
@@ -76,11 +76,9 @@
cls.keypair = cls.create_keypair()
def _create_floatingip_with_dns(self, dns_name):
- fip = self.os_primary.network_client.create_floatingip(
- CONF.network.public_network_id, dns_name=dns_name,
- dns_domain=self.zone['name'])['floatingip']
- self.floating_ips.append(fip)
- return fip
+ return self.create_floatingip(client=self.os_primary.network_client,
+ dns_name=dns_name,
+ dns_domain=self.zone['name'])
def _create_server(self, name=None):
port = self.create_port(self.network)
@@ -92,7 +90,7 @@
waiters.wait_for_server_status(self.os_primary.servers_client,
server['id'],
constants.SERVER_STATUS_ACTIVE)
- fip = self.create_and_associate_floatingip(port['id'])
+ fip = self.create_floatingip(port=port)
return {'port': port, 'fip': fip, 'server': server}
def _verify_dns_records(self, address, name):
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index 504af12..38833cd 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -21,6 +21,7 @@
from tempest.common import waiters
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions
import testscenarios
from testscenarios.scenarios import multiply_scenarios
@@ -28,7 +29,6 @@
from neutron_tempest_plugin.common import ssh
from neutron_tempest_plugin.common import utils as common_utils
from neutron_tempest_plugin import config
-from neutron_tempest_plugin import exceptions
from neutron_tempest_plugin.scenario import base
from neutron_tempest_plugin.scenario import constants
from neutron_tempest_plugin.scenario import test_qos
@@ -87,7 +87,7 @@
network = self.network
port = self.create_port(network, security_groups=[self.secgroup['id']])
if create_floating_ip:
- fip = self.create_and_associate_floatingip(port['id'])
+ fip = self.create_floatingip(port=port)
else:
fip = None
server = self.create_server(
@@ -234,19 +234,20 @@
server['server']['id'], port_id=port['id'])
waiters.wait_for_interface_status(
self.os_primary.interfaces_client, server['server']['id'],
- port['id'], 'ACTIVE')
+ port['id'], lib_constants.PORT_STATUS_ACTIVE)
fip = self.client.show_floatingip(fip['id'])['floatingip']
self._check_port_details(
- fip, port, status='ACTIVE',
+ fip, port, status=lib_constants.PORT_STATUS_ACTIVE,
device_id=server['server']['id'], device_owner='compute:nova')
# detach the port from the server; this is a cast in the compute
# API so we have to poll the port until the device_id is unset.
self.delete_interface(server['server']['id'], port['id'])
- self._wait_for_port_detach(port['id'])
- fip = self.client.show_floatingip(fip['id'])['floatingip']
+ port = self._wait_for_port_detach(port['id'])
+ fip = self._wait_for_fip_port_down(fip['id'])
self._check_port_details(
- fip, port, status='DOWN', device_id='', device_owner='')
+ fip, port, status=lib_constants.PORT_STATUS_DOWN,
+ device_id='', device_owner='')
def _check_port_details(self, fip, port, status, device_id, device_owner):
self.assertIn('port_details', fip)
@@ -287,6 +288,36 @@
return port
+ def _wait_for_fip_port_down(self, fip_id, timeout=120, interval=10):
+ """Waits for the fip's attached port status to be 'DOWN'.
+
+ :param fip_id: The id of the floating IP.
+ :returns: The final fip dict from the show_floatingip response.
+ """
+ fip = self.client.show_floatingip(fip_id)['floatingip']
+ self.assertIn('port_details', fip)
+ port_details = fip['port_details']
+ status = port_details['status']
+ start = int(time.time())
+
+ while status != lib_constants.PORT_STATUS_DOWN:
+ time.sleep(interval)
+ fip = self.client.show_floatingip(fip_id)['floatingip']
+ self.assertIn('port_details', fip)
+ port_details = fip['port_details']
+ status = port_details['status']
+
+ timed_out = int(time.time()) - start >= timeout
+
+ if status != lib_constants.PORT_STATUS_DOWN and timed_out:
+ message = ('Floating IP %s attached port status failed to '
+ 'transition to DOWN (current status %s) within '
+ 'the required time (%s s).' %
+ (fip_id, status, timeout))
+ raise exceptions.TimeoutException(message)
+
+ return fip
+
class FloatingIPQosTest(FloatingIpTestCasesMixin,
test_qos.QoSTestMixin,
diff --git a/neutron_tempest_plugin/scenario/test_migration.py b/neutron_tempest_plugin/scenario/test_migration.py
index f4b918c..3d6c1dd 100644
--- a/neutron_tempest_plugin/scenario/test_migration.py
+++ b/neutron_tempest_plugin/scenario/test_migration.py
@@ -173,11 +173,13 @@
class NetworkMigrationFromHA(NetworkMigrationTestBase):
+ @common_utils.unstable_test("bug 1789434")
@decorators.idempotent_id('b4e68ac0-3b76-4306-ae8a-51cf4d363b22')
def test_from_ha_to_legacy(self):
self._test_migration(before_dvr=False, before_ha=True,
after_dvr=False, after_ha=False)
+ @common_utils.unstable_test("bug 1789434")
@decorators.idempotent_id('42260eea-5d56-4d30-b62a-a62694dfe4d5')
@testtools.skipUnless(
CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
@@ -186,6 +188,7 @@
self._test_migration(before_dvr=False, before_ha=True,
after_dvr=True, after_ha=False)
+ @common_utils.unstable_test("bug 1789434")
@decorators.idempotent_id('e4149576-248b-43fa-9d0b-a5c2f51967ce')
@testtools.skipUnless(
CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
diff --git a/neutron_tempest_plugin/scenario/test_mtu.py b/neutron_tempest_plugin/scenario/test_mtu.py
index dbfde9b..941d499 100644
--- a/neutron_tempest_plugin/scenario/test_mtu.py
+++ b/neutron_tempest_plugin/scenario/test_mtu.py
@@ -47,8 +47,8 @@
def create_pingable_vm(self, net, keypair, secgroup):
server = self.create_server(
- flavor_ref=CONF.compute.flavor_ref,
- image_ref=CONF.compute.image_ref,
+ flavor_ref=CONF.neutron_plugin_options.advanced_image_flavor_ref,
+ image_ref=CONF.neutron_plugin_options.advanced_image_ref,
key_name=keypair['name'],
networks=[{'uuid': net['id']}],
security_groups=[{'name': secgroup[
@@ -58,7 +58,7 @@
constants.SERVER_STATUS_ACTIVE)
port = self.client.list_ports(
network_id=net['id'], device_id=server['server']['id'])['ports'][0]
- fip = self.create_and_associate_floatingip(port['id'])
+ fip = self.create_floatingip(port=port)
return server, fip
def _get_network_params(self):
@@ -105,22 +105,23 @@
self.keypair, self.secgroup)
server_ssh_client1 = ssh.Client(
self.floating_ips[0]['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
pkey=self.keypair['private_key'])
server2, fip2 = self.create_pingable_vm(self.networks[1],
self.keypair, self.secgroup)
server_ssh_client2 = ssh.Client(
self.floating_ips[0]['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
pkey=self.keypair['private_key'])
for fip in (fip1, fip2):
- self.check_connectivity(fip['floating_ip_address'],
- CONF.validation.image_ssh_user,
- self.keypair['private_key'])
+ self.check_connectivity(
+ fip['floating_ip_address'],
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
+ self.keypair['private_key'])
return server_ssh_client1, fip1, server_ssh_client2, fip2
@testtools.skipUnless(
- CONF.neutron_plugin_options.image_is_advanced,
+ CONF.neutron_plugin_options.advanced_image_ref,
"Advanced image is required to run this test.")
@decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a273d9d344')
def test_connectivity_min_max_mtu(self):
@@ -197,22 +198,23 @@
self.keypair, self.secgroup)
server_ssh_client1 = ssh.Client(
self.floating_ips[0]['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
pkey=self.keypair['private_key'])
server2, fip2 = self.create_pingable_vm(self.networks[1],
self.keypair, self.secgroup)
server_ssh_client2 = ssh.Client(
self.floating_ips[0]['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
pkey=self.keypair['private_key'])
for fip in (fip1, fip2):
- self.check_connectivity(fip['floating_ip_address'],
- CONF.validation.image_ssh_user,
- self.keypair['private_key'])
+ self.check_connectivity(
+ fip['floating_ip_address'],
+ CONF.neutron_plugin_options.advanced_image_ssh_user,
+ self.keypair['private_key'])
return server_ssh_client1, fip1, server_ssh_client2, fip2
@testtools.skipUnless(
- CONF.neutron_plugin_options.image_is_advanced,
+ CONF.neutron_plugin_options.advanced_image_ref,
"Advanced image is required to run this test.")
@decorators.idempotent_id('bc470200-d8f4-4f07-b294-1b4cbaaa35b9')
def test_connectivity_min_max_mtu(self):
diff --git a/neutron_tempest_plugin/scenario/test_qos.py b/neutron_tempest_plugin/scenario/test_qos.py
index 0230289..1ec79f9 100644
--- a/neutron_tempest_plugin/scenario/test_qos.py
+++ b/neutron_tempest_plugin/scenario/test_qos.py
@@ -49,8 +49,7 @@
def _connect_socket(host, port):
- """Try to initiate a connection to a host using an ip address
- and a port.
+ """Try to initiate a connection to a host using an ip address and a port.
Trying couple of times until a timeout is reached in case the listening
host is not ready yet.
diff --git a/neutron_tempest_plugin/scenario/test_security_groups.py b/neutron_tempest_plugin/scenario/test_security_groups.py
index 9503fe3..ebdcf93 100644
--- a/neutron_tempest_plugin/scenario/test_security_groups.py
+++ b/neutron_tempest_plugin/scenario/test_security_groups.py
@@ -43,6 +43,7 @@
def create_vm_testing_sec_grp(self, num_servers=2, security_groups=None,
ports=None):
"""Create instance for security group testing
+
:param num_servers (int): number of servers to spawn
:param security_groups (list): list of security groups
:param ports* (list): list of ports
@@ -67,7 +68,7 @@
port = self.client.list_ports(
network_id=self.network['id'], device_id=server['server'][
'id'])['ports'][0]
- fips.append(self.create_and_associate_floatingip(port['id']))
+ fips.append(self.create_floatingip(port=port))
server_ssh_clients.append(ssh.Client(
fips[i]['floating_ip_address'], CONF.validation.image_ssh_user,
pkey=self.keypair['private_key']))
@@ -260,7 +261,9 @@
@decorators.idempotent_id('f07d0159-8f9e-4faa-87f5-a869ab0ad488')
def test_multiple_ports_secgroup_inheritance(self):
- """This test creates two ports with security groups, then
+ """Test multiple port security group inheritance
+
+ This test creates two ports with security groups, then
boots two instances and verify that the security group was
inherited properly and enforced in these instances.
"""
diff --git a/neutron_tempest_plugin/scenario/test_trunk.py b/neutron_tempest_plugin/scenario/test_trunk.py
index 2ff7e5d..1903180 100644
--- a/neutron_tempest_plugin/scenario/test_trunk.py
+++ b/neutron_tempest_plugin/scenario/test_trunk.py
@@ -29,13 +29,11 @@
CONF = config.CONF
CONFIGURE_VLAN_INTERFACE_COMMANDS = (
- 'IFACE=$(PATH=$PATH:/usr/sbin ip l | grep "^[0-9]*: e" |'
- 'cut -d \: -f 2) && '
- 'sudo su -c '
- '"ip l a link $IFACE name $IFACE.%(tag)d type vlan id %(tag)d &&'
- 'ip l s up dev $IFACE.%(tag)d && '
- '{ ps -ef | grep -q "dhclient .*$IFACE.%(tag)d" || '
- 'dhclient $IFACE.%(tag)d"; }')
+ 'IFACE=$(PATH=$PATH:/usr/sbin ip l | grep "^[0-9]*: e"|cut -d \: -f 2) &&'
+ 'sudo ip l a link $IFACE name $IFACE.%(tag)d type vlan id %(tag)d &&'
+ 'sudo ip l s up dev $IFACE.%(tag)d && '
+ 'ps -ef | grep -q "[d]hclient .*$IFACE.%(tag)d" || '
+ 'sudo dhclient $IFACE.%(tag)d;')
class TrunkTest(base.BaseTempestTestCase):
@@ -61,18 +59,23 @@
def _create_server_with_trunk_port(self):
port = self.create_port(self.network, security_groups=[
self.secgroup['security_group']['id']])
- trunk = self.client.create_trunk(port['id'], subports=[])['trunk']
+ trunk = self.create_trunk(port)
server, fip = self._create_server_with_fip(port['id'])
- self.addCleanup(self._detach_and_delete_trunk, server, trunk)
return {'port': port, 'trunk': trunk, 'fip': fip,
'server': server}
- def _create_server_with_fip(self, port_id, **server_kwargs):
- fip = self.create_and_associate_floatingip(port_id)
+ def _create_server_with_fip(self, port_id, use_advanced_image=False,
+ **server_kwargs):
+ fip = self.create_floatingip(port_id=port_id)
+ flavor_ref = CONF.compute.flavor_ref
+ image_ref = CONF.compute.image_ref
+ if use_advanced_image:
+ flavor_ref = CONF.neutron_plugin_options.advanced_image_flavor_ref
+ image_ref = CONF.neutron_plugin_options.advanced_image_ref
return (
self.create_server(
- flavor_ref=CONF.compute.flavor_ref,
- image_ref=CONF.compute.image_ref,
+ flavor_ref=flavor_ref,
+ image_ref=image_ref,
key_name=self.keypair['name'],
networks=[{'port': port_id}],
security_groups=[{'name': self.secgroup[
@@ -80,18 +83,6 @@
**server_kwargs)['server'],
fip)
- def _detach_and_delete_trunk(self, server, trunk):
- # we have to detach the interface from the server before
- # the trunk can be deleted.
- self.os_primary.compute.InterfacesClient().delete_interface(
- server['id'], trunk['port_id'])
-
- def is_port_detached():
- p = self.client.show_port(trunk['port_id'])['port']
- return p['device_id'] == ''
- utils.wait_until_true(is_port_detached)
- self.client.delete_trunk(trunk['id'])
-
def _is_port_down(self, port_id):
p = self.client.show_port(port_id)['port']
return p['status'] == 'DOWN'
@@ -104,7 +95,8 @@
t = self.client.show_trunk(trunk_id)['trunk']
return t['status'] == 'ACTIVE'
- def _create_server_with_port_and_subport(self, vlan_network, vlan_tag):
+ def _create_server_with_port_and_subport(self, vlan_network, vlan_tag,
+ use_advanced_image=False):
parent_port = self.create_port(self.network, security_groups=[
self.secgroup['security_group']['id']])
port_for_subport = self.create_port(
@@ -115,15 +107,18 @@
'port_id': port_for_subport['id'],
'segmentation_type': 'vlan',
'segmentation_id': vlan_tag}
- trunk = self.client.create_trunk(
- parent_port['id'], subports=[subport])['trunk']
+ self.create_trunk(parent_port, [subport])
- server, fip = self._create_server_with_fip(parent_port['id'])
- self.addCleanup(self._detach_and_delete_trunk, server, trunk)
+ server, fip = self._create_server_with_fip(
+ parent_port['id'], use_advanced_image=use_advanced_image)
+
+ ssh_user = CONF.validation.image_ssh_user
+ if use_advanced_image:
+ ssh_user = CONF.neutron_plugin_options.advanced_image_ssh_user
server_ssh_client = ssh.Client(
fip['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ ssh_user,
pkey=self.keypair['private_key'])
return {
@@ -133,15 +128,17 @@
'subport': port_for_subport,
}
- def _wait_for_server(self, server):
+ def _wait_for_server(self, server, advanced_image=False):
+ ssh_user = CONF.validation.image_ssh_user
+ if advanced_image:
+ ssh_user = CONF.neutron_plugin_options.advanced_image_ssh_user
waiters.wait_for_server_status(self.os_primary.servers_client,
server['server']['id'],
constants.SERVER_STATUS_ACTIVE)
self.check_connectivity(server['fip']['floating_ip_address'],
- CONF.validation.image_ssh_user,
+ ssh_user,
self.keypair['private_key'])
- @utils.unstable_test("bug 1766701")
@decorators.idempotent_id('bb13fe28-f152-4000-8131-37890a40c79e')
def test_trunk_subport_lifecycle(self):
"""Test trunk creation and subport transition to ACTIVE status.
@@ -222,9 +219,8 @@
CONF.validation.image_ssh_user,
self.keypair['private_key'])
- @utils.unstable_test('bug 1766701')
@testtools.skipUnless(
- CONF.neutron_plugin_options.image_is_advanced,
+ CONF.neutron_plugin_options.advanced_image_ref,
"Advanced image is required to run this test.")
@decorators.idempotent_id('a8a02c9b-b453-49b5-89a2-cce7da66aafb')
def test_subport_connectivity(self):
@@ -234,11 +230,12 @@
self.create_subnet(vlan_network, gateway=None)
servers = [
- self._create_server_with_port_and_subport(vlan_network, vlan_tag)
+ self._create_server_with_port_and_subport(
+ vlan_network, vlan_tag, use_advanced_image=True)
for i in range(2)]
for server in servers:
- self._wait_for_server(server)
+ self._wait_for_server(server, advanced_image=True)
# Configure VLAN interfaces on server
command = CONFIGURE_VLAN_INTERFACE_COMMANDS % {'tag': vlan_tag}
server['ssh_client'].exec_command(command)
diff --git a/neutron_tempest_plugin/services/network/json/network_client.py b/neutron_tempest_plugin/services/network/json/network_client.py
index b316ce4..58dfbf4 100644
--- a/neutron_tempest_plugin/services/network/json/network_client.py
+++ b/neutron_tempest_plugin/services/network/json/network_client.py
@@ -17,12 +17,10 @@
from tempest.lib.common import rest_client as service_client
from tempest.lib import exceptions as lib_exc
-from neutron_tempest_plugin import exceptions
-
class NetworkClientJSON(service_client.RestClient):
+ """NetworkClientJSON class
- """
Tempest REST client for Neutron. Uses v2 of the Neutron API, since the
V1 API has been removed from the code base.
@@ -280,7 +278,7 @@
if self.is_resource_deleted(resource_type, id):
return
if int(time.time()) - start_time >= self.build_timeout:
- raise exceptions.TimeoutException
+ raise lib_exc.TimeoutException
time.sleep(self.build_interval)
def is_resource_deleted(self, resource_type, id):
@@ -449,7 +447,8 @@
return service_client.ResponseBody(resp, body)
def update_agent(self, agent_id, agent_info):
- """
+ """Update an agent
+
:param agent_info: Agent update information.
E.g {"admin_state_up": True}
"""
@@ -461,6 +460,12 @@
body = jsonutils.loads(body)
return service_client.ResponseBody(resp, body)
+ def delete_agent(self, agent_id):
+ uri = '%s/agents/%s' % (self.uri_prefix, agent_id)
+ resp, body = self.delete(uri)
+ self.expected_success(204, resp.status)
+ return service_client.ResponseBody(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)
diff --git a/playbooks/dvr-multinode-scenario-pre-run.yaml b/playbooks/dvr-multinode-scenario-pre-run.yaml
new file mode 100644
index 0000000..8afd8a5
--- /dev/null
+++ b/playbooks/dvr-multinode-scenario-pre-run.yaml
@@ -0,0 +1,3 @@
+- hosts: all
+ roles:
+ - multi-node-setup
diff --git a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/post.yaml b/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/post.yaml
deleted file mode 100644
index e07f551..0000000
--- a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/post.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-- hosts: primary
- tasks:
-
- - name: Copy files from {{ ansible_user_dir }}/workspace/ on node
- synchronize:
- src: '{{ ansible_user_dir }}/workspace/'
- dest: '{{ zuul.executor.log_root }}'
- mode: pull
- copy_links: true
- verify_host: true
- rsync_opts:
- - --include=/logs/**
- - --include=*/
- - --exclude=*
- - --prune-empty-dirs
diff --git a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml b/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
deleted file mode 100644
index a9ce3e0..0000000
--- a/playbooks/neutron-tempest-plugin-dvr-multinode-scenario/run.yaml
+++ /dev/null
@@ -1,60 +0,0 @@
-- hosts: primary
- name: neutron-tempest-plugin-dvr-multinode-scenario
- tasks:
-
- - name: Ensure legacy workspace directory
- file:
- path: '{{ ansible_user_dir }}/workspace'
- state: directory
-
- - shell:
- cmd: |
- set -e
- set -x
- cat > clonemap.yaml << EOF
- clonemap:
- - name: openstack-infra/devstack-gate
- dest: devstack-gate
- EOF
- /usr/zuul-env/bin/zuul-cloner -m clonemap.yaml --cache-dir /opt/git \
- git://git.openstack.org \
- openstack-infra/devstack-gate
- executable: /bin/bash
- chdir: '{{ ansible_user_dir }}/workspace'
- environment: '{{ zuul | zuul_legacy_vars }}'
-
- - shell:
- cmd: |
- set -e
- set -x
- export PYTHONUNBUFFERED=true
- export DEVSTACK_GATE_TEMPEST=1
- export DEVSTACK_GATE_TEMPEST_ALL_PLUGINS=1
- export DEVSTACK_GATE_NEUTRON=1
- export DEVSTACK_GATE_CONFIGDRIVE=0
- export DEVSTACK_GATE_TEMPEST_REGEX="(neutron_tempest_plugin.scenario)"
- export DEVSTACK_LOCAL_CONFIG="enable_plugin neutron-tempest-plugin git://git.openstack.org/openstack/neutron-tempest-plugin"
- # Test DVR works multinode
- export DEVSTACK_GATE_NEUTRON_DVR=1
- export BRANCH_OVERRIDE=default
- if [ "$BRANCH_OVERRIDE" != "default" ] ; then
- export OVERRIDE_ZUUL_BRANCH=$BRANCH_OVERRIDE
- fi
- export DEVSTACK_GATE_TOPOLOGY="multinode"
- export PROJECTS="openstack/neutron-tempest-plugin $PROJECTS"
-
- function gate_hook {
- bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh dsvm-scenario-ovs
- }
- export -f gate_hook
-
- function post_test_hook {
- bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-scenario-ovs
- }
- export -f post_test_hook
-
- cp devstack-gate/devstack-vm-gate-wrap.sh ./safe-devstack-vm-gate-wrap.sh
- ./safe-devstack-vm-gate-wrap.sh
- executable: /bin/bash
- chdir: '{{ ansible_user_dir }}/workspace'
- environment: '{{ zuul | zuul_legacy_vars }}'
diff --git a/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
new file mode 100644
index 0000000..01c94f4
--- /dev/null
+++ b/releasenotes/notes/agents-client-delete-method-de1a7fb3f845999c.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - |
+ Added a new method ``delete_agent`` to the AgentsClient class that
+ implements agent deletion according to the neutron API.
+ https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
+
diff --git a/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml b/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml
new file mode 100644
index 0000000..ab9f37a
--- /dev/null
+++ b/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml
@@ -0,0 +1,11 @@
+---
+
+features:
+ - |
+ Add new 'debtcollector' dependency with the purpose of deprecating methods
+ that are going to be removed.
+
+deprecations:
+ - |
+ Deprecate method BaseTempestTestCase.create_and_associate_floatingip after
+ replacing it with method BaseNetworkTest.create_floatingip.
diff --git a/releasenotes/source/README.rst b/releasenotes/source/README.rst
new file mode 100644
index 0000000..a6677ca
--- /dev/null
+++ b/releasenotes/source/README.rst
@@ -0,0 +1,34 @@
+==========================================
+Neutron Tempest Plugin Release Notes Howto
+==========================================
+
+Release notes are a new feature for documenting new features in
+OpenStack projects. Background on the process, tooling, and
+methodology is documented in a `mailing list post by Doug Hellmann <http://lists.openstack.org/pipermail/openstack-dev/2015-November/078301.html>`_.
+
+Writing release notes
+---------------------
+
+For information on how to create release notes, please consult the
+`reno documentation <https://docs.openstack.org/reno/latest/user/usage.html>`__.
+
+Please keep the following in your mind when you write release notes.
+
+* **Avoid using "prelude" section** for individual release notes.
+ "prelude" section is for general comments about the release.
+* **Use one entry per section** (like "feature" or "upgrade").
+ All entries which belong to a same release will be merged and rendered,
+ so there is less meaning to use multiple entries by a single topic.
+
+Maintaining release notes
+-------------------------
+
+.. warning::
+
+ Avoid modifying an existing release note file even though it is related
+ to your change. If you modify a release note file of a past release,
+ the whole content will be shown in a latest release. The only allowed
+ case is to update a release note in a same release.
+
+ If you need to update a release note of a past release,
+ edit a corresponding release note file in a stable branch directly.
diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py
index d95fd58..66d6a9e 100644
--- a/releasenotes/source/conf.py
+++ b/releasenotes/source/conf.py
@@ -52,12 +52,12 @@
master_doc = 'index'
# General information about the project.
-project = u'neutron_tempest_plugin Release Notes'
-copyright = u'2017, OpenStack Developers'
+project = u'Neutron Tempest Plugin Release Notes'
+copyright = u'2017, Neutron Tempest Plugin Developers'
# openstackdocstheme options
-repository_name = 'openstack/openstack'
-bug_project = 'neutron_tempest_plugin'
+repository_name = 'openstack/neutron-tempest-plugin'
+bug_project = 'neutron'
bug_tag = ''
# The version info for the project you're documenting, acts as replacement for
@@ -191,7 +191,7 @@
# html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = 'neutron_tempest_pluginReleaseNotesdoc'
+htmlhelp_basename = 'NeutronTempestPluginReleaseNotesdoc'
# -- Options for LaTeX output ---------------------------------------------
@@ -211,9 +211,9 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
- ('index', 'neutron_tempest_pluginReleaseNotes.tex',
- u'neutron_tempest_plugin Release Notes Documentation',
- u'OpenStack Foundation', 'manual'),
+ ('index', 'NeutronTempestPluginReleaseNotes.tex',
+ u'Neutron Tempest Plugin Release Notes Documentation',
+ u'Neutron Tempest Plugin Developers', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -242,9 +242,9 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'neutron_tempest_pluginrereleasenotes',
- u'neutron_tempest_plugin Release Notes Documentation',
- [u'OpenStack Foundation'], 1)
+ ('index', 'NeutronTempestPluginrereleasenotes',
+ u'Neutron Tempest Plugin Release Notes Documentation',
+ [u'Neutron Tempest Plugin Developers'], 1)
]
# If true, show URL addresses after external links.
@@ -257,9 +257,10 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'neutron_tempest_plugin ReleaseNotes',
- u'neutron_tempest_plugin Release Notes Documentation',
- u'OpenStack Foundation', 'neutron_tempest_pluginReleaseNotes',
+ ('index', 'Neutron Tempest Plugin ReleaseNotes',
+ u'Neutron Tempest Plugin Release Notes Documentation',
+ u'Neutron Tempest Plugin Developers',
+ 'NeutronTempestPluginReleaseNotes',
'One line description of project.',
'Miscellaneous'),
]
diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst
index 2aa8030..5648f19 100644
--- a/releasenotes/source/index.rst
+++ b/releasenotes/source/index.rst
@@ -1,8 +1,13 @@
-============================================
- neutron_tempest_plugin Release Notes
-============================================
+======================================
+ Neutron Tempest Plugin Release Notes
+======================================
.. toctree::
:maxdepth: 1
unreleased
+
+.. toctree::
+ :maxdepth: 1
+
+ README.rst
diff --git a/requirements.txt b/requirements.txt
index 5660c68..dc77e63 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,9 +10,11 @@
oslo.log>=3.36.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
+paramiko>=2.0.0 # LGPLv2.1+
six>=1.10.0 # MIT
tempest>=17.1.0 # Apache-2.0
ddt>=1.0.1 # MIT
testtools>=2.2.0 # MIT
testscenarios>=0.4 # Apache-2.0/BSD
eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
+debtcollector>=1.2.0 # Apache-2.0
diff --git a/roles/multi-node-setup/README.rst b/roles/multi-node-setup/README.rst
new file mode 100644
index 0000000..b57a977
--- /dev/null
+++ b/roles/multi-node-setup/README.rst
@@ -0,0 +1,23 @@
+Set up connection between infra bridge and Neutron external bridge
+
+Network topology used in CI multinode jobs is described In `Devstack documention
+<https://git.openstack.org/cgit/openstack-infra/devstack-gate/tree/multinode_setup_info.txt#n81>`_
+
+In case when DVR is used, there is also additional bridge ``br-infra`` added
+on each node to provide connectivity to floating IPs from main node.
+
+This bridge needs to be connected with bridge used by Neutron as
+external bridge. Typically it is ``br-ex`` and this role adds patch ports
+between those bridges.
+
+**Role Variables**
+
+.. zuul:rolevar:: neutron_external_bridge_name
+ :default: br-ex
+
+ Name of the Neutron external bridge.
+
+.. zuul:rolevar:: infra_bridge_name
+ :default: br-infra
+
+ Name of the infra bridge.
diff --git a/roles/multi-node-setup/defaults/main.yaml b/roles/multi-node-setup/defaults/main.yaml
new file mode 100644
index 0000000..f166fe7
--- /dev/null
+++ b/roles/multi-node-setup/defaults/main.yaml
@@ -0,0 +1,2 @@
+infra_bridge_name: br-infra
+neutron_external_bridge_name: br-ex
diff --git a/roles/multi-node-setup/tasks/main.yaml b/roles/multi-node-setup/tasks/main.yaml
new file mode 100644
index 0000000..043e70f
--- /dev/null
+++ b/roles/multi-node-setup/tasks/main.yaml
@@ -0,0 +1,17 @@
+- name: Ensure the infra bridge exists
+ become: yes
+ openvswitch_bridge:
+ bridge: "{{ infra_bridge_name }}"
+
+- name: Ensure the Neutron external bridge exists
+ become: yes
+ openvswitch_bridge:
+ bridge: "{{ neutron_external_bridge_name }}"
+
+- name: Create patch port between bridges
+ become: yes
+ command: >-
+ ovs-vsctl --may-exist add-port {{ infra_bridge_name }} patch-{{ neutron_external_bridge_name }}
+ -- set interface patch-{{ neutron_external_bridge_name }} type=patch options:peer=patch-{{ infra_bridge_name }}
+ -- --may-exist add-port {{ neutron_external_bridge_name }} patch-{{ infra_bridge_name }}
+ -- set interface patch-{{ infra_bridge_name }} type=patch options:peer=patch-{{ neutron_external_bridge_name }}
diff --git a/setup.cfg b/setup.cfg
index a54cc6c..c6a1fad 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[metadata]
-name = neutron_tempest_plugin
+name = neutron-tempest-plugin
summary = Tempest plugin for Neutron Project
description-file =
README.rst
@@ -16,8 +16,7 @@
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
- Programming Language :: Python :: 3.3
- Programming Language :: Python :: 3.4
+ Programming Language :: Python :: 3.5
[files]
packages =
@@ -33,11 +32,11 @@
upload-dir = doc/build/html
[compile_catalog]
-directory = neutron/locale
-domain = neutron
+directory = neutron_tempest_plugin/locale
+domain = neutron-tempest-plugin
[update_catalog]
-domain = neutron_tempest_plugin
+domain = neutron-tempest-plugin
output_dir = neutron_tempest_plugin/locale
input_file = neutron_tempest_plugin/locale/neutron_tempest_plugin.pot
diff --git a/tools/customize_ubuntu_image b/tools/customize_ubuntu_image
index 9c3fd07..3697265 100755
--- a/tools/customize_ubuntu_image
+++ b/tools/customize_ubuntu_image
@@ -31,8 +31,11 @@
chown _apt.root -fR "${apt_user_folders[@]}"
# Install desired packages to Ubuntu guest image
- apt-get update -y
- apt-get install -y "${INSTALL_GUEST_PACKAGES[@]}"
+ (
+ DEBIAN_FRONTEND=noninteractive
+ apt-get update -y
+ apt-get install -y "${INSTALL_GUEST_PACKAGES[@]}"
+ )
}
function main {
@@ -64,9 +67,12 @@
bind_dir "${temp_dir}/tmp" "${mount_dir}/var/tmp"
bind_dir "${temp_dir}/apt" "${mount_dir}/var/lib/apt"
- # Replace /etc/resolv.conf symlink to use the same DNS as this host
- sudo rm -f "${mount_dir}/etc/resolv.conf"
- sudo cp /etc/resolv.conf "${mount_dir}/etc/resolv.conf"
+ # Temporarly replace /etc/resolv.conf symlink to use the same DNS as this
+ # host
+ local resolv_file=${mount_dir}/etc/resolv.conf
+ sudo mv -f "${resolv_file}" "${resolv_file}.orig"
+ sudo cp /etc/resolv.conf "${resolv_file}"
+ add_cleanup sudo mv -f "${resolv_file}.orig" "${resolv_file}"
# Makesure /etc/fstab exists and it is readable because it is required by
# /sbin/dhclient-script
diff --git a/tox.ini b/tox.ini
index 5eb8b10..82a473c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -56,11 +56,8 @@
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
-# E265 block comment should start with '# '
-# H404 multi line docstring should start with a summary
-# H405 multi line docstring summary not separated with an empty line
# N530 direct neutron imports not allowed
-ignore = E125,E126,E128,E129,E265,H404,H405,N530
+ignore = E125,E126,E128,E129,N530
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H904: Delay string interpolations at logging calls