anyt 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. metadata +13 -119
  4. data/bin/console +0 -7
  5. data/bin/setup +0 -8
  6. data/lib/anyt/cli.rb +0 -211
  7. data/lib/anyt/client.rb +0 -112
  8. data/lib/anyt/command.rb +0 -83
  9. data/lib/anyt/config.rb +0 -41
  10. data/lib/anyt/dummy/application.rb +0 -87
  11. data/lib/anyt/dummy/config.ru +0 -16
  12. data/lib/anyt/dummy/routes.rb +0 -4
  13. data/lib/anyt/dummy/tmp/development_secret.txt +0 -1
  14. data/lib/anyt/ext/minitest.rb +0 -151
  15. data/lib/anyt/remote_control.rb +0 -33
  16. data/lib/anyt/rpc.rb +0 -44
  17. data/lib/anyt/tests/core/ping_test.rb +0 -23
  18. data/lib/anyt/tests/core/welcome_test.rb +0 -10
  19. data/lib/anyt/tests/features/channel_state_test.rb +0 -81
  20. data/lib/anyt/tests/features/remote_disconnect_test.rb +0 -35
  21. data/lib/anyt/tests/features/server_restart_test.rb +0 -30
  22. data/lib/anyt/tests/request/channel_test.rb +0 -28
  23. data/lib/anyt/tests/request/connection_test.rb +0 -54
  24. data/lib/anyt/tests/request/disconnect_reasons_test.rb +0 -25
  25. data/lib/anyt/tests/request/disconnection_test.rb +0 -148
  26. data/lib/anyt/tests/streams/broadcast_test.rb +0 -65
  27. data/lib/anyt/tests/streams/multiple_clients_test.rb +0 -61
  28. data/lib/anyt/tests/streams/multiple_test.rb +0 -60
  29. data/lib/anyt/tests/streams/single_test.rb +0 -83
  30. data/lib/anyt/tests/streams/stop_test.rb +0 -57
  31. data/lib/anyt/tests/subscriptions/ack_test.rb +0 -39
  32. data/lib/anyt/tests/subscriptions/params_test.rb +0 -29
  33. data/lib/anyt/tests/subscriptions/perform_test.rb +0 -60
  34. data/lib/anyt/tests/subscriptions/transmissions_test.rb +0 -32
  35. data/lib/anyt/tests.rb +0 -62
  36. data/lib/anyt/utils/async_helpers.rb +0 -16
  37. data/lib/anyt/utils.rb +0 -3
  38. data/lib/anyt/version.rb +0 -5
  39. data/lib/anyt.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9db289698192e906312e6ff3708370e1016b15e2b0299ace6b514f6d5e31adbf
4
- data.tar.gz: 54cad65181ffa23e5a108c416990610015ffbd1788c5d10a3dfaf1f326f91e09
3
+ metadata.gz: 6565c7892e2d696ae9f572a557be099c8cf3fff66182d65cd5d784916f97e4bd
4
+ data.tar.gz: 98975a1b4659126da5ba39380cb6ec218dc9c6c38a7970d90d9a6865cab768c5
5
5
  SHA512:
6
- metadata.gz: fea80bb2f253a3787ccdd27e37f5ba0b8ca93fbcc48d375c3ec3698d9e48138da8b137a0ceb95a0cced5c9f880562cd98cdb5e2d40cebdf3fd22335432cff5f3
7
- data.tar.gz: cfa930d46971b56a14d2f28821e642f02425c74a4e0ddc2dfabdb71ae3f29e1da6fd0148cd94c905c92d60fe06ed360cdc938b2ef93c8a30c7d1621d8e322f58
6
+ metadata.gz: ea3d7302dd78f6aeee2de72760cfcb48b53c298109830aac85dace3e5ddc35c191457d7ea846f1f99cc97f4fbf25bc6b6bb7b0284d50d0ff2c5f49f32ce6c734
7
+ data.tar.gz: 9fdf6962eaa713eb3581359e78f7d2090af6b73dd2997ef7906ba98d0483b17c47dfd55f7866709e56b69ae02eb118d7b494dbc3481c5fce8bf6a230822a2772
data/README.md CHANGED
@@ -2,9 +2,10 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/anyt.svg)](https://rubygems.org/gems/anyt)
3
3
  ![Test](https://github.com/anycable/anyt/workflows/Test/badge.svg)
4
4
 
5
- # AnyCable Conformance Testing Tool
5
+ # Action Cable / AnyCable conformance testing tool
6
+
7
+ AnyT is a command-line tool to test your Action Cable or [AnyCable](http://anycable.io)-compatible WebSocket servers.
6
8
 
7
- AnyT is a command-line tool to test your [AnyCable](http://anycable.io)-compatible WebSocket servers.
8
9
  It contains a set of tests to determine which features are supported by the implementation under consideration.
9
10
 
10
11
  ## Installation
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anyt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-12 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rack
14
+ name: anyt-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,34 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.1.0
55
- - !ruby/object:Gem::Dependency
56
- name: rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '6.0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '6.0'
69
- - !ruby/object:Gem::Dependency
70
- name: anyway_config
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 2.2.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 2.2.0
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: anycable-rails
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,48 +86,6 @@ dependencies:
114
86
  - - "~>"
115
87
  - !ruby/object:Gem::Version
116
88
  version: '4.0'
117
- - !ruby/object:Gem::Dependency
118
- name: websocket
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 1.2.4
124
- type: :runtime
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: 1.2.4
131
- - !ruby/object:Gem::Dependency
132
- name: websocket-client-simple
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: 0.3.0
138
- type: :runtime
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: 0.3.0
145
- - !ruby/object:Gem::Dependency
146
- name: concurrent-ruby
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '1.0'
152
- type: :runtime
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '1.0'
159
89
  - !ruby/object:Gem::Dependency
160
90
  name: childprocess
161
91
  requirement: !ruby/object:Gem::Requirement
@@ -204,15 +134,15 @@ dependencies:
204
134
  requirements:
205
135
  - - "~>"
206
136
  - !ruby/object:Gem::Version
207
- version: '3.6'
137
+ version: '6.0'
208
138
  type: :development
209
139
  prerelease: false
210
140
  version_requirements: !ruby/object:Gem::Requirement
211
141
  requirements:
212
142
  - - "~>"
213
143
  - !ruby/object:Gem::Version
214
- version: '3.6'
215
- description: Anycable conformance testing tool
144
+ version: '6.0'
145
+ description: Action Cable / AnyCable conformance testing tool
216
146
  email:
217
147
  - dementiev.vm@gmail.com
218
148
  executables:
@@ -223,42 +153,6 @@ files:
223
153
  - MIT-LICENSE
224
154
  - README.md
225
155
  - bin/anyt
226
- - bin/console
227
- - bin/setup
228
- - lib/anyt.rb
229
- - lib/anyt/cli.rb
230
- - lib/anyt/client.rb
231
- - lib/anyt/command.rb
232
- - lib/anyt/config.rb
233
- - lib/anyt/dummy/application.rb
234
- - lib/anyt/dummy/config.ru
235
- - lib/anyt/dummy/routes.rb
236
- - lib/anyt/dummy/tmp/development_secret.txt
237
- - lib/anyt/ext/minitest.rb
238
- - lib/anyt/remote_control.rb
239
- - lib/anyt/rpc.rb
240
- - lib/anyt/tests.rb
241
- - lib/anyt/tests/core/ping_test.rb
242
- - lib/anyt/tests/core/welcome_test.rb
243
- - lib/anyt/tests/features/channel_state_test.rb
244
- - lib/anyt/tests/features/remote_disconnect_test.rb
245
- - lib/anyt/tests/features/server_restart_test.rb
246
- - lib/anyt/tests/request/channel_test.rb
247
- - lib/anyt/tests/request/connection_test.rb
248
- - lib/anyt/tests/request/disconnect_reasons_test.rb
249
- - lib/anyt/tests/request/disconnection_test.rb
250
- - lib/anyt/tests/streams/broadcast_test.rb
251
- - lib/anyt/tests/streams/multiple_clients_test.rb
252
- - lib/anyt/tests/streams/multiple_test.rb
253
- - lib/anyt/tests/streams/single_test.rb
254
- - lib/anyt/tests/streams/stop_test.rb
255
- - lib/anyt/tests/subscriptions/ack_test.rb
256
- - lib/anyt/tests/subscriptions/params_test.rb
257
- - lib/anyt/tests/subscriptions/perform_test.rb
258
- - lib/anyt/tests/subscriptions/transmissions_test.rb
259
- - lib/anyt/utils.rb
260
- - lib/anyt/utils/async_helpers.rb
261
- - lib/anyt/version.rb
262
156
  homepage: http://github.com/anycable/anyt
263
157
  licenses:
264
158
  - MIT
@@ -271,15 +165,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
165
  requirements:
272
166
  - - ">="
273
167
  - !ruby/object:Gem::Version
274
- version: 2.6.0
168
+ version: '0'
275
169
  required_rubygems_version: !ruby/object:Gem::Requirement
276
170
  requirements:
277
171
  - - ">="
278
172
  - !ruby/object:Gem::Version
279
173
  version: '0'
280
174
  requirements: []
281
- rubygems_version: 3.4.8
175
+ rubygems_version: 3.4.20
282
176
  signing_key:
283
177
  specification_version: 4
284
- summary: Anycable conformance testing tool
178
+ summary: Action Cable / AnyCable conformance testing tool
285
179
  test_files: []
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'anyt'
5
- require 'irb'
6
-
7
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/lib/anyt/cli.rb DELETED
@@ -1,211 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "logger"
4
- require "optparse"
5
-
6
- require "anyt/version"
7
- require "anyt/remote_control"
8
- require "anyt/rpc"
9
- require "anyt/command"
10
- require "anyt/tests"
11
-
12
- $stdout.sync = true
13
-
14
- module Anyt
15
- module Cli # :nodoc:
16
- DUMMY_ROOT = ::File.expand_path(
17
- "config.ru",
18
- ::File.join(::File.dirname(__FILE__), "dummy")
19
- )
20
-
21
- RAILS_COMMAND = "bundle exec puma #{DUMMY_ROOT} -t #{ENV.fetch("RAILS_MAX_THREADS", 5)}"
22
-
23
- class << self
24
- # CLI entrypoint
25
- def run(args = ARGV)
26
- parse_options!(args)
27
-
28
- ActionCable.server.config.logger = Rails.logger = AnyCable.logger
29
-
30
- result = 1
31
-
32
- $stdout.puts "Starting AnyT v#{Anyt::VERSION} (pid: #{Process.pid})\n"
33
-
34
- begin
35
- # "Enable" AnyCable as early as possible to activate all the features in tests
36
- unless Anyt.config.use_action_cable
37
- ActionCable.server.config.cable = {"adapter" => "any_cable"}
38
- require "anycable-rails"
39
- end
40
-
41
- # Load all test scenarios
42
- Tests.load_tests unless @skip_tests
43
-
44
- Rails.application.initialize!
45
-
46
- # Start RPC server (unless specified otherwise, e.g. when
47
- # we want to test Action Cable itself)
48
- unless @skip_rpc
49
- http_rpc = AnyCable.config.http_rpc_mount_path.present?
50
-
51
- @rpc_command =
52
- if http_rpc
53
- Command.new(RAILS_COMMAND)
54
- else
55
- RPC.new
56
- end
57
-
58
- @rpc_command.start
59
-
60
- if @only_rpc
61
- if http_rpc
62
- wait_till_terminated
63
- else
64
- @rpc_command.server.wait_till_terminated
65
- end
66
- return
67
- end
68
- end
69
-
70
- # Start webosocket server under test
71
- @command = Command.default
72
- @command.run
73
-
74
- unless @skip_tests
75
- # Run tests
76
- result = Tests.run ? 0 : 1
77
- end
78
-
79
- wait_till_terminated if @only_rails
80
- rescue Interrupt => e
81
- $stdout.puts "#{e.message}. Good-bye!"
82
- ensure
83
- @rpc_command&.stop unless @skip_rpc
84
- @command&.stop
85
- end
86
-
87
- result
88
- end
89
-
90
- private
91
-
92
- def parse_options!(args)
93
- parser =
94
- OptionParser.new do |cli|
95
- cli.banner = <<~BANNER
96
- Anyt – AnyCable websocket server conformance tool.
97
-
98
- Usage: anyt [options]
99
-
100
- Options:
101
- BANNER
102
-
103
- cli.on("-cCOMMAND", "--command=COMMAND", "Command to run WS server.") do |command|
104
- Anyt.config.command = command
105
- end
106
-
107
- cli.on("--target-url=TARGET", "URL of target WebSocket server to test.") do |target|
108
- Anyt.config.target_url = target
109
- end
110
-
111
- cli.on("--redis-url=REDIS_URL", "Redis server URL.") do |redis|
112
- AnyCable.config.redis_url = redis
113
- end
114
-
115
- cli.on("--skip-rpc", TrueClass, "Do not run RPC server") do |flag|
116
- @skip_rpc = flag
117
- end
118
-
119
- cli.on("--only-rpc", TrueClass, "Run only RPC server") do |flag|
120
- @only_rpc = flag
121
- end
122
-
123
- cli.on("--only-rails", TrueClass, "Run only Rails server") do
124
- @skip_rpc = true
125
- @only_rails = true
126
- @skip_tests = true
127
-
128
- configure_rails_command!
129
- end
130
-
131
- cli.on("--self-check", "Run tests again Action Cable itself") do
132
- @skip_rpc = true
133
-
134
- configure_rails_command!
135
- end
136
-
137
- cli.on("--only test1,test2,test3", Array, "Run only specified tests") do |only_tests|
138
- Anyt.config.only_tests = only_tests
139
- end
140
-
141
- cli.on("--except test1,test2,test3", Array, "Exclude specified tests") do |except_tests|
142
- Anyt.config.except_tests = except_tests
143
- end
144
-
145
- cli.on("--wait-command=TIMEOUT", Integer,
146
- "Number of seconds to wait for WS server initialization") do |timeout|
147
- Anyt.config.wait_command = timeout
148
- end
149
-
150
- cli.on("--timeout-multiplier=VALUE", Float,
151
- "Default exceptation timeouts multiplier") do |val|
152
- Anyt.config.timeout_multiplier = val
153
- end
154
-
155
- cli.on("-rPATH", "--require=PATH",
156
- "Path to additional tests (e.g. features/*.rb") do |path|
157
- Anyt.config.tests_relative_path = path
158
- ENV["ANYT_TESTS_RELATIVE_PATH"] = path
159
- end
160
-
161
- cli.on("--debug", "Enable debug mode.") do
162
- AnyCable.config.debug = true
163
- end
164
-
165
- cli.on("-h", "--help", "Show this message.") do
166
- puts cli
167
- exit
168
- end
169
-
170
- cli.on("--version", "Print version.") do
171
- puts Anyt::VERSION
172
- exit
173
- end
174
- end
175
-
176
- parser.parse!(args)
177
- rescue OptionParser::InvalidOption => e
178
- unknown_option = e.args.first
179
- puts "This option looks unfamiliar: #{unknown_option}. A typo?"
180
- puts "Use `anyt --help` to list all available options."
181
- exit 1
182
- end
183
-
184
- def configure_rails_command!
185
- Anyt.config.command = RAILS_COMMAND
186
- Anyt.config.use_action_cable = true
187
- end
188
-
189
- def wait_till_terminated
190
- self_read = setup_signals
191
-
192
- while readable_io = IO.select([self_read]) # rubocop:disable Lint/AssignmentInCondition, Lint/IncompatibleIoSelectWithFiberScheduler
193
- signal = readable_io.first[0].gets.strip
194
- raise Interrupt, "SIG#{signal} received"
195
- end
196
- end
197
-
198
- def setup_signals
199
- self_read, self_write = IO.pipe
200
-
201
- %w[INT TERM].each do |signal|
202
- trap signal do
203
- self_write.puts signal
204
- end
205
- end
206
-
207
- self_read
208
- end
209
- end
210
- end
211
- end
data/lib/anyt/client.rb DELETED
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Anyt
4
- # Synchronous websocket client
5
- # Based on https://github.com/rails/rails/blob/v5.0.1/actioncable/test/client_test.rb
6
- class Client
7
- require "websocket-client-simple"
8
- require "concurrent"
9
-
10
- class TimeoutError < StandardError; end
11
-
12
- WAIT_WHEN_EXPECTING_EVENT = 5
13
- WAIT_WHEN_NOT_EXPECTING_EVENT = 0.5
14
-
15
- def initialize(
16
- ignore: [], url: Anyt.config.target_url, qs: "",
17
- cookies: "", headers: {},
18
- protocol: "actioncable-v1-json",
19
- timeout_multiplier: Anyt.config.timeout_multiplier
20
- )
21
- ignore_message_types = @ignore_message_types = ignore
22
- messages = @messages = Queue.new
23
- closed = @closed = Concurrent::Event.new
24
- has_messages = @has_messages = Concurrent::Semaphore.new(0)
25
-
26
- @timeout_multiplier = timeout_multiplier
27
-
28
- headers = headers.merge("cookie" => cookies)
29
- headers["Sec-WebSocket-Protocol"] = protocol
30
-
31
- open = Concurrent::Promise.new
32
-
33
- @ws = WebSocket::Client::Simple.connect(
34
- url + "?#{qs}",
35
- headers: headers
36
- ) do |ws|
37
- ws.on(:error) do |event|
38
- event = RuntimeError.new(event.message) unless event.is_a?(Exception)
39
-
40
- if open.pending?
41
- open.fail(event)
42
- else
43
- messages << event
44
- has_messages.release
45
- end
46
- end
47
-
48
- ws.on(:open) do |_event|
49
- open.set(true)
50
- end
51
-
52
- ws.on(:message) do |event|
53
- next if event.type == :ping
54
- if event.type == :close
55
- closed.set
56
- else
57
- message = JSON.parse(event.data)
58
-
59
- next if ignore_message_types.include?(message["type"])
60
-
61
- AnyCable.logger.debug "Message received: #{message}"
62
-
63
- messages << message
64
- has_messages.release
65
- end
66
- end
67
-
68
- ws.on(:close) do |_event|
69
- closed.set
70
- end
71
- end
72
-
73
- open.wait!(WAIT_WHEN_EXPECTING_EVENT * @timeout_multiplier)
74
- end
75
- # rubocop: enable Metrics/BlockLength
76
- # rubocop: enable Metrics/AbcSize
77
- # rubocop: enable Metrics/MethodLength
78
-
79
- def receive(timeout: WAIT_WHEN_EXPECTING_EVENT)
80
- timeout *= @timeout_multiplier
81
-
82
- raise TimeoutError, "Timed out to receive message" unless
83
- @has_messages.try_acquire(1, timeout)
84
-
85
- msg = @messages.pop(true)
86
- raise msg if msg.is_a?(Exception)
87
-
88
- msg
89
- end
90
-
91
- def send(message)
92
- @ws.send(JSON.generate(message))
93
- end
94
-
95
- def close(allow_messages: false)
96
- sleep WAIT_WHEN_NOT_EXPECTING_EVENT * @timeout_multiplier
97
-
98
- raise "#{@messages.size} messages unprocessed" unless allow_messages || @messages.empty?
99
-
100
- @ws.close
101
- wait_for_close
102
- end
103
-
104
- def wait_for_close
105
- @closed.wait(WAIT_WHEN_EXPECTING_EVENT * @timeout_multiplier)
106
- end
107
-
108
- def closed?
109
- @closed.set?
110
- end
111
- end
112
- end
data/lib/anyt/command.rb DELETED
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "childprocess"
4
-
5
- module Anyt
6
- # Runs system command (websocket server)
7
- class Command
8
- class << self
9
- attr_reader :instance
10
-
11
- def default
12
- @instance ||= new
13
- end
14
-
15
- def restart
16
- instance&.restart
17
- end
18
- end
19
-
20
- attr_reader :cmd
21
-
22
- def initialize(cmd = Anyt.config.command)
23
- @cmd = cmd
24
- end
25
-
26
- def run
27
- return if running?
28
-
29
- return unless cmd
30
-
31
- AnyCable.logger.debug "Running command: #{cmd}"
32
-
33
- @process = ChildProcess.build(*cmd.split(/\s+/))
34
-
35
- process.io.inherit! if AnyCable.config.debug
36
-
37
- process.detach = true
38
-
39
- process.environment["ANYCABLE_DEBUG"] = "1" if AnyCable.config.debug?
40
- process.environment["ANYT_REMOTE_CONTROL_PORT"] = Anyt.config.remote_control_port
41
- process.environment["ACTION_CABLE_ADAPTER"] = "any_cable" unless Anyt.config.use_action_cable
42
-
43
- process.start
44
-
45
- AnyCable.logger.debug "Command PID: #{process.pid}"
46
-
47
- sleep Anyt.config.wait_command
48
- raise "Command failed to start" unless running?
49
- end
50
-
51
- alias_method :start, :run
52
-
53
- # rubocop: enable Metrics/MethodLength
54
- # rubocop: enable Metrics/AbcSize
55
-
56
- def restart
57
- return unless running?
58
-
59
- AnyCable.logger.debug "Restarting command PID: #{process.pid}"
60
-
61
- stop
62
- process.wait
63
-
64
- run
65
- end
66
-
67
- def stop
68
- return unless running?
69
-
70
- AnyCable.logger.debug "Terminate PID: #{process.pid}"
71
-
72
- process.stop
73
- end
74
-
75
- def running?
76
- process&.alive?
77
- end
78
-
79
- private
80
-
81
- attr_reader :process
82
- end
83
- end
data/lib/anyt/config.rb DELETED
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anyway"
4
-
5
- module Anyt
6
- # Anyt configuration
7
- class Config < Anyway::Config
8
- attr_config :command,
9
- :only_tests,
10
- :except_tests,
11
- :tests_relative_path,
12
- remote_control_port: 8919,
13
- use_action_cable: false,
14
- target_url: "ws://localhost:9292/cable",
15
- wait_command: 2,
16
- timeout_multiplier: 1
17
-
18
- coerce_types only_tests: {type: :string, array: true}
19
- coerce_types except_tests: {type: :string, array: true}
20
-
21
- def tests_path
22
- return unless tests_relative_path
23
-
24
- File.expand_path(tests_relative_path, Dir.pwd)
25
- end
26
-
27
- def filter_tests?
28
- only_tests || except_tests
29
- end
30
-
31
- def tests_filter
32
- only_rxp = /(#{only_tests.join("|")})/ if only_tests
33
- except_rxp = /(#{except_tests.join("|")})/ if except_tests
34
-
35
- @tests_filter ||= lambda do |path|
36
- (only_rxp.nil? || only_rxp.match?(path)) &&
37
- (except_rxp.nil? || !except_rxp.match?(path))
38
- end
39
- end
40
- end
41
- end