# Logstash Rspec Test Library, how does it fundamentally work when creating pipelines?

**URL:** <https://discuss.elastic.co/t/logstash-rspec-test-library-how-does-it-fundamentally-work-when-creating-pipelines/292537>\
**Category:** Logstash\
**Created:** [December 21, 2021, 8:54am UTC](https://discuss.elastic.co/t/logstash-rspec-test-library-how-does-it-fundamentally-work-when-creating-pipelines/292537 "2021-12-21T08:54:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![UXabre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uxabre/32/96204_2.png) [@UXabre](https://discuss.elastic.co/u/UXabre)\
**Post date:** [December 21, 2021, 8:54am UTC](https://discuss.elastic.co/t/logstash-rspec-test-library-how-does-it-fundamentally-work-when-creating-pipelines/292537/1 "2021-12-21T08:54:33Z")

</div>

So, I've been using rspec for a while now while testing my "simple" pipeline configs.  
However, as of recent, I'd like to use "complex" filters like "aggregate" and "memcached" but it is hard, if not impossible to find the runtime object of this filter or even mock out some part (for example, in memcached I don't want to use an actual server and in aggregate, I don't literally want to wait for a timeout to occur).

Is there anyone, somewhere that could shed some light on this aspect?

I've tried things like:

```auto
 expect_any_instance_of(LogStash::Filters::Aggregate).to receive(:last_flush_timestamp_map).and_return({
      '172.16.0.26': 0
      })

```

But this does not get called (the tests fails because it is not called)

I've also tried "pipeline.filters" inside the "sample" block as I thought my instances would be there but it does not seem to contain this as it only returns "LogstashDelegator". Even if I would be able to access my filters, the pipeline is closed; but perhaps there is an undocumented way of having a pipeline _before_ the samples hit it?

Any help or insight is more than appreciated!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2022, 8:54am UTC](https://discuss.elastic.co/t/logstash-rspec-test-library-how-does-it-fundamentally-work-when-creating-pipelines/292537/2 "2022-01-18T08:54:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
