anyt 1.2.2 → 1.2.4
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 +4 -4
- data/lib/anyt/cli.rb +27 -11
- data/lib/anyt/command.rb +54 -34
- data/lib/anyt/config.rb +2 -2
- data/lib/anyt/dummy/application.rb +11 -1
- data/lib/anyt/dummy/config.ru +1 -1
- data/lib/anyt/ext/minitest.rb +1 -0
- data/lib/anyt/rpc.rb +20 -22
- data/lib/anyt/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9db289698192e906312e6ff3708370e1016b15e2b0299ace6b514f6d5e31adbf
|
4
|
+
data.tar.gz: 54cad65181ffa23e5a108c416990610015ffbd1788c5d10a3dfaf1f326f91e09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fea80bb2f253a3787ccdd27e37f5ba0b8ca93fbcc48d375c3ec3698d9e48138da8b137a0ceb95a0cced5c9f880562cd98cdb5e2d40cebdf3fd22335432cff5f3
|
7
|
+
data.tar.gz: cfa930d46971b56a14d2f28821e642f02425c74a4e0ddc2dfabdb71ae3f29e1da6fd0148cd94c905c92d60fe06ed360cdc938b2ef93c8a30c7d1621d8e322f58
|
data/lib/anyt/cli.rb
CHANGED
@@ -13,6 +13,13 @@ $stdout.sync = true
|
|
13
13
|
|
14
14
|
module Anyt
|
15
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
|
+
|
16
23
|
class << self
|
17
24
|
# CLI entrypoint
|
18
25
|
def run(args = ARGV)
|
@@ -39,16 +46,30 @@ module Anyt
|
|
39
46
|
# Start RPC server (unless specified otherwise, e.g. when
|
40
47
|
# we want to test Action Cable itself)
|
41
48
|
unless @skip_rpc
|
42
|
-
|
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
|
43
59
|
|
44
60
|
if @only_rpc
|
45
|
-
|
61
|
+
if http_rpc
|
62
|
+
wait_till_terminated
|
63
|
+
else
|
64
|
+
@rpc_command.server.wait_till_terminated
|
65
|
+
end
|
46
66
|
return
|
47
67
|
end
|
48
68
|
end
|
49
69
|
|
50
70
|
# Start webosocket server under test
|
51
|
-
Command.
|
71
|
+
@command = Command.default
|
72
|
+
@command.run
|
52
73
|
|
53
74
|
unless @skip_tests
|
54
75
|
# Run tests
|
@@ -59,8 +80,8 @@ module Anyt
|
|
59
80
|
rescue Interrupt => e
|
60
81
|
$stdout.puts "#{e.message}. Good-bye!"
|
61
82
|
ensure
|
62
|
-
|
63
|
-
|
83
|
+
@rpc_command&.stop unless @skip_rpc
|
84
|
+
@command&.stop
|
64
85
|
end
|
65
86
|
|
66
87
|
result
|
@@ -97,7 +118,6 @@ module Anyt
|
|
97
118
|
|
98
119
|
cli.on("--only-rpc", TrueClass, "Run only RPC server") do |flag|
|
99
120
|
@only_rpc = flag
|
100
|
-
@skip_tests = true
|
101
121
|
end
|
102
122
|
|
103
123
|
cli.on("--only-rails", TrueClass, "Run only Rails server") do
|
@@ -162,11 +182,7 @@ module Anyt
|
|
162
182
|
end
|
163
183
|
|
164
184
|
def configure_rails_command!
|
165
|
-
|
166
|
-
"config.ru",
|
167
|
-
::File.join(::File.dirname(__FILE__), "dummy")
|
168
|
-
)
|
169
|
-
Anyt.config.command = "bundle exec puma #{dummy_path}"
|
185
|
+
Anyt.config.command = RAILS_COMMAND
|
170
186
|
Anyt.config.use_action_cable = true
|
171
187
|
end
|
172
188
|
|
data/lib/anyt/command.rb
CHANGED
@@ -4,60 +4,80 @@ require "childprocess"
|
|
4
4
|
|
5
5
|
module Anyt
|
6
6
|
# Runs system command (websocket server)
|
7
|
-
|
7
|
+
class Command
|
8
8
|
class << self
|
9
|
-
|
10
|
-
return if running?
|
9
|
+
attr_reader :instance
|
11
10
|
|
12
|
-
|
11
|
+
def default
|
12
|
+
@instance ||= new
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
def restart
|
16
|
+
instance&.restart
|
17
|
+
end
|
18
|
+
end
|
15
19
|
|
16
|
-
|
20
|
+
attr_reader :cmd
|
17
21
|
|
18
|
-
|
22
|
+
def initialize(cmd = Anyt.config.command)
|
23
|
+
@cmd = cmd
|
24
|
+
end
|
19
25
|
|
20
|
-
|
26
|
+
def run
|
27
|
+
return if running?
|
21
28
|
|
22
|
-
|
23
|
-
process.environment["ANYT_REMOTE_CONTROL_PORT"] = Anyt.config.remote_control_port
|
29
|
+
return unless cmd
|
24
30
|
|
25
|
-
|
31
|
+
AnyCable.logger.debug "Running command: #{cmd}"
|
26
32
|
|
27
|
-
|
33
|
+
@process = ChildProcess.build(*cmd.split(/\s+/))
|
28
34
|
|
29
|
-
|
30
|
-
raise "Command failed to start" unless running?
|
31
|
-
end
|
32
|
-
# rubocop: enable Metrics/MethodLength
|
33
|
-
# rubocop: enable Metrics/AbcSize
|
35
|
+
process.io.inherit! if AnyCable.config.debug
|
34
36
|
|
35
|
-
|
36
|
-
return unless running?
|
37
|
+
process.detach = true
|
37
38
|
|
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
|
39
42
|
|
40
|
-
|
41
|
-
process.wait
|
43
|
+
process.start
|
42
44
|
|
43
|
-
|
44
|
-
end
|
45
|
+
AnyCable.logger.debug "Command PID: #{process.pid}"
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
sleep Anyt.config.wait_command
|
48
|
+
raise "Command failed to start" unless running?
|
49
|
+
end
|
48
50
|
|
49
|
-
|
51
|
+
alias_method :start, :run
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
+
# rubocop: enable Metrics/MethodLength
|
54
|
+
# rubocop: enable Metrics/AbcSize
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
57
66
|
|
58
|
-
|
67
|
+
def stop
|
68
|
+
return unless running?
|
59
69
|
|
60
|
-
|
70
|
+
AnyCable.logger.debug "Terminate PID: #{process.pid}"
|
71
|
+
|
72
|
+
process.stop
|
73
|
+
end
|
74
|
+
|
75
|
+
def running?
|
76
|
+
process&.alive?
|
61
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
attr_reader :process
|
62
82
|
end
|
63
83
|
end
|
data/lib/anyt/config.rb
CHANGED
@@ -29,8 +29,8 @@ module Anyt
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def tests_filter
|
32
|
-
only_rxp = /(#{only_tests.join(
|
33
|
-
except_rxp = /(#{except_tests.join(
|
32
|
+
only_rxp = /(#{only_tests.join("|")})/ if only_tests
|
33
|
+
except_rxp = /(#{except_tests.join("|")})/ if except_tests
|
34
34
|
|
35
35
|
@tests_filter ||= lambda do |path|
|
36
36
|
(only_rxp.nil? || only_rxp.match?(path)) &&
|
@@ -20,6 +20,8 @@ class TestApp < Rails::Application
|
|
20
20
|
config.paths["config/routes.rb"] << File.join(__dir__, "routes.rb")
|
21
21
|
end
|
22
22
|
|
23
|
+
DISCONNECT_DELAY = ENV["ANYCABLE_DISCONNECT_DELAY"].to_f
|
24
|
+
|
23
25
|
module ApplicationCable
|
24
26
|
class Connection < ActionCable::Connection::Base
|
25
27
|
delegate :params, to: :request
|
@@ -32,6 +34,9 @@ module ApplicationCable
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def disconnect
|
37
|
+
if DISCONNECT_DELAY > 0
|
38
|
+
sleep DISCONNECT_DELAY
|
39
|
+
end
|
35
40
|
logger.debug "Disconnected"
|
36
41
|
end
|
37
42
|
end
|
@@ -63,6 +68,11 @@ class BenchmarkChannel < ApplicationCable::Channel
|
|
63
68
|
transmit data
|
64
69
|
end
|
65
70
|
|
71
|
+
def counter(data)
|
72
|
+
num = data.fetch("num", 100).to_i
|
73
|
+
num.times { ActionCable.server.broadcast "all", {text: "Count: #{_1}"} }
|
74
|
+
end
|
75
|
+
|
66
76
|
private
|
67
77
|
|
68
78
|
def stream_id
|
@@ -70,7 +80,7 @@ class BenchmarkChannel < ApplicationCable::Channel
|
|
70
80
|
end
|
71
81
|
end
|
72
82
|
|
73
|
-
ActionCable.server.config.cable = {"adapter" => "redis"}
|
83
|
+
ActionCable.server.config.cable = {"adapter" => ENV.fetch("ACTION_CABLE_ADAPTER", "redis")}
|
74
84
|
ActionCable.server.config.connection_class = -> { ApplicationCable::Connection }
|
75
85
|
ActionCable.server.config.disable_request_forgery_protection = true
|
76
86
|
ActionCable.server.config.logger =
|
data/lib/anyt/dummy/config.ru
CHANGED
data/lib/anyt/ext/minitest.rb
CHANGED
data/lib/anyt/rpc.rb
CHANGED
@@ -6,38 +6,36 @@ require "redis"
|
|
6
6
|
|
7
7
|
module Anyt # :nodoc:
|
8
8
|
# Runs AnyCable RPC server in the background
|
9
|
-
|
9
|
+
class RPC
|
10
10
|
using AsyncHelpers
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :server
|
12
|
+
attr_accessor :running
|
13
|
+
attr_reader :server
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
def start
|
16
|
+
AnyCable.logger.debug "Starting RPC server ..."
|
18
17
|
|
19
|
-
|
18
|
+
AnyCable.server_callbacks.each(&:call)
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
@server = AnyCable::GRPC::Server.new(
|
21
|
+
host: AnyCable.config.rpc_host,
|
22
|
+
**AnyCable.config.to_grpc_params
|
23
|
+
)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
if defined?(::AnyCable::Middlewares::EnvSid)
|
26
|
+
AnyCable.middleware.use(::AnyCable::Middlewares::EnvSid)
|
27
|
+
end
|
29
28
|
|
30
|
-
|
29
|
+
AnyCable.middleware.freeze
|
31
30
|
|
32
|
-
|
31
|
+
server.start
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
AnyCable.logger.debug "RPC server started"
|
34
|
+
end
|
35
|
+
# rubocop: enable Metrics/AbcSize,Metrics/MethodLength
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
37
|
+
def stop
|
38
|
+
server&.stop
|
41
39
|
end
|
42
40
|
|
43
41
|
AnyCable.connection_factory = ActionCable.server.config.connection_class.call
|
data/lib/anyt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -278,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
278
|
- !ruby/object:Gem::Version
|
279
279
|
version: '0'
|
280
280
|
requirements: []
|
281
|
-
rubygems_version: 3.4.
|
281
|
+
rubygems_version: 3.4.8
|
282
282
|
signing_key:
|
283
283
|
specification_version: 4
|
284
284
|
summary: Anycable conformance testing tool
|