[NFVBENCH-7] Return errors when unknown options are passed 97/39897/1
authorKerim Gokarslan <kgokarsl@cisco.com>
Fri, 18 Aug 2017 23:05:05 +0000 (16:05 -0700)
committerKerim Gokarslan <kgokarsl@cisco.com>
Fri, 18 Aug 2017 23:37:24 +0000 (16:37 -0700)
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>
docs/testing/user/userguide/conf.py
nfvbench/compute.py
nfvbench/config.py
test/test_nfvbench.py

index 638764c..020533c 100644 (file)
@@ -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
index c8ec383..681a852 100644 (file)
@@ -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)
index 2a67b7e..a0587b6 100644 (file)
@@ -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():
index a220703..a70e71a 100644 (file)
@@ -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})