raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / Atom feed
38bdd11c46f57bedf822db9a238adca22d70aaec blob 1990 bytes (raw)

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
# -*- encoding: binary -*-
require "./test/rack_unicorn"
require "tempfile"
require "net/http"

$stderr.sync = $stdout.sync = true
pmq = begin
  Raindrops::Aggregate::PMQ
rescue => LoadError
  warn "W: #{e} skipping test"
  false
end
if RUBY_VERSION.to_f < 1.9
  pmq = false
  warn "W: skipping test=#{__FILE__}, only Ruby 1.9 supported for now"
end

class TestLastDataRecvUnicorn < Test::Unit::TestCase
  def setup
    @queue = "/test.#{rand}"
    @host = ENV["UNICORN_TEST_ADDR"] || "127.0.0.1"
    @sock = TCPServer.new @host, 0
    @port = @sock.addr[1]
    ENV["UNICORN_FD"] = @sock.fileno.to_s
    @host_with_port = "#@host:#@port"
    @cfg = Tempfile.new 'unicorn_config_file'
    @cfg.puts "require 'raindrops'"
    @cfg.puts "preload_app true"
      ENV['RAINDROPS_MQUEUE'] = @queue
    # @cfg.puts "worker_processes 4"
    @opts = { :listeners => [ @host_with_port ], :config_file => @cfg.path }
  end

  def test_auto_listener
    @srv = fork {
      Thread.abort_on_exception = true
      app = %q!Rack::Builder.new do
        map("/ldr") { run Raindrops::LastDataRecv.new }
        map("/") { run Rack::Lobster.new }
      end.to_app!
      def app.arity; 0; end
      def app.call; eval self; end
      Unicorn.run(app, @opts)
    }
    400.times { assert_kind_of Net::HTTPSuccess, get("/") }
    resp = get("/ldr")
    # # p(resp.methods - Object.methods)
    # resp.each_header { |k,v| p [k, "=" , v] }
    assert resp.header["x-count"]
    assert resp.header["x-min"]
    assert resp.header["x-max"]
    assert resp.header["x-mean"]
    assert resp.header["x-std-dev"]
    assert resp.header["x-outliers-low"]
    assert resp.header["x-outliers-high"]
    assert resp.body.size > 0
  end

  def get(path)
    Net::HTTP.start(@host, @port) { |http| http.get path }
  end

  def teardown
    Process.kill :QUIT, @srv
    _, status = Process.waitpid2 @srv
    assert status.success?
    POSIX_MQ.unlink @queue
  end
end if defined?(Unicorn) && RUBY_PLATFORM =~ /linux/ && pmq
debug log:

solving 38bdd11 ...
found 38bdd11 in https://yhbt.net/raindrops.git

raindrops RubyGem user+dev discussion/patches/pulls/bugs/help

Archives are clonable:
	git clone --mirror https://yhbt.net/raindrops-public
	git clone --mirror http://ou63pmih66umazou.onion/raindrops-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.raindrops

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git