[ARVADOS] updated: f889daa8dc1d59878581d0d72a60fb920a5f6320

git at public.curoverse.com git at public.curoverse.com
Mon Jun 16 14:04:11 EDT 2014


Summary of changes:
 services/api/app/models/collection.rb        | 34 ++++++++++++----------------
 services/api/test/fixtures/links.yml         | 10 ++++----
 services/api/test/integration/select_test.rb | 14 ++++++++++--
 3 files changed, 32 insertions(+), 26 deletions(-)

       via  f889daa8dc1d59878581d0d72a60fb920a5f6320 (commit)
       via  e1432f69bb9095f450e67fe24efaea5845685917 (commit)
      from  512eb320c8fdd6de2637761f5eed0fab232ac59b (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 f889daa8dc1d59878581d0d72a60fb920a5f6320
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Jun 16 13:37:12 2014 -0400

    2879: API server only searches Docker images via readable links.

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 5263a3b..64a6bb0 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -151,6 +151,7 @@ class Collection < ArvadosModel
   def self.for_latest_docker_image(search_term, search_tag=nil, readers=nil)
     readers ||= [Thread.current[:user]]
     base_search = Link.
+      readable_by(*readers).
       readable_by(*readers, table_name: "collections").
       joins("JOIN collections ON links.head_uuid = collections.uuid").
       order("links.created_at DESC")
diff --git a/services/api/test/fixtures/links.yml b/services/api/test/fixtures/links.yml
index bfd76dd..ae2511b 100644
--- a/services/api/test/fixtures/links.yml
+++ b/services/api/test/fixtures/links.yml
@@ -457,7 +457,7 @@ active_user_permission_to_docker_image_collection:
 
 docker_image_collection_hash:
   uuid: zzzzz-o0j2j-dockercollhasha
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2014-06-11 14:30:00.184389725 Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
   modified_by_user_uuid: zzzzz-tpzed-000000000000000
@@ -472,7 +472,7 @@ docker_image_collection_hash:
 
 docker_image_collection_repository:
   uuid: zzzzz-o0j2j-dockercollrepos
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2014-06-11 14:30:00.184389725 Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
   modified_by_user_uuid: zzzzz-tpzed-000000000000000
@@ -487,7 +487,7 @@ docker_image_collection_repository:
 
 docker_image_collection_tag:
   uuid: zzzzz-o0j2j-dockercolltagbb
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2014-06-11 14:30:00.184389725 Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
   modified_by_user_uuid: zzzzz-tpzed-000000000000000
@@ -502,7 +502,7 @@ docker_image_collection_tag:
 
 docker_image_collection_tag2:
   uuid: zzzzz-o0j2j-dockercolltagbc
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2014-06-11 14:30:00.184389725 Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
   modified_by_user_uuid: zzzzz-tpzed-000000000000000
@@ -521,7 +521,7 @@ ancient_docker_image_collection_hash:
   # docker_image_collection_hash, but it points to a different
   # Collection and has an older image timestamp.
   uuid: zzzzz-o0j2j-dockercollhashz
-  owner_uuid: zzzzz-tpzed-000000000000000
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   created_at: 2014-06-12 14:30:00.184389725 Z
   modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
   modified_by_user_uuid: zzzzz-tpzed-000000000000000
diff --git a/services/api/test/integration/select_test.rb b/services/api/test/integration/select_test.rb
index b5f09df..2057565 100644
--- a/services/api/test/integration/select_test.rb
+++ b/services/api/test/integration/select_test.rb
@@ -35,6 +35,16 @@ class SelectTest < ActionDispatch::IntegrationTest
     end
   end
 
+  def assert_link_classes_ascend(current_class, prev_class)
+    # Databases and Ruby don't always agree about string ordering with
+    # punctuation.  If the strings aren't ascending normally, check
+    # that they're equal up to punctuation.
+    if current_class < prev_class
+      class_prefix = current_class.split(/\W/).first
+      assert prev_class.start_with?(class_prefix)
+    end
+  end
+
   test "select two columns with order" do
     get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => ['link_class asc', "uuid desc"]}, auth(:active)
     assert_response :success
@@ -49,7 +59,7 @@ class SelectTest < ActionDispatch::IntegrationTest
         prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
       end
 
-      assert i['link_class'] >= prev_link_class
+      assert_link_classes_ascend(i['link_class'], prev_link_class)
       assert i['uuid'] < prev_uuid
 
       prev_link_class = i['link_class']
@@ -71,7 +81,7 @@ class SelectTest < ActionDispatch::IntegrationTest
         prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
       end
 
-      assert i['link_class'] >= prev_link_class
+      assert_link_classes_ascend(i['link_class'], prev_link_class)
       assert i['uuid'] < prev_uuid
 
       prev_link_class = i['link_class']

commit e1432f69bb9095f450e67fe24efaea5845685917
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Jun 16 13:30:29 2014 -0400

    2879: API server only searches Docker image hashes when name search fails.

diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index 29a1f91..5263a3b 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -164,34 +164,29 @@ class Collection < ArvadosModel
     end
 
     # Find Collections with matching Docker image repository+tag pairs.
-    repo_matches = base_search.
+    matches = base_search.
       where(link_class: "docker_image_repo+tag",
             name: "#{search_term}:#{search_tag || 'latest'}")
 
-    # Find Collections with matching Docker image hashes, unless we're
-    # obviously doing a repo+tag search and already found a match that way.
-    if search_tag.nil? or repo_matches.empty?
-      hash_matches = base_search.
+    # If that didn't work, find Collections with matching Docker image hashes.
+    if matches.empty?
+      matches = base_search.
         where("link_class = ? and name LIKE ?",
               "docker_image_hash", "#{search_term}%")
-    else
-      hash_matches = nil
     end
 
-    # Select the image that was created most recently from both repo
-    # and hash matches.  Note that the SQL search order and fallback
-    # timestamp values are chosen so that if image timestamps are
-    # missing, we use the image with the newest link.
+    # Select the image that was created most recently.  Note that the
+    # SQL search order and fallback timestamp values are chosen so
+    # that if image timestamps are missing, we use the image with the
+    # newest link.
     latest_image_link = nil
     latest_image_timestamp = "1900-01-01T00:00:00Z"
-    [repo_matches, hash_matches].compact.each do |search_result|
-      search_result.find_each do |link|
-        link_timestamp = link.properties.fetch("image_timestamp",
-                                               "1900-01-01T00:00:01Z")
-        if link_timestamp > latest_image_timestamp
-          latest_image_link = link
-          latest_image_timestamp = link_timestamp
-        end
+    matches.find_each do |link|
+      link_timestamp = link.properties.fetch("image_timestamp",
+                                             "1900-01-01T00:00:01Z")
+      if link_timestamp > latest_image_timestamp
+        latest_image_link = link
+        latest_image_timestamp = link_timestamp
       end
     end
     latest_image_link.nil? ? nil : find_by_uuid(latest_image_link.head_uuid)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list