Comments (5)
Moving here some discussion I had with @girodav and @aspacca on how to improve the situation.
- Tests share setup code by inheriting from the same base class. This makes hard to distinguish which setup code is used for which test. By extracting functionalities from this single setup function we can then leverage composition over inheritance to split the single setup in multiple setups with shared logic.
- Writing helper functions that do not leverage a global state (i.e.
_mock_awsclient
) but get state through function arguments. This would allow to reuse the same logic by changing the underlying actors. - Leverage
subTest
to group test with same setup code (helps with (1) too) - Leverage testcontainers-py library to wrap test containers we need to use (localstack, elasticsearch, logstash). This library provides an easier to use API and allows for moving bootstrap code for related services out of tests files/setup functions.
- Implement file fixture loading through some conventions, to load test and config data from files instead of writing them in variables. This helps reusing the same data.
- Add suite setup code to bootstrap shared underlying testing infrastructure (i.e. localstack). To implement this all test need to make sure to use only resources created by them (i.e. S3 buckets) and not affect shared resources. By using
type(self).__name__
is possible to use the class name as part of related resources name to achieve this.
from elastic-serverless-forwarder.
6. Add suite setup code to bootstrap shared underlying testing infrastructure (i.e. localstack). To implement this all test need to make sure to use only resources created by them (i.e. S3 buckets) and not affect shared resources. By using
type(self).__name__
is possible to use the class name as part of related resources name to achieve this.
can you clarify on this?
from elastic-serverless-forwarder.
3. Leverage
subTest
to group test with same setup code (helps with (1) too)
do you mean replacing current test_lambda_handler_continuing
/test_lambda_handler_replay
with subTest
instead?
I'd rather go the other way and remove subTest
everywhere where possible, or in case replace with https://pypi.org/project/pytest-subtests/
from elastic-serverless-forwarder.
2. Writing helper functions that do not leverage a global state (i.e.
_mock_awsclient
) but get state through function arguments. This would allow to reuse the same logic by changing the underlying actors.
can you expand on this?
for _mock_awsclient
we have both cases: global state storage.S3Storage._s3_client
, but that's basically only that. the othercases are wrapping aws client getter helper functions (handlers.aws.handler.get_sqs_client
, handlers.aws.utils.get_sqs_client
, handlers.aws.utils.get_cloudwatch_logs_client
, etc etc)
are you referring to this or to something else? :)
from elastic-serverless-forwarder.
closed by #260
from elastic-serverless-forwarder.
Related Issues (20)
- Incorrect Handling of Permissions Can Result in Data Loss
- Provide support for Python 3.12
- [DOCS] Fix outdated link
- CloudWatch log retention for ESF own logs
- Investigate ingestion of files with same IDs HOT 2
- Create pipeline to push zip file with dependencies to an S3 bucket HOT 3
- Misconfigured ESF input results in a warning message, not events sent to replay queue HOT 3
- CMA-CGM ESF Issue HOT 1
- no input defined on cloudwatch-logs trigger HOT 1
- Enable shared outputs and multiple outputs per input
- Investigate number of API calls of ESF due to ec2:describe_regions usage HOT 3
- Issue with region name check in publishing script
- Support SSM (Systems Manager) parameters
- policy size limits - max 44 log groups you can add
- Deployment method using AWS Console doesn't work HOT 5
- ESF incorrectly sets region for VPC flow logs from multi-region S3 bucket
- es_dead_letter_index
- Sercrets manager secrets caching seems not working
- What do I do when I hit the size limits?
- error: Argument 1 to "wrapper" has incompatible type "ProtocolStorageType@__init__"; expected "ProtocolStorageType@json_collector" [arg-type] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elastic-serverless-forwarder.