Sha256: 6804830f3a0c01fdbb62f4062ac0a23f284fd012d3b66160e6f62b8869d86f68

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

require 'helper'

class KubernetesOutputTest < Test::Unit::TestCase
  def setup
    Fluent::Test.setup
  end

  CONFIG = %[
  ]

  def create_driver(conf = CONFIG, tag='test')
    Fluent::Test::OutputTestDriver.new(Fluent::KubernetesOutput, tag).configure(conf)
  end

  def test_k8s_pod
    d = create_driver

    d.run do
      d.emit("container_name" => "k8s_CONTAINER.ff8e9ce_POD.NAMESPACE.api_2b249189-c3e0-11e4-839d-54ee7527188d_c306d8a8")
    end
    mapped = {'pod' => 'POD', 'pod_namespace' => 'NAMESPACE', 'pod_container' => 'CONTAINER'}
    assert_equal [
      {"container_name" => "k8s_CONTAINER.ff8e9ce_POD.NAMESPACE.api_2b249189-c3e0-11e4-839d-54ee7527188d_c306d8a8"}.merge(mapped),
    ], d.records

    d.run
  end

  def test_non_k8s_container
    d = create_driver

    d.run do
      d.emit("container_name" => "nonk8s")
    end
    assert_equal [
      {"container_name" => "nonk8s"},
    ], d.records

    d.run
  end

  def bench_k8s_pod
    input = {"container_name" => "k8s_CONTAINER.ff8e9ce_POD.NAMESPACE.api_2b249189-c3e0-11e4-839d-54ee7527188d_c306d8a8"}
    plugin = Fluent::KubernetesOutput.new
    plugin.configure({})
    assert_performance_linear do |n|
      n.times do
        plugin.enrich_record(input)
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fluent-plugin-kubernetes-0.2.3 test/plugin/test_out_kubernetes.rb
fluent-plugin-kubernetes-0.2.2 test/plugin/test_out_kubernetes.rb
fluent-plugin-kubernetes-0.2.1 test/plugin/test_out_kubernetes.rb
fluent-plugin-kubernetes-0.1.0 test/plugin/test_out_kubernetes.rb