[ARVADOS] created: 77540a1d8b180bc88d2969e3df40b22fb0466f45

git at public.curoverse.com git at public.curoverse.com
Fri Oct 3 17:20:03 EDT 2014


        at  77540a1d8b180bc88d2969e3df40b22fb0466f45 (commit)


commit 77540a1d8b180bc88d2969e3df40b22fb0466f45
Author: radhika <radhika at curoverse.com>
Date:   Fri Oct 3 17:18:12 2014 -0400

    3882: add test to verify a cancelled job stays cancelled on futher cancel actions.

diff --git a/services/api/app/controllers/arvados/v1/jobs_controller.rb b/services/api/app/controllers/arvados/v1/jobs_controller.rb
index 901b742..e2bef88 100644
--- a/services/api/app/controllers/arvados/v1/jobs_controller.rb
+++ b/services/api/app/controllers/arvados/v1/jobs_controller.rb
@@ -96,7 +96,7 @@ class Arvados::V1::JobsController < ApplicationController
 
   def cancel
     reload_object_before_update
-    @object.update_attributes! cancelled_at: Time.now
+    @object.update_attributes! state: Job::Cancelled
     show
   end
 
diff --git a/services/api/test/fixtures/jobs.yml b/services/api/test/fixtures/jobs.yml
index 2be5ef9..5836809 100644
--- a/services/api/test/fixtures/jobs.yml
+++ b/services/api/test/fixtures/jobs.yml
@@ -260,3 +260,27 @@ job_with_real_log:
   log: 0b9a7787660e1fce4a93f33e01376ba6+81
   script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
   state: Complete
+
+cancelled:
+  uuid: zzzzz-8i9sb-4cf0abc123e809j
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  cancelled_at: <%= 1.minute.ago.to_s(:db) %>
+  cancelled_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  cancelled_by_client_uuid: zzzzz-ozdt8-obw7foaks3qjyej
+  created_at: <%= 4.minute.ago.to_s(:db) %>
+  started_at: <%= 3.minute.ago.to_s(:db) %>
+  finished_at: ~
+  script_version: 1de84a854e2b440dc53bf42f8548afa4c17da332
+  running: false
+  success: ~
+  output: ~
+  priority: 0
+  log: ~
+  is_locked_by_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  tasks_summary:
+    failed: 0
+    todo: 3
+    running: 1
+    done: 1
+  runtime_constraints: {}
+  state: Cancelled
diff --git a/services/api/test/functional/arvados/v1/jobs_controller_test.rb b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
index e648523..9beacfd 100644
--- a/services/api/test/functional/arvados/v1/jobs_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
@@ -101,7 +101,47 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
                  'trigger file should be created when job is cancelled')
   end
 
-  test "cancelling a cancelled jobs stays cancelled" do
+  test "cancelling a cancelled job stays cancelled" do
+    # We need to verify that "cancel" creates a trigger file, so first
+    # let's make sure there is no stale trigger file.
+    begin
+      File.unlink(Rails.configuration.crunch_refresh_trigger)
+    rescue Errno::ENOENT
+    end
+
+    authorize_with :active
+    put :update, {
+      id: jobs(:running).uuid,
+      job: {
+        state: 'Cancelled'
+      }
+    }
+    job = JSON.parse(@response.body)
+    assert_not_nil job['cancelled_at'], 'cancelled again job did not stay cancelled'
+    assert_equal job['state'], 'Cancelled', 'cancelled again job state not cancelled'
+  end
+
+  test "cancelling a cancelled job using cancelled_at stays cancelled" do
+    # We need to verify that "cancel" creates a trigger file, so first
+    # let's make sure there is no stale trigger file.
+    begin
+      File.unlink(Rails.configuration.crunch_refresh_trigger)
+    rescue Errno::ENOENT
+    end
+
+    authorize_with :active
+    put :update, {
+      id: jobs(:running).uuid,
+      job: {
+        cancelled_at: Time.now
+      }
+    }
+    job = JSON.parse(@response.body)
+    assert_not_nil job['cancelled_at'], 'cancelled again job did not stay cancelled'
+    assert_equal job['state'], 'Cancelled', 'cancelled again job state not cancelled'
+  end
+
+  test "cancelled to any other state change results in error" do
     # We need to verify that "cancel" creates a trigger file, so first
     # let's make sure there is no stale trigger file.
     begin

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list