bugsnag-maze-runner 8.13.2 → 8.14.0

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
  SHA256:
3
- metadata.gz: b19202c96a1340f0752e1ad4f565b45d84d07ce75ee71961bd55387c63135d7e
4
- data.tar.gz: 40afc99e0843a9bed7978e5fd0f41d748e11ebfdde5f341fbd23cef8bf1b95db
3
+ metadata.gz: dd153df2adf96e3f771d981af1bc7daa36e48c08caed9493d52f5ed8a49e2f7b
4
+ data.tar.gz: ba2b8ffa6ab47ee37eaba88cdce0e86a8e0e28c6f79941651062c9260812bd5c
5
5
  SHA512:
6
- metadata.gz: ed33f57a999f5f98ee62b90fbd2817f6b6a80c0fc025ff451bd1bbf1ebf4204289ccd0c1c11816afcd1cf2b2147dcf0e28fb9c137c2a7fea2bb698ef7d155ab8
7
- data.tar.gz: d824d91a62bd68851b60b167a625f399141c5c3f4e41e557810fb6e346987d63b7fc1cd28bed8dc94eda4556a45d944c7a36da9f0ba0daaaf8711156d32f5495
6
+ metadata.gz: fddd6897ee26a623f296e4c5504869926cddb9d6e557ae054286d6551f7840755b81599816a4c2c5f670cb124815361514f41f27f0f029fb1c4d1892cd7f44b8
7
+ data.tar.gz: 9323a020df074f37c128b03f932200dcbf1c81fc54eb32df7e3ea675c7b61c3e1a94203a89a26c7c425f62debd1936510fea19d94d51cd7d0af24acdba23585b
data/bin/maze-runner CHANGED
@@ -54,6 +54,7 @@ require_relative '../lib/maze/runner'
54
54
  require_relative '../lib/maze/terminating_server'
55
55
 
56
56
  require_relative '../lib/maze/servlets/base_servlet'
57
+ require_relative '../lib/maze/servlets/all_commands_servlet'
57
58
  require_relative '../lib/maze/servlets/command_servlet'
58
59
  require_relative '../lib/maze/servlets/servlet'
59
60
  require_relative '../lib/maze/servlets/log_servlet'
data/lib/maze/helper.rb CHANGED
@@ -109,6 +109,7 @@ module Maze
109
109
  # Logs the given message and exits the program with a failure status
110
110
  def error_exit(message)
111
111
  $logger.error message
112
+ Bugsnag.notify(message)
112
113
  exit false
113
114
  end
114
115
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'securerandom'
2
3
 
3
4
  module Maze
4
5
  # An abstraction for storing a list of requests (e.g. Errors, Sessions),
@@ -24,7 +25,11 @@ module Maze
24
25
  #
25
26
  # @param request The new request, from which a clone is made
26
27
  def add(request)
27
- @requests.append request.clone
28
+ clone = request.clone
29
+ # UUID primarily used for commands, but no harm to set on everything
30
+ clone[:uuid] = SecureRandom.uuid
31
+ clone[:run_uuid] = Maze.run_uuid
32
+ @requests.append clone
28
33
  @count += 1
29
34
  end
30
35
 
@@ -33,6 +38,11 @@ module Maze
33
38
  @requests[@current] if @requests.size > @current
34
39
  end
35
40
 
41
+ # The request at the given index
42
+ def get(index)
43
+ @requests[index] if @requests.size > index
44
+ end
45
+
36
46
  # Peek at requests yet to be processed - i.e. from current onwards. All requests are left visible in the list.
37
47
  # Returns an empty array if there are no requests outstanding.
38
48
  def remaining
data/lib/maze/server.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'bugsnag'
4
4
  require 'json'
5
- require 'securerandom'
6
5
  require 'webrick'
7
6
  require_relative './logger'
8
7
  require_relative './request_list'
@@ -223,6 +222,7 @@ module Maze
223
222
  server.mount '/ndk-symbol', Servlets::Servlet, :sourcemaps
224
223
  server.mount '/proguard', Servlets::Servlet, :sourcemaps
225
224
  server.mount '/command', Servlets::CommandServlet
225
+ server.mount '/commands', Servlets::AllCommandsServlet
226
226
  server.mount '/logs', Servlets::LogServlet
227
227
  server.mount '/metrics', Servlets::Servlet, :metrics
228
228
  server.mount '/reflect', Servlets::ReflectiveServlet
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Maze
6
+ module Servlets
7
+
8
+ # Allows clients to queue up "commands", in the form of Ruby hashes, using Maze::Server.commands.add. GET
9
+ # requests made to the /command endpoint will then respond with each queued command in turn.
10
+ class AllCommandsServlet < BaseServlet
11
+ # Serves all commands held.
12
+ #
13
+ # @param request [HTTPRequest] The incoming GET request
14
+ # @param response [HTTPResponse] The response to return
15
+ def do_GET(request, response)
16
+ commands = Maze::Server.commands.all
17
+
18
+ command_json = JSON.pretty_generate(commands)
19
+ response.body = command_json
20
+ response.status = 200
21
+
22
+ response.header['Access-Control-Allow-Origin'] = '*'
23
+ end
24
+
25
+ # Logs and returns a set of valid headers for this servlet.
26
+ #
27
+ # @param request [HTTPRequest] The incoming GET request
28
+ # @param response [HTTPResponse] The response to return
29
+ def do_OPTIONS(request, response)
30
+ super
31
+
32
+ response.header['Access-Control-Allow-Methods'] = 'POST, OPTIONS'
33
+ response.status = Server.status_code('OPTIONS')
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+
@@ -8,25 +8,69 @@ module Maze
8
8
  # Allows clients to queue up "commands", in the form of Ruby hashes, using Maze::Server.commands.add. GET
9
9
  # requests made to the /command endpoint will then respond with each queued command in turn.
10
10
  class CommandServlet < BaseServlet
11
+
12
+ NOOP_COMMAND = '{"action": "noop", "message": "No commands queued"}'
13
+
11
14
  # Serves the next command, if these is one.
12
15
  #
13
- # @param _request [HTTPRequest] The incoming GET request
16
+ # @param request [HTTPRequest] The incoming GET request
14
17
  # @param response [HTTPResponse] The response to return
15
- def do_GET(_request, response)
18
+ def do_GET(request, response)
19
+
20
+ if request.query.empty?
21
+ # Non-idempotent mode - return the "current" command
22
+ commands = Maze::Server.commands
23
+
24
+ if commands.size_remaining == 0
25
+ response.body = NOOP_COMMAND
26
+ response.status = 200
27
+ else
28
+ command = commands.current
29
+ response.body = JSON.pretty_generate(command)
30
+ response.status = 200
31
+ commands.next
32
+ end
33
+ else
34
+ $logger.info "request.query = #{request.query}"
35
+
36
+
37
+ # Idempotent mode
38
+ after_uuid = request.query['after']
39
+ if after_uuid.nil?
40
+ response.body = "'after' is the only recognised query parameter"
41
+ response.status = 400
42
+ else
43
+ command_after(after_uuid, response)
44
+ end
45
+ end
46
+
16
47
  response.header['Access-Control-Allow-Origin'] = '*'
48
+ end
17
49
 
50
+ def command_after(uuid, response)
18
51
  commands = Maze::Server.commands
19
-
20
- if commands.size_remaining == 0
21
- response.body = '{"action": "noop", "message": "No commands queued"}'
22
- response.status = 200
52
+ if uuid.empty?
53
+ index = -1
54
+ else
55
+ index = commands.all.find_index {|command| command[:uuid] == uuid }
56
+ end
57
+ if index.nil?
58
+ msg = "Request invalid - there is no command with a UUID of #{uuid} to follow on from"
59
+ $logger.error msg
60
+ response.body = msg
61
+ response.status = 400
23
62
  else
24
- command = commands.current
25
- command_json = JSON.pretty_generate(command)
26
- command[:uuid] = Maze.run_uuid
27
- response.body = command_json
28
- response.status = 200
29
- commands.next
63
+ if index + 1 < commands.size_all
64
+ # Respond with the next command in the queue
65
+ command = commands.get(index + 1)
66
+ command_json = JSON.pretty_generate(command)
67
+ response.body = command_json
68
+ response.status = 200
69
+ else
70
+ # The UUID given was for the last command in the list
71
+ response.body = NOOP_COMMAND
72
+ response.status = 200
73
+ end
30
74
  end
31
75
  end
32
76
 
data/lib/maze.rb CHANGED
@@ -7,7 +7,7 @@ require_relative 'maze/timers'
7
7
  # Glues the various parts of MazeRunner together that need to be accessed globally,
8
8
  # providing an alternative to the proliferation of global variables or singletons.
9
9
  module Maze
10
- VERSION = '8.13.2'
10
+ VERSION = '8.14.0'
11
11
 
12
12
  class << self
13
13
  attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag-maze-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.13.2
4
+ version: 8.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Kirkland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -436,6 +436,7 @@ files:
436
436
  - lib/maze/schemas/trace_validator.rb
437
437
  - lib/maze/schemas/validator.rb
438
438
  - lib/maze/server.rb
439
+ - lib/maze/servlets/all_commands_servlet.rb
439
440
  - lib/maze/servlets/base_servlet.rb
440
441
  - lib/maze/servlets/command_servlet.rb
441
442
  - lib/maze/servlets/log_servlet.rb