Class: DatatrueClient::TestRun
- Inherits:
-
Object
- Object
- DatatrueClient::TestRun
- Defined in:
- lib/datatrue_client/test_run.rb
Instance Attribute Summary collapse
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#polling_interval ⇒ Object
Returns the value of attribute polling_interval.
-
#polling_timeout ⇒ Object
Returns the value of attribute polling_timeout.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TestRun
constructor
A new instance of TestRun.
-
#poll_progress(print_progress = nil) ⇒ Object
Keeps querying progress until progress status is ‘complete`.
-
#query_progress ⇒ Hash
Queries test run progress.
Constructor Details
#initialize(options = {}) ⇒ TestRun
18 19 20 21 22 23 24 25 26 |
# File 'lib/datatrue_client/test_run.rb', line 18 def initialize(={}) = @bridge = Bridge.new() @polling_timeout = [:polling_timeout] || 60 @polling_interval = [:polling_interval] || 2 create end |
Instance Attribute Details
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
8 9 10 |
# File 'lib/datatrue_client/test_run.rb', line 8 def job_id @job_id end |
#polling_interval ⇒ Object
Returns the value of attribute polling_interval.
9 10 11 |
# File 'lib/datatrue_client/test_run.rb', line 9 def polling_interval @polling_interval end |
#polling_timeout ⇒ Object
Returns the value of attribute polling_timeout.
9 10 11 |
# File 'lib/datatrue_client/test_run.rb', line 9 def polling_timeout @polling_timeout end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
8 9 10 |
# File 'lib/datatrue_client/test_run.rb', line 8 def progress @progress end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/datatrue_client/test_run.rb', line 8 def title @title end |
Instance Method Details
#poll_progress(print_progress = nil) ⇒ Object
Keeps querying progress until progress status is ‘complete`
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/datatrue_client/test_run.rb', line 36 def poll_progress(print_progress=nil) start_time = DateTime.now loop do res = query_progress @progress = progress_percentage(res) print_progress.call(@progress, res) if print_progress return res if res[:status] == 'completed' if elapsed_milliseconds(start_time, DateTime.now) >= @polling_timeout * 1000 raise TimeoutError.new("Polling progress timed out after #{@polling_timeout} seconds") break else sleep @polling_interval end end end |
#query_progress ⇒ Hash
Queries test run progress
30 31 32 |
# File 'lib/datatrue_client/test_run.rb', line 30 def query_progress @bridge.test_run_progress(job_id) end |