Commit graph

340 commits

Author SHA1 Message Date
Andrew Cholakian
78f70634ed Refactor API specs to play well with others
This is a big chang, it:

1. Moves API specs out of their special hierarchy
2. Removes the API spec spec_helper
3. Reactivates that stats command spec (that was accidentally not being
run before due to it not having _spec as a suffix

This was required to fix the preceeding commit, where we added a
before(:each) hook to the spec_helper that wasn't being picked up in
some cases due to the existence of two spec helpers and a $LOAD_PATH
that could change.

Fixes #7132
2017-05-18 13:45:27 +00:00
Andrew Cholakian
ff222b668b Clean settings before *and* after spec runs for the runner just in case.
This is a bit belt and suspenders, but I'm out of ideas for #6737 .
Its a bit worrying that the test cleanup may not be working correctly

Fixes #7132
2017-05-18 13:45:27 +00:00
Andrew Cholakian
7e9529fe47 Make test for pipeline flushing more resilient.
Instead of depending on the now deprecated multiline filter we use a
dummy filter that just emits events. This simplifies the test and
dramatically reduces timing issues.

I also increased the max-wait for the timer just in case

Fixes #7024

Fixes #7131
2017-05-17 13:57:13 +00:00
Armin
0c282105eb #7087 Fixed unstable test from premature exit of user defined pipeline
Fixes #7133
2017-05-17 13:09:35 +00:00
Pier-Hugues Pellerin
c9700220bd consistency in naming
Fixes #7103
2017-05-16 14:20:34 +00:00
Pier-Hugues Pellerin
23d0b34b53 Make the test for the write WrappedWriteClient more robust
Instead of using sleep we start two threads and we join them to do the
expectation.

Fixes: #7031 #7032

Fixes #7103
2017-05-16 14:20:33 +00:00
Armin
0020c4beab #6785 spec for nested case added
Fixes #7072
2017-05-11 18:40:14 +00:00
Armin
83a8603284 6785 interpolate settings after flattening settings hash
Fixes #7072
2017-05-11 18:40:13 +00:00
Armin
6bf4eddaff 6785 test windows style interpolation
Fixes #7072
2017-05-11 18:40:13 +00:00
Armin
9f1d889c27 #6785 Interpolate ENV into settings read from logstash.yml
Fixes #7072
2017-05-11 18:40:13 +00:00
Andrew Cholakian
623fe51474 Rename Pipeline -> PipelineIR + Fix PipelineIR concatenation
This PR helps enable https://github.com/elastic/logstash/issues/7076

This also fixes a bug where when concatenating pipelines for PipelineIR
the to_s versions of the SourceWithMetadata objects were conjoined
instead of just the `text`.

Fixes #7079
2017-05-11 17:11:47 +00:00
Jordan Sissel
e838cc7abf Skip a flakey test failing since November 2016
The failure:

    Failures:

      1) LogStash::Pipeline defaulting the pipeline workers based on thread safety when there are threadsafe filters only starts multiple filter threads
         Failure/Error: expect(pipeline.worker_threads.size).to eq(worker_thread_count)

           expected: 5
                got: 8

Related issues: #6855, #6245, #6355

Fixes #7071
2017-05-11 09:45:19 +00:00
Joao Duarte
cad59d9304 fix a few racing conditions in the agent_spec
Fixes #7066
2017-05-11 09:17:32 +00:00
Andrew Cholakian
804788c7fe Compile multiple sources together into one LIR pipeline
This sets us up to correctly set the protocol / metadata fields for LIR
pipelines and work on the refactor mentioned in https://github.com/elastic/logstash/issues/7054

Fixes #7055
2017-05-10 17:58:25 +00:00
Tal Levy
458910bcb9 Introduce DeadLetterQueue to the Execution Context (#6894)
* Introduce a DeadLetterQueueFactory

DeadLetterQueueFactory is a static class that keeps
a static collection of DeadLetterQueueWriteManagers per
pipeline that has plugins requesting to use it.

* DeadLetterQueue was added as a first-class field in the execution context that input/filter/output plugins can leverage
2017-05-09 14:40:59 -07:00
João Duarte
db2c85c5e9 only auto complete config.string (#6974)
this means the configuration read from path.config (-f) is no longer auto completed with stdin/stdout if the input/output sections are missing. This behaviour will only occur with config.string (-e).
2017-05-09 17:30:16 +01:00
João Duarte
07194b830f make e and f flags mutually exclusive (#6976) 2017-05-09 16:42:32 +01:00
Andrew Cholakian
3658c94e9b Refactor SourceLoader to no longer be a singleton.
This cleans up the code from a design patterns standpoint and makes testing plugins easier since you can just create/destroy agents at will.

Without this change the SOURCE_LOADER singleton's state will become dirty as agents are created/destroyed and be problematic.

Fixes #7048
2017-05-09 00:00:02 +00:00
Pier-Hugues Pellerin
b709eb5c68 Fix when settings set in the pipeline_pq_file_spec bleed into other examples
make sure we clone the LogStash::Settings before mutating it.

Fixes: #6868

Fixes #6981
2017-05-04 17:21:43 +00:00
Pier-Hugues Pellerin
2b3d494bbe Make the Logstash metric check for the timestamp on reload success more robust
The current implementation of the test was using a mock and an expect
on the internal classes to determine when to start testing on the
metrics. I've rewrote the setup of the test to use the file output instead of using a
instance. I believe the previous code was not completely threadsafe and was causing this error
in the spec. We should really remove any mock of the form expect_any_instance_of`.

Ref: #6935

Fixes #6956
2017-05-04 14:21:06 +00:00
Pier-Hugues Pellerin
a758412499 Replace the class declaration with let statements
Instead of using a concrete class use let statement instead, this make
sure they are reset between run and make the variable available at the
context level.

Fixes #7017
2017-05-04 13:05:24 +00:00
Pier-Hugues Pellerin
7bc91b7ceb Adding guards on the SourceLoader#fetch
When the fetch is call we are aggregating all the pipeline_config from
the different sources, if we encounter duplicates ids we will return a
failure, making the pipeline skip that fetch.

Fixes #6866
2017-05-03 21:45:57 +00:00
Pier-Hugues Pellerin
17b2218565 Allow to ask the registry to get a list of plugin klass of a specific type
This expose some of the internal of the registry to the outside world to
allow other part of the system to retrieves plugins.

This change was motivated by #6851 to retrieve the installed list of
modules.

Fixes #7011
2017-05-03 21:43:57 +00:00
Andrew Cholakian
28e51f5c6a Unify ConfigPart and SourceMeta into SourceWithMetadata
This unifies the two different config classes that represented mainly
the same data. While this does expose a plain java class into ruby
this works fine because ruby only needs to access and set values, not
work with ruby return types.

Fixes #7003

Fixes #7004
2017-05-02 13:31:06 +00:00
Armin Braun
01b4144dfe #4324 streamline behaviour of Timestamp.== and Timestamp.eql?
Fixes #7002
2017-05-02 10:45:27 +00:00
Josh Soref
3344b00404 spelling: successfully
Fixes #6969
2017-04-28 17:38:44 +00:00
Pier-Hugues Pellerin
3dfdbee515 Fix the lock errors in the LogStash::Runner test
The test was actually starting an agent with pipeline and the runner has
currently no was to stop the agent. This commit make sure we use an
agent mock instead.

Fix: #6931

Fixes #6957
2017-04-27 12:45:29 +00:00
Pier-Hugues Pellerin
251ae7fe0e Make the periodic test converge a bit more robust
This test has been a bit flaky since it relies on an external thread to
trigger, this commit add a bit more time for the trigger to happen and
also add a retry.

Fixes: #6929

Fixes #6945
2017-04-27 12:44:39 +00:00
Pier-Hugues Pellerin
ab4794375e rename the method to running_user_defined_pipelines instead of user_defined_pipelines
Fixes #6885
2017-04-26 21:07:59 +00:00
Pier-Hugues Pellerin
8ecbdf22b3 expose #user_defined_pipelines so we can use it from an input plugin
Fixes #6885
2017-04-26 21:07:59 +00:00
Pier-Hugues Pellerin
5379065249 adjust the agent and the converge spec for the system pipeline
Fixes #6885
2017-04-26 21:07:59 +00:00
Pier-Hugues Pellerin
a2bfcd85d3 Make sure we start system pipeline before normal pipeline
PipelineAction now have an `execution_priority`, we use this method to change the priority of a create action when we are creating a system pipeline

Fixes #6885
2017-04-26 21:07:58 +00:00
Pier-Hugues Pellerin
094fe10c6a Allow Finite pipeline to shutdown internal pipelines
With the creation of the x-pack we have added our first internal
pipeline, but if you were running the monitoring pipeline with a
*finite* pipeline (LIKE generator count => X) when the finite has
completed processing all the events logstash would refuse to stop.

This PR fixes the problem by adding a new pipeline settings called
`system` in the shutdown loop we will check if all the user defined
pipeline are completed if its the case we will shutdown any internal
pipeline and logtash will stop gracefully.

Fixes #6885
2017-04-26 21:07:58 +00:00
Colin Surprenant
e732255edc add acked_queue concurrent stress spec
introduce rake test:core-fast and rake test:core-slow

remove custom rspec config
2017-04-21 14:37:49 -06:00
Pier-Hugues Pellerin
6e180b025d Make the relative path more obvious
I've changed the relative path used in the test, I am using a relative
path that I can more easily control and doesn't have 10 level of nested
directories, I think it was confusing when ran in on our linux ci.

I also added an assert in the `before` to make sure we generate the
right number of configuration in the example.

Ref: #6935

Fixes #6946
2017-04-21 13:32:48 +00:00
Pier-Hugues Pellerin
e4eb28bd66 Make the load_average linux more robust by allow to inject the content of the load_average file
Fixes: #6867

Fixes #6886
2017-04-19 19:45:11 +00:00
Andrew Cholakian
ab1cfe8cf7 Make pipeline and agent available through execution context
Fixes #6920
2017-04-18 20:04:38 +00:00
Pier-Hugues Pellerin
645fcec234 Refactor of the Agent class and the loading of the configuration
This PR introduces majors changes inside Logstash, to help build future
features like supporting multiple pipeline or java execution.

The previous implementation of the agent made the class hard to refactor or add new feature to it, because it needed to
know about too much internal of the pipeline and how the configuration existed.

The changes includes:
- Externalize the loading of the configuration file using a `SourceLoader`
- The source loader can support multiple sources and will aggregate them.
- We keep some metadata about the original file so the LIR can give better feedback.
- The Agent now ask the `SourceLoader` to know which configuration need to be run
- The Agent now uses a converge state strategy to handle: start, reload, stop
- Each actions executed on the pipeline are now extracted into their own classes to help with migration to a new pipeline execution.
- The pipeline now has a start method that handle the tread
- Better out of the box support for multiple pipeline (monitoring)
- Refactor of the spec of the agent

Fixes #6632
2017-04-14 11:42:00 +00:00
Pier-Hugues Pellerin
81cb825b89 Replace the internal list of listeners with a set
Because we sync listeners with emitters when adding or creating hook
this could lead to duplicates of listeners, this PR fixes the problem by using a set
instead of a list. Making sure we can only have one instance of a specific
listener at any time.

Fixes #6916
2017-04-13 20:09:20 +00:00
Pier-Hugues Pellerin
0d1011980e ExecutionContext for the plugins
This PR add the initial building block to pass some `ExecutionContext`
from the pipeline to the plugin, currently we only pass the `pipeline_id`.

We use the accessor `execution_context=` to set the context, in a future
refactor we will pass the object to the constructor.

Fixes #6890
2017-04-07 15:59:57 +00:00
Andrew Cholakian
76711a4785 LIR UI (Read Only) (#6241)
* Read-only Java IR
* Consistent ID generation as opposed to UUIDs

Fixes #6708
2017-04-03 08:49:00 -04:00
Andrew Cholakian
096391b434 Input#clone should also clone that input's codec
Some codecs are context-specific and not threadsafe. If, for instance,
you want to use `generator { threads => 3 }` you will run into buggy
behavior with the line and multiline codecs which are not threadsafe.

This patch is a quick workaround for this behavior. This does not fix
this issue for inputs that do their own multithreading. Those inputs
should handle codec cloning / lifecycle internally according to their
specific requirements.

Fixes #6865
2017-03-31 17:26:04 -04:00
Josh Soref
a06dc211ff Spelling fixes (#6806)
Spelling fixes across the board.
2017-03-29 19:33:26 -07:00
Pier-Hugues Pellerin
918f2bae21 Adding tests for the heap calculation, also changed the visibility
In retrospect, it just easier to expose the methods in the jvm spec
monitoring to be able to test them in isolation.

Fixes #6827
2017-03-26 20:43:12 -04:00
Andrew Cholakian
b1d2b8a39b Move input metrics to be nested under 'events' for consistency
Filters/outputs nest their 'out' metric under 'events'.
Inputs should not be different.

Fixes #6835
2017-03-23 19:32:57 -04:00
Pier-Hugues Pellerin
2fd1b377c3 Implements #has_metric?(*path)
Add a new method that uses the `fast_lookup` has to find if a specific
metric exist instead of relying on exceptions.

Usage:

```ruby
metric_store.has_metric?(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :event_in) # true
metric_store.has_metric?(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :do_not_exist) # false
```
Fixes: #6533

Fixes #6759
2017-03-14 20:32:01 -04:00
Pier-Hugues Pellerin
aa2a97f6f6 Record the events.in related statistic in the right place
This PR changes where the `events.in` are calculated, previously the
values were calculated in the `ReadClient` which was fine before the
addition of the PQ, but this make the stats not accurate when the PQ was
enabled and the producer are a lot faster than the consumer.

These commits change the collection of the metric inside an
instrumented `WriteClient` so both implementation of the client queues will use
the same code.

This also make possible to record `events.out` for every inputs and the
time waiting to push to the queue.

The API is now exposing theses values for each plugins, the events level
and and the pipeline.

Using a pipeline with a sleep filter and PQ we will see this kind of
response from the API.

```json
{
  "duration_in_millis": 438624,
  "in": 3011436,
  "filtered": 2189,
  "out": 2189,
  "queue_push_duration_in_millis": 49845
}
```

Fixes: #6512

Fixes #6532
2017-03-02 16:31:49 -05:00
Tal Levy
9974df427d remove old legacy logstash-core-event (#6783)
and migrate spec tests to core
2017-03-02 10:55:30 -08:00
Tal Levy
6fb8096a54 migrate logstash-core-event-java to logstash-core (#6760) 2017-03-01 15:31:17 -08:00
Colin Surprenant
568666c777 add queue drain option support
wip queue drain option

metrics on empty batches

reenabled spec

cosmetic fixes

stats collection, mutex, specs, empty batch handling

start_metrics
2017-03-01 14:12:27 -05:00