right_develop 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58bccc63409eb4fcbd40d7357816ab0742a472f1
4
- data.tar.gz: fb027c76b663d06a0fa97bf1fac431d763b18fcd
3
+ metadata.gz: 7989cf01a6dc582f7974ca8517043149e465d0f3
4
+ data.tar.gz: b04cc7da6587497edd4c256d6ba16d74e55be1e2
5
5
  SHA512:
6
- metadata.gz: e25f3a42e141509f8f2062513f911cf3b18adbb3f94142d7958e7debd7289c5139010b3da60eb9369d754d1614458c108ca236fed7e1a7cf228f734644962819
7
- data.tar.gz: e136b4ce68d977c1a9cbe00d119f6a948b70d290d0ea4592d4479a33d1391293d40eac1ea5505eefe4580c36192b634a1e30641dc57515a2e49a47205fc4afab
6
+ metadata.gz: f00e538f03810658bd3cc41c296787f6a0621ce7aabeb26ce3b92f7c612f32d60b328bf0192ecabd9f214eb4c6c21264133e75ef2840b3455144a334d8529dbb
7
+ data.tar.gz: 7fce7bf3a7a856e04c7a359e7c01f4d335cb4f2ea6565bf1f360c6209ac2fe3ef275773b45c82a2589886220a5c2374911842c690c7110f91a2c7732cd04784c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.0.3
@@ -34,7 +34,9 @@ module RightDevelop::Testing::Client::Rest::Request
34
34
  HALT_TRANSMIT = :halt_transmit
35
35
 
36
36
  # exceptions
37
- class PlaybackError < StandardError; end
37
+ PLAYBACK_ERROR = ::RightDevelop::Testing::Recording::Metadata::PlaybackError
38
+
39
+ class PeerResetConnectionError < PLAYBACK_ERROR; end
38
40
 
39
41
  # fake Net::HTTPResponse
40
42
  class FakeNetHttpResponse
@@ -114,7 +116,7 @@ module RightDevelop::Testing::Client::Rest::Request
114
116
  "Released thread id=#{::Thread.current.object_id} after " <<
115
117
  "#{try_counter} attempts to satisfy a retryable condition:\n" <<
116
118
  response.message
117
- raise PlaybackError, message
119
+ raise PLAYBACK_ERROR, message
118
120
  end
119
121
  if 1 == try_counter
120
122
  message = "Blocking thread id=#{::Thread.current.object_id} " <<
@@ -141,7 +143,7 @@ module RightDevelop::Testing::Client::Rest::Request
141
143
  log_response(response)
142
144
  process_result(response, &block)
143
145
  else
144
- raise PlaybackError,
146
+ raise PLAYBACK_ERROR,
145
147
  'Unexpected RestClient::Request#transmit returned without calling RestClient::Request#log_request'
146
148
  end
147
149
  end
@@ -177,6 +179,9 @@ module RightDevelop::Testing::Client::Rest::Request
177
179
  end
178
180
  if file_path
179
181
  response_hash = ::Mash.new(::YAML.load_file(file_path))
182
+ if response_hash[:peer_reset_connection]
183
+ raise PeerResetConnectionError, 'Connection reset by peer'
184
+ end
180
185
  @response_metadata = create_response_metadata(
181
186
  state,
182
187
  response_hash[:http_status],
@@ -184,7 +189,7 @@ module RightDevelop::Testing::Client::Rest::Request
184
189
  response_hash[:body])
185
190
  result = FakeNetHttpResponse.new(response_hash, response_metadata)
186
191
  else
187
- raise PlaybackError,
192
+ raise PLAYBACK_ERROR,
188
193
  "Unable to locate response file(s): \"#{tried_paths.join("\", \"")}\""
189
194
  end
190
195
  logger.debug("Played back response from #{file_path.inspect}.")
@@ -209,7 +214,7 @@ module RightDevelop::Testing::Client::Rest::Request
209
214
  # current epoch must be listed.
210
215
  current_epoch = state[:epoch]
211
216
  unless current_epoch == epochs.first
212
- raise PlaybackError,
217
+ raise PLAYBACK_ERROR,
213
218
  "Unable to locate current epoch directory: #{::File.join(fixtures_dir, current_epoch.to_s).inspect}"
214
219
  end
215
220
 
@@ -232,7 +237,7 @@ module RightDevelop::Testing::Client::Rest::Request
232
237
  h
233
238
  end
234
239
  if remaining.empty?
235
- raise PlaybackError,
240
+ raise PLAYBACK_ERROR,
236
241
  "Unable to determine remaining responses from #{search_path.inspect}"
237
242
  end
238
243
  logger.debug("Pending responses for epoch = #{current_epoch}: #{remaining.inspect}")
@@ -84,6 +84,7 @@ module RightDevelop::Testing::Recording
84
84
 
85
85
  # exceptions.
86
86
  class RecordingError < StandardError; end
87
+ class PlaybackError < StandardError; end
87
88
 
88
89
  attr_reader :uri, :verb, :http_status, :headers, :body
89
90
  attr_reader :mode, :logger, :effective_route_config, :variables
@@ -520,7 +521,7 @@ module RightDevelop::Testing::Recording
520
521
  when ::Array
521
522
  # array should have a single element which should be a hash with
522
523
  # futher variable declarations for
523
- # "one ore more objects of the same type in an array."
524
+ # "zero or more objects of the same type in an array."
524
525
  # the array is only an indicator that an array is expected here.
525
526
  variables_for_elements = variable.first
526
527
  if variable.size != 1 || !variables_for_elements.kind_of?(::Hash)
@@ -609,8 +610,17 @@ module RightDevelop::Testing::Recording
609
610
 
610
611
  # Inserts (or reuses) a real value into cached array by variable name.
611
612
  def variable_to_cache(variable, real_value)
613
+ # special case for variables surrounded by parentheses; treat as a ruby
614
+ # macro to be executed on playback.
612
615
  result = nil
613
- if values = @variables[variable]
616
+ if variable.start_with?('<%=')
617
+ unless variable.end_with?('%>')
618
+ message = 'Illegal macro-for-variable was missing end-of-macro: ' +
619
+ variable.inspect
620
+ raise RecordingError, message
621
+ end
622
+ result = variable # use macro as substituted value
623
+ elsif values = @variables[variable]
614
624
  # quick out for same as initial value; don't show array index.
615
625
  if values.first == real_value
616
626
  result = variable
@@ -632,25 +642,52 @@ module RightDevelop::Testing::Recording
632
642
 
633
643
  # Requires a real value to already exist in cache by variable name.
634
644
  def variable_in_cache(path, variable, real_value)
645
+ # special case for variables surrounded by parentheses; treat as a ruby
646
+ # macro to be executed on playback.
635
647
  result = nil
636
- values = @variables[variable]
637
- case value_index = values && values.index(real_value)
638
- when nil
639
- message = 'A variable referenced by a response has not yet been ' +
640
- "defined by a request while replacing variable = " +
641
- "#{variable.inspect} at #{path.join('/').inspect}"
642
- raise RecordingError, message
643
- when 0
644
- variable
648
+ if variable.start_with?('<%=')
649
+ unless variable.end_with?('%>')
650
+ message = 'Illegal macro-for-variable was missing end-of-macro: ' +
651
+ variable.inspect
652
+ raise RecordingError, message
653
+ end
654
+ result = variable # use macro as substituted value
645
655
  else
646
- "#{variable}[#{value_index}]"
656
+ values = @variables[variable]
657
+ case value_index = values && values.index(real_value)
658
+ when nil
659
+ message = 'A variable referenced by a response has not yet been ' +
660
+ 'defined by a request while replacing variable = ' +
661
+ "#{variable.inspect} at #{path.join('/').inspect}"
662
+ raise RecordingError, message
663
+ when 0
664
+ result = variable
665
+ else
666
+ result = "#{variable}[#{value_index}]"
667
+ end
647
668
  end
669
+ result
648
670
  end
649
671
 
650
672
  # Attempts to get cached variable value by index from recorded string.
651
673
  def variable_from_cache(path, variable, target_value)
674
+ # special case for variables surrounded by parentheses; treat as a ruby
675
+ # macro to be executed on playback.
652
676
  result = nil
653
- if variable_array = @variables[variable]
677
+ if variable.start_with?('<%=')
678
+ unless variable.end_with?('%>')
679
+ message = 'Illegal macro-for-variable was missing end-of-macro: ' +
680
+ variable.inspect
681
+ raise PlaybackError, message
682
+ end
683
+ begin
684
+ result = ::Object.class_eval(variable[3..-3].strip)
685
+ rescue ::Exception => e
686
+ message = "Failed to evaluate macro-for-variable:\n#{variable}\n" +
687
+ e.message
688
+ raise PlaybackError, message
689
+ end
690
+ elsif variable_array = @variables[variable]
654
691
  if matched = VARIABLE_INDEX_REGEX.match(target_value)
655
692
  variable_array_index = Integer(matched[1])
656
693
  else
@@ -126,8 +126,20 @@ module RightDevelop::Testing::Server::MightApi
126
126
  # have come from a proxied request/response whereas 500 is never an
127
127
  # expected response.
128
128
  internal_server_error(message)
129
- rescue ::RightDevelop::Testing::Client::Rest::Request::Playback::PlaybackError => e
130
- # response has not been recorded.
129
+ rescue ::RightDevelop::Testing::Client::Rest::Request::Playback::PeerResetConnectionError => e
130
+ # FIX: have only implemented socket close for webrick; not sure if this
131
+ # is needed for other rack implementations.
132
+ if socket = ::Thread.current[:WEBrickSocket]
133
+ # closing the socket causes 'peer reset connection' on client side and
134
+ # also prevents any response coming back on connection.
135
+ socket.close
136
+ end
137
+ message = e.message
138
+ trace = [e.class.name] + (e.backtrace || [])
139
+ logger.info(message)
140
+ internal_server_error(message)
141
+ rescue ::RightDevelop::Testing::Recording::Metadata::PlaybackError => e
142
+ # response has not been recorded, etc.
131
143
  message = e.message
132
144
  trace = [e.class.name] + (e.backtrace || [])
133
145
  logger.error(message)
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: right_develop 3.0.2 ruby lib
5
+ # stub: right_develop 3.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "right_develop"
9
- s.version = "3.0.2"
9
+ s.version = "3.0.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Tony Spataro"]
14
- s.date = "2014-08-20"
14
+ s.date = "2014-09-03"
15
15
  s.description = "A toolkit of development tools created by RightScale."
16
16
  s.email = "support@rightscale.com"
17
17
  s.executables = ["right_develop"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_develop
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Spataro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: right_support