Merge branch '18348-log-cluster-id'
[arvados.git] / apps / workbench / test / integration / websockets_test.rb
index 3cfd792e8da9bf38d746e346f7339e7f1cbda755..83494173a9cea146371a703aebf67ffdc77c10ef 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'integration_helper'
 
 class WebsocketTest < ActionDispatch::IntegrationTest
@@ -6,7 +10,7 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     @dispatch_client = ArvadosApiClient.new
   end
 
-  def dispatch_log body
+  def dispatch_log(body)
     use_token :dispatch1 do
       @dispatch_client.api('logs', '', log: body)
     end
@@ -73,67 +77,6 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     end
   end
 
-  test "pipeline instance arv-refresh-on-log-event" do
-    # Do something and check that the pane reloads.
-    p = use_token :active do
-      PipelineInstance.create(state: "RunningOnServer",
-                              components: {
-                                c1: {
-                                  script: "test_hash.py",
-                                  script_version: "1de84a854e2b440dc53bf42f8548afa4c17da332"
-                                }
-                              })
-    end
-    visit(page_with_token("active", "/pipeline_instances/#{p.uuid}"))
-
-    assert_text 'Active'
-    assert page.has_link? 'Pause'
-    assert_no_text 'Complete'
-    assert page.has_no_link? 'Re-run with latest'
-
-    use_token :dispatch1 do
-      p.update_attributes!(state: 'Complete')
-    end
-
-    assert_no_text 'Active'
-    assert page.has_no_link? 'Pause'
-    assert_text 'Complete'
-    assert page.has_link? 'Re-run with latest'
-  end
-
-  test "job arv-refresh-on-log-event" do
-    # Do something and check that the pane reloads.
-    uuid = api_fixture('jobs')['running_will_be_completed']['uuid']
-    visit(page_with_token("active", "/jobs/#{uuid}"))
-
-    assert_no_text 'complete'
-    assert_no_text 'Re-run job'
-
-    use_token :dispatch1 do
-      Job.find(uuid).update_attributes!(state: 'Complete')
-    end
-
-    assert_text 'complete'
-    assert_text 'Re-run job'
-  end
-
-  test "dashboard arv-refresh-on-log-event" do
-    visit(page_with_token("active", "/"))
-
-    assert_no_text 'test dashboard arv-refresh-on-log-event'
-
-    # Do something and check that the pane reloads.
-    use_token :active do
-      p = PipelineInstance.create({state: "RunningOnServer",
-                                    name: "test dashboard arv-refresh-on-log-event",
-                                    components: {
-                                    }
-                                  })
-    end
-
-    assert_text 'test dashboard arv-refresh-on-log-event'
-  end
-
   test 'job graph appears when first data point is already in logs table' do
     job_graph_first_datapoint_test
   end
@@ -201,7 +144,6 @@ class WebsocketTest < ActionDispatch::IntegrationTest
 
   test "test running job with just a few previous log records" do
     job = api_fixture("jobs")['running']
-    visit page_with_token("active", "/jobs/#{job['uuid']}")
 
     # Create just one old log record
     dispatch_log(owner_uuid: job['owner_uuid'],
@@ -209,10 +151,10 @@ class WebsocketTest < ActionDispatch::IntegrationTest
                  event_type: "stderr",
                  properties: {"text" => "Historic log message"})
 
-    click_link("Log")
+    visit page_with_token("active", "/jobs/#{job['uuid']}\#Log")
 
     # Expect "all" historic log records because we have less than
-    # default Rails.configuration.running_job_log_records_to_fetch count
+    # default Rails.configuration.Workbench.RunningJobLogRecordsToFetch
     assert_text 'Historic log message'
 
     # Create new log record and expect it to show up in log tab
@@ -224,25 +166,23 @@ class WebsocketTest < ActionDispatch::IntegrationTest
   end
 
   test "test running job with too many previous log records" do
-    Rails.configuration.running_job_log_records_to_fetch = 5
-
+    max = 5
+    Rails.configuration.Workbench.RunningJobLogRecordsToFetch = max
     job = api_fixture("jobs")['running']
-    visit page_with_token("active", "/jobs/#{job['uuid']}")
 
-    # Create Rails.configuration.running_job_log_records_to_fetch + 1 log records
-    (0..Rails.configuration.running_job_log_records_to_fetch).each do |count|
+    # Create max+1 log records
+    (0..max).each do |count|
       dispatch_log(owner_uuid: job['owner_uuid'],
                    object_uuid: job['uuid'],
                    event_type: "stderr",
                    properties: {"text" => "Old log message #{count}"})
     end
 
-    # Go to log tab, which results in subscribing to websockets
-    click_link("Log")
+    visit page_with_token("active", "/jobs/#{job['uuid']}\#Log")
 
     # Expect all but the first historic log records,
     # because that was one too many than fetch count.
-    (1..Rails.configuration.running_job_log_records_to_fetch).each do |count|
+    (1..max).each do |count|
       assert_text "Old log message #{count}"
     end
     assert_no_text 'Old log message 0'