sauce 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/lib/job.rb CHANGED
@@ -49,7 +49,10 @@ module Sauce
49
49
  # Misnomer: Gets the most recent 100 jobs
50
50
  # TODO: Allow/automate paging
51
51
  def self.all(options={})
52
- responses = JSON.parse @@client["jobs/full"].get
52
+ url = "jobs"
53
+ url += "?full=true" if options[:full] #unless options[:id_only]
54
+ responses = @@client[url].get
55
+ responses = JSON.parse responses.to_s
53
56
  return responses.collect{|response| Sauce::Job.new(response)}
54
57
  end
55
58
 
@@ -65,7 +68,10 @@ module Sauce
65
68
  end
66
69
 
67
70
  #puts "GET-URL: #{@@client.url}jobs/#{id}"
68
- Sauce::Job.new JSON.parse(@@client["jobs/#{id}"].get)
71
+ response = @@client["jobs/#{id}"].get
72
+
73
+ # TODO: Return nil if bad response
74
+ Sauce::Job.new JSON.parse(response.to_s)
69
75
  end
70
76
 
71
77
  # Creates an instance representing a job.
@@ -75,7 +81,7 @@ module Sauce
75
81
 
76
82
  # Retrieves the latest information on this job from the Sauce Labs' server
77
83
  def refresh!
78
- response = JSON.parse @@client["jobs/#{@id}"].get
84
+ response = JSON.parse @@client["jobs/#{@id}"].get.body
79
85
  #puts "\tjob refresh with: #{response}"
80
86
  build! response
81
87
  self
@@ -83,10 +89,14 @@ module Sauce
83
89
 
84
90
  # Save/update the current information for the job
85
91
  def save
86
- response = JSON.parse(@@client["jobs/#{@id}"]. self.to_json, :content_type => :json, :accept => :json)
92
+ #puts "Saving job:\n -X PUT #{@@client['jobs']}/#{@id} -H 'Content-Type: application/json' -d '#{self.to_json}'"
93
+ response = @@client["jobs/#{@id}"].put(self.to_json,
94
+ {:content_type => :json,
95
+ :accept => :json}).body
96
+ JSON.parse(response)
87
97
  end
88
98
 
89
- def self.to_json(options={})
99
+ def to_json(options={})
90
100
  json = {
91
101
  :id => @id,
92
102
  :owner => @owner,
@@ -108,7 +118,7 @@ module Sauce
108
118
  options[:except].each { |key| json.delete(key) } if options[:except]
109
119
  json = json.select { |key,value| options[:only].include? key } if options[:only]
110
120
 
111
- return json
121
+ return json.to_json
112
122
  end
113
123
 
114
124
  def delete
@@ -119,6 +129,10 @@ module Sauce
119
129
 
120
130
  # Sets all internal variables from a hash
121
131
  def build!(options)
132
+ #puts "\tBuild with: #{options.inspect}"
133
+ # Massage JSON
134
+ options.each { |key,value| options[key] = false if options[key] == "false" }
135
+
122
136
  @id = options["id"]
123
137
  @owner = options["owner"]
124
138
  @status = options["status"]
data/lib/rest.rb CHANGED
@@ -7,7 +7,8 @@ module Sauce
7
7
  class BadAccessError < StandardError; end #:nodoc
8
8
  class MisconfiguredError < StandardError; end #:nodoc
9
9
 
10
- attr_accessor :username, :access_key, :client, :ip, :api_url
10
+ attr_accessor :username, :access_key, :client
11
+ attr_accessor :protocol, :host, :port, :api_path, :api_version, :ip, :api_url
11
12
  attr_accessor :tunnels, :jobs
12
13
 
13
14
  def initialize(options)
@@ -15,8 +16,14 @@ module Sauce
15
16
  @access_key = options[:access_key]
16
17
  @ip = options[:ip]
17
18
 
19
+ @protocol = options[:protocol] || "http"
20
+ @host = options[:host] || "saucelabs.com"
21
+ @port = options[:port] || 80
22
+ @api_path = options[:api_path] || "rest"
23
+ @api_version= options[:api_version] || 1
24
+
18
25
  raise MisconfiguredError if @username.nil? or @access_key.nil?
19
- @api_url = "https://#{@username}:#{@access_key}@saucelabs.com/api/v1/#{@username}/"
26
+ @api_url = "#{@protocol}://#{@username}:#{@access_key}@#{@host}:#{@port}/#{@api_path}/v#{@api_version}/#{@username}/"
20
27
  @client = RestClient::Resource.new @api_url
21
28
 
22
29
  @tunnels = Sauce::Tunnel
data/lib/tunnel.rb CHANGED
@@ -49,7 +49,7 @@ module Sauce
49
49
  end
50
50
 
51
51
  def self.all
52
- responses = JSON.parse @@client[:tunnels].get
52
+ responses = JSON.parse @@client[:tunnels].get.body
53
53
  return responses.collect{|response| Sauce::Tunnel.new(response)}
54
54
  end
55
55
 
@@ -59,7 +59,7 @@ module Sauce
59
59
 
60
60
  # Creates a new tunnel machine
61
61
  def self.create(options)
62
- response = JSON.parse @@client[:tunnels].post(options.to_json, :content_type => 'application/json')
62
+ response = JSON.parse @@client[:tunnels].post(options.to_json, :content_type => 'application/json').body
63
63
  #puts response.inspect
64
64
  Tunnel.new response
65
65
  end
@@ -72,13 +72,13 @@ module Sauce
72
72
  # Hits the destroy url for this tunnel, and then refreshes. Keep in mind it takes some time to completely teardown a tunnel.
73
73
  def destroy
74
74
  close_gateway
75
- response = @@client["tunnels/#{@id}"].delete
75
+ response = @@client["tunnels/#{@id}"].delete.body
76
76
  refresh!
77
77
  end
78
78
 
79
79
  # Retrieves the latest information on this tunnel from the Sauce Labs' server
80
80
  def refresh!
81
- response = JSON.parse @@client["tunnels/#{@id}"].get
81
+ response = JSON.parse @@client["tunnels/#{@id}"].get.body
82
82
  #puts "\Tunnel refresh with: #{response.inspect}"
83
83
  build! response
84
84
  self
@@ -118,7 +118,7 @@ module Sauce
118
118
  # Sauce Labs' server will say hello on port 1025 as a sanity check. If no hello, something is wrong.
119
119
  # TODO: Make it say hello on port 1025. Currently a hack.
120
120
  def says_hello?(options={})
121
- return false unless self.status == "running"
121
+ return false unless self.status == "running" and not @host.nil?
122
122
 
123
123
  # TODO: Read from options if necessary
124
124
  connection = {}
@@ -128,8 +128,6 @@ module Sauce
128
128
  connection[:telnet_mode] = true
129
129
  connection[:timeout] = 10
130
130
 
131
- #puts "telnet: #{connection.inspect}"
132
-
133
131
  host = Net::Telnet::new("Host" => connection[:host],
134
132
  "Port" => connection[:port],
135
133
  "Prompt" => connection[:prompt],
@@ -199,22 +197,41 @@ module Sauce
199
197
  not @thread.nil?
200
198
  end
201
199
 
200
+ # Returns a json representation of the current state of the tunnel object
201
+ def to_json(options={})
202
+ json = {
203
+ :id => @id,
204
+ :owner => @owner,
205
+ :status => @status,
206
+ :host => @host,
207
+ :creation_time => @creation_time,
208
+ :start_time => @start_time,
209
+ :end_time => @end_time,
210
+ :domain_name => @domain_names
211
+ }
212
+
213
+ options[:except].each { |key| json.delete(key) } if options[:except]
214
+ json = json.select { |key,value| options[:only].include? key } if options[:only]
215
+
216
+ return json
217
+ end
218
+
202
219
  protected
203
220
 
204
221
  # Sets all internal variables from a hash
205
222
  def build!(options)
223
+ options = options["tunnel"] unless options["tunnel"].nil?
206
224
  #puts "\tBuild with #{options.inspect}"
207
- @status = options["Status"]
208
- @owner = options["Owner"]
209
- @id = options["_id"]
210
- @id = options["id"] if @id.nil? or @id.empty?
211
- @host = options["Host"]
212
- @created_at = options["CreationTime"]
213
- @updated_at = options["ModificationTime"]
214
- @launch_time = options["LaunchTime"]
215
- @domain_names = options["DomainNames"]
216
-
217
- raise NoIDError if @id.nil? or @id.empty?
225
+ @status = options["status"]
226
+ @owner = options["owner"]
227
+ @id = options["id"]
228
+ @host = options["host"]
229
+ @creation_time = options["creation_time"]
230
+ @start_time = options["start_time"]
231
+ @end_time = options["end_time"]
232
+ @domain_names = options["domain_names"]
233
+
234
+ raise NoIDError if @id.nil?
218
235
  end
219
236
  end
220
237
  end
data/test/debug.rb CHANGED
@@ -1,34 +1,11 @@
1
- require 'irb_boot'
1
+ require 'helper'
2
2
 
3
3
  c = Sauce::Client.new(:username => "sgrove",
4
- :access_key => "733a44e2-4226-488f-8126-6f6d59bdf386",
5
- :ip => "67.188.3.10")
6
-
7
- =begin
8
- t = c.tunnels.first
4
+ :access_key => "4c592ce3-8f45-4cd6-8e3e-65b9f0b173d0")
9
5
 
10
6
  c.destroy_all_tunnels
11
7
  t = c.create_tunnel('DomainNames' => ["111.111.111.111"])
12
8
 
13
9
  puts c.tunnels.inspect
14
- =end
15
-
16
- t = c.tunnels.first
17
-
18
- if t.nil?
19
- puts "Starting a new tunnel"
20
- t = c.tunnels.create("DomainNames" => ["sgrove.tst"])
21
- until t.status == "running"
22
- print "." ; STDOUT.flush
23
- t.refresh!
24
- sleep 1
25
- end
26
- end
27
10
 
28
- puts t.inspect
29
- t.open_gateway
30
-
31
- puts "Checking to see if thread is running."
32
- puts t.still_running?
33
- puts t.thread.inspect
34
- t.thread.join if t.still_running?
11
+ c.destroy_all_tunnels
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'yaml'
3
+ $: << "../lib/"
4
+ require 'sauce'
5
+
6
+ account = YAML.load_file("account.yml")
7
+
8
+ client = Sauce::Client.new(:username => account["username"],
9
+ :access_key => account["access_key"])
10
+
11
+ jobs = client.jobs.all
12
+
13
+ puts jobs.inspect
data/test/test_jobs.rb CHANGED
@@ -1,20 +1,27 @@
1
1
  require 'helper'
2
2
  require 'json'
3
+ require 'yaml'
3
4
 
4
5
  class TestSauce < Test::Unit::TestCase
5
6
  context "A V1 jobs instance" do
6
7
  setup do
7
8
  # Create this file and put in your details to run the tests
8
- account = YAML.load_file "live_account.yml"
9
+ account = YAML.load_file "account2.yml"
9
10
  @username = account["username"]
10
11
  @access_key = account["access_key"]
11
12
  @ip = account["ip"]
12
13
  @client = Sauce::Client.new(:username => @username,
13
- :access_key => @access_key)
14
-
15
- @example_data = YAML.load_file('example_data.yml')
16
- end
14
+ :access_key => @access_key,
15
+ :protocol => account["protocol"],
16
+ :host => account["host"],
17
+ :port => account["port"],
18
+ :api_path => account["api_path"],
19
+ :api_version => account["api_version"])
20
+
21
+ #@example_data = YAML.load_file('example_data.yml')
22
+ end
17
23
 
24
+ =begin
18
25
  should "initialize with passed variables" do
19
26
  client = Sauce::Client.new(:username => "test_user",
20
27
  :access_key => "abc123")
@@ -24,7 +31,7 @@ class TestSauce < Test::Unit::TestCase
24
31
  assert_equal "501aca56282545a9a21ad2fc592b03fa", job.id
25
32
  assert_equal "joe", job.owner
26
33
  assert_equal "complete", job.status
27
- assert_equal "job-name", job.name
34
+ assert_equal "job-example-fixture", job.name
28
35
 
29
36
  assert_equal "firefox", job.browser
30
37
  assert_equal "3.5.", job.browser_version
@@ -40,55 +47,56 @@ class TestSauce < Test::Unit::TestCase
40
47
  assert_equal false, job.public
41
48
  assert_equal ["test", "example", "python_is_fun"], job.tags
42
49
  end
50
+ =end
43
51
 
44
- # Note: This won't pass until we have a canonical "test job" and its data
52
+ # Note: Relies on server-side data fixture
45
53
  should "retrieve and parse a job via the api" do
46
- job = @client.jobs.find("501aca56282545a9a21ad2fc592b03fa")
54
+ job = @client.jobs.find("gem-test-job")
47
55
 
48
- assert_equal "501aca56282545a9a21ad2fc592b03fa", job.id
49
- assert_equal "joe", job.owner
56
+ assert_equal "gem-test-job", job.id
57
+ assert_equal "sah", job.owner
50
58
  assert_equal "complete", job.status
51
- assert_equal "job-name", job.name
59
+ assert_equal "job-example-fixture", job.name
52
60
 
53
- assert_equal "firefox", job.browser
61
+ assert_equal "Firefox", job.browser
54
62
  assert_equal "3.5.", job.browser_version
55
63
  assert_equal "Windows 2003", job.os
56
64
 
57
- assert_equal 1253856281, job.creation_time
58
- assert_equal 1253856366, job.start_time
59
- assert_equal 1253856465, job.end_time
65
+ assert_equal 1266030817, job.creation_time
66
+ assert_equal 1266030833, job.start_time
67
+ assert_equal 1266030871, job.end_time
60
68
 
61
- assert_equal "http://saucelabs.com/video/8b6bf8d360cc338cc7cf7f6e093264d0/video.flv", job.video_url
62
- assert_equal "http://saucelabs.com/video/8b6bf8d360cc338cc7cf7f6e093264d0/selenium-server.log", job.log_url
69
+ assert_equal "http://saucelabs.com/jobs/gem-test-job/video.flv", job.video_url
70
+ assert_equal "http://saucelabs.com/jobs/gem-test-job/selenium-server.log", job.log_url
63
71
 
64
72
  assert_equal false, job.public
65
- assert_equal ["test", "example", "python_is_fun"], job.tags
73
+ assert_equal ['test', 'equal', 'multilingualism is fun'], job.tags
66
74
  end
67
75
 
68
76
  should "update writable properties" do
69
- job = @client.jobs.find("501aca56282545a9a21ad2fc592b03fa")
77
+ job = @client.jobs.find("gem-test-job")
70
78
 
71
79
  # Make sure it's in the expected condition before changing
72
80
  assert_equal false, job.public
73
- assert_equal ["test", "example", "python_is_fun"], job.tags
74
- assert_equal "job-name", job.name
81
+ assert_equal ["test", "equal", "multilingualism is fun"], job.tags
82
+ assert_equal "job-example-fixture", job.name
75
83
 
76
84
  job.public = true
77
85
  job.tags = ["changed", "updated", "ruby_is_also_fun"]
78
- job.name = "changed-job-name", job.name
86
+ job.name = "changed-job-name"
79
87
  job.save
80
88
 
81
89
  # Fresh copy of the same job
82
- job2 = @client.jobs.find("501aca56282545a9a21ad2fc592b03fa")
90
+ job2 = @client.jobs.find("gem-test-job")
83
91
 
84
- assert_equal true, job.public
85
- assert_equal ["changed", "updated", "ruby_is_also_fun"], job.tags
86
- assert_equal "changed-job-name", job.name
92
+ assert_equal true, job2.public
93
+ assert_equal ["changed", "updated", "ruby_is_also_fun"], job2.tags
94
+ assert_equal "changed-job-name", job2.name
87
95
 
88
96
  # Return the job to its original state and check it out
89
97
  job.public = false
90
- job.tags = ["test", "example", "python_is_fun"]
91
- job.name = "job-name", job.name
98
+ job.tags = ["test", "example", "multilingualism is fun"]
99
+ job.name = "job-example-fixture"
92
100
  job.save
93
101
 
94
102
  # Check to see if the change took
@@ -99,40 +107,39 @@ class TestSauce < Test::Unit::TestCase
99
107
  end
100
108
 
101
109
  should "not update read-only properties" do
102
- job = @client.jobs.find("501aca56282545a9a21ad2fc592b03fa")
110
+ job = @client.jobs.find("gem-test-job")
103
111
 
104
112
  # Make sure it's in the expected condition before changing
105
113
  assert_equal "complete", job.status
106
- assert_equal "joe", job.owner
107
- assert_equal "Linux", job.os
114
+ assert_equal "sah", job.owner
115
+ assert_equal "Windows 2003", job.os
108
116
 
109
117
  job.status = "groggy"
110
118
  job.owner = "sjobs"
111
119
  job.os = "darwin" # In a perfect world...
112
120
  assert_equal "groggy", job.status
113
- assert_equal "joe", job.owner
121
+ assert_equal "sjobs", job.owner
114
122
  assert_equal "darwin", job.os
115
123
  job.save
116
124
 
117
125
  # Changes should go away when refreshed
118
126
  job.refresh!
119
127
  assert_equal "complete", job.status
120
- assert_equal "joe", job.owner
121
- assert_equal "Linux", job.os
128
+ assert_equal "sah", job.owner
129
+ assert_equal "Windows 2003", job.os
122
130
  end
123
131
 
124
132
  should "list the 100 most recent jobs" do
125
133
  jobs = @client.jobs.all
126
134
 
127
- assert_equal 5, jobs.count
135
+ assert_equal 2, jobs.count
128
136
  end
129
137
 
130
- should "show the full job information on index if requested" do
138
+ should "show job listings with full job information if requested" do
131
139
  flunk "TODO: implement this"
132
140
  end
133
141
 
134
142
  def teardown
135
- @client.tunnels.destroy
136
143
  end
137
144
  end
138
145
  end
data/test/test_tunnels.rb CHANGED
@@ -1,22 +1,29 @@
1
1
  require 'helper'
2
+ require 'yaml'
2
3
 
3
4
  class TestSauce < Test::Unit::TestCase
4
5
  context "A V1 tunnel instance" do
5
6
  setup do
6
7
  # Create this file and put in your details to run the tests
7
- account = YAML.load_file "live_account.yml"
8
+ account = YAML.load_file "account2.yml"
8
9
  @username = account["username"]
9
10
  @access_key = account["access_key"]
10
11
  @ip = account["ip"]
11
12
  @client = Sauce::Client.new(:username => @username,
12
- :access_key => @access_key)
13
+ :access_key => @access_key,
14
+ :ip => @ip,
15
+ :protocol => account["protocol"],
16
+ :host => account["host"],
17
+ :port => account["port"])
18
+
19
+ #STDOUT.puts @client.api_url
13
20
  @client.tunnels.destroy_all
14
21
  end
15
22
 
16
23
  should "initialize with passed variables" do
17
24
  client = Sauce::Client.new(:username => "test_user",
18
25
  :access_key => "abc123")
19
- assert_equal "https://test_user:abc123@saucelabs.com/api/v1/test_user/", client.api_url
26
+ assert_equal "http://test_user:abc123@saucelabs.com:80/rest/v1/test_user/", client.api_url
20
27
  end
21
28
 
22
29
  should "create a tunnel with the current user" do
@@ -26,6 +33,14 @@ class TestSauce < Test::Unit::TestCase
26
33
  assert_equal @username, tunnel.owner
27
34
  end
28
35
 
36
+ should "error if a tunnel is created without domain names" do
37
+ flunk "TODO: Implement this"
38
+ tunnel = @client.tunnels.create('DomainNames' => [])
39
+ tunnel.refresh!
40
+ assert_not_nil tunnel
41
+ assert_equal @username, tunnel.owner
42
+ end
43
+
29
44
  should "list current tunnels" do
30
45
  @client.tunnels.create('DomainNames' => ["192.168.0.111"])
31
46
  @client.tunnels.create('DomainNames' => ["192.168.0.112"])
@@ -38,7 +53,7 @@ class TestSauce < Test::Unit::TestCase
38
53
  should "destroy a tunnel" do
39
54
  tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.114"])
40
55
  tunnel.destroy
41
- assert_equal "halting", tunnel.status
56
+ assert ["terminated", "halting"].include?(tunnel.status)
42
57
  end
43
58
 
44
59
  should "destroy all tunnels" do
@@ -49,12 +64,15 @@ class TestSauce < Test::Unit::TestCase
49
64
  @client.tunnels.destroy_all
50
65
 
51
66
  @client.tunnels.all.each do |tunnel|
52
- assert_equal "halting", tunnel.status
67
+ # This could be failing because the tunnels are already dead. Our servers too fast?
68
+ tunnel.refresh!
69
+ assert ["terminated", "halting"].include? tunnel.status
53
70
  end
54
71
  end
55
72
 
56
73
  should "say hello on port 1025 if healthy" do
57
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
74
+ tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.118"])
75
+
58
76
 
59
77
  max_retries = 30
60
78
  retries = 0
@@ -69,8 +87,26 @@ class TestSauce < Test::Unit::TestCase
69
87
  tunnel.destroy # cleanup
70
88
  end
71
89
 
90
+ should "have a host if finished booting" do
91
+ tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.119"])
92
+
93
+ max_retries = 30
94
+ retries = 0
95
+ until tunnel.status == "running" or retries >= max_retries
96
+ sleep 5
97
+ retries += 1
98
+ tunnel.refresh!
99
+ end
100
+
101
+ tunnel.refresh!
102
+
103
+ assert_not_nil tunnel.host
104
+
105
+ tunnel.destroy # cleanup
106
+ end
107
+
72
108
  should "not attempt to telnet if status is not running" do
73
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
109
+ tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.119"])
74
110
 
75
111
  tunnel.status = "booting"
76
112
  assert_equal false, tunnel.says_hello?
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sauce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 0
9
+ version: 0.5.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Sean Grove
@@ -9,29 +14,33 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-02 00:00:00 -08:00
17
+ date: 2010-03-16 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: thoughtbot-shoulda
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :development
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: rest-client
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :development
43
+ version_requirements: *id002
35
44
  description: A ruby interface to Sauce Labs' services. Start/stop tunnels, retrieve Selenium logs, access video replays, etc.
36
45
  email: sean@saucelabs.com
37
46
  executables: []
@@ -69,26 +78,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
78
  requirements:
70
79
  - - ">="
71
80
  - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
72
83
  version: "0"
73
- version:
74
84
  required_rubygems_version: !ruby/object:Gem::Requirement
75
85
  requirements:
76
86
  - - ">="
77
87
  - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
78
90
  version: "0"
79
- version:
80
91
  requirements: []
81
92
 
82
93
  rubyforge_project:
83
- rubygems_version: 1.3.5
94
+ rubygems_version: 1.3.6
84
95
  signing_key:
85
96
  specification_version: 3
86
97
  summary: Ruby access to Sauce Labs' features
87
98
  test_files:
88
99
  - test/debug.rb
89
100
  - test/helper.rb
90
- - test/irb_boot.rb
101
+ - test/monitor_jobs.rb
91
102
  - test/test_jobs.rb
92
- - test/test_jobs_old.rb
93
103
  - test/test_tunnels.rb
94
- - test/test_videos.rb
data/test/irb_boot.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'rubygems'
2
- require 'net/telnet'
3
-
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
- $LOAD_PATH.unshift(File.dirname(__FILE__))
6
-
7
- require 'sauce'
@@ -1,58 +0,0 @@
1
- require 'helper'
2
- require 'json'
3
-
4
- class TestSauce < Test::Unit::TestCase
5
- context "A jobs instance" do
6
- setup do
7
- # Create this file and put in your details to run the tests
8
- account = YAML.load_file "live_account.yml"
9
- @username = account["username"]
10
- @access_key = account["access_key"]
11
- @ip = account["ip"]
12
- @client = Sauce::Client.new(:username => @username,
13
- :access_key => @access_key)
14
- end
15
-
16
- should "initialize with passed variables" do
17
- job_json = JSON.parse '{"BrowserVersion": "3.", "Name": "example_job/name.rb", "_rev": "5-228269313", "CreationTime": 1266698090, "AssignmentTime": 1266698097, "Server": "192.168.0.1:4443", "AssignedTo": "f663372ba04444ce8cb3e6f61503f304", "ChefStartTime": 1266698101, "EndTime": 1266698139, "Type": "job", "Interactive": "true", "Status": "complete", "SeleniumServerLogUploadRequest": {"bucket": "sauce-userdata", "key": "sgrove/6337fe576deba0ba278dc1b5dfceac5f/selenium-server.log"}, "Tags": ["tag_1", "tag_2"], "ResultId": "6337fe576deba0ba278dc1b5dfceac5f", "AttachmentRequests": {}, "ModificationTime": 1266698139, "Browser": "firefox", "StartTime": 1266698101, "Owner": "sgrove", "_id": "01fc48caba6d15b46fad79e1b0562bbe", "OS": "Linux", "VideoUploadRequest": {"bucket": "sauce-userdata", "key": "sgrove/6337fe576deba0ba278dc1b5dfceac5f/video.flv"}}'
18
-
19
- client = Sauce::Client.new(:username => "test_user",
20
- :access_key => "abc123")
21
-
22
- job = client.jobs.new(job_json)
23
-
24
- assert_equal "sgrove", job.owner
25
- assert_equal "01fc48caba6d15b46fad79e1b0562bbe", job.id
26
- assert_equal "example_job/name.rb", job.name
27
- assert_equal "5-228269313", job._rev
28
- assert_equal "192.168.0.1:4443", job.server
29
- assert_equal "f663372ba04444ce8cb3e6f61503f304", job.assigned_to
30
-
31
- assert_equal "job", job.sauce_type
32
- assert_equal "true", job.interactive
33
- assert_equal "complete", job.status
34
- assert_equal ["tag_1", "tag_2"], job.tags
35
- assert_equal "6337fe576deba0ba278dc1b5dfceac5f", job.result_id
36
-
37
- # TODO: Buckets
38
- #assert_equal , job.selenium_server_log_upload_request
39
- #assert_equal , job.attachment_requests
40
- #assert_equal , job.videoupload_request
41
-
42
- assert_equal "Linux", job.os
43
- assert_equal "firefox", job.browser
44
- assert_equal "3.", job.browser_version
45
-
46
- assert_equal 1266698090, job.creation_time
47
- assert_equal 1266698097, job.assignment_time
48
- assert_equal 1266698101, job.chef_start_time
49
- assert_equal 1266698139, job.end_time
50
- assert_equal 1266698139, job.modification_time
51
- assert_equal 1266698101, job.start_time
52
- end
53
-
54
- def teardown
55
- @client.tunnels.destroy
56
- end
57
- end
58
- end
data/test/test_videos.rb DELETED
@@ -1,83 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSauce < Test::Unit::TestCase
4
- context "A Client instance" do
5
- setup do
6
- # Create this file and put in your details to run the tests
7
- account = YAML.load_file "live_account.yml"
8
- @username = account["username"]
9
- @access_key = account["access_key"]
10
- @ip = account["ip"]
11
- @client = Sauce::Client.new(:username => @username,
12
- :access_key => @access_key)
13
- @client.tunnels.destroy
14
- end
15
-
16
- should "initialize with passed variables" do
17
- client = Sauce::Client.new(:username => "test_user",
18
- :access_key => "abc123")
19
- assert_equal client.api_url, "https://test_user:abc123@saucelabs.com/rest/test_user/"
20
- end
21
-
22
- should "create a tunnel with the current user" do
23
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.110"])
24
- tunnel.refresh!
25
- assert_not_nil tunnel
26
- assert_equal @username, tunnel.owner
27
- end
28
-
29
- should "list current tunnels" do
30
- @client.tunnels.create('DomainNames' => ["192.168.0.111"])
31
- @client.tunnels.create('DomainNames' => ["192.168.0.112"])
32
- @client.tunnels.create('DomainNames' => ["192.168.0.113"])
33
-
34
- tunnels = @client.tunnels.all
35
- assert_equal 3, tunnels.select{|t| t.status != "halting"}.count
36
- end
37
-
38
- should "destroy a tunnel" do
39
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.114"])
40
- tunnel.destroy
41
- assert_equal "halting", tunnel.status
42
- end
43
-
44
- should "destroy all tunnels" do
45
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.115"])
46
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.116"])
47
- tunnel = @client.tunnels.create('DomainNames' => ["192.168.0.117"])
48
-
49
- @client.tunnels.destroy
50
-
51
- @client.tunnels.all.each do |tunnel|
52
- assert_equal "halting", tunnel.status
53
- end
54
- end
55
-
56
- should "say hello on port 1025 if healthy" do
57
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
58
-
59
- max_retries = 30
60
- retries = 0
61
- until tunnel.status == "running" or retries >= max_retries
62
- sleep 5
63
- retries += 1
64
- tunnel.refresh!
65
- end
66
-
67
- assert_equal true, tunnel.says_hello?
68
-
69
- tunnel.destroy # cleanup
70
- end
71
-
72
- should "not attempt to telnet if status is not running" do
73
- tunnel = @client.tunnels.create('DomainNames' => [@ip])
74
-
75
- tunnel.status = "booting"
76
- assert_equal false, tunnel.says_hello?
77
- end
78
-
79
- def teardown
80
- @client.tunnels.destroy
81
- end
82
- end
83
- end