Fix tests and flake8 issues.

-fix flake8 issues
-fix smoke test
-fix dvs_vcenter_security test

Change-Id: If10cfb5f26aa386cee034335af6a6bc1648d3cad
This commit is contained in:
otsvigun 2016-03-24 17:29:30 +02:00
parent 3362afb42b
commit 5b65862cdc
5 changed files with 153 additions and 149 deletions

View File

@ -1,20 +1,22 @@
# Copyright (c) 2015 Cloudbase Solutions.
# 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.
"""Copyright 2015 Mirantis, Inc.
import neutron.plugins.ml2.drivers.vmware_dvs.agent.dvs_neutron_agent as agent_main
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
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 neutron.plugins.ml2.drivers.vmware_dvs.agent.dvs_neutron_agent\
as agent_main
def main():
"""TODO."""
agent_main.main()

View File

@ -1,4 +1,19 @@
# -*- coding: utf-8 -*-
"""Copyright 2016 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
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.
"""
# -*- coding: utf-8 -*- # noqa
#
# Fuel VMware DVS plugin documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 14 12:14:29 2015.
@ -12,23 +27,21 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [ ]
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -37,14 +50,14 @@ templates_path = ['_templates']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Fuel VMware DVS plugin'
copyright = u'2015, Mirantis Inc.'
copyright = u'2015, Mirantis Inc.' # noqa
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -57,41 +70,41 @@ release = '2.1.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
#exclude_patterns = []
# exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# 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
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# keep_warnings = False
# -- Options for HTML output ----------------------------------------------
@ -103,77 +116,77 @@ html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'FuelVMwareDVSplugindoc'
@ -181,36 +194,37 @@ htmlhelp_basename = 'FuelVMwareDVSplugindoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = { 'classoptions': ',openany,oneside', 'babel': '\\usepackage[english]{babel}'
latex_elements = {
'classoptions': ',openany,oneside', 'babel': '\\usepackage[english]{babel}'
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'FuelVMwareDVSvplugin.tex', u'Fuel VMware DVS plugin user\
guide', u'Mirantis Inc.', 'manual'),
('index', 'FuelVMwareDVSvplugin.tex', u'Fuel VMware DVS plugin user\
guide', u'Mirantis Inc.', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
@ -223,7 +237,7 @@ man_pages = [
]
# If true, show URL addresses after external links.
#man_show_urls = False
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
@ -232,22 +246,22 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'FuelVMwareDVSplugin', u'Fuel VMware DVS plugin user\
guide', u'Mirantis Inc.', 'FuelVMwareDVSplugin',\
'One line description of project.', 'Miscellaneous'),
('index', 'FuelVMwareDVSplugin', u'Fuel VMware DVS plugin user guide',
u'Mirantis Inc.', 'FuelVMwareDVSplugin',
'One line description of project.', 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False
# Insert footnotes where they are defined instead of at the end.
pdf_inline_footnotes = True

View File

@ -26,7 +26,6 @@ from fuelweb_test.settings import SERVTEST_TENANT
from fuelweb_test.settings import SERVTEST_USERNAME
from fuelweb_test.tests.base_test_case import TestBasic
from tests.test_plugin_vmware_dvs_smoke import TestDVSSmoke
from helpers import openstack
@ -34,6 +33,8 @@ from proboscis import test
from proboscis.asserts import assert_true
from tests.test_plugin_vmware_dvs_smoke import TestDVSSmoke
@test(groups=["plugins"])
class TestDVSMaintenance(TestBasic):

View File

@ -245,7 +245,8 @@ class TestDVSSmoke(TestBasic):
cmd = 'fuel plugins --remove {0}=={1}'.format(
plugin.plugin_name, plugin.DVS_PLUGIN_VERSION)
assert_true(self.env.d_env.get_admin_remote().execute(cmd) == 0,
assert_true(
self.env.d_env.get_admin_remote().execute(cmd)['exit_code'] == 0,
'Can not remove plugin.')
self.show_step(3)

View File

@ -462,7 +462,7 @@ class TestDVSSystem(TestBasic):
subnet = os_conn.create_subnet(
subnet_name=network['name'],
network_id=network['id'],
cidr=self.net_data[0][self.net_data[0].keys()[0]],
cidr=self.net_data[0]['net_1'],
ip_version=4)
logger.info("Check that network are created.")
@ -493,7 +493,12 @@ class TestDVSSystem(TestBasic):
)
openstack.verify_instance_state(os_conn)
# Remove default security group
srv_list = os_conn.get_servers()
for srv in srv_list:
srv.remove_security_group(srv.security_groups[0]['name'])
os_conn.goodbye_security()
self.show_step(5)
sec_name = ['SG1', 'SG2']
sg1 = os_conn.nova.security_groups.create(
@ -509,11 +514,8 @@ class TestDVSSystem(TestBasic):
icmp["security_group_rule"]["security_group_id"] = sg2.id
os_conn.neutron.create_security_group_rule(icmp)
logger.info("""Remove default security group
and attach SG_1 and SG2 to instances""")
srv_list = os_conn.get_servers()
logger.info("""Attach SG_1 and SG2 to instances""")
for srv in srv_list:
srv.remove_security_group(srv.security_groups[0]['name'])
srv.add_security_group(sg1.id)
srv.add_security_group(sg2.id)
@ -529,98 +531,82 @@ class TestDVSSystem(TestBasic):
os_conn, floating_ip, remote=ssh_contr,
command='pingv4')
self.show_step(10)
ip_pair = [(ip_1, ip_2)
for ip_1 in floating_ip
for ip_2 in floating_ip
if ip_1 != ip_2]
self.show_step(10)
ip_pair = [(ip_1, ip_2)
for ip_1 in floating_ip
for ip_2 in floating_ip
if ip_1 != ip_2]
for ips in ip_pair:
openstack.remote_execute_command(ips[0], ips[1], ' ')
for ips in ip_pair:
openstack.remote_execute_command(ips[0], ips[1], ' ')
self.show_step(11)
sg_rules = os_conn.neutron.list_security_group_rules()[
'security_group_rules']
sg_rules = [
sg_rule for sg_rule
in os_conn.neutron.list_security_group_rules()[
self.show_step(11)
sg_rules = os_conn.neutron.list_security_group_rules()[
'security_group_rules']
if sg_rule['security_group_id'] in [sg1.id, sg2.id]]
for rule in sg_rules:
os_conn.neutron.delete_security_group_rule(rule['id'])
sg_rules = [
sg_rule for sg_rule
in os_conn.neutron.list_security_group_rules()[
'security_group_rules']
if sg_rule['security_group_id'] in [sg1.id, sg2.id]]
for rule in sg_rules:
os_conn.neutron.delete_security_group_rule(rule['id'])
time.sleep(20) # need wait to update rules on dvs
self.show_step(12)
for ip in floating_ip:
try:
openstack.get_ssh_connection(
ip, self.instance_creds[0],
self.instance_creds[1])
except Exception as e:
logger.info('{}'.format(e))
self.show_step(12)
for ip in floating_ip:
try:
openstack.get_ssh_connection(
ip, self.instance_creds[0],
self.instance_creds[1])
except Exception as e:
logger.info('{}'.format(e))
self.show_step(13)
tcp["security_group_rule"]["security_group_id"] = sg2.id
os_conn.neutron.create_security_group_rule(tcp)
tcp["security_group_rule"]["direction"] = "egress"
os_conn.neutron.create_security_group_rule(tcp)
self.show_step(13)
tcp["security_group_rule"]["security_group_id"] = sg2.id
os_conn.neutron.create_security_group_rule(tcp)
tcp["security_group_rule"]["direction"] = "egress"
os_conn.neutron.create_security_group_rule(tcp)
self.show_step(14)
for ips in ip_pair:
wait(
lambda: openstack.remote_execute_command(
ips[0], ips[1], ' '), timeout=30, interval=5)
time.sleep(20) # need wait to update rules on dvs ports
self.show_step(14)
for ips in ip_pair:
openstack.remote_execute_command(ips[0], ips[1], ' ')
self.show_step(15)
with self.fuel_web.get_ssh_for_node(controller.name) as ssh_contr:
self.show_step(15)
openstack.check_connection_vms(
os_conn, floating_ip, remote=ssh_contr,
command='pingv4', result_of_command=1)
self.show_step(16)
logger.info("Add Ingress and egress rules for ICMP protocol to SG_1")
icmp["security_group_rule"]["security_group_id"] = sg1.id
os_conn.neutron.create_security_group_rule(icmp)
icmp["security_group_rule"]["direction"] = "egress"
os_conn.neutron.create_security_group_rule(icmp)
self.show_step(16)
icmp["security_group_rule"]["security_group_id"] = sg1.id
os_conn.neutron.create_security_group_rule(icmp)
icmp["security_group_rule"]["direction"] = "egress"
os_conn.neutron.create_security_group_rule(icmp)
time.sleep(20) # need wait to update rules on dvs ports
self.show_step(17)
with self.fuel_web.get_ssh_for_node(controller.name) as ssh_contr:
time.sleep(30) # need wait to update rules on dvs ports
self.show_step(17)
openstack.check_connection_vms(
os_conn, floating_ip, remote=ssh_contr,
command='pingv4')
self.show_step(21)
self.show_step(22)
srv_list = os_conn.get_servers()
for srv in srv_list:
for sg in srv.security_groups:
srv.remove_security_group(sg['name'])
srv.add_security_group('default')
# need add tcp rule for ssh to instances
tcp["security_group_rule"]["security_group_id"] = \
[
sg['id']
for sg in os_conn.neutron.list_security_groups()[
'security_groups']
if sg['tenant_id'] == os_conn.get_tenant(SERVTEST_TENANT).id
if sg['name'] == 'default'][0]
tcp["security_group_rule"]["direction"] = "ingress"
os_conn.neutron.create_security_group_rule(tcp)
time.sleep(20) # need wait to update rules on dvs ports
self.show_step(21)
srv_list = os_conn.get_servers()
for srv in srv_list:
for sg in srv.security_groups:
srv.remove_security_group(sg['name'])
self.show_step(22)
for srv in srv_list:
srv.add_security_group('default')
self.show_step(23)
with self.fuel_web.get_ssh_for_node(controller.name) as ssh_contr:
time.sleep(30) # need wait to update rules on dvs ports
self.show_step(23)
openstack.check_connection_vms(
os_conn, floating_ip, remote=ssh_contr,
command='pingv4')
self.show_step(24)
for ips in ip_pair:
openstack.remote_execute_command(ips[0], ips[1], ' ')
self.show_step(24)
for ips in ip_pair:
openstack.remote_execute_command(ips[0], ips[1], ' ')
@test(depends_on=[dvs_vcenter_systest_setup],
groups=["dvs_vcenter_tenants_isolation", 'dvs_vcenter_system'])
@ -835,7 +821,7 @@ class TestDVSSystem(TestBasic):
ip_version=4)
self.show_step(8)
router = admin.create_router('router_1', tenant=tenant)
router = admin.create_router('router_1', tenant=tenant_admin)
admin.add_router_interface(
router_id=router["id"],
subnet_id=subnet["id"])