/
test_plugin.rb
38 lines (28 loc) · 1.05 KB
/
test_plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require_relative "helper"
require_relative "helpers/integration"
class TestPlugin < TestIntegration
def test_plugin
skip "Skipped on Windows Ruby < 2.5.0, Ruby bug" if windows? && RUBY_VERSION < '2.5.0'
@tcp_ctrl = UniquePort.call
Dir.mkdir("tmp") unless Dir.exist?("tmp")
cli_server "--control-url tcp://#{HOST}:#{@tcp_ctrl} --control-token #{TOKEN} -C test/config/plugin1.rb test/rackup/hello.ru"
File.open('tmp/restart.txt', mode: 'wb') { |f| f.puts "Restart #{Time.now}" }
true while (l = @server.gets.tap {|x| puts x}) !~ /Restarting\.\.\./
assert_match(/Restarting\.\.\./, l)
true while (l = @server.gets.tap {|x| puts x}) !~ /Ctrl-C/
assert_match(/Ctrl-C/, l)
out = StringIO.new
cli_pumactl "-C tcp://#{HOST}:#{@tcp_ctrl} -T #{TOKEN} stop"
true while (l = @server.gets) !~ /Goodbye/
@server.close
@server = nil
out.close
end
private
def cli_pumactl(argv)
pumactl = IO.popen("#{BASE} bin/pumactl #{argv}", "r")
@ios_to_close << pumactl
Process.wait pumactl.pid
pumactl
end
end