[ARVADOS] updated: ce2d2f5807822534756e52ac04bc272dd572d13d

git at public.curoverse.com git at public.curoverse.com
Tue May 20 10:30:22 EDT 2014


Summary of changes:
 .../arvados/v1/keep_services_controller.rb         |  9 ++++
 services/api/app/models/keep_disk.rb               | 24 +++++++--
 services/api/app/models/keep_service.rb            | 10 +++-
 services/api/config/routes.rb                      |  1 +
 .../migrate/20140519205916_create_keep_services.rb | 58 +++++++++++++++++-----
 services/api/db/schema.rb                          | 23 +++++++--
 services/api/test/fixtures/keep_disks.yml          | 12 ++---
 services/api/test/fixtures/keep_services.yml       | 13 +++++
 .../arvados/v1/keep_disks_controller_test.rb       | 30 +----------
 .../arvados/v1/keep_services_controller_test.rb    | 23 +++++++++
 .../api/test/unit/keep_service_test.rb             |  2 +-
 11 files changed, 144 insertions(+), 61 deletions(-)
 create mode 100644 services/api/app/controllers/arvados/v1/keep_services_controller.rb
 create mode 100644 services/api/test/fixtures/keep_services.yml
 create mode 100644 services/api/test/functional/arvados/v1/keep_services_controller_test.rb
 copy apps/workbench/test/unit/job_task_test.rb => services/api/test/unit/keep_service_test.rb (61%)

       via  ce2d2f5807822534756e52ac04bc272dd572d13d (commit)
       via  50a277569ad6277d95b7e3be83ddefc7b92661f4 (commit)
      from  efb58099eebde5bebb4cbfba9ce4ba70a142fc56 (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 ce2d2f5807822534756e52ac04bc272dd572d13d
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue May 20 10:30:20 2014 -0400

    2776: Added controller and route for keep_services, fixed tests.

diff --git a/services/api/app/controllers/arvados/v1/keep_services_controller.rb b/services/api/app/controllers/arvados/v1/keep_services_controller.rb
new file mode 100644
index 0000000..5c0375f
--- /dev/null
+++ b/services/api/app/controllers/arvados/v1/keep_services_controller.rb
@@ -0,0 +1,9 @@
+class Arvados::V1::KeepServicesController < ApplicationController
+
+  def find_objects_for_index
+    # all users can list all keep disks
+    @objects = model_class.where('1=1')
+    super
+  end
+
+end
diff --git a/services/api/app/models/keep_disk.rb b/services/api/app/models/keep_disk.rb
index 612696b..71ec963 100644
--- a/services/api/app/models/keep_disk.rb
+++ b/services/api/app/models/keep_disk.rb
@@ -37,10 +37,7 @@ class KeepDisk < ArvadosModel
 
     @bypass_arvados_authorization = true
     self.update_attributes!(o.select { |k,v|
-                             [:service_host,
-                              :service_port,
-                              :service_ssl_flag,
-                              :bytes_total,
+                             [:bytes_total,
                               :bytes_free,
                               :is_readable,
                               :is_writable,
diff --git a/services/api/app/models/keep_service.rb b/services/api/app/models/keep_service.rb
index cd6d62c..3baf098 100644
--- a/services/api/app/models/keep_service.rb
+++ b/services/api/app/models/keep_service.rb
@@ -9,5 +9,7 @@ class KeepService < ArvadosModel
     t.add  :service_ssl_flag
     t.add  :service_type
   end
+  api_accessible :superuser, :extend => :user do |t|
+  end
 
 end
diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb
index 46f0e7b..d5ef141 100644
--- a/services/api/config/routes.rb
+++ b/services/api/config/routes.rb
@@ -27,6 +27,7 @@ Server::Application.routes.draw do
       resources :keep_disks do
         post 'ping', on: :collection
       end
+      resources :keep_services
       resources :links
       resources :logs
       resources :nodes do
diff --git a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
index 2cda44f..5f1402e 100644
--- a/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/keep_disks_controller_test.rb
@@ -6,9 +6,6 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
     authorize_with :admin
     post :ping, {
       ping_secret: '',          # required by discovery doc, but ignored
-      service_host: '::1',
-      service_port: 55555,
-      service_ssl_flag: false,
       filesystem_uuid: 'eb1e77a1-db84-4193-b6e6-ca2894f67d5f'
     }
     assert_response :success
@@ -23,9 +20,6 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
     authorize_with :admin
     opts = {
       ping_secret: '',
-      service_host: '::1',
-      service_port: 55555,
-      service_ssl_flag: false
     }
     post :ping, opts
     assert_response :success
@@ -39,9 +33,6 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
   test "refuse to add keep disk without admin token" do
     post :ping, {
       ping_secret: '',
-      service_host: '::1',
-      service_port: 55555,
-      service_ssl_flag: false
     }
     assert_response 404
   end
@@ -94,25 +85,7 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
     end
   end
 
-  test "search keep_disks by service_port with >= query" do
-    authorize_with :active
-    get :index, {
-      filters: [['service_port', '>=', 25107]]
-    }
-    assert_response :success
-    assert_equal true, assigns(:objects).any?
-  end
-
-  test "search keep_disks by service_port with < query" do
-    authorize_with :active
-    get :index, {
-      filters: [['service_port', '<', 25107]]
-    }
-    assert_response :success
-    assert_equal false, assigns(:objects).any?
-  end
-
-  test "search keep_disks with 'any' operator" do
+  test "search keep_services with 'any' operator" do
     authorize_with :active
     get :index, {
       where: { any: ['contains', 'o2t1q5w'] }
@@ -122,4 +95,5 @@ class Arvados::V1::KeepDisksControllerTest < ActionController::TestCase
     assert_equal true, !!found.index('zzzzz-penuu-5w2o2t1q5wy7fhn')
   end
 
+
 end
diff --git a/services/api/test/functional/arvados/v1/keep_services_controller_test.rb b/services/api/test/functional/arvados/v1/keep_services_controller_test.rb
new file mode 100644
index 0000000..bfa138d
--- /dev/null
+++ b/services/api/test/functional/arvados/v1/keep_services_controller_test.rb
@@ -0,0 +1,23 @@
+require 'test_helper'
+
+class Arvados::V1::KeepServicesControllerTest < ActionController::TestCase
+
+  test "search keep_services by service_port with < query" do
+    authorize_with :active
+    get :index, {
+      filters: [['service_port', '<', 25107]]
+    }
+    assert_response :success
+    assert_equal false, assigns(:objects).any?
+  end
+
+  test "search keep_disks by service_port with >= query" do
+    authorize_with :active
+    get :index, {
+      filters: [['service_port', '>=', 25107]]
+    }
+    assert_response :success
+    assert_equal true, assigns(:objects).any?
+  end
+
+end

commit 50a277569ad6277d95b7e3be83ddefc7b92661f4
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue May 20 10:10:43 2014 -0400

    2776: Added keep_services model and migration.

diff --git a/services/api/app/models/keep_disk.rb b/services/api/app/models/keep_disk.rb
index ee05ec2..612696b 100644
--- a/services/api/app/models/keep_disk.rb
+++ b/services/api/app/models/keep_disk.rb
@@ -17,6 +17,7 @@ class KeepDisk < ArvadosModel
     t.add :service_host
     t.add :service_port
     t.add :service_ssl_flag
+    t.add :keep_service_uuid
   end
   api_accessible :superuser, :extend => :user do |t|
     t.add :ping_secret
@@ -49,6 +50,24 @@ class KeepDisk < ArvadosModel
                            }.merge(last_ping_at: Time.now))
   end
 
+  def service_host
+    KeepService.where(uuid: self.keep_service_uuid) do |k|
+      return k.service_host
+    end
+  end
+
+  def service_port
+    KeepService.where(uuid: self.keep_service_uuid) do |k|
+      return k.service_port
+    end
+  end
+
+  def service_ssl_flag
+    KeepService.where(uuid: self.keep_service_uuid) do |k|
+      return k.service_ssl_flag
+    end
+  end
+
   protected
 
   def ensure_ping_secret
diff --git a/services/api/app/models/keep_service.rb b/services/api/app/models/keep_service.rb
index d7af945..cd6d62c 100644
--- a/services/api/app/models/keep_service.rb
+++ b/services/api/app/models/keep_service.rb
@@ -1,7 +1,13 @@
 class KeepService < ArvadosModel
-  include AssignUuid
+  include HasUuid
   include KindAndEtag
   include CommonApiTemplate
 
+  api_accessible :user, extend: :common do |t|
+    t.add  :service_host
+    t.add  :service_port
+    t.add  :service_ssl_flag
+    t.add  :service_type
+  end
 
 end
diff --git a/services/api/db/migrate/20140519205916_create_keep_services.rb b/services/api/db/migrate/20140519205916_create_keep_services.rb
index 7138737..02caaef 100644
--- a/services/api/db/migrate/20140519205916_create_keep_services.rb
+++ b/services/api/db/migrate/20140519205916_create_keep_services.rb
@@ -1,18 +1,50 @@
 class CreateKeepServices < ActiveRecord::Migration
+  include CurrentApiClient
+
   def change
-    create_table :keep_services do |t|
-      t.string :uuid, :null => false
-      t.string :owner_uuid, :null => false
-      t.string :modified_by_client_uuid
-      t.string :modified_by_user_uuid
-      t.datetime :modified_at
-      t.string   :service_host
-      t.integer  :service_port
-      t.boolean  :service_ssl_flag
-      t.string   :service_type
-
-      t.timestamps
+    act_as_system_user do
+      create_table :keep_services do |t|
+        t.string :uuid, :null => false
+        t.string :owner_uuid, :null => false
+        t.string :modified_by_client_uuid
+        t.string :modified_by_user_uuid
+        t.datetime :modified_at
+        t.string   :service_host
+        t.integer  :service_port
+        t.boolean  :service_ssl_flag
+        t.string   :service_type
+
+        t.timestamps
+      end
+      add_index :keep_services, :uuid, :unique => true
+
+      add_column :keep_disks, :keep_service_uuid, :string
+
+      KeepDisk.reset_column_information
+
+      services = {}
+
+      KeepDisk.find_each do |k|
+        services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"] = {
+          service_host: k[:service_host],
+          service_port: k[:service_port],
+          service_ssl_flag: k[:service_ssl_flag],
+          owner_uuid: k[:owner_uuid]
+        }
+      end
+
+      services.each do |k, v|
+        v['uuid'] = KeepService.create(v).uuid
+      end
+
+      KeepDisk.find_each do |k|
+        k.keep_service_uuid = services["#{k[:service_host]}_#{k[:service_port]}_#{k[:service_ssl_flag]}"]['uuid']
+        k.save
+      end
+
+      remove_column :keep_disks, :service_host
+      remove_column :keep_disks, :service_port
+      remove_column :keep_disks, :service_ssl_flag
     end
-    add_index :keep_services, :uuid, :unique => true
   end
 end
diff --git a/services/api/db/schema.rb b/services/api/db/schema.rb
index 0613cd3..22a0194 100644
--- a/services/api/db/schema.rb
+++ b/services/api/db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20140501165548) do
+ActiveRecord::Schema.define(:version => 20140519205916) do
 
 
 
@@ -225,17 +225,30 @@ ActiveRecord::Schema.define(:version => 20140501165548) do
     t.datetime "last_ping_at"
     t.datetime "created_at",                                :null => false
     t.datetime "updated_at",                                :null => false
-    t.string   "service_host"
-    t.integer  "service_port"
-    t.boolean  "service_ssl_flag"
+    t.string   "keep_service_uuid"
   end
 
   add_index "keep_disks", ["filesystem_uuid"], :name => "index_keep_disks_on_filesystem_uuid"
   add_index "keep_disks", ["last_ping_at"], :name => "index_keep_disks_on_last_ping_at"
   add_index "keep_disks", ["node_uuid"], :name => "index_keep_disks_on_node_uuid"
-  add_index "keep_disks", ["service_host", "service_port", "last_ping_at"], :name => "keep_disks_service_host_port_ping_at_index"
   add_index "keep_disks", ["uuid"], :name => "index_keep_disks_on_uuid", :unique => true
 
+  create_table "keep_services", :force => true do |t|
+    t.string   "uuid",                    :null => false
+    t.string   "owner_uuid",              :null => false
+    t.string   "modified_by_client_uuid"
+    t.string   "modified_by_user_uuid"
+    t.datetime "modified_at"
+    t.string   "service_host"
+    t.integer  "service_port"
+    t.boolean  "service_ssl_flag"
+    t.string   "service_type"
+    t.datetime "created_at",              :null => false
+    t.datetime "updated_at",              :null => false
+  end
+
+  add_index "keep_services", ["uuid"], :name => "index_keep_services_on_uuid", :unique => true
+
   create_table "links", :force => true do |t|
     t.string   "uuid"
     t.string   "owner_uuid"
diff --git a/services/api/test/fixtures/keep_disks.yml b/services/api/test/fixtures/keep_disks.yml
index 87b4370..462b244 100644
--- a/services/api/test/fixtures/keep_disks.yml
+++ b/services/api/test/fixtures/keep_disks.yml
@@ -2,9 +2,7 @@ nonfull:
   uuid: zzzzz-penuu-5w2o2t1q5wy7fhn
   owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
   node_uuid: zzzzz-7ekkf-53y36l1lu5ijveb
-  service_host: keep0.qr1hi.arvadosapi.com
-  service_port: 25107
-  service_ssl_flag: false
+  keep_service_uuid: zzzzz-bi6l4-6zhilxar6r8ey90
   last_read_at: <%= 1.minute.ago.to_s(:db) %>
   last_write_at: <%= 2.minute.ago.to_s(:db) %>
   last_ping_at: <%= 3.minute.ago.to_s(:db) %>
@@ -14,9 +12,7 @@ full:
   uuid: zzzzz-penuu-4kmq58ui07xuftx
   owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
   node_uuid: zzzzz-7ekkf-53y36l1lu5ijveb
-  service_host: keep0.qr1hi.arvadosapi.com
-  service_port: 25107
-  service_ssl_flag: false
+  keep_service_uuid: zzzzz-bi6l4-6zhilxar6r8ey90
   last_read_at: <%= 1.minute.ago.to_s(:db) %>
   last_write_at: <%= 2.day.ago.to_s(:db) %>
   last_ping_at: <%= 3.minute.ago.to_s(:db) %>
@@ -26,9 +22,7 @@ nonfull2:
   uuid: zzzzz-penuu-1ydrih9k2er5j11
   owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
   node_uuid: zzzzz-7ekkf-2z3mc76g2q73aio
-  service_host: keep1.qr1hi.arvadosapi.com
-  service_port: 25107
-  service_ssl_flag: false
+  keep_service_uuid: zzzzz-bi6l4-rsnj3c76ndxb7o0
   last_read_at: <%= 1.minute.ago.to_s(:db) %>
   last_write_at: <%= 2.minute.ago.to_s(:db) %>
   last_ping_at: <%= 3.minute.ago.to_s(:db) %>
diff --git a/services/api/test/fixtures/keep_services.yml b/services/api/test/fixtures/keep_services.yml
new file mode 100644
index 0000000..0fde804
--- /dev/null
+++ b/services/api/test/fixtures/keep_services.yml
@@ -0,0 +1,13 @@
+keep0:
+  uuid: zzzzz-bi6l4-6zhilxar6r8ey90
+  owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  service_host: keep0.qr1hi.arvadosapi.com
+  service_port: 25107
+  service_ssl_flag: false
+
+keep1:
+  uuid: zzzzz-bi6l4-rsnj3c76ndxb7o0
+  owner_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  service_host: keep1.qr1hi.arvadosapi.com
+  service_port: 25107
+  service_ssl_flag: false
\ No newline at end of file
diff --git a/services/api/test/unit/keep_service_test.rb b/services/api/test/unit/keep_service_test.rb
new file mode 100644
index 0000000..72c4f8e
--- /dev/null
+++ b/services/api/test/unit/keep_service_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class KeepServiceTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list