Logstash插件测试

时间:2018-08-08 20:28:48

标签: elasticsearch logstash

这可能是一个愚蠢的问题,但我似乎无法弄清楚。

我正在尝试为logstash编写一个过滤器插件,并首先生成默认的“ Hello,world!”。插件并完成基本的开发过程。但是在运行 rspec 测试过程时,我陷入了困境。

这些是我遵循的步骤:

  1. https://www.elastic.co/downloads/logstash将logstash下载到我的本地计算机上。
  2. 运行bin/logstash-plugin generate --type filter --name new-plugin --path <path to a new repo I created>
  3. 发现我需要JRuby,所以我安装了 rvm 然后运行了rvm install jrubyrvm use jruby
  4. 最后使bundle install正常工作。
  5. 糟糕!我仍然需要 rspec ,所以我gem install rspec
  6. 运行bundle exec rspec,但得到以下结果:

    1) LogStash::Filters::CleanJob Set to Hello World "{"message":"some text"}" when processed
        Got 0 failures and 2 other errors:
    
        1.1) Failure/Error: expect(subject).to include("message")
    
            NameError:
                undefined local variable or method `job_1' for #<LogStashHelper::TestPipeline:0x4975dda1>
            # (eval):8:in `<eval>'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-core-5.6.4-java/lib/logstash/pipeline.rb:75:in `initialize'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-core-5.6.4-java/lib/logstash/pipeline.rb:165:in `initialize'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:134:in \`new_pipeline_from_string'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:39:in `block in pipeline'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:50:in `block in results'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:68:in `block in subject'
            # ./spec/filters/clean-job_spec.rb:16:in `block in (root)'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block in (root)'
    
        1.2) Failure/Error: Unable to find (eval) to read failed line
    
            NameError:
                undefined local variable or method `job_1' for #<LogStashHelper::TestPipeline:0x5882b202>
            # (eval):8:in `<eval>'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-core-5.6.4-java/lib/logstash/pipeline.rb:75:in `initialize'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-core-5.6.4-java/lib/logstash/pipeline.rb:165:in `initialize'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:134:in `new_pipeline_from_string'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:39:in `block in pipeline'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/logstash-devutils-1.3.6-java/lib/logstash/devutils/rspec/logstash_helpers.rb:65:in `block in sample'
            # <my-dir>/.rvm/gems/jruby-9.2.0.0/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block in (root)'
    

可能是什么原因造成的?

谢谢

0 个答案:

没有答案