Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Added Generic module #612

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

Tranquility2
Copy link
Contributor

@Tranquility2 Tranquility2 commented Jun 21, 2024

As part of the effort described, detailed and presented on #559
This is the third PR (out of 4) that should provide all the groundwork to support containers running a server.

As discussed on #595 this PR aims to refactor the ServerContainer under a new dedicated module called "generic".
image

The idea is that this module could include multiple generic implementations such as server.py with the proper documentation and examples to allow users simpler usage and QOL.
This PR adds the original FastAPI implementation as a simple doc example, I think this aligns better following #595

Next in line is feat(core): Added AWS Lambda module

Based on the work done on #585 and #595
Expended from issue #83


Please note an extra commit is included to simulate the relations when importing between and with other modules.

Fix missing doc

Fix missing httpx as optional dependency

Refactored ServerContainer
@Tranquility2
Copy link
Contributor Author

I'll remove the extra commit `Test module import' once we feel the PR is ready

Copy link

codecov bot commented Jun 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (main@3519f4b). Learn more about missing BASE report.

Current head ccf45af differs from pull request most recent head 30d3172

Please upload reports for the commit 30d3172 to get more accurate results.

Files Patch % Lines
core/testcontainers/core/generic.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #612   +/-   ##
=======================================
  Coverage        ?   76.26%           
=======================================
  Files           ?       11           
  Lines           ?      573           
  Branches        ?       83           
=======================================
  Hits            ?      437           
  Misses          ?      110           
  Partials        ?       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexanderankin
Copy link
Member

I actually really love the test module import, if it can be test_module_import instead of just one word, or maybe a different name, this is really useful for the future as a proof that it is working. I think it should be enforced with CI.

I kind of want to think about this some more before merging, as its a fairly major change. but one that I think make sense.

i have to double check what we are doing with the httpx in the poetry files because afaik, you should not need to be adding it to the extras. we already depend on urllib3, we should just do the same to httpx, if we are doing to rely on it this heavily.

@Tranquility2
Copy link
Contributor Author

I'll be happy to add test_module_import but think it should go as a separate commit right?

@alexanderankin alexanderankin force-pushed the generic_module branch 2 times, most recently from 8799049 to 30d3172 Compare June 28, 2024 08:08
@alexanderankin alexanderankin merged commit e575b28 into testcontainers:main Jun 28, 2024
19 checks passed
alexanderankin pushed a commit that referenced this pull request Jun 28, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.7.0](testcontainers-v4.6.0...testcontainers-v4.7.0)
(2024-06-28)


### Features

* **core:** Added Generic module
([#612](#612))
([e575b28](e575b28))
* **core:** allow custom dockerfile path for image build and bypassing
build cache
([#615](#615))
([ead0f79](ead0f79)),
closes
[#610](#610)
* **core:** DockerCompose.stop now stops only services that it starts
(does not stop the other services)
([#620](#620))
([e711800](e711800))


### Bug Fixes

* **ollama:** Add support for ollama module
([#618](#618))
([5442d05](5442d05))
* **cosmosdb:** Add support for the CosmosDB Emulator
([#579](#579))
([8045a80](8045a80))
* improve ollama docs, s/ollama_dir/ollama_home/g
([#619](#619))
([27f2a6b](27f2a6b))
* **kafka:** Add Kraft to Kafka containers
([#611](#611))
([762d2a2](762d2a2))


### Documentation

* **contributing:** add contribution and new-container guide
([#460](#460))
([3519f4b](3519f4b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
alexanderankin pushed a commit that referenced this pull request Jun 30, 2024
Following #612, updated the test module import with a better name and
some minor fixes.
alexanderankin pushed a commit that referenced this pull request Jul 31, 2024
As part of the effort described, detailed and presented on
#559
This is the 4th (and final in this track) PR that should provide support
for AWS Lambda containers.

This module will add the ability to test and run Amazon Lambdas (using
the built-in runtime interface emulator)
For example:

```python
from testcontainers.aws import AWSLambdaContainer
from testcontainers.core.waiting_utils import wait_for_logs
from testcontainers.core.image import DockerImage

with DockerImage(path="./modules/aws/tests/lambda_sample", tag="test-lambda:latest") as image:
    with AWSLambdaContainer(image=image, port=8080) as func:
        response = func.send_request(data={'payload': 'some data'})
        assert response.status_code == 200
        assert "Hello from AWS Lambda using Python" in response.json()
        delay = wait_for_logs(func, "START RequestId:")
```

This can (and probably will) be used with the provided
[LocalStackContainer](https://testcontainers-python.readthedocs.io/en/latest/modules/localstack/README.html)
to help simulate more advance AWS cases.

---

Based on the work done on:
- #585 
- #595 
- #612

Expended from issue
#83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants