blade-sauce_labs_plugin 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2733717f9692c727f0ab682719aed8d0ee0d4774
4
- data.tar.gz: 3e1c39b55266c0699876b259dba3defcd070c956
3
+ metadata.gz: 36b3598b5eaa5726a03629ec518e327f316bd556
4
+ data.tar.gz: f30ffedd23ac0dc98cb70bf3135690bc92b0bacc
5
5
  SHA512:
6
- metadata.gz: 57434ce3d3b2ed0076ca5144f9b13ba4c10ed2af88658ce9c88d699b55f28bc520aa266e9cbb4c845618eff6c49c6ab91af91557ba2839befbcee9c66589dc74
7
- data.tar.gz: 46cede3586837f693d622bff817d05a506c11adcfb82b7cc06fe490fedfe25a62d725aa0e2a1e015d886aa367ad5eb55ba51ad2ec5e964907de3edcada4cfc1c
6
+ metadata.gz: c7acce2a43bc42c59722174128be43291d8018f0480c02ae85b6d506cc44ce1ede98d46c62bb8bc78c95b1619a61e9d063e74820dcb723c4cea78f14fe276631
7
+ data.tar.gz: b91a3980daba289f58775c094e6eae01d13c1dd6b1efe842fd2033feb76eb1d28b2df2cffc1b3b5855a6768b38c12c116b0dce1febd1ff442f14e69fdbbff3e7
data/README.md CHANGED
@@ -1 +1,69 @@
1
1
  [Blade](https://github.com/javan/blade) plugin for [Sauce Labs](https://saucelabs.com/)
2
+
3
+ ## Configuration
4
+
5
+ ### Authenticate with Sauce Labs
6
+
7
+ Set the `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables to authenticate with Sauce Labs.
8
+
9
+ All CI tools provide a way to set environment variables for a test run. For non-CI test runs, set the environment variables in your shell or in your test runner script.
10
+
11
+ ### Pick the browsers to run against
12
+
13
+ Rather than exhaustively list every permutation of devices, operating systems,
14
+ and browsers, we use a shorthand to match all the platforms we target.
15
+
16
+ Full example:
17
+ ```yaml
18
+ plugins:
19
+ sauce_labs:
20
+ browsers:
21
+ # Internet Explorer 11 on every device and operating system it supports.
22
+ IE: 11
23
+
24
+ # Latest two Chrome releases on all Mac and Windows platforms:
25
+ Google Chrome:
26
+ os: Mac, Windows
27
+ version: -2
28
+
29
+ # Latest two Firefox releases on every platform:
30
+ Firefox:
31
+ version: -2
32
+
33
+ # Latest Safari release on every Mac platform (OS X 10.x):
34
+ Safari:
35
+ platform: Mac
36
+ version: -1
37
+
38
+ # Latest two Edge releases on every platform:
39
+ Microsoft Edge:
40
+ version: -2
41
+
42
+ # Specific iOS Mobile Safari versions:
43
+ iPhone:
44
+ version: [9.2, 8.4]
45
+
46
+ # Mobile-specific browser:
47
+ Motorola Droid 4 Emulator:
48
+ version: [5.1, 4.4]
49
+ ```
50
+
51
+ See Sauce Labs' [Platform Configurator](https://wiki.saucelabs.com/display/DOCS/Platform+Configurator) for an exhaustive list of supported devices, operating systems, and browsers.
52
+
53
+ ### Advanced configuration
54
+
55
+ For low-level Sauce Connect configuration, set `tunnel_args` to an array of command line arguments.
56
+
57
+ Example:
58
+ ```yaml
59
+ plugins:
60
+ sauce_labs:
61
+ tunnel_args:
62
+ - "--verbose" # Turn on verbose logging.
63
+ - "--vm-version" # Use the varnish VM for WebSockets support.
64
+ - "dev-varnish"
65
+ ```
66
+
67
+ The plugin already sets the `--user`, `--api-key`, `--tunnel-identifier`, and `--readyfile` arguments, so don't set these yourself.
68
+
69
+ Full [Sauce Connect command line reference](https://wiki.saucelabs.com/pages/viewpage.action?pageId=48365781).
data/bin/update_sc ADDED
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ which -s wget || brew install wget
5
+ which -s jq || brew install jq
6
+
7
+ download_and_extract() {
8
+ local url="$1"
9
+ local dirname="$2"
10
+ local extension="$3"
11
+ local filename="$dirname$extension"
12
+
13
+ wget "$url" -O "$filename"
14
+ tar -zxvf "$filename" -C "$dirname" --strip=1
15
+ rm -f "$filename"
16
+ }
17
+
18
+ platforms=$(curl https://saucelabs.com/versions.json | jq '."Sauce Connect"')
19
+
20
+ osx_url=$(echo "$platforms" | jq --raw-output '.osx.download_url')
21
+ linux_url=$(echo "$platforms" | jq --raw-output '.linux.download_url')
22
+
23
+ cd support
24
+ download_and_extract "$osx_url" "sc-osx" ".zip"
25
+ download_and_extract "$linux_url" "sc-linux" ".tar.gz"
@@ -3,7 +3,7 @@ module Blade::SauceLabsPlugin::JobManager
3
3
 
4
4
  Job = Blade::SauceLabsPlugin::Job
5
5
 
6
- delegate :config, :client, to: Blade::SauceLabsPlugin
6
+ delegate :config, :client, :session_manager, to: Blade::SauceLabsPlugin
7
7
 
8
8
  cattr_accessor(:job_queue) { EM::Queue.new }
9
9
  cattr_accessor(:jobs) { [] }
@@ -11,7 +11,12 @@ module Blade::SauceLabsPlugin::JobManager
11
11
  def start
12
12
  enqueue_jobs
13
13
  process_queue
14
- handle_completed_jobs
14
+
15
+ Blade.subscribe("/results") do |details|
16
+ if details[:completed]
17
+ EM.add_timer(1) { process_queue }
18
+ end
19
+ end
15
20
  end
16
21
 
17
22
  def stop
@@ -36,6 +41,7 @@ module Blade::SauceLabsPlugin::JobManager
36
41
  job_queue.pop do |job|
37
42
  job.callback do
38
43
  jobs << job
44
+ session_manager.update(job.session_id, job: job)
39
45
  end
40
46
 
41
47
  job.errback do
@@ -65,18 +71,6 @@ module Blade::SauceLabsPlugin::JobManager
65
71
  end
66
72
  end
67
73
 
68
- def handle_completed_jobs
69
- Blade.subscribe("/results") do |details|
70
- if details["completed"]
71
- if job = jobs.detect { |job| job.session_id == details["session_id"] }
72
- job.stop
73
- job.update(passed: (details["state"] != "failed"))
74
- EM.add_timer(1) { process_queue }
75
- end
76
- end
77
- end
78
- end
79
-
80
74
  def test_params
81
75
  camelize_keys(combined_test_config)
82
76
  end
@@ -0,0 +1,39 @@
1
+ module Blade::SauceLabsPlugin::SessionManager
2
+ extend self
3
+
4
+ delegate :client, to: Blade::SauceLabsPlugin
5
+
6
+ mattr_accessor(:sessions) { Hash.new }
7
+
8
+ def start
9
+ Blade.config.expected_sessions = client.platforms.size
10
+ handle_completed_jobs
11
+ end
12
+
13
+ def stop
14
+ end
15
+
16
+ def update(session_id, data = {})
17
+ session =
18
+ if sessions[session_id]
19
+ sessions[session_id].merge!(data)
20
+ else
21
+ sessions[session_id] = data
22
+ end
23
+
24
+ if session.has_key?(:job) && session.has_key?(:passed)
25
+ session[:job].update(passed: session[:passed])
26
+ session[:job].stop
27
+ end
28
+ end
29
+
30
+ private
31
+ def handle_completed_jobs
32
+ Blade.subscribe("/results") do |details|
33
+ if details[:completed]
34
+ passed = details[:state] != "failed"
35
+ update(details[:session_id], passed: passed)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -36,6 +36,7 @@ module Blade::SauceLabsPlugin::Tunnel
36
36
  ChildProcess.build(tunnel_command, *tunnel_args).tap do |process|
37
37
  process.leader = true
38
38
  process.io.inherit! if debug?
39
+ process.environment.merge! tunnel_env
39
40
  process.start
40
41
  debug process.inspect
41
42
  end
@@ -46,7 +47,11 @@ module Blade::SauceLabsPlugin::Tunnel
46
47
  end
47
48
 
48
49
  def tunnel_args
49
- ["--user", username, "--api-key", access_key, "--tunnel-identifier", identifier, "--readyfile", ready_file_path]
50
+ ["--tunnel-identifier", identifier, "--readyfile", ready_file_path] + Array(config.tunnel_args)
51
+ end
52
+
53
+ def tunnel_env
54
+ { "SAUCE_USERNAME" => username, "SAUCE_ACCESS_KEY" => access_key }
50
55
  end
51
56
 
52
57
  def ready_file_path
@@ -1,5 +1,5 @@
1
1
  module Blade
2
2
  module SauceLabsPlugin
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -38,9 +38,19 @@ class Blade::SauceLabsPlugin::WebDriver < EventMachine::Completion
38
38
  def navigate_to(url)
39
39
  EM.defer do
40
40
  begin
41
- driver.navigate.to url
42
- sleep 0.5
43
- yield driver.current_url == url
41
+ driver.navigate.to(url)
42
+
43
+ start = Time.now
44
+
45
+ EM.tick_loop do
46
+ if driver.current_url == url
47
+ yield true
48
+ :stop
49
+ elsif Time.now - start > 2
50
+ yield false
51
+ :stop
52
+ end
53
+ end
44
54
  rescue
45
55
  yield false
46
56
  end
@@ -13,11 +13,12 @@ module Blade::SauceLabsPlugin
13
13
  autoload :WebDriver, "blade/sauce_labs_plugin/web_driver"
14
14
  autoload :Job, "blade/sauce_labs_plugin/job"
15
15
  autoload :JobManager, "blade/sauce_labs_plugin/job_manager"
16
+ autoload :SessionManager, "blade/sauce_labs_plugin/session_manager"
16
17
 
17
18
  def start
18
19
  if Blade.config.interface == :ci
19
20
  tunnel.start do
20
- Blade.config.expected_sessions = client.platforms.size
21
+ session_manager.start
21
22
  job_manager.start
22
23
  end
23
24
  end
@@ -39,6 +40,10 @@ module Blade::SauceLabsPlugin
39
40
  Client
40
41
  end
41
42
 
43
+ def session_manager
44
+ SessionManager
45
+ end
46
+
42
47
  def job_manager
43
48
  JobManager
44
49
  end
@@ -48,11 +53,11 @@ module Blade::SauceLabsPlugin
48
53
  end
49
54
 
50
55
  def username
51
- config.username || ENV["SAUCE_USERNAME"]
56
+ ENV["SAUCE_USERNAME"] || config.username
52
57
  end
53
58
 
54
59
  def access_key
55
- config.access_key || ENV["SAUCE_ACCESS_KEY"]
60
+ ENV["SAUCE_ACCESS_KEY"] || config.access_key
56
61
  end
57
62
 
58
63
  def debug(message)
Binary file
Binary file
@@ -17,7 +17,7 @@ old_library='libsauceconnect.a'
17
17
  inherited_linker_flags=' -pthread'
18
18
 
19
19
  # Libraries that this one depends upon.
20
- dependency_libs=' -L/build/build/Linux/openssl/lib -L/build/curl/ares /build/build/sc-build-2010/lib/libevent.la /build/build/sc-build-2010/lib/libevent_openssl.la /build/build/sc-build-2010/lib/libcares.la /build/build/sc-build-2010/lib/libcurl.la /build/build/sc-build-2010/lib/libcares.la -lz -lrt /build/build/sc-build-2010/lib/libunwind.la -lc -lgcc -lssl -lcrypto -ldl'
20
+ dependency_libs=' -L/build/build/Linux/openssl/lib -L/build/c-ares/.libs -L/home/travis/build/saucelabs/libsauceconnect/curl/ares /build/build/sc-build-2396/lib/libevent.la /build/build/sc-build-2396/lib/libevent_openssl.la /build/build/sc-build-2396/lib/libcares.la /build/build/sc-build-2396/lib/libcurl.la /build/build/sc-build-2396/lib/libcares.la -lz -lrt /build/build/sc-build-2396/lib/libunwind.la -lc -lgcc -lssl -lcrypto -ldl'
21
21
 
22
22
  # Names of additional weak libraries provided by this library
23
23
  weak_library_names=''
@@ -38,4 +38,4 @@ dlopen=''
38
38
  dlpreopen=''
39
39
 
40
40
  # Directory that this library needs to be installed in:
41
- libdir='/build/build/sc-build-2010/lib'
41
+ libdir='/build/build/sc-build-2396/lib'
Binary file
File without changes
File without changes
Binary file
@@ -17,7 +17,7 @@ old_library='libsauceconnect.a'
17
17
  inherited_linker_flags=' -framework CoreFoundation -framework Security'
18
18
 
19
19
  # Libraries that this one depends upon.
20
- dependency_libs=' -L/Users/travis/build/saucelabs/libsauceconnect/build/Darwin/openssl/lib -L/Users/travis/build/saucelabs/libsauceconnect/curl/ares /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib/libevent.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib/libevent_openssl.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib/libcares.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib/libcurl.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib/libcares.la -lz -lssl -lcrypto -ldl'
20
+ dependency_libs=' -L/Users/travis/build/saucelabs/libsauceconnect/build/Darwin/openssl/lib -L/Users/travis/build/saucelabs/libsauceconnect/c-ares/.libs -L/Users/travis/build/saucelabs/libsauceconnect/curl/ares /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib/libevent.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib/libevent_openssl.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib/libcares.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib/libcurl.la /Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib/libcares.la -lz -lssl -lcrypto -ldl'
21
21
 
22
22
  # Names of additional weak libraries provided by this library
23
23
  weak_library_names=''
@@ -38,4 +38,4 @@ dlopen=''
38
38
  dlpreopen=''
39
39
 
40
40
  # Directory that this library needs to be installed in:
41
- libdir='/Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2011/lib'
41
+ libdir='/Users/travis/build/saucelabs/libsauceconnect/build/sc-build-2399/lib'
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blade-sauce_labs_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javan Makhmali
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,12 +123,14 @@ files:
123
123
  - bin/console
124
124
  - bin/rake
125
125
  - bin/setup
126
+ - bin/update_sc
126
127
  - blade-sauce_labs_plugin.gemspec
127
128
  - lib/blade/sauce_labs_plugin.rb
128
129
  - lib/blade/sauce_labs_plugin/cli.rb
129
130
  - lib/blade/sauce_labs_plugin/client.rb
130
131
  - lib/blade/sauce_labs_plugin/job.rb
131
132
  - lib/blade/sauce_labs_plugin/job_manager.rb
133
+ - lib/blade/sauce_labs_plugin/session_manager.rb
132
134
  - lib/blade/sauce_labs_plugin/tunnel.rb
133
135
  - lib/blade/sauce_labs_plugin/version.rb
134
136
  - lib/blade/sauce_labs_plugin/web_driver.rb