Retiring openstack/networking-l2gw-tempest-plugin

networking-l2gw-tempest-plugin moved to
x/networking-l2gw-tempest-plugin, thus the code in this location is no
longer maintained.

Change-Id: I59471e72a37b5d89c2ee913b824115f739c9c5c9
changes/80/749580/2
elajkat 2 years ago committed by Lajos Katona
parent 35c93a1e0b
commit 908a6a491c
  1. 58
      .gitignore
  2. 16
      CONTRIBUTING.rst
  3. 4
      HACKING.rst
  4. 175
      LICENSE
  5. 11
      README.rst
  6. 2
      babel.cfg
  7. 8
      contrib/gate_hook.sh
  8. 55
      contrib/post_test_hook.sh
  9. 4
      doc/requirements.txt
  10. 82
      doc/source/conf.py
  11. 4
      doc/source/contributing.rst
  12. 40
      doc/source/index.rst
  13. 1
      doc/source/readme.rst
  14. 5
      doc/source/releasenotes.rst
  15. 61
      doc/source/tempest-plugin.rst
  16. 0
      networking_l2gw_tempest_plugin/__init__.py
  17. 46
      networking_l2gw_tempest_plugin/config.py
  18. 12
      networking_l2gw_tempest_plugin/etc/tempest.conf.sample
  19. 40
      networking_l2gw_tempest_plugin/plugin.py
  20. 0
      networking_l2gw_tempest_plugin/services/__init__.py
  21. 0
      networking_l2gw_tempest_plugin/services/l2gw/__init__.py
  22. 59
      networking_l2gw_tempest_plugin/services/l2gw/l2_gateway_connections_client.py
  23. 72
      networking_l2gw_tempest_plugin/services/l2gw/l2_gateways_client.py
  24. 0
      networking_l2gw_tempest_plugin/tests/__init__.py
  25. 0
      networking_l2gw_tempest_plugin/tests/api/__init__.py
  26. 144
      networking_l2gw_tempest_plugin/tests/api/base_l2gw.py
  27. 92
      networking_l2gw_tempest_plugin/tests/api/clients.py
  28. 208
      networking_l2gw_tempest_plugin/tests/api/test_l2gw_extensions.py
  29. 264
      networking_l2gw_tempest_plugin/tests/api/test_l2gw_negative.py
  30. 0
      networking_l2gw_tempest_plugin/tests/scenario/__init__.py
  31. 153
      networking_l2gw_tempest_plugin/tests/scenario/ovsdb_connections.py
  32. 386
      networking_l2gw_tempest_plugin/tests/scenario/test_l2gateways.py
  33. 9
      requirements.txt
  34. 42
      setup.cfg
  35. 29
      setup.py
  36. 19
      test-requirements.txt
  37. 62
      tox.ini

58
.gitignore vendored

@ -1,58 +0,0 @@
*.py[cod]
# C extensions
*.so
# Packages
*.egg*
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Unit test / coverage reports
cover/
.coverage*
!.coveragerc
.tox
nosetests.xml
.testrepository
.venv
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Complexity
output/*.html
output/*/index.html
# Sphinx
doc/build
# pbr generates these
AUTHORS
ChangeLog
# Editors
*~
.*.swp
.*sw?
# Files created by releasenotes build
releasenotes/build

@ -1,16 +0,0 @@
If you would like to contribute to the development of OpenStack,
you must follow the steps in this page:
https://docs.openstack.org/infra/manual/developers.html
Once those steps have been completed, changes to OpenStack
should be submitted for review via the Gerrit tool, following
the workflow documented at:
https://docs.openstack.org/infra/manual/developers.html#development-workflow
Pull requests submitted through GitHub will be ignored.
Bugs should be filed on Launchpad, not GitHub:
https://bugs.launchpad.net/networking-l2gw-tempest-plugin

@ -1,4 +0,0 @@
networking-l2gw-tempest-plugin Style Commandments
===============================================
Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/

@ -1,175 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

@ -1,7 +1,6 @@
=================================
Tempest Plugin for Neutron L2GW
=================================
This project is moved to x/networking-l2gw-tempest-plugin.
For any further questions, please email
openstack-discuss@lists.openstack.org or join #openstack-dev on
Freenode.
This project defines a tempest plugin containing tests used to verify the
functionality of the Neutron L2GW service plugin. The plugin will automatically
load these tests into tempest.

@ -1,2 +0,0 @@
[python: **.py]

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -ex
GATE_DEST=$BASE/new
DEVSTACK_PATH=$GATE_DEST/devstack
$BASE/new/devstack-gate/devstack-vm-gate.sh

@ -1,55 +0,0 @@
#!/usr/bin/env bash
set -xe
NETWORKING_L2GW_DIR="$BASE/new/networking-l2gw"
TEMPEST_DIR="$BASE/new/tempest"
SCRIPTS_DIR="/usr/os-testr-env/bin/"
function generate_test_logs {
local path="$1"
# Compress all $path/*.txt files and move the directories holding those
# files to /opt/stack/logs. Files with .log suffix have their
# suffix changed to .txt (so browsers will know to open the compressed
# files and not download them).
if [[ -d "$path" ]] ; then
sudo find "$path" -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \;
sudo mv "$path/*" /opt/stack/logs/
fi
}
function generate_testr_results {
# Give job user rights to access tox logs
sudo -H -u "$owner" chmod o+rw .
sudo -H -u "$owner" chmod o+rw -R .testrepository
if [[ -f ".testrepository/0" ]] ; then
".tox/$venv/bin/subunit-1to2" < .testrepository/0 > ./testrepository.subunit
$SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html
gzip -9 ./testrepository.subunit
gzip -9 ./testr_results.html
sudo mv ./*.gz /opt/stack/logs/
fi
}
owner=stack
sudo_env=
# virtuelenv 14.0.6 gives a strange error which appears solved in version 15.
# Therefore, we force the newer version.
sudo pip uninstall -y virtualenv
sudo pip install "virtualenv>=15.0.1"
# Set owner permissions according to job's requirements.
cd "$NETWORKING_L2GW_DIR"
sudo chown -R $owner:stack "$NETWORKING_L2GW_DIR"
# Run tests
echo "Running networking-l2gw $venv tests"
set +e
sudo -H -u "$owner" tox -e "$venv"
testr_exit_code=$?
set -e
# Collect and parse results
generate_testr_results
exit $testr_exit_code

@ -1,4 +0,0 @@
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
openstackdocstheme>=1.20.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0

@ -1,82 +0,0 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.autodoc',
#'sphinx.ext.intersphinx',
'reno.sphinxext',
'openstackdocstheme'
]
# autodoc generation is a bit aggressive and a nuisance when doing heavy
# text edit cycles.
# execute "export SPHINX_DEBUG=1" in your terminal to disable
# The suffix of source filenames.
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'networking-l2gw'
copyright = u'2013, OpenStack Foundation'
# openstackdocstheme options
repository_name = 'openstack/networking-l2gw-tempest-plugin'
bug_project = 'networking-l2gw-tempest-plugin'
bug_tag = ''
html_theme = 'openstackdocs'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
add_module_names = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for HTML output --------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
# html_theme_path = ["."]
# html_theme = '_theme'
# html_static_path = ['static']
# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
]
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'http://docs.python.org/': None}

@ -1,4 +0,0 @@
============
Contributing
============
.. include:: ../../CONTRIBUTING.rst

@ -1,40 +0,0 @@
Welcome to networking-l2gw-tempest-plugin's documentation!
============================================================
Tests for the
`Networking-l2gw project <https://docs.openstack.org/networking-l2gw/latest/>`_.
It provides Networking-l2gw scenario tests framework and tempest tests.
User guide
----------
**Tempest Plugin**
.. toctree::
:maxdepth: 1
tempest-plugin
readme
contributing
releasenotes
Source
------
* License: Apache License, Version 2.0
* `PyPi`_ - package installation
* `Launchpad project`_ - release management
* `Blueprints`_ - feature specifications
* :doc:`releasenotes`
.. _PyPi: https://pypi.org/project/networking-l2gw-tempest-plugin
.. _Launchpad project: https://launchpad.net/networking-l2gw-tempest-plugin
.. _Blueprints: https://blueprints.launchpad.net/networking-l2gw-tempest-plugin
Indices and tables
------------------
* :ref:`genindex`
* :ref:`search`

@ -1 +0,0 @@
.. include:: ../../README.rst

@ -1,5 +0,0 @@
=============
Release Notes
=============
.. release-notes::

@ -1,61 +0,0 @@
Tempest Integration of Networking L2GW
=======================================
Networking L2GW Tempest plugin contains api, cli and clients tests.
There are several ways to run Tempest tests: it is possible to run them using
your Devstack or using Rally.
Run Tempest tests on Devstack
-----------------------------
See how to configure Tempest at
`Tempest Configuration Guide <https://docs.openstack.org/tempest/latest/configuration.html>`_.
Tempest automatically discovers installed plugins. That's why you just need to
install the Python packages that contains the Networking L2GW Tempest plugin in
the same environment where Tempest is installed.
.. sourcecode:: console
$ git clone https://git.openstack.org/openstack/networking-l2gw-tempest-plugin
$ cd networking-l2gw-tempest-plugin/
$ pip install networking-l2gw-tempest-plugin/
..
After that you can run Tempest tests. There you can specify the name of
test (and even run a single test from directory). One way to run Tempest
tests by using ``ostestr`` command, for instance:
.. sourcecode:: console
$ ostestr networking_l2gw_tempest_plugin.tests.api.test_l2gw_extensions.L2GatewayExtensionTestJSON.test_create_show_list_delete_l2gateway_connection
..
The command ``tempest run`` is another way to run tests. See the additional
information about using this `command <https://docs.openstack.org/tempest/latest/run.html>`_.
For example, the following command will run all the Tempest tests.
.. sourcecode:: console
$ tempest run
..
Finally, you can use ``testr`` directly to run the tests. For example,
the following command will run all the cli-tests:
.. sourcecode:: console
$ testr run networking_l2gw_tempest_plugin.tests.api
..
Useful links:
* `Running Tempest tests with testr <https://docs.openstack.org/tempest/latest/overview.html#legacy-run-method>`_.
* `Using Tempest plugins <https://docs.openstack.org/tempest/latest/plugin.html#using-plugins>`_.
* `Tempest Quickstart <https://docs.openstack.org/tempest/latest/overview.html#quickstart>`_.

@ -1,46 +0,0 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
# L2Gateway related config information
L2GW_OPTS = [
cfg.StrOpt('l2gw_switch',
default='',
help='Switch name ,interface and vlan id information '),
cfg.StrOpt('l2gw_switch_2',
default='',
help='Switch name ,interface and vlan id information'),
cfg.StrOpt('hosts',
default='',
help='Network node and compute node host names and IPs'),
cfg.StrOpt('l2gw_switch_ip',
default='',
help='Switch IP'),
cfg.StrOpt('ovsdb_ip',
default='',
help='IP of ovsdb server'),
cfg.IntOpt('ovsdb_port',
default=6632,
help='Port of ovsdb server'),
cfg.StrOpt('ovsdb_schema_name',
default='',
help='schema name of ovsdb')
]
l2gw_group = cfg.OptGroup(name='l2gw',
title='Neutron L2GW Options')

@ -1,12 +0,0 @@
[l2gw]
#List of switch device,interfaces name and segmentation_ids for l2gateway
l2gw_switch = cell08-5930-01::FortyGigE1/0/1|100
l2gw_switch_2 = cell21-5930-01::FortyGigE1/0/1|101
#l2gw_switch = cell08-5930-01::FortyGigE1/0/1|100#200;FortyGigE1/0/2|300
#l2gw_switch = cell08-5930-01::FortyGigE1/0/1|100#200,cell08-5930-02::FortyGigE1/0/2|300
l2gw_switch_ip = switch_vtep_ip
hosts = cn_host_name:cn_ip, nn_host_name:nn_ip
ovsdb_ip = ovsdb_ip
ovsdb_port = 6632
ovsdb_schema_name = hardware_vtep

@ -1,40 +0,0 @@
# Copyright 2017
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import networking_l2gw_tempest_plugin
from tempest.test_discover import plugins
from networking_l2gw_tempest_plugin import config as l2gw_config
class NeutronL2gwTempestPlugin(plugins.TempestPlugin):
def load_tests(self):
base_path = os.path.split(os.path.dirname(
os.path.abspath(networking_l2gw_tempest_plugin.__file__)))[0]
test_dir = "networking_l2gw_tempest_plugin/tests/api"
full_test_dir = os.path.join(base_path, test_dir)
return full_test_dir, base_path
def register_opts(self, conf):
conf.register_group(l2gw_config.l2gw_group)
conf.register_opts(l2gw_config.L2GW_OPTS,
group=l2gw_config.l2gw_group)
def get_opt_lists(self):
return [
(l2gw_config.l2gw_group.name, l2gw_config.L2GW_OPTS),
]

@ -1,59 +0,0 @@
# Copyright (c) 2019 Ericsson
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.services.network import base
class L2GatewayConnectionsClient(base.BaseNetworkClient):
def create_l2_gateway_connection(self, **kwargs):
"""Creates an l2gw connection.
:param kwargs: dict of l2gw in the form
{'l2_gateway_id': '1234', 'network_id': '4321',
'segmentation_id': '0'}
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateway-connections'
post_data = {'l2_gateway_connection': kwargs}
return self.create_resource(uri, post_data)
def show_l2_gateway_connection(self, l2gw_connection_id, **fields):
"""Show details of an l2gw connection.
:param l2gw_id: The uuid of the l2gw connection.
:param fields: a dict with key fields and a list of fields name
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateway-connections/%s' % l2gw_connection_id
return self.show_resource(uri, **fields)
def delete_l2_gateway_connection(self, l2gw_id):
"""Deletes and l2gw connection.
:param l2gw_id: The uuid of the l2gw connection.
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateway-connections/%s' % l2gw_id
return self.delete_resource(uri)
def list_l2_gateway_connections(self, **filters):
"""Lists l2gw connections.
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateway-connections'
return self.list_resources(uri, **filters)

@ -1,72 +0,0 @@
# Copyright (c) 2019 Ericsson
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.services.network import base
class L2GatewaysClient(base.BaseNetworkClient):
def create_l2_gateway(self, **kwargs):
"""Creates an l2gw.
:param kwargs: dict of l2gw in the form
{'name': 'foo', 'devices': [{'device_name': 'foo',
'interfaces': [{'name': 'bar', 'segmentation_id': 4}]}]
}
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateways'
post_data = {'l2_gateway': kwargs}
return self.create_resource(uri, post_data)
def update_l2_gateway(self, l2gw_id, **kwargs):
"""Updates an l2gw.
:param l2gw_id: The uuid of the l2gw
:param kwargs: dict of l2gw to be updated.
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateways/%s' % l2gw_id
post_data = {'l2_gateway': kwargs}
return self.update_resource(uri, post_data)
def show_l2_gateway(self, l2gw_id, **fields):
"""Show details of an l2gw.
:param l2gw_id: The uuid of the l2gw.
:param fields: a dict with key fields and a list of fields name
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateways/%s' % l2gw_id
return self.show_resource(uri, **fields)
def delete_l2_gateway(self, l2gw_id):
"""Deletes and l2gw.
:param l2gw_id: The uuid of the l2gw.
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateways/%s' % l2gw_id
return self.delete_resource(uri)
def list_l2_gateways(self, **filters):
"""Lists l2gws.
:return: tempest.lib.common.rest_client.ResponseBody
"""
uri = '/l2-gateways'
return self.list_resources(uri, **filters)

@ -1,144 +0,0 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
# Copyright 2015 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.api.network import base
from tempest.common import utils
from tempest import config
from networking_l2gw_tempest_plugin.tests.api import clients
CONF = config.CONF
SEGMENTATION_ID_DELIMITER = "#"
INTERFACE_SEG_ID_DELIMITER = "|"
DEVICE_INTERFACE_DELIMITER = "::"
DEVICE_DELIMITER = ","
INTERFACE_DELIMITER = ";"
"""
Sample for providing input for gateway creation in config is noted below
Options provide flexibility to user to create l2gateway
For single device ,single interface with single vlan
l2gw_switch = device_name1::int_name1|vlan1
For single device multiple interfaces with single or multiple vlans
l2gw_switch = device_name1::int_name1|vlan1#vlan2;int_name2|vlan3
For multiple devices with mutiple interfaces having single or mutiple vlan
l2gw_switch = device_name1::int_name1|vlan1,device_name2::int_name2|vlan2
"""
def get_interface(interfaces):
interface_dict = []
for interface in interfaces:
if INTERFACE_SEG_ID_DELIMITER in interface:
int_name = interface.split(INTERFACE_SEG_ID_DELIMITER)[0]
segid = interface.split(INTERFACE_SEG_ID_DELIMITER)[1]
if SEGMENTATION_ID_DELIMITER in segid:
segid = segid.split(SEGMENTATION_ID_DELIMITER)
else:
segid = [segid]
interface_detail = {'name': int_name, 'segmentation_id': segid}
else:
interface_detail = {'name': interface}
interface_dict.append(interface_detail)
return interface_dict
def get_l2gw_body(l2gw_conf):
device_dict = []
devices = l2gw_conf.split(DEVICE_DELIMITER)
for device in devices:
if DEVICE_INTERFACE_DELIMITER in device:
device_name = device.split(DEVICE_INTERFACE_DELIMITER)[0]
interface = device.split(DEVICE_INTERFACE_DELIMITER)[1]
if INTERFACE_DELIMITER in interface:
interface_dict = interface.split(INTERFACE_DELIMITER)
interfaces = get_interface(interface_dict)
else:
interfaces = get_interface([interface])
device = {'device_name': device_name,
'interfaces': interfaces}
device_dict.append(device)
body = {'devices': device_dict}
return body
def form_dict_devices(devices):
seg_ids = []
devices1 = dict()
int_seg = []
for device in devices:
device_name = device['device_name']
interfaces = device['interfaces']
for interface in interfaces:
interface_name = interface['name']
int_seg.append(interface_name)
seg_id = interface['segmentation_id']
if type(seg_id) is list:
for segid in seg_id:
seg_ids.append(segid)
else:
seg_ids.append(seg_id)
int_seg.append(seg_id)
devices1.setdefault(device_name, []).append(int_seg)
int_seg = []
return devices1
class BaseL2GatewayTest(base.BaseNetworkTest):
force_tenant_isolation = False
credentials = ['primary']
@classmethod
def setup_clients(cls):
super(BaseL2GatewayTest, cls).setup_clients()
cls.l2gws_client = cls.os.l2gw_client
cls.l2gw_conns_client = cls.os.l2gw_connection_client
@classmethod
def resource_setup(cls):
super(BaseL2GatewayTest, cls).resource_setup()
# At least one switch detail should be provided to run the tests
if (len(CONF.l2gw.l2gw_switch) <= 0):
msg = ('At least one switch detail must be defined.')
raise cls.skipException(msg)
if not utils.is_extension_enabled('l2-gateway', 'network'):
msg = "L2Gateway Extension not enabled."
raise cls.skipException(msg)
@classmethod
def get_client_manager(cls, credential_type=None, roles=None,
force_new=None):
manager = super(BaseL2GatewayTest, cls).get_client_manager(
credential_type=credential_type,
roles=roles,
force_new=force_new
)
# Neutron uses a different clients manager than the one in the Tempest
# save the original in case mixed tests need it
if credential_type == 'primary':
cls.os_tempest = manager
return clients.Manager(manager.credentials)
class BaseAdminL2GatewayTest(BaseL2GatewayTest):
credentials = ['primary', 'admin']
@classmethod
def setup_clients(cls):
super(BaseAdminL2GatewayTest, cls).setup_clients()
cls.admin_networks_client = cls.os_admin.networks_client
cls.admin_l2gws_client = cls.os_admin.l2gw_client
cls.admin_l2gw_conns_client = cls.os_admin.l2gw_connection_client

@ -1,92 +0,0 @@
# Copyright (c) 2019 Ericsson
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import clients
from tempest import config
from tempest.lib.services.identity.v2 import tenants_client
from tempest.lib.services.identity.v3 import projects_client
from networking_l2gw_tempest_plugin.services.l2gw import \
l2_gateway_connections_client
from networking_l2gw_tempest_plugin.services.l2gw import l2_gateways_client
CONF = config.CONF
class Manager(clients.Manager):
"""Top level manager for OpenStack tempest clients"""
default_params = {
'disable_ssl_certificate_validation':
CONF.identity.disable_ssl_certificate_validation,
'ca_certs': CONF.identity.ca_certificates_file,
'trace_requests': CONF.debug.trace_requests,
'proxy_url': CONF.service_clients.proxy_url
}
# NOTE: Tempest uses timeout values of compute API if project specific
# timeout values don't exist.
default_params_with_timeout_values = {
'build_interval': CONF.compute.build_interval,
'build_timeout': CONF.compute.build_timeout
}
default_params_with_timeout_values.update(default_params)
def __init__(self, credentials=None, service=None):
super(Manager, self).__init__(credentials=credentials)
self._set_identity_clients()
self.l2gw_client = l2_gateways_client.L2GatewaysClient(
self.auth_provider,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
endpoint_type=CONF.network.endpoint_type,
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params
)
self.l2gw_connection_client = \
l2_gateway_connections_client.L2GatewayConnectionsClient(
self.auth_provider,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
endpoint_type=CONF.network.endpoint_type,
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params
)
params = {
'service': CONF.compute.catalog_type,
'region': CONF.compute.region or CONF.identity.region,
'endpoint_type': CONF.compute.endpoint_type,
'build_interval': CONF.compute.build_interval,
'build_timeout': CONF.compute.build_timeout
}
params.update(self.default_params)
def _set_identity_clients(self):
params = {
'service': CONF.identity.catalog_type,
'region': CONF.identity.region
}
params.update(self.default_params_with_timeout_values)
params_v2_admin = params.copy()
params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
# Client uses admin endpoint type of Keystone API v2
self.tenants_client = tenants_client.TenantsClient(self.auth_provider,
**params_v2_admin)
# Client uses admin endpoint type of Keystone API v3
self.projects_client = projects_client.ProjectsClient(
self.auth_provider, **params_v2_admin)

@ -1,208 +0,0 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
# Copyright 2015 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import random
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from networking_l2gw_tempest_plugin.tests.api import base_l2gw
CONF = config.CONF
class L2GatewayExtensionTestJSON(base_l2gw.BaseAdminL2GatewayTest):
_interface = 'json'
"""
Tests the following operations in the Neutron API using the REST client for
Neutron:
Create l2gateway
List l2gateways
Show l2gateway
Update l2gateway
Delete l2gateway
Create l2gatewayconnection
List l2gatewayconnections
Show l2gatewayconnection
Delete l2gatewayconnection
"""
@decorators.idempotent_id('3ca07946-a3c9-49ac-b058-8be54abecf1f')
def test_create_show_list_update_delete_l2gateway(self):
# Create an L2Gateway
gw_name = data_utils.rand_name('l2gw')
devices = base_l2gw.get_l2gw_body(CONF.l2gw.l2gw_switch)["devices"]
body = self.admin_l2gws_client.create_l2_gateway(
name=gw_name, devices=devices)
l2_gateway = body['l2_gateway']
self.addCleanup(self.admin_l2gws_client.delete_l2_gateway,
l2_gateway['id'])
# Show details of L2Gateway
show_body = self.admin_l2gws_client.show_l2_gateway(l2_gateway['id'])
self.assertEqual(gw_name, show_body['l2_gateway']['name'])
conf_devices = base_l2gw.form_dict_devices(devices)
create_devices = base_l2gw.form_dict_devices(show_body['l2_gateway']
['devices'])
# Validate the resource provided in the conf and created
for k, v in zip(conf_devices.items(), create_devices.items()):
self.assertEqual(k, v)
# List L2Gateways
self.admin_l2gws_client.list_l2_gateways()
# Update the name of an L2Gateway and verify the same
updated_name = 'updated ' + gw_name
update_body = self.admin_l2gws_client.update_l2_gateway(
l2_gateway['id'], name=updated_name)
self.assertEqual(update_body['l2_gateway']['name'], updated_name)
show_body = self.admin_l2gws_client.show_l2_gateway(l2_gateway['id'])
self.assertEqual(show_body['l2_gateway']['name'], updated_name)
@decorators.idempotent_id('3ad5e945-2b42-4ea8-9c03-0bf41d4167f2')
def test_create_show_list_delete_l2gateway_connection(self):
# Create a network
name = data_utils.rand_name('network')
net_body = self.admin_networks_client.create_network(name=name)
net_id = net_body['network']['id']
self.addCleanup(self.admin_networks_client.delete_network, net_id)
# Create an L2Gateway
gw_name = data_utils.rand_name('l2gw')
devices = base_l2gw.get_l2gw_body(CONF.l2gw.l2gw_switch)["devices"]
l2_gw_body = self.admin_l2gws_client.create_l2_gateway(
name=gw_name, devices=devices)
l2_gw_id = l2_gw_body['l2_gateway']['id']
self.addCleanup(self.admin_l2gws_client.delete_l2_gateway, l2_gw_id)
# Create an L2Gateway Connection
l2_gw_conn_body = \
self.admin_l2gw_conns_client.create_l2_gateway_connection(
l2_gateway_id=l2_gw_id, network_id=net_id)
l2_gw_conn_id = l2_gw_conn_body['l2_gateway_connection']['id']
self.addCleanup(
self.admin_l2gw_conns_client.delete_l2_gateway_connection,
l2_gw_conn_id)
# Show details of created L2 Gateway connection
show_body = self.admin_l2gw_conns_client.show_l2_gateway_connection(
l2_gw_conn_id)
l2_gw_conn = show_body['l2_gateway_connection']
self.assertEqual(net_id, l2_gw_conn['network_id'])
self.assertEqual(l2_gw_id, l2_gw_conn['l2_gateway_id'])
# List L2Gateway Connections
self.admin_l2gw_conns_client.list_l2_gateway_connections()
def test_create_l2gw_conn_with_segid_when_l2gw_created_without_segid(self):
# Create an L2Gateway
gw_name = data_utils.rand_name('l2gw')
devices = base_l2gw.get_l2gw_body(CONF.l2gw.l2gw_switch)["devices"]
if devices[0]['interfaces'][0]['segmentation_id']:
seg_id = devices[0]['interfaces'][0]['segmentation_id'][0]
devices[0]['interfaces'][0].pop('segmentation_id')
body = self.admin_l2gws_client.create_l2_gateway(
name=gw_name, devices=devices)
l2_gateway = body['l2_gateway']
l2_gw_id = l2_gateway['id']
self.addCleanup(self.admin_l2gws_client.delete_l2_gateway, l2_gw_id)
# Create a network
name = data_utils.rand_name('network')
net_body = self.admin_networks_client.create_network(name=name)
net_id = net_body['network']['id']
self.addCleanup(self.admin_networks_client.delete_network, net_id)
# Create an L2Gateway Connection
l2_gw_conn_body = \
self.admin_l2gw_conns_client.create_l2_gateway_connection(
l2_gateway_id=l2_gw_id, network_id=net_id,
segmentation_id=seg_id)
l2_gw_conn_id = l2_gw_conn_body['l2_gateway_connection']['id']
l2_gw_seg_id = l2_gw_conn_body['l2_gateway_connection'][
'segmentation_id']
self.addCleanup(
self.admin_l2gw_conns_client.delete_l2_gateway_connection,
l2_gw_conn_id)
# Show details of created L2 Gateway connection
show_body = self.admin_l2gw_conns_client.show_l2_gateway_connection(
l2_gw_conn_id)
l2_gw_conn = show_body['l2_gateway_connection']
self.assertEqual(net_id, l2_gw_conn['network_id'])
self.assertEqual(l2_gw_id, l2_gw_conn['l2_gateway_id'])
self.assertEqual(str(l2_gw_seg_id),
str(l2_gw_conn['segmentation_id']))
def test_create_update_l2gw_with_multiple_devices(self):
# Generating name for multi-device L2Gateway
gw_name = data_utils.rand_name('l2gw')
# Generating a list consisting 3 random segmentation_ids
seg_id = random.sample(range(2, 4095), 3)
# Generating 3 device and interface names
dev_name1 = data_utils.rand_name('device_name')
interface_name1 = data_utils.rand_name('interface')
dev_name2 = data_utils.rand_name('device_name')
interface_name2 = data_utils.rand_name('interface')
dev_name3 = data_utils.rand_name('device_name')
interface_name3 = data_utils.rand_name('interface')
device_name_list = [dev_name1, dev_name2, dev_name3]
interface_name_list = [
interface_name1, interface_name2, interface_name3]
# Forming the device for multi-device L2Gateway
devices_list = [{"device_name": device_name_list[0], "interfaces":[{
"name": interface_name_list[0]}],
"segmentation_id": str(seg_id[0])}, {
"device_name": device_name_list[1], "interfaces":[{
"name": interface_name_list[1]}],
"segmentation_id": str(seg_id[1])}, {
"device_name": device_name_list[2], "interfaces":[{
"name": interface_name_list[2]}],
"segmentation_id": str(seg_id[2])}]
# Create the multi-device L2gateway
body = self.admin_l2gws_client.create_l2_gateway(
name=gw_name, devices=devices_list)
l2_gateway = body['l2_gateway']
l2_gw_id = l2_gateway['id']
self.addCleanup(self.admin_l2gws_client.delete_l2_gateway, l2_gw_id)
# Check the created multi-device L2Gateway
device_list = list(range(3))
interface_list = list(range(3))
show_body = self.admin_l2gws_client.show_l2_gateway(l2_gw_id)
self.assertEqual(gw_name, show_body['l2_gateway']['name'])
self.assertEqual(l2_gateway['id'], show_body['l2_gateway']['id'])
for i in range(3):
device_list[i] = show_body['l2_gateway']['devices'][i][
'device_name']
interface_list[i] = show_body['l2_gateway']['devices'][i][
'interfaces'][0]['name']
for j in [0, 1, 2]:
self.assertIn(device_name_list[j], device_list)
self.assertIn(interface_name_list[j], interface_list)
# Update the gateway device name
device_list_updated = list(range(3))
interface_list_updated = list(range(3))
device_updated = [{"device_name": device_name_list[0], "interfaces":[{
"name": "intNameNew"}]}]
interface_name_list = [
interface_name_list[2], interface_name_list[1], "intNameNew"]
body = self.admin_l2gws_client.update_l2_gateway(
l2_gateway['id'], devices=device_updated)
show_body_updated = self.admin_l2gws_client.show_l2_gateway(
l2_gateway['id'])
# Check updating of multi-device L2gateway
self.assertEqual(gw_name, show_body_updated['l2_gateway']['name'])
self.assertEqual(l2_gateway['id'],
show_body_updated['l2_gateway']['id'])
for k in range(3):
device_list_updated[k] = show_body_updated['l2_gateway'][
'devices'][k]['device_name']
interface_list_updated[k] = show_body_updated['l2_gateway'][
'devices'][k]['interfaces'][0]['name']
for l in range(3):
self.assertIn(device_name_list[l], device_list_updated)
self.assertIn(interface_name_list[l], interface_list_updated)

@ -1,264 +0,0 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
# Copyright 2015 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from random import randint
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from networking_l2gw_tempest_plugin.tests.api import base_l2gw
CONF = config.CONF
class L2GatewaysNegativeTestJSON(base_l2gw.BaseL2GatewayTest):
_interface = 'json'
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('b301d83d-3af3-4712-86dc-a6824e9b14e5')
def test_create_l2gateway_non_admin_user(self):
gw_name = data_utils.rand_name('l2gw')
devices = base_l2gw.get_l2gw_body(CONF.l2gw.l2gw_switch)["devices"]
self.assertRaises(lib_exc.Forbidden,
self.l2gws_client.create_l2_gateway,
name=gw_name, devices=devices)
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('68451dfe-b3b5-4eb1-b03f-9935d4a2dbe7')
def test_list_l2gateway_non_admin_user(self):
self.assertRaises(lib_exc.Forbidden,
self.l2gws_client.list_l2_gateways)
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('f8589452-7aff-4992-b865-5bb5c41fa755')
def test_update_l2gateway_non_admin_user(self):
non_exist_id = data_utils.rand_name('l2gw')
self.assertRaises(lib_exc.Forbidden,
self.l2gws_client.update_l2_gateway,
non_exist_id, name="updated_name")
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('d9f57800-6cae-4770-a2d7-ab60cf7417bf')
def test_delete_l2gateway_non_admin_user(self):
non_exist_id = data_utils.rand_name('l2gw')
self.assertRaises(lib_exc.Forbidden,
self.l2gws_client.delete_l2_gateway,
non_exist_id)
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('c6b61a8d-8c82-497d-9fad-9929c9acf035')
def test_create_l2gateway_connection_non_admin_user(self):
non_exist_id = data_utils.rand_name('network')
self.assertRaises(lib_exc.Forbidden,
self.l2gw_conns_client.create_l2_gateway_connection,
network_id=non_exist_id, l2_gateway_id=non_exist_id)
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('a56a0180-7d98-414c-9a44-fe47a30fe436')
def test_list_l2gateway_connection_non_admin_user(self):
self.assertRaises(lib_exc.Forbidden,
self.l2gw_conns_client.list_l2_gateway_connections)
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('ce42c68d-5c41-4988-8912-233e3fe5c8fd')
def test_delete_l2gateway_connection_non_admin_user(self):
non_exist_id = data_utils.rand_name('l2gwconnection')
self.assertRaises(lib_exc.Forbidden,
self.l2gw_conns_client.delete_l2_gateway_connection,
non_exist_id)
class L2GatewaysNegativeAdminTestJSON(base_l2gw.BaseAdminL2GatewayTest):
_interface = 'json'
@decorators.attr(type=['negative', 'smoke'])
@decorators.idempotent_id('42067b44-3aff-4428-8305-d0496bd38179')
def test_delete_l2gw_associated_l2gw_connection(self):
# Create a network
name = data_utils.rand_name('network')
net_body = self.admin_networks_client.create_network(name=name)
net_id = net_body['network']['id']
self.addCleanup(self.admin_networks_client.delete_network, net_id)
# Create an L2Gateway
gw_name = data_utils.rand_name('l2gw')
devices = base_l2gw.get_l2gw_body(CONF.l2gw.l2gw_switch)["devices"]
body = self.admin_l2gws_client.create_l2_gateway(
name=gw_name, devices=devices)
l2_gateway = body['l2_gateway']
self.addCleanup(self.admin_l2gws_client.delete_l2_gateway,
l2_gateway['id'])
# Create an L2Gateway Connection
l2_gw_conn_body = \
self.admin_l2gw_conns_client.create_l2_gateway_connection(
l2_gateway_id=l2_gateway['id'], network_id=net_id)
l2_gw_conn_id = l2_gw_conn_body['l2_gateway_connection']['id']
self.addCleanup(
self.admin_l2gw_conns_client.delete_l2_gateway_connection,
l2_gw_conn_id)
self.assertRaises(lib_exc.Conflict,
self.admin_l2gws_client.delete_l2_gateway,
l2_gateway['id'])
@decorators.attr(type=['negative', 'smoke'])
def test_create_l2gw_with_empty_device_name(self):
# Create an L2Gateway
seg_id = randint(2, 4094)
seg_id_str = [str(seg_id)]
gw_name = data_utils.rand_name('l2gw')
dev_name = ""
interface_name = data_utils.rand_name('interface')
device = [{"device_name": dev_name, "interfaces":
[{"name": interface_name, "segmentation_id": seg_id_str}]}]
self.assertRaises(lib_exc.BadRequest,
self.admin_l2gws_client.create_l2_gateway,
name=gw_name, devices=device
)
@decorators.attr(type=['negative', 'smoke'])
def test_create_l2gw_connection_with_invalid_segmentation_id(self):
# Create an L2Gateway
gw_name = data_utils.rand_name('l2gw')
dev_name = data_utils.rand_name('device_name')
interface_name = data_utils.rand_name('interface')
devices = [{"device_name": dev_name, "interfaces":
[{"name": interface_name}]}]
body = self.admin_l2gws_client.create_l2_gateway(
name=