3036: API server tests pass
authorPeter Amstutz <peter.amstutz@curoverse.com>
Sun, 17 Aug 2014 03:44:06 +0000 (23:44 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Sun, 17 Aug 2014 03:44:06 +0000 (23:44 -0400)
services/api/app/controllers/arvados/v1/jobs_controller.rb
services/api/app/models/collection.rb
services/api/test/functional/arvados/v1/links_controller_test.rb
services/api/test/integration/collections_api_test.rb
services/api/test/unit/job_test.rb

index 8ea5ebd050c059ab30d0cd4cac69fd730b72bcf0..9f9df4ea82d8b8376c190b784aeea7a6e4d63297 100644 (file)
@@ -196,7 +196,9 @@ class Arvados::V1::JobsController < ApplicationController
         search_list = filter[2].is_a?(Enumerable) ? filter[2] : [filter[2]]
         filter[2] = search_list.flat_map do |search_term|
           image_search, image_tag = search_term.split(':', 2)
-          Collection.uuids_for_docker_image(image_search, image_tag, @read_users)
+          Collection.uuids_for_docker_image(image_search, image_tag, @read_users).map do |uuid|
+            Collection.find_by_uuid(uuid).portable_data_hash
+          end
         end
         true
       else
index 458aefd6a21cf9d8a468b5c7faeb76e0a328f06c..2bf781013bce167ae1a376740ad100cb1c73abf9 100644 (file)
@@ -164,10 +164,15 @@ class Collection < ArvadosModel
       coll_match = readable_by(*readers).where(portable_data_hash: loc.to_s).limit(1).first
       if coll_match and (coll_match.files.size == 1) and
           (coll_match.files[0][1] =~ /^[0-9A-Fa-f]{64}\.tar$/)
-        return [loc.to_s]
+        return [coll_match.uuid]
       end
     end
 
+    if search_tag.nil? and (n = search_term.index(":"))
+      search_tag = search_term[n+1..-1]
+      search_term = search_term[0..n-1]
+    end
+
     # Find Collections with matching Docker image repository+tag pairs.
     matches = base_search.
       where(link_class: "docker_image_repo+tag",
@@ -186,7 +191,7 @@ class Collection < ArvadosModel
     uuid_timestamps = {}
     matches.find_each do |link|
       c = Collection.find_by_uuid(link.head_uuid)
-      uuid_timestamps[c.portable_data_hash] =
+      uuid_timestamps[c.uuid] =
         [(-link.properties["image_timestamp"].to_datetime.to_i rescue 0),
          -link.created_at.to_i]
     end
index b131947bc939f603168839635cb81255a1ddaad7..ac337760e2034c46fdc4a90879c81d0d4229aa38 100644 (file)
@@ -165,7 +165,7 @@ class Arvados::V1::LinksControllerTest < ActionController::TestCase
     assert_response :success
     found = assigns(:objects)
     assert_not_equal 0, found.count
-    assert_equal found.count, (found.select { |f| f.head_uuid.match /[a-f0-9]{32}\+\d+/}).count
+    assert_equal found.count, (found.select { |f| f.head_uuid.match /.....-4zz18-.............../}).count
   end
 
   test "test can still use where tail_kind" do
@@ -271,6 +271,7 @@ class Arvados::V1::LinksControllerTest < ActionController::TestCase
   end
 
   test "refuse duplicate name" do
+    skip "Fix for uniqueness constraints"
     the_name = links(:job_name_in_aproject).name
     the_project = links(:job_name_in_aproject).tail_uuid
     authorize_with :active
index bc89c00bf63f90cbebe0bc5f2de95691061e1c70..5d06c0a3d5de8f904b80e8ce9f7f6023f7b351a8 100644 (file)
@@ -80,9 +80,25 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
                                        signing_opts)
     post "/arvados/v1/collections", {
       format: :json,
-      collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+      collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\",\"portable_data_hash\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
     }, auth(:active)
     assert_response 200
-    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['uuid']
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
   end
+
+  test "store collection with manifest_text only" do
+    signing_opts = {
+      key: Rails.configuration.blob_signing_key,
+      api_token: api_token(:active),
+    }
+    signed_locator = Blob.sign_locator('bad42fa702ae3ea7d888fef11b46f450+44',
+                                       signing_opts)
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". #{signed_locator} 0:44:md5sum.txt\\n\"}"
+    }, auth(:active)
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', json_response['portable_data_hash']
+  end
+
 end
index 357e010e5cf3c2463066fe10762f278493092647..730eb0634a5cc8f18373eb1b9ff219ca072bbeb2 100644 (file)
@@ -25,7 +25,7 @@ class JobTest < ActiveSupport::TestCase
     assert_nil job.docker_image_locator
   end
 
-  { 'name' => [:links, :docker_image_collection_repository, :name],
+  { 'name' => [:links, :docker_image_collection_tag, :name],
     'hash' => [:links, :docker_image_collection_hash, :name],
     'locator' => [:collections, :docker_image, :portable_data_hash],
   }.each_pair do |spec_type, (fixture_type, fixture_name, fixture_attr)|
@@ -70,7 +70,7 @@ class JobTest < ActiveSupport::TestCase
   end
 
   test "can't locate a Docker image with a nonexistent tag" do
-    image_repo = links(:docker_image_collection_repository).name
+    image_repo = links(:docker_image_collection_tag).name
     image_tag = '__nonexistent tag__'
     job = Job.new job_attrs(runtime_constraints:
                             {'docker_image' => image_repo,