[ARVADOS] created: edac8924047fea353d579b5c4af91530ba54b053
git at public.curoverse.com
git at public.curoverse.com
Tue Oct 21 16:18:49 EDT 2014
at edac8924047fea353d579b5c4af91530ba54b053 (commit)
commit edac8924047fea353d579b5c4af91530ba54b053
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Oct 21 16:18:22 2014 -0400
4084: An actual failing test that detects the "new log lines causes scroll bar to jump to bottom" bug.
diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb
index de64329..7d1a160 100644
--- a/apps/workbench/test/integration/websockets_test.rb
+++ b/apps/workbench/test/integration/websockets_test.rb
@@ -33,4 +33,52 @@ class WebsocketTest < ActionDispatch::IntegrationTest
Thread.current[:arvados_api_token] = nil
end
+ test "test live logging scrolling" do
+ visit(page_with_token("active", "/pipeline_instances/zzzzz-d1hrv-9fm8l10i9z2kqc6"))
+ click_link("Log")
+ assert page.has_no_text? '123 hello'
+
+ api = ArvadosApiClient.new
+
+ text = ""
+ (1..1000).each do |i|
+ text << "#{i} hello\n"
+ end
+
+ Thread.current[:arvados_api_token] = @@API_AUTHS["active"]['api_token']
+ api.api("logs", "", {log: {
+ object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6",
+ event_type: "stderr",
+ properties: {"text" => text}}})
+ assert page.has_text? '1000 hello'
+
+ # First test that when we're already at the bottom of the page, it scrolls down
+ # when a new line is added.
+ old_top = page.evaluate_script("$('#pipeline_event_log_div').scrollTop()")
+
+ api.api("logs", "", {log: {
+ object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6",
+ event_type: "stderr",
+ properties: {"text" => "1001 hello\n"}}})
+ assert page.has_text? '1001 hello'
+
+ # Check that new value of scrollTop is greater than the old one
+ assert page.evaluate_script("$('#pipeline_event_log_div').scrollTop()") > old_top
+
+ # Now scroll to 30 pixels from the top
+ page.execute_script "$('#pipeline_event_log_div').scrollTop(30)"
+ assert_equal 30, page.evaluate_script("$('#pipeline_event_log_div').scrollTop()")
+
+ api.api("logs", "", {log: {
+ object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6",
+ event_type: "stderr",
+ properties: {"text" => "1002 hello\n"}}})
+ assert page.has_text? '1002 hello'
+
+ # Check that we haven't changed scroll position
+ assert_equal 30, page.evaluate_script("$('#pipeline_event_log_div').scrollTop()")
+
+ Thread.current[:arvados_api_token] = nil
+ end
+
end
commit 3203a943bfbed114215ee53c84ecd21a04cb88ff
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Oct 21 15:34:01 2014 -0400
4084: Add live logging test
diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb
index c8ffcfe..de64329 100644
--- a/apps/workbench/test/integration/websockets_test.rb
+++ b/apps/workbench/test/integration/websockets_test.rb
@@ -17,4 +17,20 @@ class WebsocketTest < ActionDispatch::IntegrationTest
assert page.has_text? '"status":400'
end
+ test "test live logging" do
+ visit(page_with_token("active", "/pipeline_instances/zzzzz-d1hrv-9fm8l10i9z2kqc6"))
+ click_link("Log")
+ assert page.has_no_text? '123 hello'
+
+ api = ArvadosApiClient.new
+
+ Thread.current[:arvados_api_token] = @@API_AUTHS["active"]['api_token']
+ api.api("logs", "", {log: {
+ object_uuid: "zzzzz-d1hrv-9fm8l10i9z2kqc6",
+ event_type: "stderr",
+ properties: {"text" => "123 hello"}}})
+ assert page.has_text? '123 hello'
+ Thread.current[:arvados_api_token] = nil
+ end
+
end
commit 22dbb0614da70ce16ec86d906ea222532b3b7c9f
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Oct 21 15:18:40 2014 -0400
4084: Should be able to write tests against websocket-based functionality now.
diff --git a/apps/workbench/test/integration/websockets_test.rb b/apps/workbench/test/integration/websockets_test.rb
new file mode 100644
index 0000000..c8ffcfe
--- /dev/null
+++ b/apps/workbench/test/integration/websockets_test.rb
@@ -0,0 +1,20 @@
+require 'integration_helper'
+require 'selenium-webdriver'
+require 'headless'
+
+class WebsocketTest < ActionDispatch::IntegrationTest
+
+ setup do
+ headless = Headless.new
+ headless.start
+ Capybara.current_driver = :selenium
+ end
+
+ test "test page" do
+ visit(page_with_token("active", "/websockets"))
+ fill_in("websocket-message-content", :with => "Stuff")
+ click_button("Send")
+ assert page.has_text? '"status":400'
+ end
+
+end
diff --git a/apps/workbench/test/test_helper.rb b/apps/workbench/test/test_helper.rb
index 89341a6..c0d6ac8 100644
--- a/apps/workbench/test/test_helper.rb
+++ b/apps/workbench/test/test_helper.rb
@@ -97,18 +97,19 @@ end
class ApiServerForTests
ARV_API_SERVER_DIR = File.expand_path('../../../../services/api', __FILE__)
SERVER_PID_PATH = File.expand_path('tmp/pids/wbtest-server.pid', ARV_API_SERVER_DIR)
+ WEBSOCKET_PID_PATH = File.expand_path('tmp/pids/wstest-server.pid', ARV_API_SERVER_DIR)
@main_process_pid = $$
- def self._system(*cmd)
+ def _system(*cmd)
$stderr.puts "_system #{cmd.inspect}"
Bundler.with_clean_env do
- if not system({'RAILS_ENV' => 'test'}, *cmd)
+ if not system({'RAILS_ENV' => 'test', "ARVADOS_WEBSOCKETS" => (if @websocket then "ws-only" end)}, *cmd)
raise RuntimeError, "#{cmd[0]} returned exit code #{$?.exitstatus}"
end
end
end
- def self.make_ssl_cert
+ def make_ssl_cert
unless File.exists? './self-signed.key'
_system('openssl', 'req', '-new', '-x509', '-nodes',
'-out', './self-signed.pem',
@@ -118,42 +119,49 @@ class ApiServerForTests
end
end
- def self.kill_server
+ def kill_server
if (pid = find_server_pid)
$stderr.puts "Sending TERM to API server, pid #{pid}"
Process.kill 'TERM', pid
end
end
- def self.find_server_pid
+ def find_server_pid
pid = nil
begin
- pid = IO.read(SERVER_PID_PATH).to_i
+ pid = IO.read(if @websocket then WEBSOCKET_PID_PATH else SERVER_PID_PATH end).to_i
$stderr.puts "API server is running, pid #{pid.inspect}"
rescue Errno::ENOENT
end
return pid
end
- def self.run(args=[])
+ def run(args=[])
::MiniTest.after_run do
self.kill_server
end
+ @websocket = args.include?("--websockets")
+
# Kill server left over from previous test run
self.kill_server
Capybara.javascript_driver = :poltergeist
Dir.chdir(ARV_API_SERVER_DIR) do |apidir|
ENV["NO_COVERAGE_TEST"] = "1"
- make_ssl_cert
- _system('bundle', 'exec', 'rake', 'db:test:load')
- _system('bundle', 'exec', 'rake', 'db:fixtures:load')
- _system('bundle', 'exec', 'passenger', 'start', '-d', '-p3000',
- '--pid-file', SERVER_PID_PATH,
- '--ssl',
- '--ssl-certificate', 'self-signed.pem',
- '--ssl-certificate-key', 'self-signed.key')
+ if @websocket
+ _system('bundle', 'exec', 'passenger', 'start', '-d', '-p3333',
+ '--pid-file', WEBSOCKET_PID_PATH)
+ else
+ make_ssl_cert
+ _system('bundle', 'exec', 'rake', 'db:test:load')
+ _system('bundle', 'exec', 'rake', 'db:fixtures:load')
+ _system('bundle', 'exec', 'passenger', 'start', '-d', '-p3000',
+ '--pid-file', SERVER_PID_PATH,
+ '--ssl',
+ '--ssl-certificate', 'self-signed.pem',
+ '--ssl-certificate-key', 'self-signed.key')
+ end
timeout = Time.now.tv_sec + 10
good_pid = false
while (not good_pid) and (Time.now.tv_sec < timeout)
@@ -191,5 +199,6 @@ class ActionController::TestCase
end
if ENV["RAILS_ENV"].eql? 'test'
- ApiServerForTests.run
+ ApiServerForTests.new.run
+ ApiServerForTests.new.run ["--websockets"]
end
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index b85df8c..c665b5f 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -45,6 +45,7 @@ test:
blob_signing_key: zfhgfenhffzltr9dixws36j1yhksjoll2grmku38mi7yxd66h5j4q9w4jzanezacp8s6q0ro3hxakfye02152hncy6zml2ed0uc
user_profile_notification_address: arvados at example.com
workbench_address: https://localhost:3001/
+ websocket_address: ws://127.0.0.1:3333/websocket
common:
uuid_prefix: <%= Digest::MD5.hexdigest(`hostname`).to_i(16).to_s(36)[0..4] %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list