aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKerim Gokarslan <kgokarsl@cisco.com>2017-08-18 16:05:05 -0700
committerKerim Gokarslan <kgokarsl@cisco.com>2017-08-18 16:37:24 -0700
commit1fe5e7adb3e1d90910c18386ed64d0a787a7bf94 (patch)
tree1f0de78e8851fdc0c16d7aaadf5e2a32b9df19e5
parent5d2becfd9d6398ce9dfd4c83618de42e272ec830 (diff)
[NFVBENCH-7] Return errors when unknown options are passed
1) Return all errors when unknown options are passed 2) Fixed pep8 warnings 3) Fixed image deletion Change-Id: If21ca07c797a602b9a60f3ccae665149ed1ac148 Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
-rw-r--r--docs/testing/user/userguide/conf.py29
-rw-r--r--nfvbench/compute.py2
-rw-r--r--nfvbench/config.py14
-rw-r--r--test/test_nfvbench.py8
4 files changed, 30 insertions, 23 deletions
diff --git a/docs/testing/user/userguide/conf.py b/docs/testing/user/userguide/conf.py
index 638764c..020533c 100644
--- a/docs/testing/user/userguide/conf.py
+++ b/docs/testing/user/userguide/conf.py
@@ -20,8 +20,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
-import sys
from pbr import version as pbr_ver
+import sys
sys.path.insert(0, os.path.abspath('../..'))
@@ -118,13 +118,12 @@ pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
-
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-#html_theme = 'haiku'
+# html_theme = 'haiku'
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
@@ -244,21 +243,21 @@ htmlhelp_basename = 'NFVBenchdoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
- # The paper size ('letterpaper' or 'a4paper').
- #
- # 'papersize': 'letterpaper',
+ # The paper size ('letterpaper' or 'a4paper').
+ #
+ # 'papersize': 'letterpaper',
- # The font size ('10pt', '11pt' or '12pt').
- #
- # 'pointsize': '10pt',
+ # The font size ('10pt', '11pt' or '12pt').
+ #
+ # 'pointsize': '10pt',
- # Additional stuff for the LaTeX preamble.
- #
- # 'preamble': '',
+ # Additional stuff for the LaTeX preamble.
+ #
+ # 'preamble': '',
- # Latex figure (float) alignment
- #
- # 'figure_align': 'htbp',
+ # Latex figure (float) alignment
+ #
+ # 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
diff --git a/nfvbench/compute.py b/nfvbench/compute.py
index c8ec383..681a852 100644
--- a/nfvbench/compute.py
+++ b/nfvbench/compute.py
@@ -90,7 +90,7 @@ class Compute(object):
def delete_image(self, img_name):
try:
LOG.log("Deleting image %s...", img_name)
- img = self.glance_client.images.find(name=img_name)
+ img = self.find_image(image_name=img_name)
self.glance_client.images.delete(img.id)
except Exception:
LOG.error("Failed to delete the image %s.", img_name)
diff --git a/nfvbench/config.py b/nfvbench/config.py
index 2a67b7e..a0587b6 100644
--- a/nfvbench/config.py
+++ b/nfvbench/config.py
@@ -49,17 +49,21 @@ def config_loads(cfg_text, from_cfg=None):
def get_err_config(subset, superset):
+ result = {}
for k, v in subset.items():
if k not in superset:
- return {k: v}
- if v is not None and superset[k] is not None:
+ result.update({k: v})
+ elif v is not None and superset[k] is not None:
if not isinstance(v, type(superset[k])):
- return {k: v}
+ result.update({k: v})
+ continue
if isinstance(v, dict):
res = get_err_config(v, superset[k])
if res:
- return {k: res}
- return None
+ result.update({k: res})
+ if not result:
+ return None
+ return result
def test_config():
diff --git a/test/test_nfvbench.py b/test/test_nfvbench.py
index a220703..a70e71a 100644
--- a/test/test_nfvbench.py
+++ b/test/test_nfvbench.py
@@ -648,7 +648,11 @@ def test_config():
assert(get_err_config({3: "abc"}, refcfg) is None)
# correctly fails
assert(get_err_config({4: 0}, refcfg) == {4: 0})
- assert(get_err_config({2: {0: 1, 1: 2}}, refcfg) == {2: {0: 1}})
+ assert(get_err_config({2: {21: 100, 30: 50}}, refcfg) == {2: {30: 50}})
+ assert(get_err_config({2: {0: 1, 1: 2}}, refcfg) == {2: {0: 1, 1: 2}})
+ assert(get_err_config({2: {0: 1, 1: 2}, 5: 5}, refcfg) == {2: {0: 1, 1: 2}, 5: 5})
# invalid value type
assert(get_err_config({1: 'abc', 2: {21: 0}}, refcfg) == {1: 'abc'})
- assert(get_err_config({2: 100, 5: 10}, refcfg) == {2: 100})
+ assert(get_err_config({2: 100}, refcfg) == {2: 100})
+ # both correctly fail and invalid value type
+ assert(get_err_config({2: 100, 5: 10}, refcfg) == {2: 100, 5: 10})