blade-sauce_labs_plugin 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36b3598b5eaa5726a03629ec518e327f316bd556
4
- data.tar.gz: f30ffedd23ac0dc98cb70bf3135690bc92b0bacc
3
+ metadata.gz: 3977ba73eab86543539631e96c9dc25a55eb4f12
4
+ data.tar.gz: af389e81192ba197558b643af01e3deb1e4f1e5d
5
5
  SHA512:
6
- metadata.gz: c7acce2a43bc42c59722174128be43291d8018f0480c02ae85b6d506cc44ce1ede98d46c62bb8bc78c95b1619a61e9d063e74820dcb723c4cea78f14fe276631
7
- data.tar.gz: b91a3980daba289f58775c094e6eae01d13c1dd6b1efe842fd2033feb76eb1d28b2df2cffc1b3b5855a6768b38c12c116b0dce1febd1ff442f14e69fdbbff3e7
6
+ metadata.gz: 5ea529d7521022b7465531ee078613637814d28467420afcb3c85d8b1fc3306078822c68cb8b3d07151d01108caac502890b91268e7aff54eab512c641ee7667
7
+ data.tar.gz: 17d01ba5bbd1322443e0787d3c6d7c05287c233ef1cfea754be9011719f69e1068dacb5c773ccfba54aa8ea5af0e3a8024893e36afe6fb4607954d271124dadc
@@ -60,6 +60,10 @@ module Blade::SauceLabsPlugin
60
60
  ENV["SAUCE_ACCESS_KEY"] || config.access_key
61
61
  end
62
62
 
63
+ def tunnel_timeout
64
+ (ENV["SAUCE_TUNNEL_TIMEOUT"] || config.tunnel_timeout || 60).to_i
65
+ end
66
+
63
67
  def debug(message)
64
68
  if debug?
65
69
  STDERR.puts message
@@ -5,7 +5,7 @@ module Blade::SauceLabsPlugin::Tunnel
5
5
  extend self
6
6
 
7
7
  extend Forwardable
8
- def_delegators Blade::SauceLabsPlugin, :username, :access_key, :config, :debug, :debug?
8
+ def_delegators Blade::SauceLabsPlugin, :username, :access_key, :tunnel_timeout, :config, :debug, :debug?
9
9
 
10
10
  attr_reader :identifier, :process
11
11
 
@@ -13,16 +13,26 @@ module Blade::SauceLabsPlugin::Tunnel
13
13
  @identifier = SecureRandom.hex(10)
14
14
  @process = create_child_process
15
15
 
16
+ started_at = Time.now
16
17
  timer = EM::PeriodicTimer.new(1) do
17
18
  if ready_file_exists?
18
19
  timer.cancel
19
20
  yield
21
+ elsif !debug?
22
+ elapsed = Time.now - started_at
23
+ if elapsed > tunnel_timeout
24
+ timer.cancel
25
+ STDERR.puts "Failed to establish tunnel connection after #{elapsed}s:\n#{logs}"
26
+ STDERR.puts tunnel_io.tap(&:rewind).read
27
+ exit(1)
28
+ end
20
29
  end
21
30
  end
22
31
  end
23
32
 
24
33
  def stop
25
34
  begin
35
+ tunnel_io.unlink
26
36
  process.poll_for_exit(10)
27
37
  rescue ChildProcess::TimeoutError
28
38
  process.stop
@@ -34,8 +44,13 @@ module Blade::SauceLabsPlugin::Tunnel
34
44
  private
35
45
  def create_child_process
36
46
  ChildProcess.build(tunnel_command, *tunnel_args).tap do |process|
47
+ if debug?
48
+ process.io.inherit!
49
+ else
50
+ process.io.stdout = process.io.stderr = tunnel_io
51
+ process.duplex = true
52
+ end
37
53
  process.leader = true
38
- process.io.inherit! if debug?
39
54
  process.environment.merge! tunnel_env
40
55
  process.start
41
56
  debug process.inspect
@@ -54,6 +69,10 @@ module Blade::SauceLabsPlugin::Tunnel
54
69
  { "SAUCE_USERNAME" => username, "SAUCE_ACCESS_KEY" => access_key }
55
70
  end
56
71
 
72
+ def tunnel_io
73
+ @tunnel_io ||= Tempfile.new("blade_sauce_tunel_#{identifier}").tap { |io| io.sync = true }
74
+ end
75
+
57
76
  def ready_file_path
58
77
  Blade.tmp_path.join("sauce_tunnel_#{identifier}_ready").to_s
59
78
  end
@@ -1,5 +1,5 @@
1
1
  module Blade
2
2
  module SauceLabsPlugin
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
5
5
  end
Binary file
@@ -0,0 +1,83 @@
1
+ Systemd is a system and service manager for Linux that, among other things, can be used to control the starting and stopping of services. For more information check out https://www.freedesktop.org/wiki/Software/systemd/
2
+
3
+ Sauce Connect is a secure tunneling application that allows the Sauce Labs browser cloud to connect to websites you want to test that are hosted on localhost or behind a firewall. For more information check out the Sauce Labs documentation wiki: https://wiki.saucelabs.com/display/DOCS/Sauce+Connect
4
+
5
+ These instructions will show you how to set up systemd with Sauce Connect to manage the starting and stopping of Sauce Connect tunnels.
6
+
7
+ Systemd will automatically start the Sauce Connect service, monitor each client, and tranparently restart the client if the client gets disconnected or a tunnel goes down.
8
+
9
+ Setting Up systemd
10
+ ----------------
11
+
12
+ 1. Copy the files `sc.service` & `sc@.service` to `/etc/systemd/system`.
13
+ 2. Create a directory `sc.service.wants` in `/etc/systemd/system`.
14
+ You'll have to create symbolic links inside this directory to set up new instances of Sauce
15
+ Connect. For example, if you'd like to have two Sauce Connect instances listening on
16
+ port 8000 & 8001:
17
+ ```
18
+ $ cd /etc/systemd/system/
19
+ $ sudo mkdir -p ./sc.service.wants
20
+ $ sudo ln -s /etc/systemd/system/sc@.service ./sc.service.wants/sc@8000.service
21
+ $ sudo ln -s /etc/systemd/system/sc@.service ./sc.service.wants/sc@8001.service
22
+ ```
23
+ 3. Add your Saucelabs credentials to `/etc/systemd/system/sc@.service` in the
24
+ service section like this:
25
+ ```
26
+ Environment=SAUCE_USERNAME=myusername
27
+ Environment=SAUCE_ACCESS_KEY=fd69b0a8-337c-3303-b1bd-xxxxxxxxxxx
28
+ ```
29
+
30
+ Starting and Stopping the Service
31
+ ---------------------
32
+ After you have configured the instances, you can start up the new service:
33
+ ```
34
+ # This is important otherwise systemd won't pick up the new configuration
35
+ $ sudo systemctl daemon-reload
36
+ $ sudo systemctl start sc
37
+ $ sudo systemctl status sc
38
+ ● sc.service - Sauce Connect workers hypervisor
39
+ Loaded: loaded (/etc/systemd/system/sc.service; disabled; vendor preset: enabled)
40
+ Active: active (exited) since Wed 2016-04-06 17:44:37 PDT; 6s ago
41
+ ...
42
+
43
+ $ sudo systemctl status 'sc@*'
44
+ ● sc@8000.service - Sauce Connect worker service on port 8000
45
+ Loaded: loaded (/etc/systemd/system/sc@.service; enabled; vendor preset: enabled)
46
+ Active: active (running) since Wed 2016-04-06 17:44:37 PDT; 23s ago
47
+ ...
48
+ Apr 06 17:44:50 usery-BigFatServerzz sc[6772]: 20160406 174450.926 [06772] Sauce Connect is up, you may start your tests.
49
+ ```
50
+ To stop all the instances:
51
+ ```
52
+ $ sudo systemctl stop sc
53
+ ```
54
+ Managing Individual Instances
55
+ -----------------------------
56
+ You can also manage invididual instance without impacting the other instances by using the syntax `sc@<PORT NUMBER>`. For example, here's how you'd manage the instance listening on port 8000:
57
+ ```
58
+ $ sudo systemctl status 'sc@8000.service'
59
+ ● sc@8000.service - Sauce Connect worker service on port 8000
60
+ Loaded: loaded (/etc/systemd/system/sc@.service; enabled; vendor preset: enabled)
61
+ Active: active (running) since Wed 2016-04-06 17:44:37 PDT; 5min ago
62
+ ...
63
+
64
+
65
+ # This won't affect the other instances
66
+ $ sudo systemctl restart 'sc@8000.service'
67
+
68
+ ```
69
+ Systemd Tips and Tricks
70
+ =====================
71
+
72
+ When working with systemd I recommend making an alias for systemctl to automate
73
+ the configuration reload:
74
+
75
+ function sd() {
76
+ sudo systemctl daemon-reload > /dev/null
77
+ sudo systemctl $@
78
+ }
79
+
80
+ When debugging problems with a unit:
81
+
82
+ $ systemctl status unit
83
+ $ journalctl -xe -u unit
@@ -0,0 +1,16 @@
1
+ #
2
+ # Start & stop Sauce Connect workers
3
+ #
4
+ [Unit]
5
+ Description=Sauce Connect workers hypervisor
6
+ After=network.target
7
+
8
+ [Service]
9
+ Type=oneshot
10
+ RemainAfterExit=yes
11
+ ExecStart=/bin/true
12
+ ExecReload=/bin/true
13
+ WorkingDirectory=/tmp
14
+
15
+ [Install]
16
+ WantedBy=multi-user.target
@@ -0,0 +1,28 @@
1
+ [Unit]
2
+ Description=Sauce Connect worker service on port %i
3
+ PartOf=sc.service
4
+ ReloadPropagatedFrom=sc.service
5
+
6
+ [Service]
7
+ Type=simple
8
+ User=nobody
9
+ Group=nogroup
10
+ WorkingDirectory=/tmp
11
+ LimitNOFILE=8192
12
+ Restart=always
13
+
14
+ # Set those to match your Saucelabs credentials
15
+ Environment=SAUCE_USERNAME=username
16
+ Environment=SAUCE_ACCESS_KEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
17
+
18
+ ExecStart = /usr/local/bin/sc \
19
+ --logfile - \
20
+ --pidfile "/tmp/sauceconnect_%i.pid" \
21
+ --se-port "%i" \
22
+ --no-remove-colliding-tunnels \
23
+ --wait-tunnel-shutdown
24
+ # Not needed with systemd
25
+ ExecStartPost = /bin/rm -f /tmp/sauceconnect_%i.pid
26
+
27
+ [Install]
28
+ WantedBy=multi-user.target
@@ -0,0 +1,76 @@
1
+ Upstart is an event-based replacement for the `/sbin/init` Linux daemon that handles starting of tasks and services during boot, stopping them during shutdown, and supervising them while the system is running. For more information check out http://upstart.ubuntu.com.
2
+
3
+ Upstart will automatically start the Sauce Connect service, monitor each client, and tranparently restart the client if the client gets disconnected or a tunnel goes down.
4
+
5
+ Sauce Connect is a secure tunneling application that enables the Sauce Labs browser cloud to connect with websites you want to test that are hosted on your local machine or behind a firewall.
6
+
7
+ These instructions will help you set up Sauce Connect so that the starting and stopping of tunnels is controlled by Upstart.
8
+
9
+ 1. Install the Sauce connect binary to `/usr/local/bin/sc`.
10
+ 2. Copy the `sc_worker.conf` & `sc.conf` files to `/etc/init`.
11
+ This will create two new upstart services, `sc_worker` and `sc.conf`. `sc_worker` manages individual Sauce Connect instance, while `sc.conf` manages multiple-instances started with `sc_worker`, allowing you to start multiple instances on the same server.
12
+ 3. Check that the services are installed correctly with the `initctl list` command:
13
+ ```
14
+ $ initctl list | grep '^sc'
15
+ sc_worker stop/waiting
16
+ sc stop/waiting
17
+ ```
18
+ 4. Create a file named `/etc/default/sc` to store Sauce Connect's configuration options.
19
+ It should look something like that:
20
+ ```
21
+ SAUCE_USERNAME=username
22
+ SAUCE_ACCESS_KEY=fd698b0a-744c-4205-pa3d-16e2734127bf
23
+ ```
24
+ Single Instance
25
+ ---------------
26
+
27
+ Once that's done you can start and stop invidual Sauce Connect instance like this:
28
+ ```
29
+ $ sudo start sc_worker SE_PORT=8888
30
+ sc_worker (8888) start/running, process 8856
31
+ ```
32
+ The value `SE_PORT` corresponds to the Selenium port, each instance must have a
33
+ unique Seleniun port to listen on.
34
+
35
+ Let's check that our instace was started properly:
36
+
37
+ $ status sc_worker SE_PORT=8888
38
+ sc_worker (8888) start/running, process 8856
39
+
40
+ Looks all good, you now have a single instance of Sauce Connect running. If the
41
+ tunnel closes or anything unexpected happens upstart will automatically restart
42
+ Sauce Connect to re-establish connectivity.
43
+
44
+ Multiple Instances
45
+ ------------------
46
+
47
+ While single instance setups are perfectly acceptable for small scale operations, you should set up multiple instances of Sauce Connect with High Availability to improve reliability & performance. For more information about the High Availability configuration for Sauce Connect, check our our documentation wiki: https://wiki.saucelabs.com/display/DOCS/Sauce+Connect
48
+
49
+ To use multiple instances, edit `/etc/default/sc` and add the parameter `SE_PORTS`
50
+ like this:
51
+ ```
52
+ SAUCE_USERNAME=username
53
+ SAUCE_ACCESS_KEY=fd698b0a-744c-4205-pa3d-16e2734127bf
54
+ SE_PORTS='8000 8001 8002 8003'
55
+ ```
56
+ This will create four Sauce Connect instances, listening on port 8000, 8001, 8002,
57
+ & 8003. Let's try it out with the `sc` service:
58
+ ```
59
+ $ sudo start sc
60
+ sc start/running
61
+ ```
62
+ Let's check the status of the `sc_worker` services:
63
+ ```
64
+ $ initctl list | grep sc_worker
65
+ sc_worker (8001) start/running, process 8503
66
+ sc_worker (8000) start/running, process 8500
67
+ sc_worker (8003) start/running, process 8512
68
+ sc_worker (8002) start/running, process 8508
69
+ ```
70
+ Stopping those instances is the same as starting them:
71
+ ```
72
+ $ sudo stop sc
73
+ sc stop/waiting
74
+ $ initctl list | grep sc_worker
75
+ sc_worker stop/waiting
76
+ ```
@@ -0,0 +1,29 @@
1
+ # vim:ft=upstart:
2
+ description "SauceLabs' Sauce Connect tunnel worker supervisor service"
3
+
4
+ start on runlevel [2345]
5
+ stop on runlevel [016]
6
+
7
+ pre-start script
8
+ # Load configuration
9
+ test -r /etc/default/sc || { stop; exit 0; }
10
+ . /etc/default/sc
11
+ test -n "$SE_PORTS" || { stop; exit 1; }
12
+
13
+ for se_port in $SE_PORTS
14
+ do
15
+ start sc_worker SE_PORT=$se_port
16
+ done
17
+ end script
18
+
19
+ post-stop script
20
+ # Load configuration
21
+ test -r /etc/default/sc || { stop; exit 0; }
22
+ . /etc/default/sc
23
+ test -n "$SE_PORTS" || { stop; exit 1; }
24
+
25
+ for se_port in $SE_PORTS
26
+ do
27
+ stop sc_worker SE_PORT=$se_port || true # ignore shutdown instances
28
+ done
29
+ end script
@@ -0,0 +1,59 @@
1
+ #
2
+ # This Upstart config expects that Sauce Connect (SC) is installed at
3
+ # /usr/local/bin/sc. Edit that path if it is installed somewhere else.
4
+ #
5
+ # Copy this file to /etc/init/sc.conf, and do:
6
+ #
7
+ # $ sudo initctl reload-configuration
8
+ #
9
+ # Then you can manage SC via the usual upstart tools, e.g.:
10
+ #
11
+ # $ sudo start sc
12
+ # $ sudo restart sc
13
+ # $ sudo stop sc
14
+ # $ sudo status sc
15
+ #
16
+
17
+ description "SauceLabs' Sauce Connect tunnel worker service"
18
+
19
+ instance $SE_PORT
20
+ usage "SE_PORT - selenium port"
21
+
22
+ stop on stopping sc
23
+
24
+ setuid nobody
25
+ setgid nogroup
26
+ chdir /tmp
27
+ # Restart Sauce Connect if it exits
28
+ respawn
29
+ # Sauce Connect output go to $logdir/sc.log.
30
+ console log
31
+ # Bump maximum number of open files/sockets.
32
+ limit nofile 8192 8192
33
+
34
+ # Sauce Connect will be killed if doesn't stop within 2 minutes. SC usually
35
+ # exits much faster than 2 minutes but it can occasionally get stuck if the
36
+ # connectivity between SC & Saucelabs is interupted.
37
+ kill timeout 120
38
+
39
+ script
40
+ # Load configuration
41
+ test -r /etc/default/sc || { stop; exit 0; }
42
+ . /etc/default/sc
43
+
44
+ # Temporary PID file since it's a required option for SauceConnect
45
+ pidfile="/tmp/.sauceconnect_$SE_PORT.pid"
46
+ exec \
47
+ env \
48
+ SAUCE_USERNAME="$SAUCE_USERNAME" \
49
+ SAUCE_ACCESS_KEY="$SAUCE_ACCESS_KEY" \
50
+ /usr/local/bin/sc \
51
+ --logfile - \
52
+ --pidfile "$pidfile" \
53
+ --se-port "$SE_PORT" \
54
+ --no-remove-colliding-tunnels \
55
+ --wait-tunnel-shutdown
56
+ end script
57
+
58
+ # Remove PID file once we've started the service since it's not needed
59
+ post-start exec rm -f "/tmp/.sauceconnect_$SE_PORT.pid"
Binary file
@@ -0,0 +1,76 @@
1
+ Systemd is a system and service manager for Linux that, among other things, can be used to control the starting and stopping of services. For more information check out https://www.freedesktop.org/wiki/Software/systemd/
2
+
3
+ Sauce Connect is a secure tunneling application that allows the Sauce Labs browser cloud to connect to websites you want to test that are hosted on localhost or behind a firewall. For more information check out the Sauce Labs documentation wiki: https://wiki.saucelabs.com/display/DOCS/Sauce+Connect
4
+
5
+ These instructions will show you how to set up systemd with Sauce Connect to manage the starting and stopping of Sauce Connect tunnels.
6
+
7
+ Systemd will automatically start the Sauce Connect service, monitor each client, and tranparently restart the client if the client gets disconnected or a tunnel goes down.
8
+
9
+ Setting Up systemd
10
+ ----------------
11
+
12
+ 1. Copy the files `sc.service` & `sc@.service` to `/etc/systemd/system`.
13
+ 2. Create a directory `sc.service.wants` in `/etc/systemd/system`.
14
+ You'll have to create symbolic links inside this directory to set up new instances of Sauce
15
+ Connect. For example, if you'd like to have two Sauce Connect instances listening on
16
+ port 8000 & 8001:
17
+ ```
18
+ $ cd /etc/systemd/system/
19
+ $ sudo mkdir -p ./sc.service.wants
20
+ $ sudo ln -s /etc/systemd/system/sc@.service ./sc.service.wants/sc@8000.service
21
+ $ sudo ln -s /etc/systemd/system/sc@.service ./sc.service.wants/sc@8001.service
22
+ ```
23
+ Starting and Stopping the Service
24
+ ---------------------
25
+ After you have configured the instances, you can start up the new service:
26
+ ```
27
+ # This is important otherwise systemd won't pick up the new configuration
28
+ $ sudo systemctl daemon-reload
29
+ $ sudo systemctl start sc
30
+ $ sudo systemctl status sc
31
+ ● sc.service - Sauce Connect workers hypervisor
32
+ Loaded: loaded (/etc/systemd/system/sc.service; disabled; vendor preset: enabled)
33
+ Active: active (exited) since Wed 2016-04-06 17:44:37 PDT; 6s ago
34
+ ...
35
+
36
+ $ sudo systemctl status 'sc@*'
37
+ ● sc@8000.service - Sauce Connect worker service on port 8000
38
+ Loaded: loaded (/etc/systemd/system/sc@.service; enabled; vendor preset: enabled)
39
+ Active: active (running) since Wed 2016-04-06 17:44:37 PDT; 23s ago
40
+ ...
41
+ Apr 06 17:44:50 usery-BigFatServerzz sc[6772]: 20160406 174450.926 [06772] Sauce Connect is up, you may start your tests.
42
+ ```
43
+ To stop all the instances:
44
+ ```
45
+ $ sudo systemctl stop sc
46
+ ```
47
+ Managing Individual Instances
48
+ -----------------------------
49
+ You can also manage invididual instance without impacting the other instances by using the syntax `sc@<PORT NUMBER>`. For example, here's how you'd manage the instance listening on port 8000:
50
+ ```
51
+ $ sudo systemctl status 'sc@8000.service'
52
+ ● sc@8000.service - Sauce Connect worker service on port 8000
53
+ Loaded: loaded (/etc/systemd/system/sc@.service; enabled; vendor preset: enabled)
54
+ Active: active (running) since Wed 2016-04-06 17:44:37 PDT; 5min ago
55
+ ...
56
+
57
+
58
+ # This won't affect the other instances
59
+ $ sudo systemctl restart 'sc@8000.service'
60
+
61
+ ```
62
+ Systemd Tips and Tricks
63
+ =====================
64
+
65
+ When working with systemd I recommend making an alias for systemctl to automate
66
+ the configuration reload:
67
+
68
+ function sd() {
69
+ sudo systemctl daemon-reload > /dev/null
70
+ sudo systemctl $@
71
+ }
72
+
73
+ When debugging problems with a unit:
74
+
75
+ $ systemctl status unit
76
+ $ journalctl -xe -u unit
@@ -0,0 +1,16 @@
1
+ #
2
+ # Start & stop Sauce Connect workers
3
+ #
4
+ [Unit]
5
+ Description=Sauce Connect workers hypervisor
6
+ After=network.target
7
+
8
+ [Service]
9
+ Type=oneshot
10
+ RemainAfterExit=yes
11
+ ExecStart=/bin/true
12
+ ExecReload=/bin/true
13
+ WorkingDirectory=/tmp
14
+
15
+ [Install]
16
+ WantedBy=multi-user.target
@@ -0,0 +1,25 @@
1
+ [Unit]
2
+ Description=Sauce Connect worker service on port %i
3
+ PartOf=sc.service
4
+ ReloadPropagatedFrom=sc.service
5
+
6
+ [Service]
7
+ Type=simple
8
+ User=nobody
9
+ Group=nogroup
10
+ WorkingDirectory=/tmp
11
+ LimitNOFILE=8192
12
+
13
+ EnvironmentFile=/etc/default/sc
14
+ ExecStart = /usr/local/bin/sc \
15
+ --logfile - \
16
+ --user "$SAUCE_USERNAME" \
17
+ --api-key "$SAUCE_ACCESS_KEY" \
18
+ --pidfile "/tmp/.sauceconnect_%i.pid" \
19
+ --se-port "%i" \
20
+ --no-remove-colliding-tunnels \
21
+ --wait-tunnel-shutdown
22
+ # ExecStartPost = /bin/rm -f /tmp/.sauceconnect_%i.pid
23
+
24
+ [Install]
25
+ WantedBy=multi-user.target
@@ -0,0 +1,76 @@
1
+ Upstart is an event-based replacement for the `/sbin/init` Linux daemon that handles starting of tasks and services during boot, stopping them during shutdown, and supervising them while the system is running. For more information check out http://upstart.ubuntu.com.
2
+
3
+ Upstart will automatically start the Sauce Connect service, monitor each client, and tranparently restart the client if the client gets disconnected or a tunnel goes down.
4
+
5
+ Sauce Connect is a secure tunneling application that enables the Sauce Labs browser cloud to connect with websites you want to test that are hosted on your local machine or behind a firewall.
6
+
7
+ These instructions will help you set up Sauce Connect so that the starting and stopping of tunnels is controlled by Upstart.
8
+
9
+ 1. Install the Sauce connect binary to `/usr/local/bin/sc`.
10
+ 2. Copy the `sc_worker.conf` & `sc.conf` files to `/etc/init`.
11
+ This will create two new upstart services, `sc_worker` and `sc.conf`. `sc_worker` manages individual Sauce Connect instance, while `sc.conf` manages multiple-instances started with `sc_worker`, allowing you to start multiple instances on the same server.
12
+ 3. Check that the services are installed correctly with the `initctl list` command:
13
+ ```
14
+ $ initctl list | grep '^sc'
15
+ sc_worker stop/waiting
16
+ sc stop/waiting
17
+ ```
18
+ 4. Create a file named `/etc/default/sc` to store Sauce Connect's configuration options.
19
+ It should look something like that:
20
+ ```
21
+ SAUCE_USERNAME=username
22
+ SAUCE_ACCESS_KEY=fd698b0a-744c-4205-pa3d-16e2734127bf
23
+ ```
24
+ Single Instance
25
+ ---------------
26
+
27
+ Once that's done you can start and stop invidual Sauce Connect instance like this:
28
+ ```
29
+ $ sudo start sc_worker SE_PORT=8888
30
+ sc_worker (8888) start/running, process 8856
31
+ ```
32
+ The value `SE_PORT` corresponds to the Selenium port, each instance must have a
33
+ unique Seleniun port to listen on.
34
+
35
+ Let's check that our instace was started properly:
36
+
37
+ $ status sc_worker SE_PORT=8888
38
+ sc_worker (8888) start/running, process 8856
39
+
40
+ Looks all good, you now have a single instance of Sauce Connect running. If the
41
+ tunnel closes or anything unexpected happens upstart will automatically restart
42
+ Sauce Connect to re-establish connectivity.
43
+
44
+ Multiple Instances
45
+ ------------------
46
+
47
+ While single instance setups are perfectly acceptable for small scale operations, you should set up multiple instances of Sauce Connect with High Availability to improve reliability & performance. For more information about the High Availability configuration for Sauce Connect, check our our documentation wiki: https://wiki.saucelabs.com/display/DOCS/Sauce+Connect
48
+
49
+ To use multiple instances, edit `/etc/default/sc` and add the parameter `SE_PORTS`
50
+ like this:
51
+ ```
52
+ SAUCE_USERNAME=username
53
+ SAUCE_ACCESS_KEY=fd698b0a-744c-4205-pa3d-16e2734127bf
54
+ SE_PORTS='8000 8001 8002 8003'
55
+ ```
56
+ This will create four Sauce Connect instances, listening on port 8000, 8001, 8002,
57
+ & 8003. Let's try it out with the `sc` service:
58
+ ```
59
+ $ sudo start sc
60
+ sc start/running
61
+ ```
62
+ Let's check the status of the `sc_worker` services:
63
+ ```
64
+ $ initctl list | grep sc_worker
65
+ sc_worker (8001) start/running, process 8503
66
+ sc_worker (8000) start/running, process 8500
67
+ sc_worker (8003) start/running, process 8512
68
+ sc_worker (8002) start/running, process 8508
69
+ ```
70
+ Stopping those instances is the same as starting them:
71
+ ```
72
+ $ sudo stop sc
73
+ sc stop/waiting
74
+ $ initctl list | grep sc_worker
75
+ sc_worker stop/waiting
76
+ ```
@@ -0,0 +1,29 @@
1
+ # vim:ft=upstart:
2
+ description "SauceLabs' Sauce Connect tunnel worker supervisor service"
3
+
4
+ start on runlevel [2345]
5
+ stop on runlevel [016]
6
+
7
+ pre-start script
8
+ # Load configuration
9
+ test -r /etc/default/sc || { stop; exit 0; }
10
+ . /etc/default/sc
11
+ test -n "$SE_PORTS" || { stop; exit 1; }
12
+
13
+ for se_port in $SE_PORTS
14
+ do
15
+ start sc_worker SE_PORT=$se_port
16
+ done
17
+ end script
18
+
19
+ post-stop script
20
+ # Load configuration
21
+ test -r /etc/default/sc || { stop; exit 0; }
22
+ . /etc/default/sc
23
+ test -n "$SE_PORTS" || { stop; exit 1; }
24
+
25
+ for se_port in $SE_PORTS
26
+ do
27
+ stop sc_worker SE_PORT=$se_port || true # ignore shutdown instances
28
+ done
29
+ end script
@@ -0,0 +1,57 @@
1
+ #
2
+ # This Upstart config expects that Sauce Connect (SC) is installed at
3
+ # /usr/local/bin/sc. Edit that path if it is installed somewhere else.
4
+ #
5
+ # Copy this file to /etc/init/sc.conf, and do:
6
+ #
7
+ # $ sudo initctl reload-configuration
8
+ #
9
+ # Then you can manage SC via the usual upstart tools, e.g.:
10
+ #
11
+ # $ sudo start sc
12
+ # $ sudo restart sc
13
+ # $ sudo stop sc
14
+ # $ sudo status sc
15
+ #
16
+
17
+ description "SauceLabs' Sauce Connect tunnel worker service"
18
+
19
+ instance $SE_PORT
20
+ usage "SE_PORT - selenium port"
21
+
22
+ stop on stopping sc
23
+
24
+ setuid nobody
25
+ setgid nogroup
26
+ chdir /tmp
27
+ # Restart Sauce Connect if it exits
28
+ respawn
29
+ # Sauce Connect output go to $logdir/sc.log.
30
+ console log
31
+ # Bump maximum number of open files/sockets.
32
+ limit nofile 8192 8192
33
+
34
+ # Sauce Connect will be killed if doesn't stop within 2 minutes. SC usually
35
+ # exits much faster than 2 minutes but it can occasionally get stuck if the
36
+ # connectivity between SC & Saucelabs' is degraded/interupted.
37
+ kill timeout 120
38
+
39
+ script
40
+ # Load configuration
41
+ test -r /etc/default/sc || { stop; exit 0; }
42
+ . /etc/default/sc
43
+
44
+ # Temporary PID file since it's a required option for SauceConnect
45
+ pidfile="/tmp/.sauceconnect_$SE_PORT.pid"
46
+ exec /usr/local/bin/sc \
47
+ --logfile - \
48
+ --user "$SAUCE_USERNAME" \
49
+ --api-key "$SAUCE_ACCESS_KEY" \
50
+ --pidfile "$pidfile" \
51
+ --se-port "$SE_PORT" \
52
+ --no-remove-colliding-tunnels \
53
+ --wait-tunnel-shutdown
54
+ end script
55
+
56
+ # Remove PID file once we've started the service since it's not needed
57
+ post-start exec rm -f "/tmp/.sauceconnect_$SE_PORT.pid"
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.2
4
+ version: 0.5.3
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-06-04 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,12 @@ files:
135
135
  - lib/blade/sauce_labs_plugin/version.rb
136
136
  - lib/blade/sauce_labs_plugin/web_driver.rb
137
137
  - support/sc-linux/bin/sc
138
+ - support/sc-linux/config/systemd/README.md
139
+ - support/sc-linux/config/systemd/sc.service
140
+ - support/sc-linux/config/systemd/sc@.service
141
+ - support/sc-linux/config/upstart/README.md
142
+ - support/sc-linux/config/upstart/sc.conf
143
+ - support/sc-linux/config/upstart/sc_worker.conf
138
144
  - support/sc-linux/include/sauceconnect.h
139
145
  - support/sc-linux/lib/libsauceconnect.a
140
146
  - support/sc-linux/lib/libsauceconnect.la
@@ -142,6 +148,12 @@ files:
142
148
  - support/sc-osx/bin/sc
143
149
  - support/sc-osx/bin/sc.dSYM/Contents/Info.plist
144
150
  - support/sc-osx/bin/sc.dSYM/Contents/Resources/DWARF/sc
151
+ - support/sc-osx/config/systemd/README.md
152
+ - support/sc-osx/config/systemd/sc.service
153
+ - support/sc-osx/config/systemd/sc@.service
154
+ - support/sc-osx/config/upstart/README.md
155
+ - support/sc-osx/config/upstart/sc.conf
156
+ - support/sc-osx/config/upstart/sc_worker.conf
145
157
  - support/sc-osx/include/sauceconnect.h
146
158
  - support/sc-osx/lib/libsauceconnect.a
147
159
  - support/sc-osx/lib/libsauceconnect.la
@@ -166,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
178
  version: '0'
167
179
  requirements: []
168
180
  rubyforge_project:
169
- rubygems_version: 2.5.1
181
+ rubygems_version: 2.6.6
170
182
  signing_key:
171
183
  specification_version: 4
172
184
  summary: Blade Runner plugin for Sauce Labs (saucelabs.com)