9372: test cancel button for jobs and container_requests.
authorradhika <radhika@curoverse.com>
Tue, 14 Jun 2016 17:26:21 +0000 (13:26 -0400)
committerradhika <radhika@curoverse.com>
Tue, 14 Jun 2016 17:26:21 +0000 (13:26 -0400)
apps/workbench/app/controllers/container_requests_controller.rb
apps/workbench/app/models/container_request.rb
apps/workbench/app/models/container_work_unit.rb
apps/workbench/app/views/projects/_show_dashboard.html.erb
apps/workbench/test/integration/application_layout_test.rb
services/api/test/fixtures/containers.yml

index ea268017fa8b1e4c29f8aa8f966fc34e63799fab..4a32cd8171c53ffa64d17a1e4640abb7ca837bf6 100644 (file)
@@ -5,5 +5,10 @@ class ContainerRequestsController < ApplicationController
 
   def cancel
     @object.update_attributes! priority: 0
+    if params[:return_to]
+      redirect_to params[:return_to]
+    else
+      redirect_to @object
+    end
   end
 end
index b41cec9c836d160214c96057a11a3d4309550daa..765300b192cb06fbf57d0b2d6dcedec875a69b50 100644 (file)
@@ -1,8 +1,4 @@
 class ContainerRequest < ArvadosBase
-  def cancel
-    arvados_api_client.api "container_requests/#{self.uuid}/", "cancel", {}
-  end
-
   def work_unit(label=nil)
     ContainerWorkUnit.new(self, label)
   end
index 9796ef8a23c88f7e64773e074f9f28c170027807..2fe1ff06698c452aee44c0e7df143e6a185af36d 100644 (file)
@@ -45,7 +45,7 @@ class ContainerWorkUnit < ProxyWorkUnit
   end
 
   def can_cancel?
-    @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"])
+    @proxied.is_a?(ContainerRequest) && state_label.in?(["Queued", "Locked", "Running"]) && priority > 0
   end
 
   def container_uuid
index 12b3ef2846db568a654dc69ea411fa49df3a56ab..8c394b13e9e43d952156647f583f9c7c90d35f0d 100644 (file)
@@ -1,9 +1,10 @@
   <div class="row">
     <div class="col-md-6">
       <div class="panel panel-default" style="min-height: 10.5em">
-        <div class="panel-heading"><span class="panel-title">Recent pipelines and processes</span>
+        <div class="panel-heading">
+          <span class="panel-title">Recent pipelines and processes</span>
           <% if current_user.andand.is_active %>
-            <span class="pull-right">
+            <span class="pull-right recent-processes-actions">
               <span>
                 <%= link_to(
                 choose_pipeline_templates_path(
       <% nodes = Node.all %>
       <div class="panel panel-default" style="min-height: 10.5em">
         <div class="panel-heading"><span class="panel-title">Compute node status</span>
-          <span class="pull-right">
+          <span class="pull-right compute-node-actions">
             <% if current_user.andand.is_admin %>
               <span>
                 <%= link_to nodes_path, class: 'btn btn-default btn-xs' do %>
index 2d101f94e4c764423fd5af7c89040851f12edca0..02dc06cc0dcceb7ceb2c625cb81fccb012ce6193 100644 (file)
@@ -250,21 +250,57 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
       visit page_with_token(token)
 
       assert_text 'Recent pipelines and processes' # seeing dashboard now
+      within('.recent-processes-actions') do
+        assert page.has_link?('Run a pipeline')
+        assert page.has_link?('All pipelines')
+      end
+
       within('.recent-processes') do
-        page.has_button? 'Run a pipeline'
-        page.has_link? 'All pipelines'
         assert_text 'zzzzz-d1hrv-partdonepipelin'
         assert_text 'zzzzz-d1hrv-twodonepipeline'
         assert_text 'zzzzz-dz642-runningcontainr'
         assert_text 'zzzzz-dz642-runningcontain2'
       end
 
+      within('.compute-node-actions') do
+        if is_admin
+          assert page.has_link?('All nodes')
+        else
+          assert page.has_no_link?('All nodes')
+        end
+        assert page.has_link? 'All jobs'
+      end
+
       within('.compute-node-summary-pane') do
-        page.has_link?('All nodes') if is_admin
-        page.has_link? 'All jobs'
         click_link 'Details'
         assert_text 'compute0'
       end
     end
   end
+
+  [
+    ['jobs', 'running_job_with_components', true],
+    ['pipeline_instances', 'components_is_jobspec', false],
+    ['containers', 'running', false],
+    ['container_requests', 'running', true],
+  ].each do |type, fixture, cancelable|
+    test "cancel button for #{type}/#{fixture}" do
+      if cancelable
+        need_selenium 'to cancel'
+      end
+
+      obj = api_fixture(type)[fixture]
+      visit page_with_token "active", "/#{type}/#{obj['uuid']}"
+
+      assert_text 'created_at'
+      if cancelable
+        assert page.has_button?('Cancel'), 'No Cancel button'
+        click_button 'Cancel'
+        wait_for_ajax
+        assert page.has_no_button?('Cancel'), 'Cancel button not expected after clicking'
+      else
+        assert page.has_no_button?('Cancel'), 'Cancel button not expected'
+      end
+    end
+  end
 end
index 8e2e95ce655973fd4bf7b42bbe60ae107f4dd79f..c250d401dae49f792f4a8ce35b4640f54aa18a45 100644 (file)
@@ -30,6 +30,7 @@ running:
   runtime_constraints:
     ram: 12000000000
     vcpus: 4
+  auth_uuid: zzzzz-gj3su-077z32aux8dg2s1
 
 running-older:
   uuid: zzzzz-dz642-runningcontain2