moto 0.8.1 → 0.8.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: a9047650162e05dd57e1c30c44865874ec1bb5df
4
- data.tar.gz: d2682493617e1cf95121304fcd1d07eefe31ccd0
3
+ metadata.gz: 2ba797b82d95217eeee0ffd6e9f08cdf8f75b5de
4
+ data.tar.gz: 7f12124132318e7566953a2a9dfd12ed52cf4a39
5
5
  SHA512:
6
- metadata.gz: e0573260ccd434bdb0eef6a8ef95102f17644565a209e48e15ad75f882a1c393aedf1266db61b63161f94b800da8b8d0227408ea92b27adb46eb3d22ed86555e
7
- data.tar.gz: e181e2cf69fcf4bbe6e0ac4b8a607e576ff432a6cfa5e8287d98d33e355946f761fd2208d20c92251210502e96646442c0d64d268d4c01f79a8223b40fd22b33
6
+ metadata.gz: 6e020d6ec1a6c96d798f598784678b4a531d981a0b477acd9248ec9073d19bc5ae63ce0e2d01c5b7c6ab5b5975d18108df13a93b774a663d1c5329c05931e024
7
+ data.tar.gz: 339ac7bfebc0a3a2b872f88fde2e8010e3c7ff6f9b62d3cd9f5c381691dd6b7eae778ab6819e34e964811a0329f980d8525ef19d93879eb1188e52b26c75e168
@@ -11,7 +11,8 @@ module Moto
11
11
 
12
12
  run_status_hash = {
13
13
  errors: run_status.tests_error.length,
14
- failures: run_status.tests_error.length,
14
+ failures: run_status.tests_failed.length,
15
+ skipped: run_status.tests_skipped.length,
15
16
  name: custom_run_name,
16
17
  tests: run_status.tests_all.length,
17
18
  time: run_status.duration,
@@ -33,11 +34,11 @@ module Moto
33
34
  if test_status.results.last.code == Moto::Test::Result::ERROR
34
35
  xml.error(message: test_status.results.last.message)
35
36
  elsif test_status.results.last.code == Moto::Test::Result::FAILURE
36
-
37
37
  test_status.results.last.failures.each do |failure_message|
38
38
  xml.failure(message: failure_message)
39
39
  end
40
-
40
+ elsif test_status.results.last.code == Moto::Test::Result::SKIPPED
41
+ xml.skipped
41
42
  end
42
43
  end
43
44
  end
@@ -6,69 +6,85 @@ module Moto
6
6
  module Listeners
7
7
  class Webui < Base
8
8
 
9
+ REST_MAX_TRIES = 3
10
+ REST_TIMEOUT = 15
11
+
9
12
  def start_run
10
13
 
11
14
  @url = Moto::Lib::Config.moto[:test_reporter][:listeners][:webui][:url]
12
15
 
13
16
  data = {
14
- name: custom_run_name,
15
- result: :running,
16
- cnt_all: nil,
17
- cnt_passed: nil,
18
- cnt_failure: nil,
19
- cnt_error: nil,
20
- cnt_skipped: nil,
21
- user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
22
- host: Sys::Uname.nodename,
23
- pid: Process.pid
17
+ name: custom_run_name,
18
+ result: :running,
19
+ cnt_all: nil,
20
+ cnt_passed: nil,
21
+ cnt_failure: nil,
22
+ cnt_error: nil,
23
+ cnt_skipped: nil,
24
+ user: Sys::Uname.sysname.downcase.include?('windows') ? ENV['USERNAME'] : ENV['LOGNAME'],
25
+ host: Sys::Uname.nodename,
26
+ pid: Process.pid
27
+ }
28
+
29
+ result = try {
30
+ RestClient::Request.execute(method: :post, url: "#{@url}/api/runs", payload: data.to_json, timeout: REST_TIMEOUT, headers: {content_type: :json, accept: :json})
24
31
  }
25
32
 
26
- @run = JSON.parse( RestClient.post( "#{@url}/api/runs", data.to_json, :content_type => :json, :accept => :json ) )
33
+ @run = JSON.parse(result)
27
34
  @tests = {}
28
35
  end
29
36
 
30
37
  def end_run(run_status)
31
38
  # PUT http://sandbox.dev:3000/api/runs/1
32
39
  data = {
33
- result: run_status.result,
34
- cnt_all: run_status.tests_all.length,
35
- cnt_passed: run_status.tests_passed.length,
36
- cnt_failure: run_status.tests_failed.length,
37
- cnt_error: run_status.tests_error.length,
38
- cnt_skipped: run_status.tests_skipped.length,
39
- duration: run_status.duration
40
+ result: run_status.result,
41
+ cnt_all: run_status.tests_all.length,
42
+ cnt_passed: run_status.tests_passed.length,
43
+ cnt_failure: run_status.tests_failed.length,
44
+ cnt_error: run_status.tests_error.length,
45
+ cnt_skipped: run_status.tests_skipped.length,
46
+ duration: run_status.duration
40
47
  }
41
48
 
42
- @run = JSON.parse( RestClient.put( "#{@url}/api/runs/#{@run['id']}", data.to_json, :content_type => :json, :accept => :json ) )
49
+ result = try {
50
+ RestClient::Request.execute(method: :put, url: "#{@url}/api/runs/#{@run['id']}", payload: data.to_json, timeout: REST_TIMEOUT, headers: {content_type: :json, accept: :json})
51
+ }
52
+ @run = JSON.parse(result)
43
53
  end
44
54
 
45
55
  def start_test(test_status)
46
56
  # POST http://sandbox.dev:3000/api/tests/create
47
57
  data = {
48
- name: test_status.name,
49
- class_name: test_status.test_class_name,
50
- log: nil,
51
- run_id: @run['id'],
52
- env: test_status.env,
53
- parameters: test_status.params.to_s,
54
- result: :running,
55
- error: nil,
56
- failures: nil
58
+ name: test_status.name,
59
+ class_name: test_status.test_class_name,
60
+ log: nil,
61
+ run_id: @run['id'],
62
+ env: test_status.env,
63
+ parameters: test_status.params.to_s,
64
+ result: :running,
65
+ error: nil,
66
+ failures: nil
57
67
  }
58
68
 
59
- @tests[test_status.name] = JSON.parse( RestClient.post( "#{@url}/api/tests", data.to_json, :content_type => :json, :accept => :json ) )
69
+ result = try {
70
+ RestClient::Request.execute(method: :post, url: "#{@url}/api/tests", payload: data.to_json, timeout: REST_TIMEOUT, headers: {content_type: :json, accept: :json})
71
+ }
72
+ @tests[test_status.name] = JSON.parse(result)
60
73
  end
61
74
 
62
75
  def end_test(test_status)
63
76
  data = {
64
- log: File.read(test_status.log_path),
65
- result: test_status.results.last.code,
66
- error: test_status.results.last.code == Moto::Test::Result::ERROR ? nil : test_status.results.last.message,
67
- failures: test_failures(test_status),
68
- duration: test_status.duration
77
+ log: File.read(test_status.log_path),
78
+ result: test_status.results.last.code,
79
+ error: test_status.results.last.code == Moto::Test::Result::ERROR ? nil : test_status.results.last.message,
80
+ failures: test_failures(test_status),
81
+ duration: test_status.duration
69
82
  }
70
83
 
71
- @tests[test_status.name] = JSON.parse( RestClient.put( "#{@url}/api/tests/#{@tests[test_status.name]['id']}", data.to_json, :content_type => :json, :accept => :json ) )
84
+ result = try {
85
+ RestClient::Request.execute(method: :put, url: "#{@url}/api/tests/#{@tests[test_status.name]['id']}", payload: data.to_json, timeout: REST_TIMEOUT, headers: {content_type: :json, accept: :json})
86
+ }
87
+ @tests[test_status.name] = JSON.parse(result)
72
88
  end
73
89
 
74
90
  # @return [String] string with messages of all failures in a test
@@ -76,6 +92,21 @@ module Moto
76
92
  test_status.results.last.failures.join("\n\t")
77
93
  end
78
94
 
95
+ # Tries to execute, without an error, block of code passed to the function.
96
+ # @param block Block of code to be executed up to MAX_REST_TRIES
97
+ def try(&block)
98
+
99
+ tries = REST_MAX_TRIES
100
+
101
+ begin
102
+ yield
103
+ rescue
104
+ tries -= 1
105
+ tries > 0 ? retry : raise
106
+ end
107
+
108
+ end
109
+
79
110
  end
80
111
  end
81
112
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Moto
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bartek Wilczek
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-09-06 00:00:00.000000000 Z
14
+ date: 2016-09-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport