getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.65k stars 2.05k forks source link

Feature: Mocking firehose failing behavior #1871

Open zeeshanabid94 opened 6 years ago

zeeshanabid94 commented 6 years ago

I have a use case of this sort. I have a function with this signature.

write_to_firehose(data, firehose_name, num_retries)

Inside the function, I use a firehose client that is a global variable. I want to simulate the behavior of firehose failing for num_retries time so that I can check if an exception is raised. Idk if I read the docs right, may be there is already a way to do this. Any guidance would help. If this has not been implemented, then I can look into implementing it.

spulec commented 6 years ago

We don't currently have a way to do this; open to ideas.

zeeshanabid94 commented 6 years ago

All right, so my use case was the following: I had a serverless function running on AWS Lambda reading from a stream and pushing to Firehose. PutRecordBatch on firehose is an unreliable call that can Fail completely or Fail partially. I had a retry mechanism in place that I needed to test through unittests. Hence, I had to create successful and failed responses and mock PutRecordBatch method on an empty object

So I figured out: 1- Moto does not have AWS Firehose methods implemented yet. 2- There is no explanation about mocking / simulating failing behavior of API methods.

Proposition:

Idk if this is a good idea, but let me know what you guys think. It is always great to have conversation with fellow engineers.