[ARVADOS] created: 95e59f8e8c427bf199445a75102f1dfaeb4bf8a6

git at public.curoverse.com git at public.curoverse.com
Wed Mar 19 14:50:11 EDT 2014


        at  95e59f8e8c427bf199445a75102f1dfaeb4bf8a6 (commit)


commit 95e59f8e8c427bf199445a75102f1dfaeb4bf8a6
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 14:50:21 2014 -0400

    workbench: Document integration test dependencies.
    
    This adds appropriate notes to the installation guide, and suggestions
    to application.yml.example.

diff --git a/apps/workbench/config/application.yml.example b/apps/workbench/config/application.yml.example
index 395f1a9..5db52ed 100644
--- a/apps/workbench/config/application.yml.example
+++ b/apps/workbench/config/application.yml.example
@@ -18,3 +18,11 @@ common:
   arvados_login_base: https://arvados.local:3000/login
   arvados_v1_base: https://arvados.local:3000/arvados/v1
   arvados_insecure_https: true
+
+test:
+  # When you run the Workbench's integration tests, it starts the API server
+  # as a dependency.  These settings should match the API server's Rails
+  # defaults.  If you adjust those, change these settings to match.
+  arvados_login_base: https://localhost:3001/login
+  arvados_v1_base: https://localhost:3001/arvados/v1
+  arvados_insecure_https: true
diff --git a/doc/install/install-workbench-app.html.textile.liquid b/doc/install/install-workbench-app.html.textile.liquid
index 73fbd15..9c1e560 100644
--- a/doc/install/install-workbench-app.html.textile.liquid
+++ b/doc/install/install-workbench-app.html.textile.liquid
@@ -51,4 +51,8 @@ irb(main):002:0> <span class="userinput">ApiClient.find(1234).update_attribut
 </code></pre>
 </notextile>
 
+h2. Running tests
 
+The Workbench application includes a series of integration tests.  When you run these, it starts the API server in a test environment, with all of its fixtures loaded, then tests Workbench by starting that server and making requests against it.
+
+In addition to bundled gems, running the integration tests requires "PhantomJS":http://phantomjs.org/download.html to test JavaScript elements.  The simplest way to get started is to download one of the binary builds provided, and install the executable into one of the directories in your @$PATH at .
\ No newline at end of file

commit c50aa22b70789edf34fd72741f02f48ea138d5fe
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 12:24:37 2014 -0400

    workbench: Add basic login integration tests.

diff --git a/apps/workbench/test/integration/logins_test.rb b/apps/workbench/test/integration/logins_test.rb
new file mode 100644
index 0000000..84170dd
--- /dev/null
+++ b/apps/workbench/test/integration/logins_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+class LoginsTest < ActionDispatch::IntegrationTest
+  test "login with api_token works after redirect" do
+    visit page_with_token('active_trustedclient')
+    assert page.has_text? 'Recent jobs'
+    assert_no_match(/\bapi_token=/, current_path)
+  end
+
+  test "can't use expired token" do
+    visit page_with_token('expired_trustedclient')
+    assert page.has_text? 'Log in'
+  end
+end

commit 764a15cfda6fc6c612a64f9b8542c408afbda921
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 12:10:51 2014 -0400

    workbench: Add VM integration tests.
    
    This is the "start test" that Ward suggested I implement to start off.
    It's easy but not trivial: it requires JavaScript support and filling
    out a form.

diff --git a/apps/workbench/test/integration/virtual_machines_test.rb b/apps/workbench/test/integration/virtual_machines_test.rb
new file mode 100644
index 0000000..541a7aa
--- /dev/null
+++ b/apps/workbench/test/integration/virtual_machines_test.rb
@@ -0,0 +1,17 @@
+require 'integration_helper'
+
+class VirtualMachinesTest < ActionDispatch::IntegrationTest
+  test "make and name a new virtual machine" do
+    Capybara.current_driver = Capybara.javascript_driver
+    visit page_with_token('admin_trustedclient')
+    click_link 'Virtual machines'
+    assert page.has_text? 'testvm.shell'
+    click_on 'Add a new virtual machine'
+    assert page.has_text? 'none'
+    click_link 'none'
+    assert page.has_text? 'Update hostname'
+    fill_in 'editable-text', with: 'testname'
+    click_button 'editable-submit'
+    assert page.has_text? 'testname'
+  end
+end

commit e348aa5023875dbbbd40a0dc2ee32ea6aee53edd
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 12:09:51 2014 -0400

    workbench: Use Poltergeist for integration tests.
    
    This is faster and will enable us to run integration tests on the
    build server.
    
    PhantomJS (http://phantomjs.org/) has to be installed in the $PATH for
    this to work.

diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index 488a355..b273d91 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -27,6 +27,7 @@ group :test do
   gem 'rvm-capistrano'
   gem 'selenium-webdriver'
   gem 'capybara'
+  gem 'poltergeist'
 end
 
 gem 'jquery-rails'
diff --git a/apps/workbench/Gemfile.lock b/apps/workbench/Gemfile.lock
index 463fa7d..0c65ca8 100644
--- a/apps/workbench/Gemfile.lock
+++ b/apps/workbench/Gemfile.lock
@@ -50,6 +50,7 @@ GEM
       xpath (~> 2.0)
     childprocess (0.5.1)
       ffi (~> 1.0, >= 1.0.11)
+    cliver (0.3.2)
     coffee-rails (3.2.2)
       coffee-script (>= 2.2.0)
       railties (~> 3.2.0)
@@ -102,6 +103,11 @@ GEM
       actionpack
       activesupport
       rails (>= 3.0.0)
+    poltergeist (1.5.0)
+      capybara (~> 2.1)
+      cliver (~> 0.3.1)
+      multi_json (~> 1.0)
+      websocket-driver (>= 0.2.0)
     polyglot (0.3.3)
     rack (1.4.5)
     rack-cache (1.2)
@@ -163,6 +169,7 @@ GEM
       execjs (>= 0.3.0)
       json (>= 1.8.0)
     websocket (1.0.7)
+    websocket-driver (0.3.2)
     xpath (2.0.0)
       nokogiri (~> 1.3)
 
@@ -185,6 +192,7 @@ DEPENDENCIES
   oj
   passenger
   piwik_analytics
+  poltergeist
   rails (~> 3.2.0)
   rvm-capistrano
   sass
diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb
index b6467b5..b3d9f01 100644
--- a/apps/workbench/test/integration_helper.rb
+++ b/apps/workbench/test/integration_helper.rb
@@ -1,5 +1,6 @@
 require 'test_helper'
 require 'capybara/rails'
+require 'capybara/poltergeist'
 require 'uri'
 require 'yaml'
 
@@ -42,6 +43,7 @@ class IntegrationTestRunner < MiniTest::Unit
   end
 
   def _run(args=[])
+    Capybara.javascript_driver = :poltergeist
     server_pid = Dir.chdir($ARV_API_SERVER_DIR) do |apidir|
       _system('bundle', 'exec', 'rake', 'db:test:load')
       _system('bundle', 'exec', 'rake', 'db:fixtures:load')

commit 5a5b2ae2ce1f5898bacb913459ecbc2d575733af
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 11:44:49 2014 -0400

    workbench: Add integration test helper module.
    
    This provide a base test class that provides the Capybara DSL and a
    couple of convenience methods.  It also specifies a test runner class
    that sets up the API server consistently, with the proper environment.

diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb
new file mode 100644
index 0000000..b6467b5
--- /dev/null
+++ b/apps/workbench/test/integration_helper.rb
@@ -0,0 +1,59 @@
+require 'test_helper'
+require 'capybara/rails'
+require 'uri'
+require 'yaml'
+
+$ARV_API_SERVER_DIR = File.expand_path('../../../../services/api', __FILE__)
+
+class ActionDispatch::IntegrationTest
+  # Make the Capybara DSL available in all integration tests
+  include Capybara::DSL
+
+  def self.api_fixture(name)
+    # Returns the data structure from the named API server test fixture.
+    path = File.join($ARV_API_SERVER_DIR, 'test', 'fixtures', "#{name}.yml")
+    YAML.load(IO.read(path))
+  end
+
+  @@API_AUTHS = api_fixture('api_client_authorizations')
+
+  def page_with_token(token, path='/')
+    # Generate a page path with an embedded API token.
+    # Typical usage: visit page_with_token('token_name', page)
+    # The token can be specified by the name of an api_client_authorizations
+    # fixture, or passed as a raw string.
+    api_token = ((@@API_AUTHS.include? token) ?
+                 @@API_AUTHS[token]['api_token'] : token)
+    sep = (path.include? '?') ? '&' : '?'
+    q_string = URI.encode_www_form('api_token' => api_token)
+    "#{path}#{sep}#{q_string}"
+  end
+end
+
+class IntegrationTestRunner < MiniTest::Unit
+  # Launch the API server in test mode, with appropriate environment.
+  @@APIENV = {'RAILS_ENV' => 'test'}
+  ['GEM_HOME', 'GEM_PATH', 'PATH'].each { |key| @@APIENV[key] = ENV[key] }
+
+  def _system(*cmd)
+    if not system(@@APIENV, *cmd, {unsetenv_others: true})
+      raise RuntimeError, "#{cmd[0]} returned exit code #{$?.exitstatus}"
+    end
+  end
+
+  def _run(args=[])
+    server_pid = Dir.chdir($ARV_API_SERVER_DIR) do |apidir|
+      _system('bundle', 'exec', 'rake', 'db:test:load')
+      _system('bundle', 'exec', 'rake', 'db:fixtures:load')
+      _system('bundle', 'exec', 'rails', 'server', '-d')
+      `cat tmp/pids/server.pid`.to_i
+    end
+    begin
+      super(args)
+    ensure
+      Process.kill('TERM', server_pid)
+    end
+  end
+end
+
+MiniTest::Unit.runner = IntegrationTestRunner.new

commit 36b981fd2ddc6c491a9da1c5410ce802ecb13e65
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Mar 19 11:42:30 2014 -0400

    workbench: Add Capybara gem for integration tests.

diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index 6ae12f7..488a355 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -23,6 +23,12 @@ group :assets do
   gem 'uglifier', '>= 1.0.3'
 end
 
+group :test do
+  gem 'rvm-capistrano'
+  gem 'selenium-webdriver'
+  gem 'capybara'
+end
+
 gem 'jquery-rails'
 gem 'bootstrap-sass', '~> 3.1.0'
 gem 'bootstrap-x-editable-rails'
@@ -45,8 +51,6 @@ gem 'less-rails'
 # To use debugger
 #gem 'byebug'
 
-gem 'rvm-capistrano', :group => :test
-
 gem 'passenger', :group => :production
 gem 'andand'
 gem 'RedCloth'
diff --git a/apps/workbench/Gemfile.lock b/apps/workbench/Gemfile.lock
index c7ffeb0..463fa7d 100644
--- a/apps/workbench/Gemfile.lock
+++ b/apps/workbench/Gemfile.lock
@@ -42,6 +42,14 @@ GEM
       net-sftp (>= 2.0.0)
       net-ssh (>= 2.0.14)
       net-ssh-gateway (>= 1.1.0)
+    capybara (2.2.1)
+      mime-types (>= 1.16)
+      nokogiri (>= 1.3.3)
+      rack (>= 1.0.0)
+      rack-test (>= 0.5.4)
+      xpath (~> 2.0)
+    childprocess (0.5.1)
+      ffi (~> 1.0, >= 1.0.11)
     coffee-rails (3.2.2)
       coffee-script (>= 2.2.0)
       railties (~> 3.2.0)
@@ -54,6 +62,7 @@ GEM
     deep_merge (1.0.1)
     erubis (2.7.0)
     execjs (2.0.2)
+    ffi (1.9.3)
     highline (1.6.20)
     hike (1.2.3)
     httpclient (2.3.4.1)
@@ -73,6 +82,7 @@ GEM
       mime-types (~> 1.16)
       treetop (~> 1.4.8)
     mime-types (1.25)
+    mini_portile (0.5.2)
     multi_json (1.8.2)
     net-scp (1.1.2)
       net-ssh (>= 2.6.5)
@@ -81,6 +91,8 @@ GEM
     net-ssh (2.7.0)
     net-ssh-gateway (1.2.0)
       net-ssh (>= 2.6.5)
+    nokogiri (1.6.1)
+      mini_portile (~> 0.5.0)
     oj (2.1.7)
     passenger (4.0.23)
       daemon_controller (>= 1.1.0)
@@ -117,6 +129,7 @@ GEM
     rdoc (3.12.2)
       json (~> 1.4)
     ref (1.0.5)
+    rubyzip (1.1.0)
     rvm-capistrano (1.5.1)
       capistrano (~> 2.15.4)
     sass (3.2.12)
@@ -124,6 +137,11 @@ GEM
       railties (~> 3.2.0)
       sass (>= 3.1.10)
       tilt (~> 1.3)
+    selenium-webdriver (2.40.0)
+      childprocess (>= 0.5.0)
+      multi_json (~> 1.0)
+      rubyzip (~> 1.0)
+      websocket (~> 1.0.4)
     sprockets (2.2.2)
       hike (~> 1.2)
       multi_json (~> 1.0)
@@ -144,6 +162,9 @@ GEM
     uglifier (2.3.1)
       execjs (>= 0.3.0)
       json (>= 1.8.0)
+    websocket (1.0.7)
+    xpath (2.0.0)
+      nokogiri (~> 1.3)
 
 PLATFORMS
   ruby
@@ -153,6 +174,7 @@ DEPENDENCIES
   andand
   bootstrap-sass (~> 3.1.0)
   bootstrap-x-editable-rails
+  capybara
   coffee-rails (~> 3.2.0)
   deep_merge
   httpclient
@@ -167,6 +189,7 @@ DEPENDENCIES
   rvm-capistrano
   sass
   sass-rails (~> 3.2.0)
+  selenium-webdriver
   sqlite3
   themes_for_rails
   therubyracer

commit 366c5db829a38cfceb5894a4af5ee4c3ec5901c8
Author: Brett Smith <brett at curoverse.com>
Date:   Mon Mar 17 14:48:02 2014 -0400

    js: Add identifiers to X-Editable templates.
    
    This gives the form elements name and id attributes, as appropriate.
    This will make it easier for us to refer to them in integration tests.

diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js
index e37b944..e6799bf 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/editable.js
@@ -23,3 +23,12 @@ $.fn.editable.defaults.validate = function (value) {
         return "Invalid selection";
     }
 }
+
+$.fn.editabletypes.text.defaults.tpl = '<input type="text" name="editable-text">'
+
+$.fn.editableform.buttons = '\
+<button type="submit" class="btn btn-primary btn-sm editable-submit" \
+  id="editable-submit"><i class="glyphicon glyphicon-ok"></i></button>\
+<button type="button" class="btn btn-default btn-sm editable-cancel" \
+  id="editable-cancel"><i class="glyphicon glyphicon-remove"></i></button>\
+'

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list