elastic / logstash-devutils

An assortment of tooling/libraries to make Logstash core and plugin development and releasing a bit easier.
Apache License 2.0
17 stars 29 forks source link

wrong number of arguments (given 0, expected 1) #102

Closed nunofernandes closed 10 months ago

nunofernandes commented 10 months ago

Hello,

I have unit tests that are working perfectly with logstash 7.17. When upgrading to 8.10, all the tests fail with the following error:

An error occurred while loading ./spec/05_logstash_squid_service_prd_spec.rb.
Failure/Error:
  sample('message' => message, 'type' => 'logs-systems', 'logStream' => 'logs-squid-service-prd/service/b99b3b857c8148b19bc73bc8b85aaba4', '@timestamp' => LogStash::Timestamp.coerce('2020-01-14T11:35:54.795Z')) do # <2>
    # Check the ouput event/message properties
    insist { subject.class } == LogStash::Event # <3>
    insist { subject.get('type') } == 'logs-systems'
    insist { subject.get('@timestamp').to_iso8601 } == '2020-02-26T11:47:08.467Z'
    insist { subject.get('system') } == 'squid'
    insist { subject.get('subcomponent') } == 'service'
    insist { subject.get('env') } == 'prd'
    insist { subject.get('url') } == 'http://app.abc.com/api/abc'
    insist { subject.get('cache_result') } == 'TCP_MISS'

ArgumentError:
  wrong number of arguments (given 0, expected 1)
# ./vendor/bundle/jruby/3.1.0/gems/logstash-devutils-2.5.0-java/lib/logstash/devutils/rspec/logstash_helpers.rb:67:in `sample'
# ./spec/05_logstash_squid_service_prd_spec.rb:15:in `block in <main>'
# ./spec/05_logstash_squid_service_prd_spec.rb:10:in `<main>'

Here is the content of the spec:

# encoding: utf-8

require 'logstash/devutils/rspec/spec_helper'

# Load the configuration file
@@configuration = String.new
@@configuration << File.read('/etc/logstash/conf.d/kinesis-filter.conf')

describe 'Kinesis filter' do
  config(@@configuration) # <1>

  # Inject input event/message into the pipeline
  message = '1582717628.467   4724 10.0.4.126 TCP_MISS/200 76725 GET http://app.abc.com/api/abc - - - ORIGINAL_DST/104.24.116.191 application/json'
  sample('message' => message, 'type' => 'logs-systems', 'logStream' => 'logs-squid-service-prd/service/b99b3b857c8148b19bc73bc8b85aaba4', '@timestamp' => LogStash::Timestamp.coerce('2020-01-14T11:35:54.795Z')) do # <2>
    # Check the ouput event/message properties
    insist { subject.class } == LogStash::Event # <3>
    insist { subject.get('type') } == 'logs-systems'
    insist { subject.get('@timestamp').to_iso8601 } == '2020-02-26T11:47:08.467Z'
    insist { subject.get('system') } == 'squid'
    insist { subject.get('subcomponent') } == 'service'
    insist { subject.get('env') } == 'prd'
    insist { subject.get('url') } == 'http://app.abc.com/api/abc'
    insist { subject.get('cache_result') } == 'TCP_MISS'
    insist { subject.get('server_ip') } == '104.24.116.191'
    insist { subject.get('client_address') } == '10.0.4.126'
    insist { subject.get('bytes') } == 76725
    insist { subject.get('duration') } == 4724
    expect(subject.get('tags').include?('_grokparsefailure')).to be_falsey
    expect(subject.get('tags').include?('_dateparsefailure')).to be_falsey
  end
end

What can be the reason for this?

Thanks