Sha256: 7f45e78bef0f1d017e446ba595dd2770974b9de130ff841df7d66dbb3b4f1cd4
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
require 'helper' class EC2MetadataOutputTest < Test::Unit::TestCase def setup Fluent::Test.setup end CONFIG = %[ output_tag ${instance_id}.${tag} <record> instance_id ${instance_id} az ${availability_zone} </record> ] def create_driver(conf = CONFIG, tag='test') Fluent::Test::OutputTestDriver.new(Fluent::EC2MetadataOutput, tag).configure(conf) end def get_instance_id Net::HTTP.get_response('169.254.169.254', '/latest/meta-data/instance-id').body end def get_avaivality_zone Net::HTTP.get_response('169.254.169.254', '/latest/meta-data/placement/availability-zone').body end def test_emit d = create_driver(CONFIG, 'foo.bar') d.run do d.emit("a" => 1) d.emit("a" => 2) end instance_id = get_instance_id availability_zone = get_avaivality_zone # tag assert_equal "#{instance_id}.foo.bar", d.emits[0][0] assert_equal "#{instance_id}.foo.bar", d.emits[1][0] # record mapped = { 'instance_id' => instance_id, 'az' => availability_zone } assert_equal [ {"a" => 1}.merge(mapped), {"a" => 2}.merge(mapped), ], d.records end end
Version data entries
6 entries across 6 versions & 1 rubygems