Class: ParallelReportPortal::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/parallel_report_portal/configuration.rb

Overview

The Configuration class holds the connection properties to communicate with Report Portal and to identify the user and project for reporting.

It attempts to load a configuration file called report_portal.yml first in a local directory called config and if that's not found in the current directory. (Report Portal actually tells you to create a files called REPORT_PORTAL.YML in uppercase -- for this reason the initializer is case insensitive with regards to the file name)

It will then try an apply the following environment variables, if present (these can be specified in either lowercase for backwards compatibility with the official gem or in uppercase for reasons of sanity)

Environment variables

RP_API_KEY

The API key required for authentication

RP_ENDPOINT

the URL of the Report Portal API endpoint

RP_PROJECT

the Report Portal project name -- this must already exist within Report Port and this user must be a member of the project

RP_LAUNCH

The name of this launch

RP_DESCRIPTION

A textual string describing this launch

RP_TAGS

A set of tags to pass to Report Portal for this launch. If these are set via an environment variable, provide a comma-separated string of tags

RP_ATTRIBUTES

A set of attribute tags to pass to Report Portal for this launch. If these are set via an environment variable, provide a comma-separated string of attributes

Constant Summary collapse

ATTRIBUTES =
[:api_key, :endpoint, :project, :launch, :debug, :description, :tags, :attributes, :open_timeout, :idle_timeout, :read_timeout]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Create an instance of Configuration.

The initializer will first attempt to load a configuration files called report_portal.yml (case insensitive) in the both the config and current working directory (the former takes precedence). It will then apply any of the environment variable values.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/parallel_report_portal/configuration.rb', line 61

def initialize
  load_configuration_file
  ATTRIBUTES.each do |attr|
    env_value = get_env("rp_#{attr.to_s}")
    send(:"#{attr}=", env_value) if env_value
  end

  # If this is compiled against OpenSSL v3, we need to turn off the exception raising
  # when the server closes the stream without sending an EOF message in advance
  if OpenSSL::SSL.const_defined?(:OP_IGNORE_UNEXPECTED_EOF)
    # Assign the additional parameter with a bitwise 'or' assignment
    OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_IGNORE_UNEXPECTED_EOF
  end
end

Instance Attribute Details

#api_keyString

Returns the Report Portal API key required for authorization.

Returns:

  • (String)

    the Report Portal API key required for authorization



28
29
30
# File 'lib/parallel_report_portal/configuration.rb', line 28

def api_key
  @api_key
end

#attributesArray<String>

Returns an array of attributes to attach to this launch (Report Portal 5).

Returns:

  • (Array<String>)

    an array of attributes to attach to this launch (Report Portal 5)



47
48
49
# File 'lib/parallel_report_portal/configuration.rb', line 47

def attributes
  @attributes
end

#debugBoolean

Returns true if this is a debug run (this launch will appear on the debug tab in Report Portal).

Returns:

  • (Boolean)

    true if this is a debug run (this launch will appear on the debug tab in Report Portal).



42
43
44
# File 'lib/parallel_report_portal/configuration.rb', line 42

def debug
  @debug
end

#descriptionString

Returns a textual description of this launch.

Returns:

  • (String)

    a textual description of this launch.



44
45
46
# File 'lib/parallel_report_portal/configuration.rb', line 44

def description
  @description
end

#endpointString

Returns the Report Portal URI - this should include the scheme e.g. https://reportportal.local/api/v1.

Returns:

  • (String)

    the Report Portal URI - this should include the scheme e.g. https://reportportal.local/api/v1



31
32
33
# File 'lib/parallel_report_portal/configuration.rb', line 31

def endpoint
  @endpoint
end

#idle_timeoutInteger

Returns the number of seconds for the open and idle connection to timeout.

Returns:

  • (Integer)

    the number of seconds for the open and idle connection to timeout



51
52
53
# File 'lib/parallel_report_portal/configuration.rb', line 51

def idle_timeout
  @idle_timeout
end

#launchObject

@return [String] the launch name for this test run.



37
38
39
# File 'lib/parallel_report_portal/configuration.rb', line 37

def launch
  @launch
end

#open_timeoutInteger

Returns the number of seconds for the open connection to timeout.

Returns:

  • (Integer)

    the number of seconds for the open connection to timeout



49
50
51
# File 'lib/parallel_report_portal/configuration.rb', line 49

def open_timeout
  @open_timeout
end

#projectString

Returns the Report Portal project name. This must exist and match the project name within Report Portal.

Returns:

  • (String)

    the Report Portal project name. This must exist and match the project name within Report Portal.



35
36
37
# File 'lib/parallel_report_portal/configuration.rb', line 35

def project
  @project
end

#read_timeoutInteger

Returns the number of seconds for the read connection to timeout.

Returns:

  • (Integer)

    the number of seconds for the read connection to timeout



53
54
55
# File 'lib/parallel_report_portal/configuration.rb', line 53

def read_timeout
  @read_timeout
end

#tagsArray<String>

Returns an array of tags to attach to this launch.

Returns:

  • (Array<String>)

    an array of tags to attach to this launch.



39
40
41
# File 'lib/parallel_report_portal/configuration.rb', line 39

def tags
  @tags
end

Instance Method Details

#fetch(key, default_value) ⇒ Object

Simple method to obtain an attribute from this class or set default value param [symbol] a symbol version of the attribute



113
114
115
# File 'lib/parallel_report_portal/configuration.rb', line 113

def fetch(key, default_value)
  self.send(key).nil? ? default_value : self.send(key)
end