Sha256: 9afadba8110efdba536cf576043da7d69b77a0584df42a18bd548401df6d5e85
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
require "minitest/autorun" require_relative "support/fake_udp_socket" require "twirl/instrumenters/noop" module ClusterTestHelpers def build(what, *args) send "build_#{what}", *args end private def build_item(key, value, client, instrumenter = nil) Twirl::Item.new(key, value, client, instrumenter) end # Builds a cluster that will connect to what script/kestrel starts. def build_cluster(options = {}) clients = [ KJess::Client.new(host: "localhost", port: 9444), KJess::Client.new(host: "localhost", port: 9544), ] queue_names = Array(options.delete(:queues)) Twirl::Cluster.new(clients, options).tap { |cluster| queue_names.each { |queue_name| cluster.each { |client| client.flush queue_name } } } end def build_mock_cluster(options = {}) number_of_clients = options.delete(:number_of_clients) || 3 clients = number_of_clients.times.map { Minitest::Mock.new } Twirl::Cluster.new clients, options end end module StatsdTestHelpers def assert_timer(socket, metric) regex = /#{Regexp.escape metric}\:\d+\|ms/ assert socket.buffer.detect { |op| op.first =~ regex }, "Timer #{metric} was not found in #{socket.buffer.inspect}" end def assert_counter(socket, metric) assert socket.buffer.detect { |op| op.first == "#{metric}:1|c" }, "Counter #{metric} was not found in #{socket.buffer.inspect}" end def assert_no_timer(socket, metric) regex = /#{Regexp.escape metric}\:\d+\|ms/ assert_nil socket.buffer.detect { |op| op.first =~ regex }, "Timer #{metric} was found in #{socket.buffer.inspect}" end def assert_no_counter(socket, metric) assert_nil socket.buffer.detect { |op| op.first == "#{metric}:1|c" }, "Counter #{metric} was found in #{socket.buffer.inspect}" end end Minitest::Test.send :include, ClusterTestHelpers Minitest::Test.send :include, StatsdTestHelpers
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twirl-0.2.0 | test/helper.rb |
twirl-0.1.0 | test/helper.rb |