[ARVADOS] updated: 1.1.3-253-gfea63ac

Git user git at public.curoverse.com
Mon Apr 2 11:59:14 EDT 2018


Summary of changes:
 services/api/lib/sweep_trashed_objects.rb |  2 +-
 services/api/test/fixtures/groups.yml     | 12 +++++++++-
 services/api/test/fixtures/jobs.yml       | 11 +++++++++
 services/api/test/unit/group_test.rb      | 40 ++++++++++++++++++++++++++-----
 4 files changed, 57 insertions(+), 8 deletions(-)

       via  fea63ac8216b2a15101bc75cd02586d934897160 (commit)
      from  2e1892bbd21d7ac8432c923fa84eb8526cfae558 (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 fea63ac8216b2a15101bc75cd02586d934897160
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Mon Apr 2 12:57:29 2018 -0300

    12414: Add tests for projects (and their contents) deletion.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/services/api/lib/sweep_trashed_objects.rb b/services/api/lib/sweep_trashed_objects.rb
index 1dc45a0..c4db856 100644
--- a/services/api/lib/sweep_trashed_objects.rb
+++ b/services/api/lib/sweep_trashed_objects.rb
@@ -7,7 +7,7 @@ require 'current_api_client'
 module SweepTrashedObjects
   extend CurrentApiClient
 
-  def delete_project_and_contents(p_uuid)
+  def self.delete_project_and_contents(p_uuid)
     p = Group.find_by_uuid(p_uuid)
     if !p || p.group_class != 'project'
       raise "can't sweep group '#{p_uuid}', it may not exist or not be a project"
diff --git a/services/api/test/fixtures/groups.yml b/services/api/test/fixtures/groups.yml
index 07d46d8..68cc769 100644
--- a/services/api/test/fixtures/groups.yml
+++ b/services/api/test/fixtures/groups.yml
@@ -305,7 +305,7 @@ trashed_project:
   name: trashed project
   group_class: project
   trash_at: 2001-01-01T00:00:00Z
-  delete_at: 2038-03-01T00:00:00Z
+  delete_at: 2008-03-01T00:00:00Z
   is_trashed: true
   modified_at: 2001-01-01T00:00:00Z
 
@@ -325,4 +325,14 @@ trashed_subproject3:
   trash_at: 2001-01-01T00:00:00Z
   delete_at: 2038-03-01T00:00:00Z
   is_trashed: true
+  modified_at: 2001-01-01T00:00:00Z
+
+trashed_on_next_sweep:
+  uuid: zzzzz-j7d0g-soontobetrashed
+  owner_uuid: zzzzz-j7d0g-xurymjxw79nv3jz
+  name: soon to be trashed project
+  group_class: project
+  trash_at: 2001-01-01T00:00:00Z
+  delete_at: 2038-03-01T00:00:00Z
+  is_trashed: false
   modified_at: 2001-01-01T00:00:00Z
\ No newline at end of file
diff --git a/services/api/test/fixtures/jobs.yml b/services/api/test/fixtures/jobs.yml
index 7b1fb90..4b26edc 100644
--- a/services/api/test/fixtures/jobs.yml
+++ b/services/api/test/fixtures/jobs.yml
@@ -415,6 +415,17 @@ job_in_subproject:
   state: Complete
   script_parameters_digest: 99914b932bd37a50b983c5e7c90ae93b
 
+job_in_trashed_project:
+  uuid: zzzzz-8i9sb-subprojectjob02
+  created_at: 2014-10-15 12:00:00
+  owner_uuid: zzzzz-j7d0g-trashedproject1
+  log: ~
+  repository: active/foo
+  script: hash
+  script_version: 4fe459abe02d9b365932b8f5dc419439ab4e2577
+  state: Complete
+  script_parameters_digest: 99914b932bd37a50b983c5e7c90ae93b
+
 running_will_be_completed:
   uuid: zzzzz-8i9sb-rshmckwoma9pjh8
   owner_uuid: zzzzz-j7d0g-v955i6s2oi1cbso
diff --git a/services/api/test/unit/group_test.rb b/services/api/test/unit/group_test.rb
index a5dc0ec..892086b 100644
--- a/services/api/test/unit/group_test.rb
+++ b/services/api/test/unit/group_test.rb
@@ -60,7 +60,7 @@ class GroupTest < ActiveSupport::TestCase
     assert g_foo.errors.messages[:owner_uuid].join(" ").match(/ownership cycle/)
   end
 
-  test "delete group hides contents" do
+  test "trash group hides contents" do
     set_user_from_auth :active_trustedclient
 
     g_foo = Group.create!(name: "foo")
@@ -74,7 +74,7 @@ class GroupTest < ActiveSupport::TestCase
     assert Collection.readable_by(users(:active)).where(uuid: col.uuid).any?
   end
 
-  test "delete group" do
+  test "trash group" do
     set_user_from_auth :active_trustedclient
 
     g_foo = Group.create!(name: "foo")
@@ -95,7 +95,7 @@ class GroupTest < ActiveSupport::TestCase
   end
 
 
-  test "delete subgroup" do
+  test "trash subgroup" do
     set_user_from_auth :active_trustedclient
 
     g_foo = Group.create!(name: "foo")
@@ -115,7 +115,7 @@ class GroupTest < ActiveSupport::TestCase
     assert Group.readable_by(users(:active), {:include_trash => true}).where(uuid: g_baz.uuid).any?
   end
 
-  test "delete subsubgroup" do
+  test "trash subsubgroup" do
     set_user_from_auth :active_trustedclient
 
     g_foo = Group.create!(name: "foo")
@@ -133,7 +133,7 @@ class GroupTest < ActiveSupport::TestCase
   end
 
 
-  test "delete group propagates to subgroups" do
+  test "trash group propagates to subgroups" do
     set_user_from_auth :active_trustedclient
 
     g_foo = groups(:trashed_project)
@@ -158,7 +158,7 @@ class GroupTest < ActiveSupport::TestCase
     assert Group.readable_by(users(:active)).where(uuid: g_bar.uuid).any?
     assert Collection.readable_by(users(:active)).where(uuid: col.uuid).any?
 
-    # this one should still be deleted.
+    # this one should still be trashed.
     assert Group.readable_by(users(:active)).where(uuid: g_baz.uuid).empty?
 
     g_baz.update! is_trashed: false
@@ -189,4 +189,32 @@ class GroupTest < ActiveSupport::TestCase
     assert User.readable_by(users(:admin)).where(uuid:  u_bar.uuid).any?
   end
 
+  test "move projects to trash in SweepTrashedObjects" do
+    p = groups(:trashed_on_next_sweep)
+    assert_empty Group.where('uuid=? and is_trashed=true', p.uuid)
+    SweepTrashedObjects.sweep_now
+    assert_not_empty Group.where('uuid=? and is_trashed=true', p.uuid)
+  end
+
+  test "delete projects and their contents in SweepTrashedObjects" do
+    g_foo = groups(:trashed_project)
+    g_bar = groups(:trashed_subproject)
+    g_baz = groups(:trashed_subproject3)
+    col = collections(:collection_in_trashed_subproject)
+    job = jobs(:job_in_trashed_project)
+    cr = container_requests(:cr_in_trashed_project)
+    assert_not_empty Group.where(uuid: g_foo.uuid)
+    assert_not_empty Group.where(uuid: g_bar.uuid)
+    assert_not_empty Group.where(uuid: g_baz.uuid)
+    assert_not_empty Collection.where(uuid: col.uuid)
+    assert_not_empty Job.where(uuid: job.uuid)
+    assert_not_empty ContainerRequest.where(uuid: cr.uuid)
+    SweepTrashedObjects.sweep_now
+    assert_empty Group.where(uuid: g_foo.uuid)
+    assert_empty Group.where(uuid: g_bar.uuid)
+    assert_empty Group.where(uuid: g_baz.uuid)
+    assert_empty Collection.where(uuid: col.uuid)
+    assert_empty Job.where(uuid: job.uuid)
+    assert_empty ContainerRequest.where(uuid: cr.uuid)
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list