Class: Inferno::Entities::Result

Inherits:
Entity
  • Object
show all
Includes:
HasRunnable
Defined in:
lib/inferno/entities/result.rb

Overview

A Result represents the result of running a Test, TestGroup, or TestSuite

Constant Summary collapse

ATTRIBUTES =
[
  :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
  :test_group, :test_suite_id, :test_suite, :test_run_id,
  :test_session_id, :result, :result_message, :messages, :requests,
  :input_json, :output_json
].freeze
RESULT_OPTIONS =
['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasRunnable

#runnable

Methods inherited from Entity

#to_hash

Constructor Details

#initialize(params) ⇒ Result

Returns a new instance of Result.



55
56
57
58
59
60
# File 'lib/inferno/entities/result.rb', line 55

def initialize(params)
  super(params, ATTRIBUTES - [:messages, :requests])

  @messages = (params[:messages] || []).map { |message| Message.new(message) }
  @requests = (params[:requests] || []).map { |request| Request.new(request) }
end

Instance Attribute Details

#created_atTime

Returns creation timestamp.

Returns:

  • (Time)

    creation timestamp



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#idString

Returns id of the session.

Returns:

  • (String)

    id of the session



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#input_jsonString

Returns JSON string of the inputs used for this result.

Returns:

  • (String)

    JSON string of the inputs used for this result



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#messagesArray<Inferno::Entities::Message>

result

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#output_jsonString

Returns JSON string of the outputs created by this result.

Returns:

  • (String)

    JSON string of the outputs created by this result



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#requestsArray<Inferno::Entities::Request>

associated with this result

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#resultString

running, wait, cancel)

Returns:

  • (String)

    the result (pass, fail, skip, omit, error,



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#result_messageString

Returns summary message for this result.

Returns:

  • (String)

    summary message for this result



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#testTest?

Returns the Test this result belongs to.

Returns:

  • (Test, nil)

    the Test this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_groupTestGroup?

Returns the TestGroup this result belongs to.

Returns:

  • (TestGroup, nil)

    the TestGroup this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_group_idString?

Returns id of the TestGroup this result belongs to.

Returns:

  • (String, nil)

    id of the TestGroup this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_idString?

Returns id of the Test this result belongs to.

Returns:

  • (String, nil)

    id of the Test this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_run_idString

Returns the TestRun this result belongs to.

Returns:

  • (String)

    the TestRun this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_session_idString

Returns the TestSession this result belongs to.

Returns:

  • (String)

    the TestSession this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_suiteTestSuite?

Returns the TestSuite this result belongs to.

Returns:

  • (TestSuite, nil)

    the TestSuite this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#test_suite_idString?

Returns id of the TestSuite this result belongs to.

Returns:

  • (String, nil)

    id of the TestSuite this result belongs to



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

#updated_atTime

Returns update timestamp.

Returns:

  • (Time)

    update timestamp



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = <<~MESSAGE
        #{io_type.singularize.capitalize} is too large to display, please visit
        #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
        for details
      MESSAGE
    end

    io_array
  end

  # @private
  def io_is_large?(io_value)
    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
  end
end

Instance Method Details

#handle_large_io(io_type) ⇒ Array<Hash>

Flags large inputs or outputs and replaces their values with a reference message.

This method inspects either the inputs or outputs array and, for each item whose value exceeds the configured size threshold, sets is_large: true and replaces the value with a message pointing to the full content endpoint.

Parameters:

  • io_type (String)

    Must be either 'inputs' or 'outputs'.

Returns:

  • (Array<Hash>)

    The mutated list of inputs or outputs.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/inferno/entities/result.rb', line 91

def handle_large_io(io_type)
  io_array = public_send(io_type)

  io_array.each do |io|
    next unless io_is_large?(io['value'])

    io['is_large'] = true
    io['value'] = <<~MESSAGE
      #{io_type.singularize.capitalize} is too large to display, please visit
      #{Inferno::Application['base_url']}/api/test_sessions/#{test_session_id}/results/#{id}/io/#{io_type}/#{io['name']}
      for details
    MESSAGE
  end

  io_array
end

#inputsObject



75
76
77
# File 'lib/inferno/entities/result.rb', line 75

def inputs
  input_json.present? ? JSON.parse(input_json) : []
end

#optional?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/inferno/entities/result.rb', line 62

def optional?
  runnable.nil? || runnable.optional?
end

#outputsObject



79
80
81
# File 'lib/inferno/entities/result.rb', line 79

def outputs
  output_json.present? ? JSON.parse(output_json) : []
end

#required?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/inferno/entities/result.rb', line 66

def required?
  !optional?
end

#waiting?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/inferno/entities/result.rb', line 71

def waiting?
  result == 'wait'
end