Skip to content

Commit

Permalink
various updates (reportportal#23)
Browse files Browse the repository at this point in the history
* Set description to cmd args of parallel_tests process

* Fix matcher to detect when start time needs to be updated

* Clean up formatting in report.rb

* Implement a folder creation lock file to address duplicate folders being created

* Delay each process by its ID number to create a staggered start to reporting in Report Portal (addresses load issues)

* Formatting and cleanup in parallel_report.rb

* Use temporary directory for tracking folder creation

* Add commenting around why we are delaying threads

* Make sure to use a "full path" for folder creation tracking

* fixing report description when run in parallel

- refactoring how runner process is detected
  - added fallback to cucumber if parallel test was not for parallel formatter

* - reverting some changes
- launch_uuid related fixes

* Fix Cucumber parallel formatter

* Fix parallel_tests version and possible endless loop

* Add debug logging to debug some issue

* Add more debug logging

* Remove retrying of requests to Report Portal

* Set last_used_time to a time of the parent item

* Set description to cmd args of parallel_tests process

* Fix URLs to include required "filter.eq.launch" parameter

* Fix matcher to detect when start time needs to be updated

* Clean up formatting in report.rb

* Implement a folder creation lock file to address duplicate folders being created

* Delay each process by its ID number to create a staggered start to reporting in Report Portal (addresses load issues)

* fixing report description when run in parallel

- if launch_id or file_with_launch_id is provided launch will not be marked as finished
- moved sleep time, since we are waiting for report to be created anyways

* - reverting file lock changes for reading the file
- moving lock file related functions to private

* - fixing temp file path generation
- refactoring how runner process is detected
  - added fallback to cucumber if parallel test was not for parallel formatter

* using single formatter for both parallel_cucumber and cucumber

* adding logger for report portal

* updating readme and adding settings for logging level

* updating how response processing is handling

* fixing issue with child process not closing the folder's items

* fixing value for time, removing cucumber IO as it's no longer needed

* - adding logging
- when run in parallel, child process should not close items in process(folder)

* - adding logging
- add exception handling when closing item , if already closed , ignore RP 40018 error code

* adding patch for multipart

* updating version
  • Loading branch information
vveliev-tc authored Jul 10, 2019
1 parent ee207f3 commit a64ff9e
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 251 deletions.
67 changes: 63 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,75 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/AlignArguments:
Exclude:
- 'lib/report_portal/rspec/formatter.rb'

# Offense count: 2
# Cop supports --auto-correct.
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'lib/report_portal/cucumber/json_slurper.rb'
- 'tests/features/step_definitions/steps.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'lib/report_portal/logging/logging_appender.rb'

# Offense count: 1
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
Enabled: true

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'lib/report_portal/cucumber/report.rb'

# Offense count: 3
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Exclude:
- 'lib/report_portal/cucumber/report.rb'
- 'lib/reportportal.rb'
- 'tests/formatter_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
Exclude:
- 'lib/reportportal.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
Exclude:
- 'lib/report_portal/cucumber/report.rb'
- 'lib/report_portal/logging/logging_appender.rb'
- 'lib/report_portal/rspec/formatter.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideBlockBraces:
Exclude:
- 'tests/formatter_spec.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
Expand Down Expand Up @@ -58,7 +120,7 @@ Metrics/BlockLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 169
Max: 250

# Offense count: 3
Metrics/CyclomaticComplexity:
Expand Down Expand Up @@ -118,8 +180,6 @@ Style/Documentation:
- 'spec/**/*'
- 'test/**/*'
- 'lib/report_portal/cucumber/formatter.rb'
- 'lib/report_portal/cucumber/parallel_formatter.rb'
- 'lib/report_portal/cucumber/parallel_report.rb'
- 'lib/report_portal/logging/logger.rb'
- 'lib/report_portal/patches/rest_client.rb'
- 'lib/report_portal/rspec/formatter.rb'
Expand Down Expand Up @@ -174,7 +234,6 @@ Style/GlobalVars:
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/report_portal/cucumber/parallel_report.rb'
- 'lib/report_portal/cucumber/report.rb'
- 'lib/report_portal/rspec/formatter.rb'
- 'lib/reportportal.rb'
Expand Down
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ source 'https://rubygems.org'

gemspec

gem 'faraday'
gem 'cucumber', '~> 3'
gem 'parallel_tests'
gem 'log4r'
gem 'logging'
gem 'parallel_tests', '~> 2.15.0'
gem 'rake'
gem 'rspec'
gem 'rubytree', git: 'https://github.com/razboev/RubyTree'

gem 'log4r'
gem 'logging'
gem 'sys-proctable', '~> 1.1.5'
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ 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'```
```parallel_cucumber <some options> -o '<some other options> -f ReportPortal::Cucumber::Formatter'```

* With RSpec:

Expand All @@ -54,6 +54,7 @@ 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:
- log_level - this is log level for report_portal agent (useful for troubleshooting issued 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
```
Expand All @@ -75,12 +76,35 @@ WebMock.disable_net_connect!(:net_http_connect_on_start => true, :allow_localhos
## Formatter modes

The following modes are supported:

| 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 |
<table><thead><tr><th>Name</th><th>Purpose</th></tr></thead>
<tbody>
<tr>
<td>attach_to_launch</td>
<td>
Add executing features/scenarios to an existing launch.
Use following options to configure that.

1. launch_id
2. file_with_launch_id
3. rp_launch_id.tmp in `Dir.tmpdir`

If above options not present client will create 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>

## Logging
Experimental support for three common logging frameworks was added:
Expand All @@ -91,12 +115,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/)
10 changes: 3 additions & 7 deletions lib/report_portal/cucumber/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ module Cucumber
class Formatter
# @api private
def initialize(config)
ENV['REPORT_PORTAL_USED'] = 'true'

@logger ||= Logger.new(config.out_stream)
@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)
Expand All @@ -23,8 +21,6 @@ def initialize(config)

def puts(message)
process_message(:puts, message)
@io.puts(message)
@io.flush
end

def embed(*args)
Expand All @@ -34,7 +30,7 @@ def embed(*args)
private

def report
@report ||= ReportPortal::Cucumber::Report.new
@report ||= ReportPortal::Cucumber::Report.new(@logger)
end

def setup_message_processing
Expand Down
14 changes: 0 additions & 14 deletions lib/report_portal/cucumber/parallel_formatter.rb

This file was deleted.

54 changes: 0 additions & 54 deletions lib/report_portal/cucumber/parallel_report.rb

This file was deleted.

Loading

0 comments on commit a64ff9e

Please sign in to comment.