]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Ensures that task list is a python list 561/head
authorIvo Jimenez <ivo.jimenez@gmail.com>
Tue, 7 Jul 2015 19:38:06 +0000 (12:38 -0700)
committerIvo Jimenez <ivo.jimenez@gmail.com>
Wed, 8 Jul 2015 18:25:52 +0000 (11:25 -0700)
  * Modifies test for task list validation
  * Shows contents of config['tasks'] for error msg
  * Properly checks distinct failure conditions
  * Fixes typo on kernel task AssertionError

README.rst
teuthology/run.py
teuthology/test/test_run.py

index 6fa645e3ad4b7a5d69c573e198a601e6fcbe86ba..30a1d35aa8253a04c3f17c4d0aba4b7d0ca23b92 100644 (file)
@@ -97,7 +97,9 @@ the nodes & use the live cluster ad hoc), might look like this::
 
 The number of entries under ``roles`` and ``targets`` must match.
 
-Note the colon after every task name in the ``tasks`` section.
+Note the colon after every task name in the ``tasks`` section. Also note the
+dashes before each task. This is the YAML syntax for an ordered list and
+specifies the order in which tasks are executed.
 
 The ``install`` task needs to precede all other tasks.
 
index 1db3aa056b600ad51eed3af4234b9ab319808ecb..48a69593e163d779aabc020a4ea179f96fa8ee71 100644 (file)
@@ -151,7 +151,7 @@ def get_summary(owner, description):
 
 def validate_tasks(config):
     """
-    Ensures that config tasks do not include 'kernel'.
+    Ensures that config tasks is a list and doesn't include 'kernel'.
 
     Returns the original tasks key if found.  If not, returns an
     empty list.
@@ -161,8 +161,11 @@ def validate_tasks(config):
         # return the default value for tasks
         return []
 
+    msg = "Expected list in 'tasks'; instead got: {0}".format(config['tasks'])
+    assert isinstance(config['tasks'], list), msg
+
     for task in config['tasks']:
-        msg = ('kernel installation shouldn be a base-level item, not part ' +
+        msg = ('kernel installation should be a base-level item, not part ' +
                'of the tasks list')
         assert 'kernel' not in task, msg
 
index 3f4ba40406ee3779677b7ef74ee6972c426cf1c6..f2c4e9099a04e505c4c9b626eb7b8b5e173ba324 100644 (file)
@@ -74,22 +74,29 @@ class TestRun(object):
         assert result == {"owner": "the_owner", "success": True}
 
     def test_validate_tasks_invalid(self):
-        config = {"tasks": {"kernel": "can't be here"}}
-        with pytest.raises(AssertionError):
+        config = {"tasks": [{"kernel": "can't be here"}]}
+        with pytest.raises(AssertionError) as excinfo:
             run.validate_tasks(config)
+        assert excinfo.value.message.startswith("kernel installation")
 
     def test_validate_task_no_tasks(self):
         result = run.validate_tasks({})
         assert result == []
 
     def test_validate_tasks_valid(self):
-        expected = {"foo": "bar"}
+        expected = [{"foo": "bar"}, {"bar": "foo"}]
         result = run.validate_tasks({"tasks": expected})
         assert result == expected
 
+    def test_validate_tasks_is_list(self):
+        with pytest.raises(AssertionError) as excinfo:
+            run.validate_tasks({"tasks": {"foo": "bar"}})
+        assert excinfo.value.message.startswith("Expected list")
+
     def test_get_initial_tasks_invalid(self):
-        with pytest.raises(AssertionError):
+        with pytest.raises(AssertionError) as excinfo:
             run.get_initial_tasks(True, {"targets": "can't be here"}, "machine_type")
+        assert excinfo.value.message.startswith("You cannot")
 
     def test_get_inital_tasks(self):
         config = {"roles": range(2), "kernel": "the_kernel", "use_existing_cluster": False}