Sha256: f19bb7e8312ee36db3c9730d810d802a9244f4db33c0a4ad2f17d22aa1c0d9d1

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 KB

Contents

require_relative "../../../spec/es_spec_helper"

describe "client create actions", :integration => true do
  require "logstash/outputs/elasticsearch"

  def get_es_output(action, id)
    settings = {
      "manage_template" => true,
      "index" => "logstash-create",
      "template_overwrite" => true,
      "hosts" => get_host_port(),
      "action" => action
    }
    settings['document_id'] = id
    LogStash::Outputs::ElasticSearch.new(settings)
  end

  before :each do
    @es = get_client
    # Delete all templates first.
    # Clean ES of data before we start.
    @es.indices.delete_template(:name => "*")
    # This can fail if there are no indexes, ignore failure.
    @es.indices.delete(:index => "*") rescue nil
  end

  context "when action => create" do
    it "should create new documents with or without id" do
      subject = get_es_output("create", "id123")
      subject.register
      subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
      @es.indices.refresh
      # Wait or fail until everything's indexed.
      Stud::try(3.times) do
        r = @es.search
        insist { r["hits"]["total"] } == 1
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-6.1.0-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-6.0.0-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.4.1-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.4.0-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.5-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.4-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.2.1-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.3-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.2-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.1-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.3.0-java spec/integration/outputs/create_spec.rb
logstash-output-elasticsearch-5.2.0-java spec/integration/outputs/create_spec.rb