[ARVADOS] updated: 497fdb2505efa9a3231c39ec696da6b749d30af2

Git user git at public.curoverse.com
Tue May 3 15:22:57 EDT 2016


Summary of changes:
 sdk/python/arvados/commands/put.py                 | 10 ++--
 sdk/python/tests/test_arv_put.py                   | 16 +++++-
 .../arvnodeman/computenode/driver/__init__.py      |  6 ++-
 .../nodemanager/tests/test_computenode_driver.py   | 61 ++++++++++++++++++++++
 4 files changed, 88 insertions(+), 5 deletions(-)
 create mode 100644 services/nodemanager/tests/test_computenode_driver.py

       via  497fdb2505efa9a3231c39ec696da6b749d30af2 (commit)
       via  149957a7a86cd9fae98edfdc9c797d16656b3684 (commit)
       via  721bd171547f1c1ddcce5532a96f9bb801800757 (commit)
       via  96aad215edcc0f314216c07df9246799665dd19d (commit)
       via  71cca58c580f919c01e0f5fc7b6f469cef3b03c6 (commit)
      from  e8ccb474e5dbfee3d600fdd5ac3218ccb4625eb6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 497fdb2505efa9a3231c39ec696da6b749d30af2
Merge: 96aad21 149957a
Author: Brett Smith <brett at curoverse.com>
Date:   Tue May 3 15:22:33 2016 -0400

    Merge branch '9120-node-manager-search-ex-methods-wip'
    
    Closes #9120, #9124.


commit 149957a7a86cd9fae98edfdc9c797d16656b3684
Author: Brett Smith <brett at curoverse.com>
Date:   Mon May 2 17:06:09 2016 -0400

    9120: search_for_now falls back to real driver methods when needed.
    
    This fixes a regression introduced in 32eb510594.

diff --git a/services/nodemanager/arvnodeman/computenode/driver/__init__.py b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
index 1bf2493..fa9cfff 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/__init__.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/__init__.py
@@ -92,7 +92,11 @@ class BaseComputeNodeDriver(RetryMixin):
           value search for a `term` match on each item.  Returns the
           object's 'id' attribute by default.
         """
-        items = getattr(self, list_method)(**kwargs)
+        try:
+            list_func = getattr(self, list_method)
+        except AttributeError:
+            list_func = getattr(self.real, list_method)
+        items = list_func(**kwargs)
         results = [item for item in items if key(item) == term]
         count = len(results)
         if count != 1:
diff --git a/services/nodemanager/tests/test_computenode_driver.py b/services/nodemanager/tests/test_computenode_driver.py
index 221f3cc..71a39a6 100644
--- a/services/nodemanager/tests/test_computenode_driver.py
+++ b/services/nodemanager/tests/test_computenode_driver.py
@@ -22,6 +22,13 @@ class ComputeNodeDriverTestCase(unittest.TestCase):
         self.assertIs(image, driver.search_for_now('id_1', 'list_images'))
         self.assertEqual(1, self.driver_mock().list_images.call_count)
 
+    def test_search_for_now_uses_private_method(self):
+        net = testutil.cloud_object_mock(1)
+        self.driver_mock().ex_list_networks.return_value = [net]
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        self.assertIs(net, driver.search_for_now('id_1', 'ex_list_networks'))
+        self.assertEqual(1, self.driver_mock().ex_list_networks.call_count)
+
     def test_search_for_now_raises_ValueError_on_zero_results(self):
         self.driver_mock().list_images.return_value = []
         driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)

commit 721bd171547f1c1ddcce5532a96f9bb801800757
Author: Brett Smith <brett at curoverse.com>
Date:   Mon May 2 16:59:21 2016 -0400

    9120: Add tests for BaseComputeNodeDriver's search_for methods.

diff --git a/services/nodemanager/tests/test_computenode_driver.py b/services/nodemanager/tests/test_computenode_driver.py
new file mode 100644
index 0000000..221f3cc
--- /dev/null
+++ b/services/nodemanager/tests/test_computenode_driver.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+from __future__ import absolute_import, print_function
+
+import unittest
+
+import libcloud.common.types as cloud_types
+import mock
+
+import arvnodeman.computenode.driver as driver_base
+from . import testutil
+
+class ComputeNodeDriverTestCase(unittest.TestCase):
+    def setUp(self):
+        self.driver_mock = mock.MagicMock(name='driver_mock')
+        driver_base.BaseComputeNodeDriver.SEARCH_CACHE = {}
+
+    def test_search_for_now_uses_public_method(self):
+        image = testutil.cloud_object_mock(1)
+        self.driver_mock().list_images.return_value = [image]
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        self.assertIs(image, driver.search_for_now('id_1', 'list_images'))
+        self.assertEqual(1, self.driver_mock().list_images.call_count)
+
+    def test_search_for_now_raises_ValueError_on_zero_results(self):
+        self.driver_mock().list_images.return_value = []
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        with self.assertRaises(ValueError) as test:
+            driver.search_for_now('id_1', 'list_images')
+
+    def test_search_for_now_raises_ValueError_on_extra_results(self):
+        image = testutil.cloud_object_mock(1)
+        self.driver_mock().list_images.return_value = [image, image]
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        with self.assertRaises(ValueError) as test:
+            driver.search_for_now('id_1', 'list_images')
+
+    def test_search_for_now_does_not_cache_results(self):
+        image1 = testutil.cloud_object_mock(1)
+        image2 = testutil.cloud_object_mock(1)
+        self.driver_mock().list_images.side_effect = [[image1], [image2]]
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        self.assertIsNot(driver.search_for_now('id_1', 'list_images'),
+                         driver.search_for_now('id_1', 'list_images'))
+        self.assertEqual(2, self.driver_mock().list_images.call_count)
+
+    def test_search_for_returns_cached_results(self):
+        image1 = testutil.cloud_object_mock(1)
+        image2 = testutil.cloud_object_mock(1)
+        self.driver_mock().list_images.side_effect = [[image1], [image2]]
+        driver = driver_base.BaseComputeNodeDriver({}, {}, {}, self.driver_mock)
+        self.assertIs(driver.search_for('id_1', 'list_images'),
+                      driver.search_for('id_1', 'list_images'))
+        self.assertEqual(1, self.driver_mock().list_images.call_count)

commit 96aad215edcc0f314216c07df9246799665dd19d
Merge: e8ccb47 71cca58
Author: Brett Smith <brett at curoverse.com>
Date:   Tue May 3 15:22:00 2016 -0400

    Merge branch '9118-arv-put-nameerror-fix-wip'
    
    Closes #9118, #9127.


commit 71cca58c580f919c01e0f5fc7b6f469cef3b03c6
Author: Brett Smith <brett at curoverse.com>
Date:   Mon May 2 17:47:45 2016 -0400

    9118: Fix arv-put crash when finishing without output.

diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index d3510db..5cb699f 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -508,6 +508,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
     if args.progress:  # Print newline to split stderr from stdout for humans.
         print >>stderr
 
+    output = None
     if args.stream:
         output = writer.manifest_text()
         if args.normalize:
@@ -548,9 +549,12 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
             status = 1
 
     # Print the locator (uuid) of the new collection.
-    stdout.write(output)
-    if not output.endswith('\n'):
-        stdout.write('\n')
+    if output is None:
+        status = status or 1
+    else:
+        stdout.write(output)
+        if not output.endswith('\n'):
+            stdout.write('\n')
 
     for sigcode, orig_handler in orig_signal_handlers.items():
         signal.signal(sigcode, orig_handler)
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index a6c1233..e64d914 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -19,7 +19,7 @@ from cStringIO import StringIO
 import arvados
 import arvados.commands.put as arv_put
 
-from arvados_testutil import ArvadosBaseTestCase
+from arvados_testutil import ArvadosBaseTestCase, fake_httplib2_response
 import run_test_server
 
 class ArvadosPutResumeCacheTest(ArvadosBaseTestCase):
@@ -460,6 +460,20 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase):
                           self.call_main_with_args,
                           ['--project-uuid', self.Z_UUID, '--stream'])
 
+    def test_api_error_handling(self):
+        collections_mock = mock.Mock(name='arv.collections()')
+        coll_create_mock = collections_mock().create().execute
+        coll_create_mock.side_effect = arvados.errors.ApiError(
+            fake_httplib2_response(403), '{}')
+        arv_put.api_client = arvados.api('v1')
+        arv_put.api_client.collections = collections_mock
+        with self.assertRaises(SystemExit) as exc_test:
+            self.call_main_with_args(['/dev/null'])
+        self.assertLess(0, exc_test.exception.args[0])
+        self.assertLess(0, coll_create_mock.call_count)
+        self.assertEqual("", self.main_stdout.getvalue())
+
+
 class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
                             ArvadosBaseTestCase):
     def _getKeepServerConfig():

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list