-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
various updates (#23) #59
Changes from all commits
ec9b1b1
a41828b
97e1f5d
69da60c
75ad0f9
3def39e
25c5159
f18bb5e
396a961
e1c4805
623fd05
80c4380
1153181
05b83ba
62b388d
4ea36e6
3c58d20
e11290b
580850b
b188a34
10fb831
2c26a48
357e707
868f789
c540c01
7ed6e2c
c49d5eb
a69014c
c01819c
86bc1c7
ecc4801
e62541e
01fbe3a
c15caef
494fda0
dad6361
9f2bbde
a76e451
e40548b
1e2628e
624cd59
ad05252
5067695
3242ac1
ab9483c
c25fb0e
4fbf863
41e0604
24e16f6
1ec43e8
d1c128a
b62c7eb
ad7c8d6
b9b6b14
1f40f58
e61d8f7
3bc8d9a
893af0f
a92fc75
c6bb6ec
f97e072
d2d2cbe
f30977b
265edef
0d3fba8
6215a53
3e655b6
d31ab44
8985eca
f5cc434
0cb6a6c
9056c74
52707ca
b3359a7
af18470
fe8d51d
aabebcf
7694f48
37fbb35
e132c1c
f338909
58d0468
b929ce8
1cb735e
a6edfa7
aa0342c
8549179
0da36cc
f668bfb
321f256
9ba5fce
10af2f4
92671e7
cad3f7c
1c3b42f
369af40
8cf2206
475eac9
e559f3f
61c4bbb
d631143
2cb3597
3a7c4a2
638a7bf
e8d5dbb
a79d207
67e1092
45b47a6
2794ce9
abb0cb8
c3a7f79
3c06300
66799ab
083a83a
a64ff9e
1e50fec
2340184
f8e75c6
1d37021
9fd2cda
2c447d8
7be5353
92af68d
72d496a
efc07c0
d657458
00e5d88
da82da3
cd14bd3
0811ede
ead9cc1
8414edc
3c76071
69ed4ae
c7c177b
2de8740
e400952
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,12 +28,18 @@ Add `gem 'reportportal', git: 'https://github.com/reportportal/agent-ruby.git'` | |
|
||
* With Cucumber: | ||
|
||
```cucumber <other options> -f ReportPortal::Cucumber::Formatter``` | ||
```cucumber <other options> -f ReportPortal::Cucumber::Formatter -o '<log_file>'``` | ||
|
||
* With Cucumber and parallel_tests gem: | ||
|
||
```parallel_cucumber <some options> -o '<some other options> -f ReportPortal::Cucumber::ParallelFormatter'``` | ||
* With Cucumber (Advanced) | ||
|
||
```ruby | ||
AfterConfiguration do |config| | ||
... | ||
#rp_log_file = <Generated or from ENV> | ||
... | ||
config.formats.push(["ReportPortal::Cucumber::Formatter", {}, rp_log_file]) | ||
end | ||
``` | ||
* With RSpec: | ||
|
||
```rspec <other options> -f ReportPortal::RSpec::Formatter``` | ||
|
@@ -54,6 +60,8 @@ Supported settings: | |
- launch_id - id of previously created launch (to be used if formatter_modes contains attach_to_launch) | ||
- file_with_launch_id - path to file with id of launch (to be used if formatter_modes contains attach_to_launch) | ||
- disable_ssl_verification - set to true to disable SSL verification on connect to ReportPortal (potential security hole!). Set `disable_ssl_verification` to `true` if you see the following error: | ||
- launch_uuid - when formatter_modes contains `attach_to_launch`, launch_uuid will be used to create uniq report group (tmp dir should be shared across all launches) | ||
- log_level - this is log level for report_portal agent (useful for troubleshooting issues when run in parallel mode) | ||
``` | ||
Request to https://rp.epam.com/reportportal-ws/api/v1/pass-team/launch//finish produced an exception: RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed | ||
``` | ||
|
@@ -75,13 +83,37 @@ WebMock.disable_net_connect!(:net_http_connect_on_start => true, :allow_localhos | |
## Formatter modes | ||
|
||
The following modes are supported: | ||
<table><thead><tr><th>Name</th><th>Purpose</th></tr></thead> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is rendered with horizontal scrolling in Github. So a text becomes harder to read in comparison to the current table rendered using Github flavored markdown. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.github.com/gfm/#html-blocks - not sure what you are asking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you can see on the screenshot you attached, not all text in column "Purpose" is visible. There is a horizontal scrolling (at least in Chrome). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, but I don't see what is the issue here. If you know how to do multiple lines in a simple table block let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previous formatting looked better in the browser IMO. Could you use it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is subjective. Put everything in a single paragraph, and it will not look good in the browser IMO. Hense I had to change it to be more presentable. |
||
<tbody> | ||
<tr> | ||
<td>attach_to_launch</td> | ||
<td> | ||
Add executing features/scenarios to same launch. | ||
Use following options are available to configure that. | ||
|
||
1. launch_id | ||
2. file_with_launch_id | ||
3. launch_uuid | ||
4. rp_launch_id_for_<first process pid>.lock in `Dir.tmpdir` | ||
|
||
*** If launch is not created, cucumber process will create one. Such that user does not need to worry about creating new launch. | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>use_same_thread_for_reporting</td> | ||
<td> | ||
Send reporting commands in the same main thread used for running tests. This mode is useful for debugging | ||
Report Portal client. It changes default behavior to send commands in the separate thread. | ||
Default behavior is there not to slow test execution. </td> | ||
</tr> | ||
<tr> | ||
<td>skip_reporting_hierarchy</td> | ||
<td> | ||
Do not create items for folders and feature files</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
| Name | Purpose | | ||
| --- | --- | | ||
| attach_to_launch | Do not create a new launch but add executing features/scenarios to an existing launch. Use launch_id or file_with_launch_id settings to configure that. If they are not present client will check rp_launch_id.tmp in `Dir.tmpdir`) | ||
| use_same_thread_for_reporting | Send reporting commands in the same main thread used for running tests. This mode is useful for debugging this Report Portal client. It changes default behavior to send commands in the separate thread. Default behavior is there not to slow test execution. | | ||
| skip_reporting_hierarchy | Do not create items for folders and feature files | | ||
| use_persistent_connection | Use persistent connection to connect to the server | | ||
|
||
## Logging | ||
Experimental support for three common logging frameworks was added: | ||
|
@@ -92,12 +124,6 @@ Experimental support for three common logging frameworks was added: | |
|
||
To use Logger, set use_standard_logger parameter to true (see Configuration chapter). For the other two corresponding appenders/outputters are available under reportportal/logging. | ||
|
||
## Parallel formatter | ||
|
||
ReportPortal::Cucumber::ParallelFormatter can be used for tests started via parallel_tests gem. | ||
|
||
Note: Launch id is shared between independent processes (as is the case with parallel_tests gem) via a file in `Dir.tmpdir`. | ||
|
||
## Links | ||
|
||
- [ReportPortal](https://github.com/reportportal/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module ReportPortal | ||
# @api private | ||
class Client | ||
attr_accessor :logger | ||
|
||
def initialize(logger) | ||
@logger = logger | ||
end | ||
|
||
def process_request(path, method, *options) | ||
tries = 2 | ||
begin | ||
response = rp_client.send(method, path, *options) | ||
rescue Faraday::ClientError => e | ||
logger.error("TRACE[#{e.backtrace}]") | ||
response = JSON.parse(e.response[:body]) | ||
logger.warn("Exception[#{e}], response:[#{response}]], retry_count: [#{tries}]") | ||
m = response['message'].match(%r{Start time of child \['(.+)'\] item should be same or later than start time \['(.+)'\] of the parent item\/launch '.+'}) | ||
case response['error_code'] | ||
when 4001 | ||
return | ||
end | ||
|
||
if m | ||
parent_time = Time.strptime(m[2], '%a %b %d %H:%M:%S %z %Y') | ||
data = JSON.parse(options[0]) | ||
logger.warn("RP error : 40025, time of a child: [#{data['start_time']}], paren time: [#{(parent_time.to_f * 1000).to_i}]") | ||
data['start_time'] = (parent_time.to_f * 1000).to_i + 1000 | ||
options[0] = data.to_json | ||
ReportPortal.last_used_time = data['start_time'] | ||
end | ||
|
||
retry unless (tries -= 1).zero? | ||
end | ||
JSON.parse(response.body) | ||
end | ||
|
||
def rp_client | ||
@connection ||= Faraday.new(url: Settings.instance.project_url) do |f| | ||
f.headers = { Authorization: "Bearer #{Settings.instance.uuid}", Accept: 'application/json', 'Content-type': 'application/json' } | ||
verify_ssl = Settings.instance.disable_ssl_verification | ||
f.ssl.verify = !verify_ssl unless verify_ssl.nil? | ||
f.request :multipart | ||
f.request :url_encoded | ||
f.response :raise_error | ||
f.adapter :net_http_persistent | ||
end | ||
|
||
@connection | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,12 +5,10 @@ module Cucumber | |||||
class Formatter | ||||||
# @api private | ||||||
def initialize(config) | ||||||
ENV['REPORT_PORTAL_USED'] = 'true' | ||||||
abotalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
@logger = Logger.new(config.out_stream) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
@logger.level = ReportPortal::Settings.instance.log_level || :warn | ||||||
setup_message_processing | ||||||
|
||||||
@io = config.out_stream | ||||||
|
||||||
[:test_case_started, :test_case_finished, :test_step_started, :test_step_finished, :test_run_finished].each do |event_name| | ||||||
config.on_event event_name do |event| | ||||||
process_message(event_name, event) | ||||||
|
@@ -21,8 +19,6 @@ def initialize(config) | |||||
|
||||||
def puts(message) | ||||||
process_message(:puts, message) | ||||||
@io.puts(message) | ||||||
@io.flush | ||||||
end | ||||||
|
||||||
def embed(*args) | ||||||
|
@@ -32,7 +28,7 @@ def embed(*args) | |||||
private | ||||||
|
||||||
def report | ||||||
@report ||= ReportPortal::Cucumber::Report.new | ||||||
@report ||= ReportPortal::Cucumber::Report.new(@logger) | ||||||
end | ||||||
|
||||||
def setup_message_processing | ||||||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have an example for parallel_cucumber to show that the gem supports parallel_tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're missing the point, it's single formatted for both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that it's a single formatter. But the potential user looking at README should also be aware that agent works when tests are run in parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are more than welcome to contribute.