[ARVADOS] updated: 11c04627d0fd81782d6fff890412c7a820cb370a

git at public.curoverse.com git at public.curoverse.com
Thu Jan 8 14:46:43 EST 2015


Summary of changes:
 .../arvados/v1/collections_controller_test.rb      | 31 +++++++
 .../api/test/integration/collections_api_test.rb   | 95 ++++++++++++----------
 services/api/test/unit/collection_test.rb          | 38 +++------
 3 files changed, 94 insertions(+), 70 deletions(-)

       via  11c04627d0fd81782d6fff890412c7a820cb370a (commit)
       via  a2806c0a3f7cc1a2c38539a6e208dff7a3172a88 (commit)
      from  cf670551c6832408f3f24cfad892cbfdd94d913a (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 11c04627d0fd81782d6fff890412c7a820cb370a
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Thu Jan 8 14:44:17 2015 -0500

    4523: add a few functional tests for collections with file_names testing.

diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index 269474a..3023c9f 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -661,4 +661,35 @@ EOS
     }
     assert_response :success
   end
+
+  test "get collection and verify that file_names is not included" do
+    authorize_with :active
+    get :show, {id: collections(:foo_file).uuid}
+    assert_response :success
+    assert_equal collections(:foo_file).uuid, json_response['uuid']
+    assert_nil json_response['file_names']
+    assert json_response['manifest_text']
+  end
+
+  [
+    [2**8, :success],
+    [2**18, 422],
+  ].each do |description_size, expected_response|
+    test "create collection with description size #{description_size}
+          and expect response #{expected_response}" do
+      authorize_with :active
+
+      description = ''
+      while description.length < description_size
+        description += 'a'
+      end
+
+      post :create, collection: {
+        manifest_text: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:foo.txt\n",
+        description: description,
+      }
+
+      assert_response expected_response
+    end
+  end
 end
diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index 83c5b7f..8193213 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -177,7 +177,6 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_equal true, json_response['manifest_text'].include?('my_test_file.txt')
     assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', json_response['portable_data_hash']
-    assert_nil json_response['file_names']
 
     created = json_response
 
@@ -193,7 +192,6 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_equal created['uuid'], json_response['uuid']
     assert_equal true, json_response['manifest_text'].include?('my_updated_test_file.txt')
     assert_equal false, json_response['manifest_text'].include?('my_test_file.txt')
-    assert_nil json_response['file_names']
 
     # search using the new filename
     search_using_filter 'my_updated_test_file.txt', 1, '17d7d7e6f09ae17e3b580143586a1a3f+68'
@@ -216,7 +214,6 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
       first_item = response_items.first
       assert_not_nil first_item
       assert_equal pdh, first_item['portable_data_hash']
-      assert_nil first_item['file_names']
     end
   end
 end
diff --git a/services/api/test/unit/collection_test.rb b/services/api/test/unit/collection_test.rb
index ed257a7..9253ddd 100644
--- a/services/api/test/unit/collection_test.rb
+++ b/services/api/test/unit/collection_test.rb
@@ -52,16 +52,12 @@ class CollectionTest < ActiveSupport::TestCase
   end
 
   [
-    [2**15, 0, false],
-    [2**15, 100, false],
-    [2**15, 2**13, false],
-    [2**15, 2**18, true],
-    [100, 2**18, true],
-    [2**18, 100, false],  # file_names has a max size, hence no error even on large manifest
-  ].each do |manifest_size, description_size, expect_exception|
-    test "create collection with manifest size #{manifest_size},
-          description size #{description_size},
-          expect exception #{expect_exception}" do
+    2**8,
+    2**18,
+  ].each do |manifest_size|
+    test "create collection with manifest size #{manifest_size} and
+          not expect exceptions even on very large manifest texts" do
+      # file_names has a max size, hence there will be no errors even on large manifests
       act_as_system_user do
         manifest_text = '. d41d8cd98f00b204e9800998ecf8427e+0'
         index = 0
@@ -71,26 +67,12 @@ class CollectionTest < ActiveSupport::TestCase
         end
         manifest_text += "\n"
 
-        description = ''
-        while description.length < description_size
-          description += 'a'
-        end
-
-        begin
-          c = Collection.create(manifest_text: manifest_text, description: description)
-        rescue Exception => e
-        end
+        c = Collection.create(manifest_text: manifest_text)
 
-        if !expect_exception
-          assert c.valid?
-          created_file_names = c.file_names
-          assert created_file_names
-        else
-          assert e
-          assert e.message.include? 'exceeds maximum'
-        end
+        assert c.valid?
+        created_file_names = c.file_names
+        assert created_file_names
       end
     end
   end
-
 end

commit a2806c0a3f7cc1a2c38539a6e208dff7a3172a88
Author: Radhika Chippada <radhika at curoverse.com>
Date:   Thu Jan 8 13:01:36 2015 -0500

    4523: separate filename based tests and description based tests.

diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index 8d3ea7e..83c5b7f 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -133,27 +133,36 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_equal 'a name', json_response['name']
   end
 
-  test "create collection, verify file_names not returned, and search with filename" do
-    def search_using_file_name name, expected_items, desc, pdh
-      get '/arvados/v1/collections', {
-        where: { any: ['contains', name] }
-      }, auth(:active)
-      assert_response :success
-      response_items = json_response['items']
-      assert_not_nil response_items
-      if expected_items == 0
-        assert_equal 0, json_response['items_available']
-        assert_equal 0, response_items.size
-      else
-        assert_equal expected_items, response_items.size
-        first_item = response_items.first
-        assert_not_nil first_item
-        assert_equal desc, first_item['description']
-        assert_equal pdh, first_item['portable_data_hash']
-        assert_nil first_item['file_names']
-      end
-    end
+  test "create collection, update description, and search for description" do
+    signing_opts = {
+      key: Rails.configuration.blob_signing_key,
+      api_token: api_token(:active),
+    }
+    signed_locator = Blob.sign_locator('bad42fa702ae1234d999fef11b46f450+44', signing_opts)
+
+    # create collection
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". #{signed_locator} 0:44:foo.txt\\n\"}"
+    }, auth(:active)
+    assert_response :success
+    assert_equal '087e2f211aba2881c08fd8d1646522a3+51', json_response['portable_data_hash']
+
+    # update collection's description
+    put "/arvados/v1/collections/#{json_response['uuid']}", {
+      format: :json,
+      collection: { description: "something specific" }
+    }, auth(:active)
+    assert_response :success
+    assert_equal 'something specific', json_response['description']
+    assert_equal '087e2f211aba2881c08fd8d1646522a3+51', json_response['portable_data_hash']
+
+    # search
+    search_using_filter 'specific', 1, '087e2f211aba2881c08fd8d1646522a3+51'
+    search_using_filter 'not specific enough', 0, nil
+  end
 
+  test "create collection, update manifest, and search with filename" do
     signing_opts = {
       key: Rails.configuration.blob_signing_key,
       api_token: api_token(:active),
@@ -168,28 +177,15 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_equal true, json_response['manifest_text'].include?('my_test_file.txt')
     assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', json_response['portable_data_hash']
-    assert_nil json_response['description']
     assert_nil json_response['file_names']
 
     created = json_response
 
     # search using the filename
-    search_using_file_name 'my_test_file.txt', 1, nil, '0f99f4087beb13dec46d36db9fa6cebf+60'
-
-    # update collection's desc
-    put "/arvados/v1/collections/#{created['uuid']}", {
-      format: :json,
-      collection: { description: "my test collection description" }
-    }, auth(:active)
-    assert_response :success
-    assert_equal created['uuid'], json_response['uuid']
-    assert_equal true, json_response['manifest_text'].include?('my_test_file.txt')
-    assert_equal 'my test collection description', json_response['description']
-    assert_equal '0f99f4087beb13dec46d36db9fa6cebf+60', json_response['portable_data_hash']
-    assert_nil json_response['file_names']
+    search_using_filter 'my_test_file.txt', 1, '0f99f4087beb13dec46d36db9fa6cebf+60'
 
     # update the collection's manifest text
-    put "/arvados/v1/collections/#{json_response['uuid']}", {
+    put "/arvados/v1/collections/#{created['uuid']}", {
       format: :json,
       collection: "{\"manifest_text\":\". #{signed_locator} 0:44:my_updated_test_file.txt\\n\"}"
     }, auth(:active)
@@ -197,12 +193,30 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
     assert_equal created['uuid'], json_response['uuid']
     assert_equal true, json_response['manifest_text'].include?('my_updated_test_file.txt')
     assert_equal false, json_response['manifest_text'].include?('my_test_file.txt')
-    assert_equal 'my test collection description', json_response['description']
-    assert_equal '17d7d7e6f09ae17e3b580143586a1a3f+68', json_response['portable_data_hash']
     assert_nil json_response['file_names']
 
-    search_using_file_name 'my_updated_test_file.txt', 1, 'my test collection description', '17d7d7e6f09ae17e3b580143586a1a3f+68'
-    search_using_file_name 'my_test_file.txt', 0, nil, nil
-    search_using_file_name 'there_is_no_such_file.txt', 0, nil, nil
+    # search using the new filename
+    search_using_filter 'my_updated_test_file.txt', 1, '17d7d7e6f09ae17e3b580143586a1a3f+68'
+    search_using_filter 'my_test_file.txt', 0, nil
+    search_using_filter 'there_is_no_such_file.txt', 0, nil
+  end
+
+  def search_using_filter search_filter, expected_items, pdh
+    get '/arvados/v1/collections', {
+      where: { any: ['contains', search_filter] }
+    }, auth(:active)
+    assert_response :success
+    response_items = json_response['items']
+    assert_not_nil response_items
+    if expected_items == 0
+      assert_equal 0, json_response['items_available']
+      assert_equal 0, response_items.size
+    else
+      assert_equal expected_items, response_items.size
+      first_item = response_items.first
+      assert_not_nil first_item
+      assert_equal pdh, first_item['portable_data_hash']
+      assert_nil first_item['file_names']
+    end
   end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list