Sha256: a6dfed0de05912385a42dde3e34c732ec2eb66d5738a1ba0cb34ce8fbb3427c1

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

require_relative "test_helper.rb"

module LogjamAgent
  class ZMQForwarderTest < MiniTest::Test

    def teardown
      LogjamAgent.compression_method = NO_COMPRESSION
    end

    test "sets up single connection with default port" do
      f = ZMQForwarder.new(:host => "a.b.c", :port => 3001)
      assert_equal ["tcp://a.b.c:3001"], f.connection_specs
    end

    test "sets up multiple connections" do
      f = ZMQForwarder.new(:host => "a.b.c,tcp://x.y.z:9000,zmq.gnu.org:600")
      assert_equal %w(tcp://a.b.c:9605 tcp://x.y.z:9000 tcp://zmq.gnu.org:600), f.connection_specs
    end

    test "encodes the payload" do
      data = {a: 1, b: "str"}
      msg = LogjamAgent.encode_payload(data)
      f = ZMQForwarder.new
      f.expects(:publish).with("a-b", "x", msg)
      f.forward(data, :routing_key => "x", :app_env => "a-b")
    end

    test "compressed message using snappy can be uncompressed" do
      data = {a: 1, b: "str"}
      normal_msg = LogjamAgent.encode_payload(data)
      LogjamAgent.compression_method = SNAPPY_COMPRESSION
      compressed_msg = LogjamAgent.encode_payload(data)
      assert_equal normal_msg, Snappy.inflate(compressed_msg)
      f = ZMQForwarder.new
      f.expects(:publish).with("a-b", "x", compressed_msg)
      f.forward(data, :routing_key => "x", :app_env => "a-b")
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logjam_agent-0.22.0 test/zmq_forwarder_test.rb
logjam_agent-0.21.1 test/zmq_forwarder_test.rb
logjam_agent-0.21.0 test/zmq_forwarder_test.rb
logjam_agent-0.20.0 test/zmq_forwarder_test.rb
logjam_agent-0.19.6 test/zmq_forwarder_test.rb
logjam_agent-0.19.5 test/zmq_forwarder_test.rb