Skip to content

Commit

Permalink
chore(ci): migrate E2E tests to CDK CLI and off Docker (#1501)
Browse files Browse the repository at this point in the history
Co-authored-by: Rúben Fonseca <[email protected]>
  • Loading branch information
heitorlessa and rubenfonseca committed Oct 14, 2022
1 parent 0c8453f commit e201bd2
Show file tree
Hide file tree
Showing 30 changed files with 751 additions and 563 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
strategy:
matrix:
# Maintenance: disabled until we discover concurrency lock issue with multiple versions and tmp
# version: ["3.7", "3.8", "3.9"]
version: ["3.7"]
version: ["3.7", "3.8", "3.9"]
# version: ["3.7"]
steps:
- name: "Checkout"
uses: actions/checkout@v3
Expand All @@ -41,6 +41,14 @@ jobs:
python-version: ${{ matrix.version }}
architecture: "x64"
cache: "poetry"
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "16.12"
- name: Install CDK CLI
run: |
npm install
cdk --version
- name: Install dependencies
run: make dev
- name: Configure AWS credentials
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,7 @@ site/

!.github/workflows/lib
examples/**/sam/.aws-sam

cdk.out
# NOTE: different accounts will be used for E2E thus creating unnecessary git clutter
cdk.context.json
393 changes: 326 additions & 67 deletions MAINTAINERS.md

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions aws_lambda_powertools/tracing/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,6 @@ def handler(event, context):
@functools.wraps(lambda_handler)
def decorate(event, context, **kwargs):
with self.provider.in_subsegment(name=f"## {lambda_handler_name}") as subsegment:
global is_cold_start
logger.debug("Annotating cold start")
subsegment.put_annotation(key="ColdStart", value=is_cold_start)

if is_cold_start:
is_cold_start = False

if self.service:
subsegment.put_annotation(key="Service", value=self.service)

try:
logger.debug("Calling lambda handler")
response = lambda_handler(event, context, **kwargs)
Expand All @@ -325,7 +315,18 @@ def decorate(event, context, **kwargs):
self._add_full_exception_as_metadata(
method_name=lambda_handler_name, error=err, subsegment=subsegment, capture_error=capture_error
)

raise
finally:
global is_cold_start
logger.debug("Annotating cold start")
subsegment.put_annotation(key="ColdStart", value=is_cold_start)

if is_cold_start:
is_cold_start = False

if self.service:
subsegment.put_annotation(key="Service", value=self.service)

return response

Expand Down Expand Up @@ -672,7 +673,7 @@ def _add_response_as_metadata(
if data is None or not capture_response or subsegment is None:
return

subsegment.put_metadata(key=f"{method_name} response", value=data, namespace=self._config["service"])
subsegment.put_metadata(key=f"{method_name} response", value=data, namespace=self.service)

def _add_full_exception_as_metadata(
self,
Expand All @@ -697,7 +698,7 @@ def _add_full_exception_as_metadata(
if not capture_error:
return

subsegment.put_metadata(key=f"{method_name} error", value=error, namespace=self._config["service"])
subsegment.put_metadata(key=f"{method_name} error", value=error, namespace=self.service)

@staticmethod
def _disable_tracer_provider():
Expand Down
58 changes: 58 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "aws-lambda-powertools-python-e2e",
"version": "1.0.0",
"devDependencies": {
"aws-cdk": "2.40.0"
}
}
1 change: 0 additions & 1 deletion parallel_run_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def main():
workers = len(list(features)) - 1

command = f"poetry run pytest -n {workers} --dist loadfile -o log_cli=true tests/e2e"
print(f"Running E2E tests with: {command}")
subprocess.run(command.split(), shell=False)


Expand Down
102 changes: 35 additions & 67 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ xenon = "^0.9.0"
flake8-eradicate = "^1.2.1"
flake8-bugbear = "^22.9.23"
mkdocs-git-revision-date-plugin = "^0.3.2"
mike = "^0.6.0"
mike = "^1.1.2"
mypy = "^0.971"
retry = "^0.9.2"
pytest-xdist = "^2.5.0"
Expand All @@ -73,6 +73,7 @@ types-requests = "^2.28.11"
typing-extensions = "^4.4.0"
mkdocs-material = "^8.5.4"
filelock = "^3.8.0"
checksumdir = "^1.2.0"

[tool.poetry.extras]
pydantic = ["pydantic", "email-validator"]
Expand Down
Loading

0 comments on commit e201bd2

Please sign in to comment.